temporarily disabling torrus source build
[freeside.git] / httemplate / browse / part_pkg_taxproduct / compliance_solutions.html
1 <& /elements/header-popup.html, 'Select tax product' &>
2
3 <& '/elements/xmlhttp.html',
4      'url'  => $fsurl.'misc/xmlhttp-part_pkg_taxproduct.html',
5      'subs' => [ 'get_part_pkg_taxproduct'] &>
6
7 <script>
8
9 $().ready(function() {
10
11
12   $('#taxproduct_submit').on('click', function() {
13     var service_code = $('#service_code').val().split(' ');
14     select_taxproduct(
15       service_code[0],
16       service_code[1] + ' ' + $('#service_code :selected').text()
17     );
18   });
19 });
20
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;
25   parent.cClick();
26 }
27
28 function jopt(what,value,text) {
29   var optionName = new Option(text, value, false, false);
30   what.append(optionName);
31 }
32
33 function category_changed(what) {
34   var category = what.options[what.selectedIndex].value;
35
36   if ( category.length == 0 ) {
37     $('#product_code').empty();
38     $('#service_code').empty();
39     $('#taxproduct_submit').prop('disabled', true);
40     return;
41   }
42
43   get_part_pkg_taxproduct(
44     'data_vendor', 'compliance_solutions', 'category', category,
45     function (data) {
46
47       $('#product_code').empty();
48       $('#service_code').empty();
49       $('#taxproduct_submit').prop('disabled', true);
50
51       var reply = JSON.parse(data);
52
53       jopt( $('#product_code'), '', 'Select product code' );
54
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 );
60       }
61
62     },
63   );
64
65 }
66
67 function product_code_changed(what) {
68   var product_code = what.options[what.selectedIndex].value;
69
70   if ( product_code.length == 0 ) {
71     $('#service_code').empty();
72     $('#taxproduct_submit').prop('disabled', true);
73     return;
74   }
75
76   get_part_pkg_taxproduct(
77     'data_vendor', 'compliance_solutions', 'product_code', product_code,
78     function (data) {
79
80       $('#service_code').empty();
81       $('#taxproduct_submit').prop('disabled', true);
82
83       jopt( $('#service_code'), '', 'Select service code' );
84
85       var reply = JSON.parse(data);
86
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 );
92       }
93
94     },
95   );
96
97 }
98
99 function service_code_changed(what) {
100   var service_code = what.options[what.selectedIndex].value;
101
102   if ( service_code.length > 0 ) {
103     $('#taxproduct_submit').prop('disabled', false);
104   } else {
105     $('#taxproduct_submit').prop('disabled', true);
106   }
107 }
108
109 </script>  
110
111 <FORM>
112   <% ntable('#cccccc', 2) %>
113
114     <& /elements/tr-select.html,
115          label   => emt('Category'),
116          field   => 'category',
117          id      => 'category',
118          options => [ '', qw( C G N S T V W )],
119          labels  => {
120                       ''  => 'Select category',
121                       'C' => 'COMPUTER',
122                       'G' => 'GENERAL MERCHANDISE',
123                       'N' => 'NON-TAXABLE AND EXEMPT',
124                       'S' => 'SATELLITE',
125                       'T' => 'TELECOM',
126                       'V' => 'VOIP',
127                       'W' => 'WIRELESS',
128                     },
129         onchange => 'category_changed(what);',
130     &>
131
132     <& /elements/tr-select.html,
133         label    => emt('Product code'),
134         field    => 'product_code',
135         id       => 'product_code',
136         onchange => 'product_code_changed(what);',
137     &>
138
139     <& /elements/tr-select.html,
140         label    => emt('Service code'),
141         field    => 'service_code',
142         id       => 'service_code',
143         onchange => 'service_code_changed(what);',
144     &>
145
146   </table>
147   <BR>
148
149   <input type="button" id="taxproduct_submit" value="Select Product" DISABLED>
150 </FORM>
151
152 <& /elements/footer-popup.html &>
153 <%init>
154
155 die "access denied"
156   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
157
158 $cgi->param('id') =~ /^\w+$/ or die "missing id parameter";
159 my $id = $cgi->param('id');
160
161 my $hashref = { data_vendor => 'compliance_solutions' };
162
163 </%init>