chiark / gitweb /
Tickbox for each line
[ypp-sc-tools.web-live.git] / yarrg / web / routetrade
index c5c2ab7e3b8d042de5660aaef9f4f96d2940865b..dcf3671620f32b8680c7375b6d714e911442ed0d 100644 (file)
@@ -162,16 +162,46 @@ push @columns,                 qw(commodname
 </pre>
 % }
 
+<& dumptable:start, qa => $qa, sth => $sth &>
 % {
-<& dumptable:start, sth => $sth &>
-%   my $flow;
-%   while ($flow= $sth->fetchrow_hashref()) {
-%      $flow->{Ix}= @flows;
-%      $flow->{Var}= "f$flow->{Ix}";
-%      push @flows, $flow;
-<& dumptable:row, sth => $sth, row => $flow &>
+%   my $f;
+%   while ($f= $sth->fetchrow_hashref()) {
+<%perl>
+
+       $f->{Ix}= @flows;
+       $f->{Var}= "f$f->{Ix}";
+
+       $f->{MaxQty}= $f->{'org_qty'} < $f->{'dst_qty'}
+               ? $f->{'org_qty'} : $f->{'dst_qty'};
+       $f->{MaxProfit}= $f->{MaxQty} * $f->{'unitprofit'};
+       $f->{MaxCapital}= $f->{MaxQty} * $f->{'org_price'};
+
+       $f->{PctProfit}= sprintf "%3.1f%%",
+               $f->{'dst_price'} * 100.0 / $f->{'org_price'} - 100.0;
+
+       $f->{"org_stallid"}= $f->{"dst_stallid"}= 'all'
+               if !$qa->{ShowStalls};
+
+       my @uid= $f->{commodid};
+       foreach my $od (qw(org dst)) {
+               push @uid,
+                       $f->{"${od}_id"},
+                       $f->{"${od}_price"},
+                       $f->{"${od}_stallid"};
+       }
+       $f->{Uid}= join '_', @uid;
+
+       if ($qa->{"rtsela_$f->{Uid}"} &&
+           !$qa->{"rtselg_$f->{Uid}"}) {
+               $f->{Suppress}= 1;
+       }
+
+       push @flows, $f;
+
+</%perl>
+<& dumptable:row, qa => $qa, sth => $sth, row => $f &>
 %   }
-<& dumptable:end &>
+<& dumptable:end, qa => $qa &>
 % }
 
 % my $optimise= $specific && !$confusing && @islandids>1;
@@ -205,13 +235,22 @@ Subject To
 
 my %avail_csts;
 foreach my $flow (@flows) {
+       if ($flow->{Suppress}) {
+               $cplex .= "
+   $flow->{Var} = 0
+";
+               next;
+       }
        foreach my $od (qw(org dst)) {
-               my $cstname= join '_',
+               my $cstname= join '_', (
                        'avail',
                        $flow->{'commodid'},
                        $od,
                        $flow->{"${od}_id"},
-                       $flow->{"${od}_price"};
+                       $flow->{"${od}_price"},
+                       $flow->{"${od}_stallid"},
+               );
+                       
                push @{ $avail_csts{$cstname}{Flows} }, $flow->{Var};
                $avail_csts{$cstname}{Qty}= $flow->{"${od}_qty"};
        }
@@ -285,6 +324,7 @@ push @columns, qw(OptQty OptCapital OptProfit);
 %      my $cdstall= $qa->{ShowStalls} ? '<th>Stall</th>' : '';
 <table>
 <tr>
+<th>
 <th<% $cdspan %>>Collect
 <th<% $cdspan %>>Deliver
 <th>
@@ -297,6 +337,7 @@ push @columns, qw(OptQty OptCapital OptProfit);
 %      }
 
 <tr>
+<th>
 <th>Island <% $cdstall %>
 <th>Island <% $cdstall %>
 <th>Commodity
@@ -318,19 +359,17 @@ push @columns, qw(OptQty OptCapital OptProfit);
 
 % foreach my $flow (@flows) {
 <tr>
+<td><input type=hidden   name=rtsela_<% $flow->{Uid} %> value=1>
+    <input type=checkbox name=rtselg_<% $flow->{Uid} %> value=1
+       <% $flow->{Suppress} ? '' : 'checked' %> >
 %      foreach my $col (@columns) {
-%              $flow->{MaxQty}= $flow->{'org_qty'} < $flow->{'dst_qty'}
-%                      ? $flow->{'org_qty'} : $flow->{'dst_qty'};
-%              $flow->{MaxProfit}= $flow->{MaxQty} * $flow->{'unitprofit'};
-%              $flow->{PctProfit}= sprintf "%3.1f%%",
-%                      $flow->{'dst_price'} * 100.0 / $flow->{'org_price'}
-%                      - 100.0;
-%              $flow->{MaxCapital}= $flow->{MaxQty} * $flow->{'org_price'};
 <td><% $flow->{$col} |h %>
 %      }
 % }
 </table>
 
+<input type=submit name=update value="Update">
+
 <%init>
 use CommodsWeb;
 use Commods;