This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / httemplate / edit / process / bulk-cust_main_county.html
1 % if ( $error ) { #better to redirect back to 
2 %# <% $cgi->redirect("$url?". $cgi->query_string ) %>
3   <% include('/elements/header-popup.html', "Error ${action}ing taxes" ) %>
4
5   <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error |h %></FONT>
6   <BR><BR>
7
8   </BODY>
9   </HTML>
10
11 % } else {
12   <% include('/elements/header-popup.html', "Taxes ${action}ed") %>
13
14   <SCRIPT TYPE="text/javascript">
15     window.top.location.reload();
16   </SCRIPT>
17
18   </BODY>
19   </HTML>
20 % }
21 <%init>
22
23 $cgi->param('taxnum') =~ /^([\d,]+)$/
24   or die 'Guru Meditation #69'; #??? should have been passed in
25 my @taxnum = split(',', $1);
26
27 $cgi->param('action') =~ /^(add|edit)$/ or die "unknown action";
28 my $action = $1;
29
30 my $error = '';
31 foreach my $taxnum ( @taxnum ) {
32
33   my $cust_main_county = qsearchs('cust_main_county', { 'taxnum' => $taxnum } )
34     or die "unknown taxnum: $taxnum";
35
36   if ( $action eq 'edit' || $cust_main_county->tax == 0 ) { #let's replace
37
38     foreach (qw( taxname tax exempt_amount setuptax recurtax )) {
39       $cust_main_county->set( $_ => scalar($cgi->param($_)) )
40     }
41
42     $error = $cust_main_county->replace and last;
43
44   } else { #let's insert a new record
45
46     my $new =
47       new FS::cust_main_county {
48         ( map { $_ => scalar($cgi->param($_)) }
49               qw( taxname tax exempt_amount setuptax recurtax )
50         ),
51         ( map { $_ => $cust_main_county->get($_) }
52               qw( country state county taxclass ) 
53         )
54       };
55
56     $error = $new->insert and last;
57     
58   }
59
60 }
61
62 if ( $error ) {
63   $cgi->param('error', $error);
64 }
65
66 </%init>