default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / edit / process / bulk-cust_main_county.html
index e05192e..55832e9 100644 (file)
@@ -1,6 +1,6 @@
 % if ( $error ) { #better to redirect back to 
 %# <% $cgi->redirect("$url?". $cgi->query_string ) %>
-  <% include('/elements/header-popup.html', 'Error adding taxes' ) %>
+  <% include('/elements/header-popup.html', "Error ${action}ing taxes" ) %>
 
   <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error |h %></FONT>
   <BR><BR>
@@ -9,10 +9,10 @@
   </HTML>
 
 % } else {
-  <% include('/elements/header-popup.html', 'Taxes added') %>
+  <% include('/elements/header-popup.html', "Taxes ${action}ed") %>
 
   <SCRIPT TYPE="text/javascript">
-    window.top.location.reload();
+    topreload();
   </SCRIPT>
 
   </BODY>
@@ -24,16 +24,26 @@ $cgi->param('taxnum') =~ /^([\d,]+)$/
   or die 'Guru Meditation #69'; #??? should have been passed in
 my @taxnum = split(',', $1);
 
+$cgi->param('action') =~ /^(add|edit)$/ or die "unknown action";
+my $action = $1;
+
+my $rate_only = $cgi->param('rate_only') if $cgi->param('rate_only');
+
 my $error = '';
 foreach my $taxnum ( @taxnum ) {
 
   my $cust_main_county = qsearchs('cust_main_county', { 'taxnum' => $taxnum } )
     or die "unknown taxnum: $taxnum";
 
-  if ( $cust_main_county->tax == 0 ) { #let's replace
+  if ( $action eq 'edit' || $cust_main_county->tax == 0 ) { #let's replace
 
-    foreach (qw( taxname tax exempt_amount setuptax recurtax )) {
-      $cust_main_county->set( $_ => scalar($cgi->param($_)) )
+    if ($rate_only) {
+      $cust_main_county->set( tax => scalar($cgi->param('tax')) );
+    }
+    else {
+      foreach (qw( taxname tax exempt_amount setuptax recurtax )) {
+        $cust_main_county->set( $_ => scalar($cgi->param($_)) )
+      }
     }
 
     $error = $cust_main_county->replace and last;
@@ -46,7 +56,7 @@ foreach my $taxnum ( @taxnum ) {
               qw( taxname tax exempt_amount setuptax recurtax )
         ),
         ( map { $_ => $cust_main_county->get($_) }
-              qw( country state county taxclass ) 
+              qw( country state county city district taxclass ) 
         )
       };