--- /dev/null
+<& /elements/header-popup.html, $title &>
+<& /browse/elements/browse.html,
+ 'name_singular' => 'tax product',
+ #'html_form' => include('.form', $category_code),
+ 'query' => {
+ 'table' => 'part_pkg_taxproduct',
+ 'hashref' => $hashref,
+ 'order_by' => 'ORDER BY taxproduct',
+ },
+ 'count_query' => $count_query,
+ 'header' => \@header,
+ 'fields' => \@fields,
+ 'align' => $align,
+ 'links' => [],
+ 'link_onclicks' => \@link_onclicks,
+ 'nohtmlheader' => 1,
+ 'disable_total' => 1,
+&>
+<script>
+$().ready(function() {
+ var new_taxproduct = $('#new_taxproduct');
+ var new_taxproduct2 = $('#new_taxproduct2');
+// var new_category_desc = $('#new_category_desc');
+ var new_taxproduct_desc = $('#new_taxproduct_desc');
+ var new_taxproduct_submit = $('#new_taxproduct_submit');
+
+// new_taxproduct.on('keyup', function() {
+// var curr_value = this.value || '';
+// if (curr_value.match(/^\d{7}$/)) {
+// new_taxproduct_submit.prop('disabled', false);
+// } else {
+// new_taxproduct_submit.prop('disabled', true);
+// }
+// });
+
+ new_taxproduct_submit.on('click', function() {
+ select_taxproduct( -1,
+ new_taxproduct.val() + new_taxproduct2.val()
+ + ' '
+// + new_category_desc.val()
+// + ':'
+ + new_taxproduct_desc.val()
+ );
+ });
+});
+// post the values back to the parent form
+function select_taxproduct(taxproductnum, description) {
+ parent.document.getElementById('<% $id %>').value = taxproductnum;
+ parent.document.getElementById('<% $id %>_description').value = description;
+ parent.cClick();
+}
+
+</script>
+<BR>
+
+Please contact <a href="http://csilongwood.com/" target="_blank">Compliance Solutions</a> for a full list of your product and service codes.<BR><BR>
+
+<FORM NAME="myform">
+ <FONT SIZE="+1"><B><% emt('Add tax product') %></B></FONT>
+ <% ntable('#cccccc', 2) %>
+ <& /elements/tr-input-text.html,
+ 'label' => emt('Product code'),
+ 'field' => 'new_taxproduct',
+ 'id' => 'new_taxproduct',
+ 'size' => 4,
+ 'maxlength' => 4,
+ &>
+ <& /elements/tr-input-text.html,
+ 'label' => emt('Service code'),
+ 'field' => 'new_taxproduct2',
+ 'id' => 'new_taxproduct2',
+ 'size' => 3,
+ 'maxlength' => 3,
+ &>
+ <& /elements/tr-input-text.html,
+ 'label' => emt('Product name'),
+ 'field' => 'new_taxproduct_desc',
+ 'id' => 'new_taxproduct_desc',
+ &>
+ </table>
+%# <input type="button" id="new_taxproduct_submit" disabled=1 value="Add">
+ <input type="button" id="new_taxproduct_submit" value="Add">
+</FORM>
+
+<& /elements/footer-popup.html &>
+<%shared>
+# populate dropdown
+
+#taxproduct is 7 digits: 4-digit (well, alpha) productcode + 3-digit servicecode
+# Description is also two parts, corresponding to those codes, separated with
+# a :.
+
+my (@productcodes, @servicecodes);
+foreach my $row ( qsearch({
+ table => 'part_pkg_taxproduct',
+ select => 'DISTINCT substr(taxproduct, 1, 4) AS productcode ',
+ hashref => { data_vendor => 'compliance_solutions' },
+ }))
+{
+ push @productcodes, $row->{productcode};
+}
+
+foreach my $row ( qsearch({
+ table => 'part_pkg_taxproduct',
+ select => 'DISTINCT substr(taxproduct, 4, 3) AS servicecode ',
+ hashref => { data_vendor => 'compliance_solutions' },
+ }))
+{
+ push @servicecodes, $row->{servicecode};
+}
+
+</%shared>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+$cgi->param('id') =~ /^\w+$/ or die "missing id parameter";
+my $id = $cgi->param('id');
+
+my $select_onclick = sub {
+ my $row = shift;
+ my $taxnum = $row->taxproductnum;
+ my $desc = $row->taxproduct . ' ' . $row->description;
+ "select_taxproduct('$taxnum', '$desc')";
+};
+
+my @menubar;
+my $title = 'Tax Products';
+
+my $hashref = { data_vendor => 'compliance_solutions' };
+
+#my ($category_code, $taxproduct);
+#if ( $cgi->param('category_code') =~ /^(\d+)$/ ) {
+# $category_code = $1;
+# $taxproduct = $category_code . '%';
+#} else {
+# $taxproduct = '%';
+#}
+my $taxproduct = '%';
+
+$hashref->{taxproduct} = { op => 'LIKE', value => $taxproduct };
+
+my $count_query = "SELECT COUNT(*) FROM part_pkg_taxproduct ".
+ "WHERE data_vendor = 'compliance_solutions' AND ".
+ "taxproduct LIKE '$taxproduct'";
+
+my @fields = (
+ 'taxproduct',
+ 'description',
+# 'note'
+);
+
+my @header = (
+ 'Code',
+ 'Description',
+# '',
+);
+
+my $align = 'lll';
+my @link_onclicks = ( $select_onclick, $select_onclick );
+
+</%init>