X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=blobdiff_plain;f=yarrg%2Fweb%2Fquery_commod;h=8d55f2686130568ba92d2c578dd787d2362e368e;hp=3c2049ca3a509af276a9c28b9c59dbdf463667f5;hb=53dfe71f6c510ee12bbf6bdaeb3984024d34a7be;hpb=767e625796d67e5f5cc94d7e1949b1389f753764 diff --git a/yarrg/web/query_commod b/yarrg/web/query_commod index 3c2049c..8d55f26 100644 --- a/yarrg/web/query_commod +++ b/yarrg/web/query_commod @@ -36,6 +36,7 @@ <%args> $quri $dbh +$commodid => undef; $commodstring => ''; $prselector $someresults @@ -44,35 +45,23 @@ $emsgokorprint <%perl> my $emsg; -my ($commodname,$commodid); +my ($commodname,$cmid); my $qa= \%ARGS; +

Commodity enquiry

% $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)= @_; } +<& enter_commod, qa => $qa, dbh => $dbh, emsg_r => \$emsg, + commodname_r => \$commodname, + cmid_r => \$cmid &> - size=80 - - -% } else { #---------- dropdowns, user selects from menus ---------- - -Not yet implemented. - -% } #---------- end of dropdowns, now common middle of page code ---------- % my $ours= sub { $_[0] =~ m/^commodstring|^commodid/; }; @@ -81,10 +70,13 @@ Not yet implemented.
%#========== results ========== +
+
<%perl> -$emsgokorprint->($emsg) or $commodid=undef; -return unless defined $commodid; +$emsgokorprint->($emsg) or $cmid=undef; +print("
"), return + unless defined $cmid; $someresults->(); #---------- actually compute the results and print them ---------- @@ -111,15 +103,24 @@ 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) { +
++++ - @@ -132,13 +133,9 @@ foreach my $bs (split /_/, $ARGS{BuySell}) { -% $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= ''; @@ -177,22 +174,23 @@ 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) %>"> % for my $cix (0..$#$s) { % $ts_sortkeys{$cix}{$rowid}= $s->[$cix]; % } % $rowix++; % } +% if ($rowix) {
+ + Prices Quantity at price
+/-10% Any
<% $s->[0]= $island->{'archipelago'} |h %> <% $s->[1]= $island->{'islandname'} |h %> <% $stallname |h %> - <% $s->[3]= (length $bestqty ? $bestprice : '-') %> - <% $s->[4]= $median %> - <% $s->[5]= $bestqty %> - <% $s->[6]= $approxqty %> - <% $s->[7]= $cqty %> + <% $s->[3]= (length $bestqty ? $bestprice : '-') %> + <% $s->[4]= $median %> + <% $s->[5]= $bestqty %> + <% $s->[6]= $approxqty %> + <% $s->[7]= $cqty %>
<&| tabsort, table => "${bs}_table", sortkeys => "${bs}_sortkeys", @@ -211,7 +209,11 @@ foreach my $bs (split /_/, $ARGS{BuySell}) { return price; } +% } else { +No offers. +% } <%perl> } +