chiark / gitweb /
Fix spurious ARRAY in deststring (due to erroneous multiple deststring inputs)
[ypp-sc-tools.db-test.git] / yarrg / web / query_routesearch
index 2816086c068c9ed39a92e2e0221c649048f3dee9..1828f374bc5b97e90546bc417d0b7bd5940d61f6 100644 (file)
@@ -42,6 +42,7 @@ $islandstring => '';
 $capacitystring => '';
 $lossperleague => '';
 $capitalstring => '';
 $capacitystring => '';
 $lossperleague => '';
 $capitalstring => '';
+$minprofitstring => '';
 $distance => '';
 $prselector
 $someresults
 $distance => '';
 $prselector
 $someresults
@@ -56,6 +57,8 @@ my $emsg;
 my @warningfs;
 my @islandids;
 
 my @warningfs;
 my @islandids;
 
+my $destspec;
+
 my $maxmaxdist=35;
 my $maxcpu=90;
 my $concur_lim=5;
 my $maxmaxdist=35;
 my $maxcpu=90;
 my $concur_lim=5;
@@ -83,21 +86,44 @@ This feature is not available from the "drop down menus" interface.
        islandids_r => \@islandids, archipelagoes_r => undef
  &>
 
        islandids_r => \@islandids, archipelagoes_r => undef
  &>
 
+% my $searchtype= $ARGS{RouteSearchType};
+% if ($searchtype == 0) {
+%      $destspec= 'any';
+% } elsif ($searchtype == 1) {
+%      $destspec= 'circ';
+% } elsif ($searchtype == 2) {
+
+Destination (one island only):
+<& qtextstring, qa => $qa, dbh => $dbh, emsgstore => \$emsg,
+    thingstring => 'deststring',
+    prefix => 'ds', boxopts => 'size=40',
+    onresults => sub {
+print STDERR "ONRESULTS @_\n";
+       return unless @_;
+       my ($canonname, $island, $arch) = @{ $_[0] };
+       die unless defined $island;
+       $destspec= $island;
+    }
+ &>
+
+% } else {
+%      die "$destspec ?";
+% }
+
 <&| enter_advrouteopts, qa=>$qa, dbh=>$dbh, routeparams=>$routeparams &>
 <td>
 &nbsp;
 &nbsp;
 <td>
  Maximum distance:
 <&| enter_advrouteopts, qa=>$qa, dbh=>$dbh, routeparams=>$routeparams &>
 <td>
 &nbsp;
 &nbsp;
 <td>
  Maximum distance:
- <&| qtextstring, qa => $qa, dbh => $dbh, prefix => 'ml',
-    thingstring => 'distance', emsgstore => \$emsg,
-    onresults => sub { ($maxdist)= @_; } &>
-   size=10
- </&>
+ <& qtextstring, qa => $qa, dbh => $dbh, prefix => 'ml',
+    thingstring => 'distance', emsgstore => \$emsg, boxopts => 'size=10',
+    onresults => sub { ($maxdist)= @_; }
+   &>
 </&>
 
 <input type=submit name=submit value="Search">
 </&>
 
 <input type=submit name=submit value="Search">
-% my $ours= sub { $_[0] =~ m/^lossperleague|^islandstring|^capitalstring|^capacitystring|^distance/; };
+% my $ours= sub { $_[0] =~ m/^lossperleague|^islandstring|^deststring|^capitalstring|^capacitystring|^minprofitstring|^distance/; };
 <& "lookup:formhidden", ours => $ours &>
 
 % }
 <& "lookup:formhidden", ours => $ours &>
 
 % }
@@ -112,10 +138,13 @@ if (!$emsg && $maxdist > $maxmaxdist) {
                " supported, sorry.";
 }
 
                " supported, sorry.";
 }
 
-$emsgokorprint->($emsg) or return;
-@islandids or return;
-$allargs->{'submit'} or return;
-defined $routeparams->{MaxMass} or defined $routeparams->{MaxVolume} or return;
+print("</div>"), return
+     unless $emsgokorprint->($emsg)
+       and @islandids
+       and $allargs->{'submit'}
+       and defined $destspec
+       and (defined $routeparams->{MaxMass} or
+            defined $routeparams->{MaxVolume});
 
 #---------- prepare island names ----------
 
 
 #---------- prepare island names ----------
 
@@ -145,9 +174,9 @@ foreach my $k (qw(MaxMass MaxVolume MaxCapital)) {
 }
 push @rsargs, defined $routeparams->{LossPerLeaguePct}
        ? $routeparams->{LossPerLeaguePct}*0.01 : 1e-9;
 }
 push @rsargs, defined $routeparams->{LossPerLeaguePct}
        ? $routeparams->{LossPerLeaguePct}*0.01 : 1e-9;
-push @rsargs, '0';
+push @rsargs, 0; #$routeparams->{MinProfit};
 push @rsargs, 'search',$maxdist, $maxcountea,$maxcountea;
 push @rsargs, 'search',$maxdist, $maxcountea,$maxcountea;
-push @rsargs, $ARGS{RouteSearchType} ? 'circ' : 'any';
+push @rsargs, $destspec;
 push @rsargs, @islandids;
 
 m/[^-.0-9a-zA-Z]/ and die "$_ $& ?" foreach @rsargs;
 push @rsargs, @islandids;
 
 m/[^-.0-9a-zA-Z]/ and die "$_ $& ?" foreach @rsargs;
@@ -255,7 +284,7 @@ YARRG website still runs quickly.
 <p>
 
 If you submitted several searches and gave up on them (eg by hitting
 <p>
 
 If you submitted several searches and gave up on them (eg by hitting
-`back' or `stop' in your browser), be aware that that doesn't
+"back" or "stop" in your browser), be aware that that doesn't
 generally stop the search process at the server end.  So it's best to
 avoid asking for large searches that you're not sure about.
 
 generally stop the search process at the server end.  So it's best to
 avoid asking for large searches that you're not sure about.
 
@@ -296,7 +325,6 @@ $someresults->();
 <th>Start
 <th>Via
 <th>Finish
 <th>Start
 <th>Via
 <th>Finish
-<tr>
 <tr id="ap<% $ap %>_sortrow"><th><th><th><th><th><th><th>
 %      my $datarow=0;
 %      my %sortkeys;
 <tr id="ap<% $ap %>_sortrow"><th><th><th><th><th><th><th>
 %      my $datarow=0;
 %      my %sortkeys;
@@ -344,6 +372,8 @@ $someresults->();
 <h2>Notes</h2>
 
 Per league values count each island visited as one
 <h2>Notes</h2>
 
 Per league values count each island visited as one
-(additional) league; the `Dist.' column is however the actual distance
+(additional) league; the "Dist." column is however the actual distance
 to be sailed.  All profit figures are somewhat approximate; get a
 complete trading plan for a route for accurate information.
 to be sailed.  All profit figures are somewhat approximate; get a
 complete trading plan for a route for accurate information.
+
+</div>