X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Fquery_commod;h=8d55f2686130568ba92d2c578dd787d2362e368e;hb=9595706c6d171b4efc94932002e2ff7343b18d42;hp=ee4c9f3177aad6eb311bcb11ecb7e2b5234ca173;hpb=ee80b1ab92305277d07d99faea8682aea690b59a;p=ypp-sc-tools.main.git
diff --git a/yarrg/web/query_commod b/yarrg/web/query_commod
index ee4c9f3..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;
%perl>
+
Commodity enquiry
% $prselector->('BuySell');
% $prselector->('ShowBlank');
-%#---------- textbox, user enters route as string ----------
-% if (!$qa->{Dropdowns}) {
-
-Enter commodity (abbreviations are OK):
-
%#========== 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 ----------
-my $onloads= "";
-
foreach my $bs (split /_/, $ARGS{BuySell}) {
$bs =~ m/^(buy|sell)$/ or die;
$bs= $1;
@@ -113,15 +103,24 @@ foreach my $bs (split /_/, $ARGS{BuySell}) {
WHERE commodid = ? AND islandid = ?
ORDER BY price $ascdesc"
);
- # fixme this query is utterly wrong
%perl>
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) {
+
+
+
+
+
-
+ |
+ |
| Prices
| Quantity at price
|
@@ -134,12 +133,9 @@ foreach my $bs (split /_/, $ARGS{BuySell}) {
+/-10%
| Any
|
-% $islands->execute($commodid);
-% my $island;
-% my %ts_sortkeys;
-% 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= '';
@@ -178,25 +174,27 @@ 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) %>">
<% $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 %>
|
% for my $cix (0..$#$s) {
% $ts_sortkeys{$cix}{$rowid}= $s->[$cix];
% }
+% $rowix++;
% }
+% if ($rowix) {
-<& tabsort, table => "${bs}_table", sortkeys => "${bs}_sortkeys",
- throw => "${bs}_table_thr", cols => [
+<&| tabsort, table => "${bs}_table", sortkeys => "${bs}_sortkeys",
+ throw => "${bs}_table_thr", rowclass => 'datarow', cols => [
{}, {},
{ DoReverse => 1 },
{ DoReverse => 1, Numeric => 1, MapFn => "ts_Pricemap_${bs}" },
@@ -205,22 +203,17 @@ 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";
+&tabsort>
+% } else {
+No offers.
+% }
<%perl>
}
%perl>
-
-<&| script &>
- function all_onload() {
-<% $onloads %>
- }
- window.onload= all_onload;
-&>
+