cf07b31890465906c7c8cfbc0a38fb80da97fd0f
[freeside.git] / httemplate / browse / part_pkg_taxproduct / compliance_solutions.html
1 <& /elements/header-popup.html, $title &>
2 <& /browse/elements/browse.html,
3   'name_singular'  => 'tax product',
4   #'html_form'      => include('.form', $category_code),
5   'query'          => {
6                         'table'     => 'part_pkg_taxproduct',
7                         'hashref'   => $hashref,
8                         'order_by'  => 'ORDER BY taxproduct',
9                       },
10   'count_query'    => $count_query,
11   'header'         => \@header,
12   'fields'         => \@fields,
13   'align'          => $align,
14   'links'          => [],
15   'link_onclicks'  => \@link_onclicks,
16   'nohtmlheader'   => 1,
17   'disable_total'  => 1,
18 &>
19 <script>
20 $().ready(function() {
21   var new_taxproduct = $('#new_taxproduct');
22   var new_taxproduct2 = $('#new_taxproduct2');
23 //  var new_category_desc = $('#new_category_desc');
24   var new_taxproduct_desc = $('#new_taxproduct_desc');
25   var new_taxproduct_submit = $('#new_taxproduct_submit');
26
27 //  new_taxproduct.on('keyup', function() {
28 //    var curr_value = this.value || '';
29 //    if (curr_value.match(/^\d{7}$/)) {
30 //      new_taxproduct_submit.prop('disabled', false);
31 //    } else {
32 //      new_taxproduct_submit.prop('disabled', true);
33 //    }
34 //  });
35
36   new_taxproduct_submit.on('click', function() {
37     select_taxproduct( -1,
38                        new_taxproduct.val() + new_taxproduct2.val()
39                           + ' '
40 //                          + new_category_desc.val()
41 //                          + ':'
42                           + new_taxproduct_desc.val()
43                      );
44   });
45 });
46 // post the values back to the parent form
47 function select_taxproduct(taxproductnum, description) {
48   parent.document.getElementById('<% $id %>').value = taxproductnum;
49   parent.document.getElementById('<% $id %>_description').value = description;
50   parent.cClick();
51 }
52   
53 </script>  
54 <BR>
55
56 Please contact <a href="http://csilongwood.com/" target="_blank">Compliance Solutions</a> for a full list of your product and service codes.<BR><BR>
57
58 <FORM NAME="myform">
59   <FONT SIZE="+1"><B><% emt('Add tax product') %></B></FONT>
60   <% ntable('#cccccc', 2) %>
61     <& /elements/tr-input-text.html,
62       'label'     => emt('Product code'),
63       'field'     => 'new_taxproduct',
64       'id'        => 'new_taxproduct',
65       'size'      => 4,
66       'maxlength' => 4,
67     &>
68     <& /elements/tr-input-text.html,
69       'label'     => emt('Service code'),
70       'field'     => 'new_taxproduct2',
71       'id'        => 'new_taxproduct2',
72       'size'      => 3,
73       'maxlength' => 3,
74     &>
75     <& /elements/tr-input-text.html,
76       'label'     => emt('Product name'),
77       'field'     => 'new_taxproduct_desc',
78       'id'        => 'new_taxproduct_desc',
79     &>
80   </table>
81 %#  <input type="button" id="new_taxproduct_submit" disabled=1 value="Add">
82   <input type="button" id="new_taxproduct_submit" value="Add">
83 </FORM>
84
85 <& /elements/footer-popup.html &>
86 <%shared>
87 # populate dropdown
88
89 #taxproduct is 7 digits: 4-digit (well, alpha) productcode + 3-digit servicecode
90 # Description is also two parts, corresponding to those codes, separated with
91 # a :.
92
93 my (@productcodes, @servicecodes);
94 foreach my $row ( qsearch({
95   table   => 'part_pkg_taxproduct',
96   select  => 'DISTINCT substr(taxproduct, 1, 4) AS productcode ',
97   hashref => { data_vendor => 'compliance_solutions' },
98   }))
99 {
100   push @productcodes, $row->{productcode};
101 }
102
103 foreach my $row ( qsearch({
104   table   => 'part_pkg_taxproduct',
105   select  => 'DISTINCT substr(taxproduct, 4, 3) AS servicecode ',
106   hashref => { data_vendor => 'compliance_solutions' },
107   }))
108 {
109   push @servicecodes, $row->{servicecode};
110 }
111
112 </%shared>
113 <%init>
114
115 die "access denied"
116   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
117
118 $cgi->param('id') =~ /^\w+$/ or die "missing id parameter";
119 my $id = $cgi->param('id');
120
121 my $select_onclick = sub {
122   my $row = shift;
123   my $taxnum = $row->taxproductnum;
124   my $desc = $row->taxproduct . ' ' . $row->description;
125   "select_taxproduct('$taxnum', '$desc')";
126 };
127
128 my @menubar;
129 my $title = 'Tax Products';
130
131 my $hashref = { data_vendor => 'compliance_solutions' };
132
133 #my ($category_code, $taxproduct);
134 #if ( $cgi->param('category_code') =~ /^(\d+)$/ ) {
135 #  $category_code = $1;
136 #  $taxproduct = $category_code . '%';
137 #} else {
138 #  $taxproduct = '%';
139 #}
140 my $taxproduct = '%';
141
142 $hashref->{taxproduct} = { op => 'LIKE', value => $taxproduct };
143
144 my $count_query = "SELECT COUNT(*) FROM part_pkg_taxproduct ".
145                   "WHERE data_vendor = 'compliance_solutions' AND ".
146                   "taxproduct LIKE '$taxproduct'";
147
148 my @fields = (
149   'taxproduct',
150   'description',
151 #  'note'
152 );
153
154 my @header = (
155   'Code',
156   'Description',
157 #  '',
158 );
159
160 my $align = 'lll';
161 my @link_onclicks = ( $select_onclick, $select_onclick );
162
163 </%init>