chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.db-live.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Query for vessel capacity
[ypp-sc-tools.db-live.git]
/
yarrg
/
web
/
query_route
diff --git
a/yarrg/web/query_route
b/yarrg/web/query_route
index 66dee1dd08135de011871b15d71d963f7db235af..d4a3bd15e4c06cd362765852d3e63bcc8c6284fd 100644
(file)
--- a/
yarrg/web/query_route
+++ b/
yarrg/web/query_route
@@
-35,7
+35,10
@@
</%doc>
<%args>
$quri
</%doc>
<%args>
$quri
+$dbh
+$prselector
$routestring => '';
$routestring => '';
+$capacitystring => '';
$someresults
$emsgokorprint
</%args>
$someresults
$emsgokorprint
</%args>
@@
-45,21
+48,35
@@
my $emsg;
my @archipelagoes;
my @islandids;
my %islandid2;
my @archipelagoes;
my @islandids;
my %islandid2;
+my ($max_volume, $max_mass);
my $qa= \%ARGS;
my $qa= \%ARGS;
+
+my $be_post;
+my $startform= sub {
+ ($be_post)= @_;
</%perl>
</%perl>
+<form action="<% $quri->() |h %>" method="<% $be_post ? 'post' : 'get' %>">
+<%perl>
+};
+my $goupdate= sub { $be_post ? 'Update' : 'Go' };
-%#---------- textbox, user enters route as string ----------
-% if (!$qa->{Dropdowns}) {
+</%perl>
<h1>Specify route</h1>
<h1>Specify route</h1>
+% $prselector->('ShowStalls');
+
+%#---------- textbox, user enters route as string ----------
+% if (!$qa->{Dropdowns}) {
+
Enter route (islands, or archipelagoes, separated by |s or commas;
abbreviations are OK):<br>
Enter route (islands, or archipelagoes, separated by |s or commas;
abbreviations are OK):<br>
-<form action="<% $quri->() |h %>" method="get">
+% $startform->($routestring =~ m/\S/);
-<&| qtextstring, qa => $qa, thingstring => 'routestring', emsgstore => \$emsg,
+<&| qtextstring, qa => $qa, dbh => $dbh,
+ thingstring => 'routestring', emsgstore => \$emsg,
perresult => sub {
my ($canonname, $island, $arch) = @_;
push @islandids, $island;
perresult => sub {
my ($canonname, $island, $arch) = @_;
push @islandids, $island;
@@
-69,8
+86,22
@@
Enter route (islands, or archipelagoes, separated by |s or commas;
size=80
</&>
size=80
</&>
+Vessel capacity:
+<&| qtextstring, qa => $qa, dbh => $dbh, prefix => 'cs',
+ thingstring => 'capacitystring', emsgstore => \$emsg,
+ perresult => sub {
+ ($max_volume,$max_mass) = @_;
+ }
+ &>
+</&>
+
% } else { #---------- dropdowns, user selects from menus ----------
% } else { #---------- dropdowns, user selects from menus ----------
+% $startform->(grep {
+% defined $ARGS{"archipelago$_"} ||
+% defined $ARGS{"islandid$_"}
+% } (0..$qa->{Dropdowns}-1));
+
<%perl>
my ($sth,$row);
my @archlistdata;
<%perl>
my ($sth,$row);
my @archlistdata;
@@
-90,8
+121,6
@@
my $optionlistmap= sub {
return $out;
};
return $out;
};
-my $dbh= dbw_connect($qa->{Ocean});
-
$sth= $dbh->prepare("SELECT DISTINCT archipelago FROM islands
ORDER BY archipelago;");
$sth->execute();
$sth= $dbh->prepare("SELECT DISTINCT archipelago FROM islands
ORDER BY archipelago;");
$sth->execute();
@@
-120,8
+149,6
@@
foreach my $arch (keys %islandlistdata) {
$optionlistmap->($islandlistdata{$arch}, '');
}
$optionlistmap->($islandlistdata{$arch}, '');
}
-$dbh->rollback();
-
</%perl>
<&| script &>
</%perl>
<&| script &>
@@
-164,10
+191,11
@@
function ms_Setarch(dd) {
% } #---------- end of dropdowns, now common middle of page code ----------
% } #---------- end of dropdowns, now common middle of page code ----------
-<input type=submit name=submit value="Go">
-% my $ours= sub { $_[0] =~ m/^island|^archipelago|^routestring/; };
+<input type=submit name=submit value="<% $goupdate->() %>">
+% my $ours= sub { $_[0] =~
+% m/^island|^archipelago|^routestring|^capacitystring|^[RT]/;
+% };
<& "lookup:formhidden", ours => $ours &>
<& "lookup:formhidden", ours => $ours &>
-</form>
<%perl>
#========== results ==========
<%perl>
#========== results ==========
@@
-205,6
+233,12
@@
for my $dd (0..$qa->{Dropdowns}-1) {
</%perl>
% if (@islandids) {
</%perl>
% if (@islandids) {
-% $someresults->();
-<& routetrade, islandids => \@islandids, archipelagoes => \@archipelagoes &>
+% $someresults->('Relevant trades');
+<& routetrade,
+ dbh => $dbh,
+ islandids => \@islandids,
+ archipelagoes => \@archipelagoes,
+ qa => $qa
+ &>
+</form>
% }
% }