2 my $conf = FS::Conf->new;
3 my $vendor = $conf->config('tax_data_vendor');
6 my $term = $cgi->param('term');
7 warn "taxproduct.cgi?$term"; # XXX debug
9 table => 'part_pkg_taxproduct',
10 hashref => { 'data_vendor' => $vendor }
12 if ( $term =~ /^\d+$/ ) {
13 $search->{extra_sql} = " AND taxproduct LIKE '$term%'";
14 $search->{order_by} = " ORDER BY taxproduct ASC";
15 } elsif ( length($term) ) {
16 $term = dbh->quote( lc($term) ); # protect against bad strings
17 $search->{extra_sql} = " AND POSITION($term IN LOWER(description)) > 0";
18 # and sort by how close to the beginning of the string it is
19 $search->{order_by} = " ORDER BY POSITION($term IN LOWER(description)) ASC, LOWER(description) ASC, taxproduct ASC";
21 my @taxproducts = qsearch($search);
23 { label => $_->taxproduct . ' ' . $_->description,
24 value => $_->taxproductnum }
27 <% encode_json(\@results) %>\