1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
<& /elements/header-popup.html, 'Select tax product' &>
<& '/elements/xmlhttp.html',
'url' => $fsurl.'misc/xmlhttp-part_pkg_taxproduct.html',
'subs' => [ 'get_part_pkg_taxproduct'] &>
<script>
$().ready(function() {
$('#taxproduct_submit').on('click', function() {
var service_code = $('#service_code').val().split(' ');
select_taxproduct(
service_code[0],
service_code[1] + ' ' + $('#service_code :selected').text()
);
});
});
// post the values back to the parent form
function select_taxproduct(taxproductnum, description) {
parent.document.getElementById('<% $id %>').value = taxproductnum;
parent.document.getElementById('<% $id %>_description').value = description;
parent.cClick();
}
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;
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' );
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);
}
}
</script>
<FORM>
<% ntable('#cccccc', 2) %>
<& /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-select.html,
label => emt('Product code'),
field => 'product_code',
id => 'product_code',
onchange => 'product_code_changed(what);',
&>
<& /elements/tr-select.html,
label => emt('Service code'),
field => 'service_code',
id => 'service_code',
onchange => 'service_code_changed(what);',
&>
</table>
<BR>
<input type="button" id="taxproduct_submit" value="Select Product" DISABLED>
</FORM>
<& /elements/footer-popup.html &>
<%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 $hashref = { data_vendor => 'compliance_solutions' };
</%init>
|