summaryrefslogtreecommitdiff
path: root/httemplate/misc
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2017-07-24 20:33:01 -0700
committerIvan Kohler <ivan@freeside.biz>2017-07-24 20:33:01 -0700
commit07df8db4a07137e678a36b37070721566955295c (patch)
tree024f76e17cd9e03cd15122765f9b94b887fe6910 /httemplate/misc
parent67d171a04ecbccbfd7d5fc2f1be2810299008c15 (diff)
compliance solutions integration: import and use produce/service code catalog, RT#75262
Diffstat (limited to 'httemplate/misc')
-rw-r--r--httemplate/misc/taxproduct.cgi16
-rw-r--r--httemplate/misc/xmlhttp-part_pkg_taxproduct.html36
2 files changed, 48 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) %>\
diff --git a/httemplate/misc/xmlhttp-part_pkg_taxproduct.html b/httemplate/misc/xmlhttp-part_pkg_taxproduct.html
new file mode 100644
index 000000000..5e22dd86b
--- /dev/null
+++ b/httemplate/misc/xmlhttp-part_pkg_taxproduct.html
@@ -0,0 +1,36 @@
+<% encode_json({ part_pkg_taxproduct => [ map { $_->taxproduct => $_->description } @part_pkg_taxproduct ] }) %>\
+<%init>
+
+#compliance solutions specific for now, since they asked for a multi-level
+# select
+
+#my $sub = $cgi->param('sub');
+
+warn join(', ', $cgi->param);
+
+my( %args ) = $cgi->multi_param('arg');
+
+my $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 ",
+ });
+
+} 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 ",
+ });
+
+} else {
+ die 'neither category nor product_code specified';
+}
+
+</%init>