X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-part_pkg_taxproduct.html;h=f7c8d24a6ee1bbf63eff68ad82e2508dfbd9ca69;hb=b6c5d35cc215c18d3fb1d9aeb0239a610eb68c32;hp=5e22dd86bbce4b918d0ac5c1a699083b038e860c;hpb=07df8db4a07137e678a36b37070721566955295c;p=freeside.git diff --git a/httemplate/misc/xmlhttp-part_pkg_taxproduct.html b/httemplate/misc/xmlhttp-part_pkg_taxproduct.html index 5e22dd86b..f7c8d24a6 100644 --- a/httemplate/misc/xmlhttp-part_pkg_taxproduct.html +++ b/httemplate/misc/xmlhttp-part_pkg_taxproduct.html @@ -1,4 +1,4 @@ -<% encode_json({ part_pkg_taxproduct => [ map { $_->taxproduct => $_->description } @part_pkg_taxproduct ] }) %>\ +<% encode_json({ part_pkg_taxproduct => \@part_pkg_taxproduct }) %>\ <%init> #compliance solutions specific for now, since they asked for a multi-level @@ -6,28 +6,35 @@ #my $sub = $cgi->param('sub'); -warn join(', ', $cgi->param); - my( %args ) = $cgi->multi_param('arg'); -my $hashref = { 'data_vendor' => $args{'data_vendor'} }; +my @qsearch = ( + table => 'part_pkg_taxproduct', + hashref => { 'data_vendor' => $args{'data_vendor'} }, +); my @part_pkg_taxproduct; if ( $args{category} =~ /^(\w)$/ ) { + my $category = $1; - @part_pkg_taxproduct = qsearch({ - table => 'part_pkg_taxproduct', - hashref => $hashref, - extra_sql => " AND taxproduct LIKE '$category%' AND length(taxproduct) = 4 ", - }); + + @part_pkg_taxproduct = + map { $_->taxproduct => $_->description } + qsearch({ @qsearch, + extra_sql => " AND taxproduct LIKE '$category%' ". + " AND length(taxproduct) = 4 ", + }); } elsif ( $args{product_code} =~ /^([A-Z]\d+)$/ ) { + my $product_code = $1; - @part_pkg_taxproduct = qsearch({ - table => 'part_pkg_taxproduct', - hashref => $hashref, - extra_sql => " AND taxproduct LIKE '$product_code%' AND length(taxproduct) > 4 ", - }); + + @part_pkg_taxproduct = + map { $_->taxproductnum. ' '. $_->taxproduct => $_->description } + qsearch({ @qsearch, + extra_sql => " AND taxproduct LIKE '$product_code%'". + " AND length(taxproduct) > 4 ", + }); } else { die 'neither category nor product_code specified';