From ce49620ef8a4e24daa206185138919bb58d35d37 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 18 Oct 2009 15:47:45 +0100 Subject: [PATCH] routetrade: put trades table below voyage plan; include toc --- yarrg/web/query_route | 2 +- yarrg/web/routetrade | 243 ++++++++++++++++++++++-------------------- 2 files changed, 129 insertions(+), 116 deletions(-) diff --git a/yarrg/web/query_route b/yarrg/web/query_route index 3c37d6f..fb32bcd 100644 --- a/yarrg/web/query_route +++ b/yarrg/web/query_route @@ -113,7 +113,7 @@ foreach my $warningf (@warningfs) { % if (@islandids) { -% $someresults->('Relevant trades'); +% $someresults->(); <& routetrade, dbh => $dbh, islandids => \@islandids, diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 53e9636..6148439 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -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} ? 'Stall' : ''; - ---<% $qa->{ShowStalls} ? '' : '' %> -------% if ($optimise) { --% } - - - -% foreach my $col (@cols) { - - -
->Collect ->Deliver - -Collect -Deliver -Profit -Max - -Max -% if ($optimise) { -Planned -% } - -
-Island <% $cdstall %> -Island <% $cdstall %> -Commodity -Price -Qty -Price -Qty -Margin -Unit -Qty -Capital -Profit -Dist -Mass -Vol -% if ($optimise) { -Qty -Capital -Profit -% } +

Contents

+
-% } - -% foreach my $flowix (0..$#flows) { -% my $flow= $flows[$flowix]; -% my $rowid= "id_row_$flow->{UidShort}"; -
{UidShort} %> value=""> - {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; -{Span} ? "colspan=$spec->{Span}" : '' - %> <% $spec->{Align} - %>><% exists $spec->{String} ? $spec->{String} : $v |h %> -% $ci += $spec->{Span}; -% } -% } -
-Total -% foreach my $ci (3..$#cols) { -% my $col= $cols[$ci]; - -% if (defined $col->{Total}) { -<% $col->{Total} |h %> -% } -% } -
- -<&| tabsort, cols => \@cols, table => 'trades', rowclass => 'datarow', - throw => 'trades_sort', tbrow => 'trades_total' &> - ts_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>; - - - +
  • Relevant trades + % if ($optimise) { # ========== TRADING PLAN ========== % @@ -710,7 +606,8 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw( % my $total_total= 0; % my $total_dist= 0; % -

    Voyage trading plan

    +

    Voyage trading plan

    + % foreach my $i (0..$#islandids) { @@ -870,7 +767,7 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw( } $show_total_now->($totals); } - +' : ''; +

    Relevant trades

    +
    Total distance: <% $total_dist %> leagues. 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} ? 'Stall
    +++<% $qa->{ShowStalls} ? '' : '' %> +++++++% if ($optimise) { ++% } + + + +% foreach my $col (@cols) { + + +
    +>Collect +>Deliver + +Collect +Deliver +Profit +Max + +Max +% if ($optimise) { +Planned +% } + +
    +Island <% $cdstall %> +Island <% $cdstall %> +Commodity +Price +Qty +Price +Qty +Margin +Unit +Qty +Capital +Profit +Dist +Mass +Vol +% if ($optimise) { +Qty +Capital +Profit +% } +% } + +
    +% } + +% foreach my $flowix (0..$#flows) { +% my $flow= $flows[$flowix]; +% my $rowid= "id_row_$flow->{UidShort}"; +
    {UidShort} %> value=""> + {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; +{Span} ? "colspan=$spec->{Span}" : '' + %> <% $spec->{Align} + %>><% exists $spec->{String} ? $spec->{String} : $v |h %> +% $ci += $spec->{Span}; +% } +% } +
    +Total +% foreach my $ci (3..$#cols) { +% my $col= $cols[$ci]; + +% if (defined $col->{Total}) { +<% $col->{Total} |h %> +% } +% } +
    + +<&| tabsort, cols => \@cols, table => 'trades', rowclass => 'datarow', + throw => 'trades_sort', tbrow => 'trades_total' &> + ts_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>; + + + + <%init> use CommodsWeb; use Commods; -- 2.30.2