<& /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, &>
<% emt('Add tax product') %> <% ntable('#cccccc', 2) %> <& /elements/tr-input-text.html, 'label' => emt('Product code'), 'field' => 'new_taxproduct', 'id' => 'new_taxproduct', 'size' => 6, 'maxlength' => 6, &> <& /elements/tr-input-text.html, 'label' => emt('Category'), 'field' => 'new_category_desc', 'id' => 'new_category_desc', 'disabled' => 1 &> <& /elements/tr-input-text.html, 'label' => emt('Product'), 'field' => 'new_taxproduct_desc', 'id' => 'new_taxproduct_desc', &>
<& /elements/footer-popup.html &> <%shared> # populate dropdown # taxproduct is 6 digits: 2-digit category code + 4-digit detail code. # Description is also two parts, corresponding to those codes, separated with # a :. my (@category_codes, @taxproduct_codes, %category_labels, %taxproduct_labels); foreach my $row ( qsearch({ table => 'part_pkg_taxproduct', select => 'DISTINCT substr(taxproduct, 1, 2) AS code, '. "substring(description from '(.*):') AS label", hashref => { data_vendor => 'suretax' }, })) { $category_labels{$row->get('code')} = $row->get('label'); } @category_codes = sort {$a <=> $b} keys %category_labels; <%def .form> % my ($category_code) = @_;
<& /elements/select.html, field => 'category_code', options => \@category_codes, labels => \%category_labels, curr_value => $category_code, onchange => 'this.form.submit()', &> <& /elements/hidden.html, field => 'id', curr_value => scalar($cgi->param('id')), &> <%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 => 'suretax' }; my ($category_code, $taxproduct); if ( $cgi->param('category_code') =~ /^(\d+)$/ ) { $category_code = $1; $taxproduct = $category_code . '%'; } else { $taxproduct = '%'; } $hashref->{taxproduct} = { op => 'LIKE', value => $taxproduct }; my $count_query = "SELECT COUNT(*) FROM part_pkg_taxproduct ". "WHERE data_vendor = 'suretax' AND ". "taxproduct LIKE '$taxproduct'"; my @fields = ( 'taxproduct', 'description', 'note' ); my @header = ( 'Code', 'Description', '', ); my $align = 'lll'; my @link_onclicks = ( $select_onclick, $select_onclick );