From: Ian Jackson Date: Sun, 30 Aug 2009 18:42:07 +0000 (+0100) Subject: Show total distance X-Git-Tag: 3.4~69 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=commitdiff_plain;h=2beb3d43799508cd77b7f214513ac2f9e33fbc51;ds=sidebyside Show total distance --- diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 7d112b7..4885782 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -575,6 +575,7 @@ $addcols->({ Total => 0, DoReverse => 1 }, qw( % WHERE islandid = ?'); % my %da_ages; % my $total_total= 0; +% my $total_dist= 0; %

Voyage trading plan

@@ -583,11 +584,13 @@ $addcols->({ Total => 0, DoReverse => 1 }, qw( +- <% $this_dist |h %> leagues % } <%perl> my $age_reported= 0; @@ -695,7 +698,7 @@ $addcols->({ Total => 0, DoReverse => 1 }, qw( } -
% $iquery->execute($islandids[$i]); % my ($islandname) = $iquery->fetchrow_array(); +% my $this_dist= $distance->($islandids[$i-1],$islandids[$i]); +% $total_dist += $this_dist; % if (!$i) { Start at <% $islandname |h %> % } else { Sail to <% $islandname |h %> -- <% $distance->($islandids[$i-1],$islandids[$i]) |h %>leagues
+Total distance: <% $total_dist %> leagues. Overall net cash flow <% $total_total < 0 ? -$total_total." loss" : $total_total." gain"