chiark / gitweb /
routetrade: put trades table below voyage plan; include toc
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 18 Oct 2009 14:47:45 +0000 (15:47 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 18 Oct 2009 14:47:45 +0000 (15:47 +0100)
yarrg/web/query_route
yarrg/web/routetrade

index 3c37d6fc9f7833359394af29dd8bab35dbb7b81c..fb32bcdd705017d6ad82f7da4a3344c55b44b47e 100644 (file)
@@ -113,7 +113,7 @@ foreach my $warningf (@warningfs) {
 </%perl>
 
 % if (@islandids) {
-%      $someresults->('Relevant trades');
+%      $someresults->();
 <& routetrade,
    dbh => $dbh,
    islandids => \@islandids,
index 53e96365963f25c71374db8a815b716afe08edd1..61484391130a9341b3b90d099c4b2889f27d0619 100644 (file)
@@ -587,120 +587,16 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw(
 
 % } # ========== OPTIMISATION ==========
 
-% my %ts_sortkeys;
-% {
-%      my $cdspan= $qa->{ShowStalls} ? ' colspan=2' : '';
-%      my $cdstall= $qa->{ShowStalls} ? '<th>Stall</th>' : '';
-<table id="trades" rules=groups>
-<colgroup span=1>
-<colgroup span=2>
-<% $qa->{ShowStalls} ? '<colgroup span=2>' : '' %>
-<colgroup span=1>
-<colgroup span=2>
-<colgroup span=2>
-<colgroup span=2>
-<colgroup span=3>
-<colgroup span=3>
-%      if ($optimise) {
-<colgroup span=3>
-%      }
-<tr>
-<th>
-<th<% $cdspan %>>Collect
-<th<% $cdspan %>>Deliver
-<th>
-<th colspan=2>Collect
-<th colspan=2>Deliver
-<th colspan=2>Profit
-<th colspan=3>Max
-<th colspan=1>
-<th colspan=2>Max
-%      if ($optimise) {
-<th colspan=3>Planned
-%      }
-
-<tr>
-<th>
-<th>Island <% $cdstall %>
-<th>Island <% $cdstall %>
-<th>Commodity
-<th>Price
-<th>Qty
-<th>Price
-<th>Qty
-<th>Margin
-<th>Unit
-<th>Qty
-<th>Capital
-<th>Profit
-<th>Dist
-<th>Mass
-<th>Vol
-%      if ($optimise) {
-<th>Qty
-<th>Capital
-<th>Profit
-%      }
+<h2>Contents</h2>
+<ul>
+% if ($optimise) {
+ <li><a href="#plan">Voyage trading plan</a>
+  <ul>
+   <li><a href="#summary">Summary statistics</a>
+  </ul>
 % }
-
-<tr id="trades_sort">
-% foreach my $col (@cols) {
-<th>
-% }
-
-% foreach my $flowix (0..$#flows) {
-%      my $flow= $flows[$flowix];
-%      my $rowid= "id_row_$flow->{UidShort}";
-<tr id="<% $rowid %>" class="datarow<% $flowix & 1 %>">
-<td><input type=hidden   name=R<% $flow->{UidShort} %> value="">
-    <input type=checkbox name=T<% $flow->{UidShort} %> value=""
-       <% $flow->{Suppress} ? '' : 'checked' %> >
-%      my $ci= 1;
-%      while ($ci < @cols) {
-%              my $col= $cols[$ci];
-%              my $spec= {
-%                      Span => 1,
-%                      Align => ($col->{Text} ? '' : 'align=right')
-%              };
-%              my $cn= $col->{Name};
-%              my $v;
-%              if (!$col->{TotalSubflows}) {
-%                      $v= $flow->{$cn};
-%              } else {
-%                      $v= 0;
-%                      $v += $_->{$cn} foreach @{ $flow->{Subflows} };
-%              }
-%              if ($col->{Special}) { $col->{Special}($flow,$col,$v,$spec); }
-%              $col->{Total} += $v
-%                      if defined $col->{Total} and not $flow->{Suppress};
-%              $v='' if !$col->{Text} && !$v;
-%              my $sortkey= $col->{SortColKey} ?
-%                      $flow->{$col->{SortColKey}} : $v;
-%              $ts_sortkeys{$ci}{$rowid}= $sortkey;
-<td <% $spec->{Span} ? "colspan=$spec->{Span}" : ''
- %> <% $spec->{Align}
- %>><% exists $spec->{String} ? $spec->{String} : $v |h %>
-%              $ci += $spec->{Span};
-%      }
-% }
-<tr id="trades_total">
-<th>
-<th colspan=2>Total
-% foreach my $ci (3..$#cols) {
-%      my $col= $cols[$ci];
-<td align=right>
-%      if (defined $col->{Total}) {
-<% $col->{Total} |h %>
-%      }
-% }
-</table>
-
-<&| tabsort, cols => \@cols, table => 'trades', rowclass => 'datarow',
-       throw => 'trades_sort', tbrow => 'trades_total' &>
-  ts_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>;
-</&tabsort>
-
-<input type=submit name=update value="Update">
+ <li><a href="#trades">Relevant trades</a>
+</ul>
 
 % if ($optimise) { # ========== TRADING PLAN ==========
 %
@@ -710,7 +606,8 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw(
 % my $total_total= 0;
 % my $total_dist= 0;
 %
-<h1>Voyage trading plan</h1>
+<h2><a name="plan">Voyage trading plan</a></h2>
+
 <table rules=groups>
 % foreach my $i (0..$#islandids) {
 <tbody>
@@ -870,7 +767,7 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw(
      }
      $show_total_now->($totals);
 }
-</%perl>
+</%perl><a name="summary"></a>
 <tbody><tr>
 <td colspan=2>Total distance: <% $total_dist %> leagues.
 <td colspan=3 align=right>Overall net cash flow
@@ -885,6 +782,122 @@ Expected average profit:
 %
 % } # ========== TRADING PLAN ==========
 
+% my %ts_sortkeys;
+% {
+%      my $cdspan= $qa->{ShowStalls} ? ' colspan=2' : '';
+%      my $cdstall= $qa->{ShowStalls} ? '<th>Stall</th>' : '';
+<h2><a name="trades">Relevant trades</a></h2>
+<table id="trades" rules=groups>
+<colgroup span=1>
+<colgroup span=2>
+<% $qa->{ShowStalls} ? '<colgroup span=2>' : '' %>
+<colgroup span=1>
+<colgroup span=2>
+<colgroup span=2>
+<colgroup span=2>
+<colgroup span=3>
+<colgroup span=3>
+%      if ($optimise) {
+<colgroup span=3>
+%      }
+<tr>
+<th>
+<th<% $cdspan %>>Collect
+<th<% $cdspan %>>Deliver
+<th>
+<th colspan=2>Collect
+<th colspan=2>Deliver
+<th colspan=2>Profit
+<th colspan=3>Max
+<th colspan=1>
+<th colspan=2>Max
+%      if ($optimise) {
+<th colspan=3>Planned
+%      }
+
+<tr>
+<th>
+<th>Island <% $cdstall %>
+<th>Island <% $cdstall %>
+<th>Commodity
+<th>Price
+<th>Qty
+<th>Price
+<th>Qty
+<th>Margin
+<th>Unit
+<th>Qty
+<th>Capital
+<th>Profit
+<th>Dist
+<th>Mass
+<th>Vol
+%      if ($optimise) {
+<th>Qty
+<th>Capital
+<th>Profit
+%      }
+% }
+
+<tr id="trades_sort">
+% foreach my $col (@cols) {
+<th>
+% }
+
+% foreach my $flowix (0..$#flows) {
+%      my $flow= $flows[$flowix];
+%      my $rowid= "id_row_$flow->{UidShort}";
+<tr id="<% $rowid %>" class="datarow<% $flowix & 1 %>">
+<td><input type=hidden   name=R<% $flow->{UidShort} %> value="">
+    <input type=checkbox name=T<% $flow->{UidShort} %> value=""
+       <% $flow->{Suppress} ? '' : 'checked' %> >
+%      my $ci= 1;
+%      while ($ci < @cols) {
+%              my $col= $cols[$ci];
+%              my $spec= {
+%                      Span => 1,
+%                      Align => ($col->{Text} ? '' : 'align=right')
+%              };
+%              my $cn= $col->{Name};
+%              my $v;
+%              if (!$col->{TotalSubflows}) {
+%                      $v= $flow->{$cn};
+%              } else {
+%                      $v= 0;
+%                      $v += $_->{$cn} foreach @{ $flow->{Subflows} };
+%              }
+%              if ($col->{Special}) { $col->{Special}($flow,$col,$v,$spec); }
+%              $col->{Total} += $v
+%                      if defined $col->{Total} and not $flow->{Suppress};
+%              $v='' if !$col->{Text} && !$v;
+%              my $sortkey= $col->{SortColKey} ?
+%                      $flow->{$col->{SortColKey}} : $v;
+%              $ts_sortkeys{$ci}{$rowid}= $sortkey;
+<td <% $spec->{Span} ? "colspan=$spec->{Span}" : ''
+ %> <% $spec->{Align}
+ %>><% exists $spec->{String} ? $spec->{String} : $v |h %>
+%              $ci += $spec->{Span};
+%      }
+% }
+<tr id="trades_total">
+<th>
+<th colspan=2>Total
+% foreach my $ci (3..$#cols) {
+%      my $col= $cols[$ci];
+<td align=right>
+%      if (defined $col->{Total}) {
+<% $col->{Total} |h %>
+%      }
+% }
+</table>
+
+<&| tabsort, cols => \@cols, table => 'trades', rowclass => 'datarow',
+       throw => 'trades_sort', tbrow => 'trades_total' &>
+  ts_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>;
+</&tabsort>
+
+<input type=submit name=update value="Update">
+
 <%init>
 use CommodsWeb;
 use Commods;