From 817c1ce0e1cbcfd1f684222c66f46dd13b2d6dd7 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Sat, 30 May 2015 15:12:07 -0700 Subject: SureTax, #31639, #33015, #34598 --- httemplate/browse/part_pkg_taxproduct/suretax.html | 172 +++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100755 httemplate/browse/part_pkg_taxproduct/suretax.html (limited to 'httemplate/browse/part_pkg_taxproduct/suretax.html') diff --git a/httemplate/browse/part_pkg_taxproduct/suretax.html b/httemplate/browse/part_pkg_taxproduct/suretax.html new file mode 100755 index 000000000..667c07ee9 --- /dev/null +++ b/httemplate/browse/part_pkg_taxproduct/suretax.html @@ -0,0 +1,172 @@ +<& /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, +&> + + + +
+
+ + +
+ + +
+ + +
+ +
+
+<%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 => $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 $code = $row->taxproduct; + my $desc = $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 ); + + -- cgit v1.2.1