chiark / gitweb /
WIP trade plan
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 23 Aug 2009 15:41:47 +0000 (16:41 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 23 Aug 2009 15:41:47 +0000 (16:41 +0100)
yarrg/web/routetrade

index cb0ef9379e1a451ebbe3b5c3aff332794ada7850..6bc7277d341a69049358dbb40176700657674187 100644 (file)
@@ -466,6 +466,41 @@ $addcols->({ Total => 0 }, qw(
 
 <input type=submit name=update value="Update">
 
+% if ($optimise) { # ========== TRADING PLAN ==========
+%
+% my $iquery= $dbh->prepare('SELECT islandname FROM islands
+%                              WHERE islandid = ?');
+%
+<h1>Voyage trading plan</h1>
+<table>
+% foreach my $i (0..$#islandids) {
+<tr><td colspan=4><strong>
+%      $iquery->execute($islandids[$i]);
+%      my ($islandname) = $iquery->fetchrow_array();
+%      if (!$i) {
+Start at <% $islandname |h %>
+%      } else {
+Sail to <% $islandname |h %>
+%      }
+</strong>
+%    foreach my $od (qw(dst org)) {
+%      my $sign= $od eq 'dst' ? -1 : +1;
+%      foreach my $f (sort {
+%                      $a->{'commodname'} cmp $b->{'commodname'}
+%              or $sign * ($a->{"${od}_price"} <=> $b->{"${od}_price"})
+%              or      $a->{"${od}_stallname"} cmp $b->{"${od}_stallname"}
+%              } @flows) {
+%              next if $f->{Suppress};
+%              next unless $f->{"${od}_id"} == $islandids[$i];
+%              next unless $f->{OptQty};
+<tr>Buy or sell flow 
+%      }
+%    }
+% }
+</table>
+%
+% } # ========== TRADING PLAN ==========
+
 <%init>
 use CommodsWeb;
 use Commods;