chiark / gitweb /
More clearly explain [?] for location codes
[ypp-sc-tools.db-live.git] / yarrg / web / routetrade
index ce319facae713bb9e32edddf86a1509d979b4772..59a856631b5a1cfdc042664a3d7c67815453c61f 100644 (file)
@@ -140,6 +140,9 @@ my $stmt= "
                commods.commodid                                commodid,
                commods.unitmass                                unitmass,
                commods.unitvolume                              unitvolume,
                commods.commodid                                commodid,
                commods.unitmass                                unitmass,
                commods.unitvolume                              unitvolume,
+               commods.ordval                                  ordval,
+               commods.posinclass                              posinclass,
+               commods.commodclassid                           commodclassid,
                dist                                            dist,
                buy.price - sell.price                          unitprofit
        FROM commods
                dist                                            dist,
                buy.price - sell.price                          unitprofit
        FROM commods
@@ -546,7 +549,7 @@ if ($qa->{'debug'}) {
                my ($varname, $qty) = m/^
                        \s* \d+ \s+
                        (\w+) \s+ (?: [A-Z*]+ \s+ )?
                my ($varname, $qty) = m/^
                        \s* \d+ \s+
                        (\w+) \s+ (?: [A-Z*]+ \s+ )?
-                       ([0-9.]+) \s
+                       ([+-e0-9.]+) \s
                        /x or die "$cplex \n==\n $glpsol_out $_ ?";
                if ($varname =~ m/^f(\d+)s(\d+)_/) {
                        my ($ix,$orgix) = ($1,$2);
                        /x or die "$cplex \n==\n $glpsol_out $_ ?";
                if ($varname =~ m/^f(\d+)s(\d+)_/) {
                        my ($ix,$orgix) = ($1,$2);
@@ -635,14 +638,18 @@ Generated by YARRG at <strong><%
 %
 % foreach my $i (0..$#islandids) {
 <% $tbody->(1) %>
 %
 % foreach my $i (0..$#islandids) {
 <% $tbody->(1) %>
-<tr><td colspan=4>
+<tr>
 %      $iquery->execute($islandids[$i]);
 %      my ($islandname) = $iquery->fetchrow_array();
 %      if (!$i) {
 %      $iquery->execute($islandids[$i]);
 %      my ($islandname) = $iquery->fetchrow_array();
 %      if (!$i) {
+<td colspan=2>
 <strong>Start at <% $islandname |h %></strong>
 <strong>Start at <% $islandname |h %></strong>
+<td colspan=2><a href="docs#posinclass">[what are these codes?]</a>
+<td>
 %      } else {
 %              my $this_dist= $distance->($islandids[$i-1],$islandids[$i]);
 %              $total_dist += $this_dist;
 %      } else {
 %              my $this_dist= $distance->($islandids[$i-1],$islandids[$i]);
 %              $total_dist += $this_dist;
+<td colspan=5>
 <%perl>
                my $total_value= 0;
                foreach my $sf (@subflows) {
 <%perl>
                my $total_value= 0;
                foreach my $sf (@subflows) {
@@ -659,7 +666,7 @@ Generated by YARRG at <strong><%
 <%perl>
      my $age_reported= 0;
      my %flowlists;
 <%perl>
      my $age_reported= 0;
      my %flowlists;
-     #print "<tr><td colspan=6>" if $qa->{'debug'};
+     #print "<tr><td colspan=7>" if $qa->{'debug'};
      foreach my $od (qw(org dst)) {
        #print " [[ i $i od $od " if $qa->{'debug'};
        foreach my $sf (@subflows) {
      foreach my $od (qw(org dst)) {
        #print " [[ i $i od $od " if $qa->{'debug'};
        foreach my $sf (@subflows) {
@@ -673,6 +680,7 @@ Generated by YARRG at <strong><%
                my $price= $f->{"${od}_price"};
                my $stallname= $f->{"${od}_stallname"};
                my $todo= \$flowlists{$od}{
                my $price= $f->{"${od}_price"};
                my $stallname= $f->{"${od}_stallname"};
                my $todo= \$flowlists{$od}{
+                               (sprintf "%010d", $f->{'ordval'}),
                                $f->{'commodname'},
                                (sprintf "%07d", ($od eq 'dst' ?
                                                9999999-$price : $price)),
                                $f->{'commodname'},
                                (sprintf "%07d", ($od eq 'dst' ?
                                                9999999-$price : $price)),
@@ -684,6 +692,33 @@ Generated by YARRG at <strong><%
                        dstArbitrage => 0,
                } unless $$todo;
                $$todo->{'commodname'}= $f->{'commodname'};
                        dstArbitrage => 0,
                } unless $$todo;
                $$todo->{'commodname'}= $f->{'commodname'};
+               $$todo->{'posinclass'}= '';
+               my $incl= $f->{'posinclass'};
+
+               my $findclass= $dbh->prepare(<<END);
+SELECT commodclass, maxposinclass FROM commodclasses WHERE commodclassid = ?
+END
+               $findclass->execute($f->{'commodclassid'});
+               my $classinfo= $findclass->fetchrow_hashref();
+               if ($classinfo) {
+                       my $clname= $classinfo->{'commodclass'};
+                       my $desc= encode_entities(sprintf "%s is under %s",
+                                       $f->{'commodname'}, $clname);
+                       my $abbrev= substr($clname,0,1);
+                       if ($incl) {
+                               my $maxpic= $classinfo->{'maxposinclass'};
+                               $desc.= (sprintf ", commodity %d of %d",
+                                       $incl, $maxpic);
+                               if ($classinfo->{'maxposinclass'} >= 8) {
+                                       my @tmbs= qw(0 1 2 3 4 5 6 7 8 9);
+                                       my $tmbi= ($incl+0.5)*$#tmbs/$maxpic;
+                                       $abbrev.= " ".$tmbs[$tmbi]."&nbsp;";
+                               }
+                       }
+                       $$todo->{'posinclass'}=
+                               "<div class=mouseover title=\"$desc\">"
+                               .$abbrev."</div>";
+               }
                $$todo->{'stallname'}= $stallname;
                $$todo->{Price}= $price;
                $$todo->{Timestamp}= $f->{"${od}_timestamp"};
                $$todo->{'stallname'}= $stallname;
                $$todo->{Price}= $price;
                $$todo->{Timestamp}= $f->{"${od}_timestamp"};
@@ -715,7 +750,7 @@ Generated by YARRG at <strong><%
 </%perl>
 <tr>
 <td colspan=1>
 </%perl>
 <tr>
 <td colspan=1>
-<td colspan=2><% $xinfo %>
+<td colspan=3><% $xinfo %>
 <td colspan=2 align=right><% $totaldesc %>
 <td align=right><% $totalwas |h %> total
 <%perl>
 <td colspan=2 align=right><% $totaldesc %>
 <td align=right><% $totalwas |h %> total
 <%perl>
@@ -746,6 +781,7 @@ Generated by YARRG at <strong><%
 % tr_datarow($m,$dline);
 <<% $td %>><% $collectdeliver %>
 <<% $td %>><% $t->{'commodname'} |h %>
 % tr_datarow($m,$dline);
 <<% $td %>><% $collectdeliver %>
 <<% $td %>><% $t->{'commodname'} |h %>
+<<% $td %>><% $t->{'posinclass'} %>
 %
 %              my @stalls= sort keys %{ $t->{Stalls} };
 %              my $pstall= sub {
 %
 %              my @stalls= sort keys %{ $t->{Stalls} };
 %              my $pstall= sub {
@@ -792,7 +828,7 @@ Generated by YARRG at <strong><%
 }
 </%perl><a name="summary"></a>
 <% $tbody->(1) %><tr>
 }
 </%perl><a name="summary"></a>
 <% $tbody->(1) %><tr>
-<td colspan=2>Total distance: <% $total_dist %> leagues.
+<td colspan=3>Total distance: <% $total_dist %> leagues.
 <td colspan=3 align=right>Overall net cash flow
 <td align=right><strong><%
   $total_total < 0 ? -$total_total." loss" : $total_total." gain"
 <td colspan=3 align=right>Overall net cash flow
 <td align=right><strong><%
   $total_total < 0 ? -$total_total." loss" : $total_total." gain"