X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-part_pkg_taxproduct.html;h=f7c8d24a6ee1bbf63eff68ad82e2508dfbd9ca69;hb=360f89789c45e1fd7cb84b1442d2f0c8353066d9;hp=4cc3a3e64ef08d250049e404176922d45ea2e1cb;hpb=e6968c64eb7a29323d09e32de729e8c0731731a8;p=freeside.git diff --git a/httemplate/misc/xmlhttp-part_pkg_taxproduct.html b/httemplate/misc/xmlhttp-part_pkg_taxproduct.html index 4cc3a3e64..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 @@ -8,24 +8,33 @@ 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';