X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Fquery_commod;h=b37fa39001e25ec966f234e4ff84735c340c18b7;hb=38888dbd9221f97b1886ee545d0113c88432556a;hp=34b1347f20f5034315a1821d535cd6de40f8f8e2;hpb=f6d7a4d627f3ecc0624649bb895dbf8e59afcf47;p=ypp-sc-tools.web-live.git diff --git a/yarrg/web/query_commod b/yarrg/web/query_commod index 34b1347..b37fa39 100644 --- a/yarrg/web/query_commod +++ b/yarrg/web/query_commod @@ -36,6 +36,7 @@ <%args> $quri $dbh +$commodid => undef; $commodstring => ''; $prselector $someresults @@ -44,7 +45,7 @@ $emsgokorprint <%perl> my $emsg; -my ($commodname,$commodid); +my ($commodname,$cmid); my $qa= \%ARGS; @@ -54,23 +55,34 @@ my $qa= \%ARGS; % $prselector->('BuySell'); % $prselector->('ShowBlank'); +
+ %#---------- textbox, user enters route as string ---------- % if (!$qa->{Dropdowns}) { Enter commodity (abbreviations are OK):
- - <&| qtextstring, qa => $qa, dbh => $dbh, thingstring => 'commodstring', emsgstore => \$emsg, - perresult => sub { ($commodname,$commodid)= @_; } + perresult => sub { ($commodname,$cmid)= @_; } &> size=80 % } else { #---------- dropdowns, user selects from menus ---------- -Not yet implemented. +% my $sth= $dbh->prepare("SELECT commodname,commodid FROM commods +% ORDER BY commodname"); +% $sth->execute(); +% my $row; + % } #---------- end of dropdowns, now common middle of page code ---------- @@ -83,14 +95,12 @@ Not yet implemented. %#========== results ========== <%perl> -$emsgokorprint->($emsg) or $commodid=undef; -return unless defined $commodid; +$emsgokorprint->($emsg) or $cmid=undef; +return unless defined $cmid; $someresults->(); #---------- actually compute the results and print them ---------- -my $onloads= ""; - foreach my $bs (split /_/, $ARGS{BuySell}) { $bs =~ m/^(buy|sell)$/ or die; $bs= $1; @@ -113,12 +123,16 @@ foreach my $bs (split /_/, $ARGS{BuySell}) { WHERE commodid = ? AND islandid = ? ORDER BY price $ascdesc" ); - # fixme this query is utterly wrong

Offers to <% uc $bs |h %> <% $commodname |h %>

- +% $islands->execute($cmid); +% my $island; +% my %ts_sortkeys; +% my $rowix= 0; +% while ($island= $islands->fetchrow_hashref) { +% if (!$rowix) { -% $islands->execute($commodid); -% my $island; -% my %ts_sortkeys; -% my $rowix= 0; -% while ($island= $islands->fetchrow_hashref) { +% } % my $islandid= $island->{'islandid'}; -% $offers->execute($commodid, $islandid); +% $offers->execute($cmid, $islandid); % my ($offer, $bestprice, $marginal, @beststalls); % my $tqty= $island->{'tqty'}; % my $cqty= ''; @@ -179,7 +189,7 @@ foreach my $bs (split /_/, $ARGS{BuySell}) { % $stallname= sprintf "%d offers", scalar @beststalls; % } % -% $cqty == $tqty or die "$bs $cqty $tqty $commodid $islandid "; +% $cqty == $tqty or die "$bs $cqty $tqty $cmid $islandid "; class="<% 'datarow'.($rowix & 1) %>">
@@ -134,13 +148,9 @@ foreach my $bs (split /_/, $ARGS{BuySell}) { +/-10% Any
<% $s->[0]= $island->{'archipelago'} |h %> <% $s->[1]= $island->{'islandname'} |h %> @@ -195,9 +205,10 @@ foreach my $bs (split /_/, $ARGS{BuySell}) { % } % $rowix++; % } +% if ($rowix) {
-<& tabsort, table => "${bs}_table", sortkeys => "${bs}_sortkeys", +<&| tabsort, table => "${bs}_table", sortkeys => "${bs}_sortkeys", throw => "${bs}_table_thr", rowclass => 'datarow', cols => [ {}, {}, { DoReverse => 1 }, @@ -207,22 +218,16 @@ foreach my $bs (split /_/, $ARGS{BuySell}) { { DoReverse => 1, Numeric => 1 }, { DoReverse => 1, Numeric => 1 }, ] &> -<&| script &> <% $bs %>_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>; function ts_Pricemap_<% $bs %>(price) { if (price=='-') { return <% $bs eq 'buy' ? '-1' : '99999999' %>; } return price; } - -% $onloads .= " ts_onload__${bs}_table();\n"; + +% } else { +No offers. +% } <%perl> } - -<&| script &> - function all_onload() { -<% $onloads %> - } - window.onload= all_onload; -