quiet warnings about CGI::param in list context
[freeside.git] / httemplate / misc / xmlhttp-part_pkg_taxproduct.html
1 <% encode_json({ part_pkg_taxproduct => \@part_pkg_taxproduct }) %>\
2 <%init>
3
4 #compliance solutions specific for now, since they asked for a multi-level
5 # select
6
7 #my $sub = $cgi->param('sub');
8
9 my( %args ) = $cgi->multi_param('arg');
10
11 my @qsearch = (
12   table   => 'part_pkg_taxproduct',
13   hashref => { 'data_vendor' => $args{'data_vendor'} },
14 );
15
16 my @part_pkg_taxproduct;
17 if ( $args{category} =~ /^(\w)$/ ) {
18
19   my $category = $1;
20
21   @part_pkg_taxproduct =
22     map { $_->taxproduct => $_->description }
23       qsearch({ @qsearch,
24         extra_sql => " AND taxproduct LIKE '$category%' ".
25                      " AND length(taxproduct) = 4 ",
26       });
27
28 } elsif ( $args{product_code} =~ /^([A-Z]\d+)$/ ) {
29
30   my $product_code = $1;
31
32   @part_pkg_taxproduct =
33     map { $_->taxproductnum. ' '. $_->taxproduct => $_->description }
34       qsearch({ @qsearch,
35         extra_sql => " AND taxproduct LIKE '$product_code%'".
36                      " AND length(taxproduct) > 4 ",
37       });
38
39 } else {
40   die 'neither category nor product_code specified';
41 }
42
43 </%init>