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 if ( part_pkg_taxproduct.length == 0 ) {
57 alert('No compliance solutions product codes found; did you run freeside-compliance_solutions-import?');
59 for ( var s = 0; s < part_pkg_taxproduct.length; s=s+2 ) {
60 var product_code = part_pkg_taxproduct[s];
61 var description = part_pkg_taxproduct[s+1];
62 jopt( $('#product_code'), product_code, description );
70 function product_code_changed(what) {
71 var product_code = what.options[what.selectedIndex].value;
73 if ( product_code.length == 0 ) {
74 $('#service_code').empty();
75 $('#taxproduct_submit').prop('disabled', true);
79 get_part_pkg_taxproduct(
80 'data_vendor', 'compliance_solutions', 'product_code', product_code,
83 $('#service_code').empty();
84 $('#taxproduct_submit').prop('disabled', true);
86 jopt( $('#service_code'), '', 'Select service code' );
88 var reply = JSON.parse(data);
90 var part_pkg_taxproduct = reply.part_pkg_taxproduct;
91 for ( var s = 0; s < part_pkg_taxproduct.length; s=s+2 ) {
92 var product_service_code = part_pkg_taxproduct[s];
93 var description = part_pkg_taxproduct[s+1];
94 jopt( $('#service_code'), product_service_code, description );
102 function service_code_changed(what) {
103 var service_code = what.options[what.selectedIndex].value;
105 if ( service_code.length > 0 ) {
106 $('#taxproduct_submit').prop('disabled', false);
108 $('#taxproduct_submit').prop('disabled', true);
115 <% ntable('#cccccc', 2) %>
117 <& /elements/tr-select.html,
118 label => emt('Category'),
121 options => [ '', qw( C G N S T V W )],
123 '' => 'Select category',
125 'G' => 'GENERAL MERCHANDISE',
126 'N' => 'NON-TAXABLE AND EXEMPT',
132 onchange => 'category_changed(what);',
135 <& /elements/tr-select.html,
136 label => emt('Product code'),
137 field => 'product_code',
138 id => 'product_code',
139 onchange => 'product_code_changed(what);',
142 <& /elements/tr-select.html,
143 label => emt('Service code'),
144 field => 'service_code',
145 id => 'service_code',
146 onchange => 'service_code_changed(what);',
152 <input type="button" id="taxproduct_submit" value="Select Product" DISABLED>
155 <& /elements/footer-popup.html &>
159 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
161 $cgi->param('id') =~ /^\w+$/ or die "missing id parameter";
162 my $id = $cgi->param('id');
164 my $hashref = { data_vendor => 'compliance_solutions' };