9b7324b0dc399c868dae550bc5a53611a56293e4
[freeside.git] / httemplate / misc / process / enable_or_disable_tax.html
1 %if ($error) {
2 <% $cgi->redirect(popurl(2).'enable_or_disable_tax.html?'.$cgi->query_string) %>
3 %}else{
4   <% include('/elements/header-popup.html', $title) %>
5
6   <SCRIPT TYPE="text/javascript">
7     window.top.location.reload();
8   </SCRIPT>
9
10   </BODY>
11   </HTML>
12 %}
13 <%init>
14
15 die "access denied"
16   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
17
18 my $action = '';
19 if ( $cgi->param('action') =~ /^(\w+)$/ ) {
20   $action = $1;
21 }
22
23 my ($query, $count_query) = FS::tax_rate::browse_queries(scalar($cgi->Vars));
24 my @tax_rate = qsearch( $query );
25
26 #transaction?
27 my $error;
28 $error = "Invalid action" unless ($action =~ /enable|disable/);
29
30 foreach my $tax_rate (@tax_rate) {
31   $action eq 'enable' ? $tax_rate->disabled('') : $tax_rate->disabled('Y');
32   # $tax_rate->manual('Y');
33   $error ||= $tax_rate->replace;
34   last if $error;
35 }
36 $cgi->param('error', $error) if $error;
37
38 my $title = scalar(@tax_rate) == 1 ? 'Tax rate ' : 'Tax rates ';
39 $title .= lc($action). 'd';
40
41 </%init>