chiark / gitweb /
Fix up search too long error message - really fix up
[ypp-sc-tools.db-live.git] / yarrg / web / enter_commod
1 <%doc>
2
3  This is part of the YARRG website.  YARRG is a tool and website
4  for assisting players of Yohoho Puzzle Pirates.
5
6  Copyright (C) 2009 Ian Jackson <ijackson@chiark.greenend.org.uk>
7  Copyright (C) 2009 Clare Boothby
8
9   YARRG's client code etc. is covered by the ordinary GNU GPL (v3 or later).
10   The YARRG website is covered by the GNU Affero GPL v3 or later, which
11    basically means that every installation of the website will let you
12    download the source.
13
14  This program is free software: you can redistribute it and/or modify
15  it under the terms of the GNU Affero General Public License as
16  published by the Free Software Foundation, either version 3 of the
17  License, or (at your option) any later version.
18
19  This program is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  GNU Affero General Public License for more details.
23
24  You should have received a copy of the GNU Affero General Public License
25  along with this program.  If not, see <http://www.gnu.org/licenses/>.
26
27  Yohoho and Puzzle Pirates are probably trademarks of Three Rings and
28  are used without permission.  This program is not endorsed or
29  sponsored by Three Rings.
30
31
32  This Mason component generates form contents for selecting a commodity.
33
34
35 </%doc>
36 <%args>
37 $qa
38 $dbh
39 $emsg_r
40
41 $commodname_r
42 $cmid_r
43 </%args>
44
45 %#---------- textbox, user enters commodity as string ----------
46 % if (!$qa->{Dropdowns}) {
47
48 Enter commodity (abbreviations are OK):<br>
49
50 <& qtextstring, qa => $qa, dbh => $dbh, emsgstore => $emsg_r,
51     thingstring => 'commodstring', prefix => 'cm', boxopts => 'size=80',
52     onresults => sub { ($$commodname_r,$$cmid_r)= @{ $_[0] } if @_ }
53  &>
54
55 % } else { #---------- dropdowns, user selects from menus ----------
56
57 %       my $sth= $dbh->prepare("SELECT commodname,commodid FROM commods
58 %                                       ORDER BY commodname");
59 %       $sth->execute();
60 %       my $row;
61 <select name="commodid">
62 <option value="">Select commodity...</option>
63 %       while ($row= $sth->fetchrow_arrayref) {
64 %               my $selected= $qa->{'commodid'} eq $row->[1] ? 'selected' : '';
65 <option value="<% $row->[1] %>" <% $selected %>><% $row->[0] |h %></option>
66 %               ($$commodname_r,$$cmid_r) = @$row if $selected;
67 %       }
68 </select>
69 <p>
70
71 % } #---------- end of dropdowns, now common middle of page code ----------