1 <% include('/elements/header-popup.html', ucfirst($action). ' Tax Rates') %>
2 <% include('/elements/error.html') %>
4 <FORM ACTION="<% popurl(1) %>process/enable_or_disable_tax.html" METHOD=POST>
5 <INPUT TYPE="hidden" NAME="action" VALUE="<% $action %>">
6 <INPUT TYPE="hidden" NAME="data_vendor" VALUE="<% $data_vendor %>">
7 <INPUT TYPE="hidden" NAME="geocode" VALUE="<% $geocode %>">
8 <INPUT TYPE="hidden" NAME="taxclassnum" VALUE="<% $taxclassnum %>">
9 <INPUT TYPE="hidden" NAME="tax_type" VALUE="<% $tax_type %>">
10 <INPUT TYPE="hidden" NAME="tax_cat" VALUE="<% $tax_cat %>">
12 This will <B><% $action %></B> <% $count %> tax
13 <% $count == 1 ? 'rate' : 'rates' %>. Are you <B>certain</B> you want to do
15 <BR><BR><INPUT TYPE="submit" VALUE="Yes">
21 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
24 if ( $cgi->param('action') =~ /^(\w+)$/ ) {
29 if ( $cgi->param('data_vendor') =~ /^(\w+)$/ ) {
34 if ( $cgi->param('geocode') =~ /^(\w+)$/ ) {
39 if ( $cgi->param('taxclassnum') =~ /^(\d+)$/ ) {
41 my $tax_class = qsearchs('tax_class', {'taxclassnum' => $taxclassnum});
47 if ( $cgi->param('tax_type') =~ /^(\d+)$/ );
49 if ( $cgi->param('tax_cat') =~ /^(\d+)$/ );
52 if ($tax_type || $tax_cat ) {
53 my $compare = "LIKE '". ( $tax_type || "%" ). ":". ( $tax_cat || "%" ). "'";
54 $compare = "= '$tax_type:$tax_cat'" if ($tax_type && $tax_cat);
56 qsearch({ 'table' => 'tax_class',
58 'extra_sql' => "WHERE taxclass $compare",
61 @taxclassnum = map { $_->taxclassnum } @tax_class;
62 $tax_class[0]->description =~ /^(.*):(.*)/;
71 $extra_sql .= ' WHERE data_vendor = '. dbh->quote($data_vendor);
75 $extra_sql .= ( $extra_sql =~ /WHERE/i ? ' AND ' : ' WHERE ' ).
76 ' geocode LIKE '. dbh->quote($geocode.'%');
80 $extra_sql .= ( $extra_sql =~ /WHERE/i ? ' AND ' : ' WHERE ' ).
81 ' taxclassnum = '. dbh->quote($taxclassnum);
85 $extra_sql .= ( $extra_sql =~ /WHERE/i ? ' AND ' : ' WHERE ' ).
86 join(' OR ', map { " taxclassnum = $_ " } @taxclassnum );
89 my $count_query = "SELECT COUNT(*) FROM tax_rate $extra_sql";
91 my $count_sth = dbh->prepare($count_query)
92 or die "Error preparing $count_query: ". dbh->errstr;
94 or die "Error executing $count_query: ". $count_sth->errstr;
95 my $count = $count_sth->fetchrow_arrayref->[0];