1 <& /elements/header-popup.html, 'Select tax product' &>
3 <& '/elements/xmlhttp.html',
4 'url' => $fsurl.'misc/xmlhttp-part_pkg_taxproduct.html',
5 'subs' => [ 'get_part_pkg_taxproduct'] &>
12 $('#taxproduct_submit').on('click', function() {
13 var service_code = $('#service_code').val().split(' ');
16 service_code[1] + ' ' + $('#service_code :selected').text()
21 // post the values back to the parent form
22 function select_taxproduct(taxproductnum, description) {
23 parent.document.getElementById('<% $id %>').value = taxproductnum;
24 parent.document.getElementById('<% $id %>_description').value = description;
28 function jopt(what,value,text) {
29 var optionName = new Option(text, value, false, false);
30 what.append(optionName);
33 function category_changed(what) {
34 var category = what.options[what.selectedIndex].value;
36 if ( category.length == 0 ) {
37 $('#product_code').empty();
38 $('#service_code').empty();
39 $('#taxproduct_submit').prop('disabled', true);
43 get_part_pkg_taxproduct(
44 'data_vendor', 'compliance_solutions', 'category', category,
47 $('#product_code').empty();
48 $('#service_code').empty();
49 $('#taxproduct_submit').prop('disabled', true);
51 var reply = JSON.parse(data);
53 jopt( $('#product_code'), '', 'Select product code' );
55 var part_pkg_taxproduct = reply.part_pkg_taxproduct;
56 for ( var s = 0; s < part_pkg_taxproduct.length; s=s+2 ) {
57 var product_code = part_pkg_taxproduct[s];
58 var description = part_pkg_taxproduct[s+1];
59 jopt( $('#product_code'), product_code, description );
67 function product_code_changed(what) {
68 var product_code = what.options[what.selectedIndex].value;
70 if ( product_code.length == 0 ) {
71 $('#service_code').empty();
72 $('#taxproduct_submit').prop('disabled', true);
76 get_part_pkg_taxproduct(
77 'data_vendor', 'compliance_solutions', 'product_code', product_code,
80 $('#service_code').empty();
81 $('#taxproduct_submit').prop('disabled', true);
83 jopt( $('#service_code'), '', 'Select service code' );
85 var reply = JSON.parse(data);
87 var part_pkg_taxproduct = reply.part_pkg_taxproduct;
88 for ( var s = 0; s < part_pkg_taxproduct.length; s=s+2 ) {
89 var product_service_code = part_pkg_taxproduct[s];
90 var description = part_pkg_taxproduct[s+1];
91 jopt( $('#service_code'), product_service_code, description );
99 function service_code_changed(what) {
100 var service_code = what.options[what.selectedIndex].value;
102 if ( service_code.length > 0 ) {
103 $('#taxproduct_submit').prop('disabled', false);
105 $('#taxproduct_submit').prop('disabled', true);
112 <% ntable('#cccccc', 2) %>
114 <& /elements/tr-select.html,
115 label => emt('Category'),
118 options => [ '', qw( C G N S T V W )],
120 '' => 'Select category',
122 'G' => 'GENERAL MERCHANDISE',
123 'N' => 'NON-TAXABLE AND EXEMPT',
129 onchange => 'category_changed(what);',
132 <& /elements/tr-select.html,
133 label => emt('Product code'),
134 field => 'product_code',
135 id => 'product_code',
136 onchange => 'product_code_changed(what);',
139 <& /elements/tr-select.html,
140 label => emt('Service code'),
141 field => 'service_code',
142 id => 'service_code',
143 onchange => 'service_code_changed(what);',
149 <input type="button" id="taxproduct_submit" value="Select Product" DISABLED>
152 <& /elements/footer-popup.html &>
156 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
158 $cgi->param('id') =~ /^\w+$/ or die "missing id parameter";
159 my $id = $cgi->param('id');
161 my $hashref = { data_vendor => 'compliance_solutions' };