summaryrefslogtreecommitdiff
path: root/httemplate/misc/taxproduct.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/misc/taxproduct.cgi')
-rw-r--r--httemplate/misc/taxproduct.cgi16
1 files changed, 12 insertions, 4 deletions
diff --git a/httemplate/misc/taxproduct.cgi b/httemplate/misc/taxproduct.cgi
index 1533e8810..a397f2364 100644
--- a/httemplate/misc/taxproduct.cgi
+++ b/httemplate/misc/taxproduct.cgi
@@ -1,16 +1,20 @@
+<% encode_json(\@results) %>\
<%once>
my $conf = FS::Conf->new;
my $vendor = $conf->config('tax_data_vendor');
</%once>
<%init>
+
my $term = $cgi->param('term');
-warn "taxproduct.cgi?$term"; # XXX debug
+#warn "taxproduct.cgi?$term"; # XXX debug
+
my $search = {
table => 'part_pkg_taxproduct',
hashref => { 'data_vendor' => $vendor }
};
-if ( $term =~ /^\d+$/ ) {
- $search->{extra_sql} = " AND taxproduct LIKE '$term%'";
+
+if ( $term =~ /^[A-Z]?\d+$/ ) {
+ $search->{extra_sql} = " AND taxproduct ILIKE '$term%'";
$search->{order_by} = " ORDER BY taxproduct ASC";
} elsif ( length($term) ) {
$term = dbh->quote( lc($term) ); # protect against bad strings
@@ -18,10 +22,14 @@ if ( $term =~ /^\d+$/ ) {
# and sort by how close to the beginning of the string it is
$search->{order_by} = " ORDER BY POSITION($term IN LOWER(description)) ASC, LOWER(description) ASC, taxproduct ASC";
}
+
+$search->{extra_sql} .= ' AND length(taxproduct) > 4'
+ if $vendor eq 'compliance_solutions';
+
my @taxproducts = qsearch($search);
my @results = map {
{ label => $_->taxproduct . ' ' . $_->description,
value => $_->taxproductnum }
} @taxproducts;
+
</%init>
-<% encode_json(\@results) %>\