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