X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_pkg_taxproduct%2Fcompliance_solutions.html;h=b5936daef39effd5dbef7c62cd88897b64fce849;hb=0bca43616911f2b48d9a0617e70a3bf0f30b92db;hp=cf07b31890465906c7c8cfbc0a38fb80da97fd0f;hpb=e5b2660aefd03bc4b32386e1c38c53814c002c8d;p=freeside.git diff --git a/httemplate/browse/part_pkg_taxproduct/compliance_solutions.html b/httemplate/browse/part_pkg_taxproduct/compliance_solutions.html index cf07b3189..b5936daef 100644 --- a/httemplate/browse/part_pkg_taxproduct/compliance_solutions.html +++ b/httemplate/browse/part_pkg_taxproduct/compliance_solutions.html @@ -1,115 +1,158 @@ -<& /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, -&> +<& /elements/header-popup.html, 'Select tax product' &> + +<& '/elements/xmlhttp.html', + 'url' => $fsurl.'misc/xmlhttp-part_pkg_taxproduct.html', + 'subs' => [ 'get_part_pkg_taxproduct'] &> + -
-Please contact Compliance Solutions for a full list of your product and service codes.

+function jopt(what,value,text) { + var optionName = new Option(text, value, false, false); + what.append(optionName); +} + +function category_changed(what) { + var category = what.options[what.selectedIndex].value; + + if ( category.length == 0 ) { + $('#product_code').empty(); + $('#service_code').empty(); + $('#taxproduct_submit').prop('disabled', true); + return; + } + + get_part_pkg_taxproduct( + 'data_vendor', 'compliance_solutions', 'category', category, + function (data) { + + $('#product_code').empty(); + $('#service_code').empty(); + $('#taxproduct_submit').prop('disabled', true); + + var reply = JSON.parse(data); + + jopt( $('#product_code'), '', 'Select product code' ); + + var part_pkg_taxproduct = reply.part_pkg_taxproduct; + if ( part_pkg_taxproduct.length == 0 ) { + alert('No compliance solutions product codes found; did you run freeside-compliance_solutions-import?'); + } + for ( var s = 0; s < part_pkg_taxproduct.length; s=s+2 ) { + var product_code = part_pkg_taxproduct[s]; + var description = part_pkg_taxproduct[s+1]; + jopt( $('#product_code'), product_code, description ); + } + + }, + ); + +} + +function product_code_changed(what) { + var product_code = what.options[what.selectedIndex].value; + + if ( product_code.length == 0 ) { + $('#service_code').empty(); + $('#taxproduct_submit').prop('disabled', true); + return; + } + + get_part_pkg_taxproduct( + 'data_vendor', 'compliance_solutions', 'product_code', product_code, + function (data) { + + $('#service_code').empty(); + $('#taxproduct_submit').prop('disabled', true); + + jopt( $('#service_code'), '', 'Select service code' ); -
- <% emt('Add tax product') %> + var reply = JSON.parse(data); + + var part_pkg_taxproduct = reply.part_pkg_taxproduct; + for ( var s = 0; s < part_pkg_taxproduct.length; s=s+2 ) { + var product_service_code = part_pkg_taxproduct[s]; + var description = part_pkg_taxproduct[s+1]; + jopt( $('#service_code'), product_service_code, description ); + } + + }, + ); + +} + +function service_code_changed(what) { + var service_code = what.options[what.selectedIndex].value; + + if ( service_code.length > 0 ) { + $('#taxproduct_submit').prop('disabled', false); + } else { + $('#taxproduct_submit').prop('disabled', true); + } +} + + + + <% ntable('#cccccc', 2) %> - <& /elements/tr-input-text.html, - 'label' => emt('Product code'), - 'field' => 'new_taxproduct', - 'id' => 'new_taxproduct', - 'size' => 4, - 'maxlength' => 4, + + <& /elements/tr-select.html, + label => emt('Category'), + field => 'category', + id => 'category', + options => [ '', qw( C G N S T V W )], + labels => { + '' => 'Select category', + 'C' => 'COMPUTER', + 'G' => 'GENERAL MERCHANDISE', + 'N' => 'NON-TAXABLE AND EXEMPT', + 'S' => 'SATELLITE', + 'T' => 'TELECOM', + 'V' => 'VOIP', + 'W' => 'WIRELESS', + }, + onchange => 'category_changed(what);', &> - <& /elements/tr-input-text.html, - 'label' => emt('Service code'), - 'field' => 'new_taxproduct2', - 'id' => 'new_taxproduct2', - 'size' => 3, - 'maxlength' => 3, + + <& /elements/tr-select.html, + label => emt('Product code'), + field => 'product_code', + id => 'product_code', + onchange => 'product_code_changed(what);', &> - <& /elements/tr-input-text.html, - 'label' => emt('Product name'), - 'field' => 'new_taxproduct_desc', - 'id' => 'new_taxproduct_desc', + + <& /elements/tr-select.html, + label => emt('Service code'), + field => 'service_code', + id => 'service_code', + onchange => 'service_code_changed(what);', &> + -%# - +
+ +
<& /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}; -} - - <%init> die "access denied" @@ -118,46 +161,6 @@ die "access denied" $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 ); -