summaryrefslogtreecommitdiff
path: root/httemplate/misc/process/enable_or_disable_tax.html
blob: 9b7324b0dc399c868dae550bc5a53611a56293e4 (plain)
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
%if ($error) {
<% $cgi->redirect(popurl(2).'enable_or_disable_tax.html?'.$cgi->query_string) %>
%}else{
  <% include('/elements/header-popup.html', $title) %>

  <SCRIPT TYPE="text/javascript">
    window.top.location.reload();
  </SCRIPT>

  </BODY>
  </HTML>
%}
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

my $action = '';
if ( $cgi->param('action') =~ /^(\w+)$/ ) {
  $action = $1;
}

my ($query, $count_query) = FS::tax_rate::browse_queries(scalar($cgi->Vars));
my @tax_rate = qsearch( $query );

#transaction?
my $error;
$error = "Invalid action" unless ($action =~ /enable|disable/);

foreach my $tax_rate (@tax_rate) {
  $action eq 'enable' ? $tax_rate->disabled('') : $tax_rate->disabled('Y');
  # $tax_rate->manual('Y');
  $error ||= $tax_rate->replace;
  last if $error;
}
$cgi->param('error', $error) if $error;

my $title = scalar(@tax_rate) == 1 ? 'Tax rate ' : 'Tax rates ';
$title .= lc($action). 'd';

</%init>