% } # ========== 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 ==========
%
% 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>
}
$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
%
% } # ========== 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;