chiark / gitweb /
Make including islands with no offers optional
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Wed, 19 Aug 2009 23:30:23 +0000 (00:30 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Wed, 19 Aug 2009 23:33:03 +0000 (00:33 +0100)
yarrg/web/lookup
yarrg/web/query_commod

index 0b6466e3f6a4fc53a61fc4202643fddc67f3b438..a56adf7a2e7d8ee2b45e047ba30d85c92e72f017 100755 (executable)
@@ -66,6 +66,12 @@ my %styles;
                                [ 'sell',       'Sell offers only' ],
                        ],
                QuerySpecific => 1,
+       }, {    Name => 'ShowBlank',
+               Before => '',
+               Values => [     [ 'omit', 'Omit islands with no offers' ],
+                               [ 'show', 'Show all islands' ],
+                       ],
+               QuerySpecific => 1,
        });
 
 foreach my $var (@vars) {
index 4869e5c50fad00d6222fa0a1ce8e2df110f488a9..c9b17ae6700b72a0e5ba135a14d95ff381ae3a98 100644 (file)
@@ -52,6 +52,7 @@ my $qa= \%ARGS;
 <h1>Commodity enquiry</h1>
 
 % $prselector->('BuySell');
+% $prselector->('ShowBlank');
 
 %#---------- textbox, user enters route as string ----------
 % if (!$qa->{Dropdowns}) {
@@ -94,11 +95,12 @@ foreach my $bs (split /_/, $ARGS{BuySell}) {
        my ($ascdesc) = ($bs eq 'buy')
                ? ('DESC')
                : ('ASC');
-#INNER JOIN 
+       my $joinkind= $ARGS{ShowBlank} eq 'show'
+               ? 'LEFT OUTER JOIN' : 'INNER JOIN';
        my $islands= $dbh->prepare(
        "SELECT islands.islandid AS islandid, archipelago, islandname,
                        sum(qty) as tqty
-               FROM islands LEFT OUTER JOIN $bs offers
+               FROM islands $joinkind $bs offers
                ON islands.islandid == offers.islandid AND commodid == ?
                GROUP BY islands.islandid,
                ORDER BY archipelago, islandname"