clean up tax rate editing:
[freeside.git] / httemplate / edit / process / cust_main_county-collapse.cgi
1 <%
2 # <!-- $Id: cust_main_county-collapse.cgi,v 1.1 2001-08-17 11:05:31 ivan Exp $ -->
3
4 use strict;
5 use vars qw ( $cgi $taxnum $cust_main_county @expansion $expansion );
6 use CGI;
7 use CGI::Carp qw(fatalsToBrowser);
8 use FS::UID qw(cgisuidsetup datasrc);
9 use FS::Record qw(qsearch qsearchs);
10 use FS::CGI qw(popurl);
11 use FS::cust_main_county;
12 use FS::cust_main;
13
14 $cgi = new CGI;
15 &cgisuidsetup($cgi);
16
17 my($query) = $cgi->keywords;
18 $query =~ /^(\d+)$/ or die "Illegal taxnum!";
19 $taxnum = $1;
20 $cust_main_county = qsearchs('cust_main_county',{'taxnum'=>$taxnum})
21   or die ("Unknown taxnum!");
22
23 #really should do this in a .pm & start transaction
24
25 foreach my $delete ( qsearch('cust_main_county', {
26                     'country' => $cust_main_county->country,
27                     'state' => $cust_main_county->state  
28                  } ) ) {
29 #  unless ( qsearch('cust_main',{
30 #    'state'  => $cust_main_county->getfield('state'),
31 #    'county' => $cust_main_county->getfield('county'),
32 #    'country' =>  $cust_main_county->getfield('country'),
33 #  } ) ) {
34     my $error = $delete->delete;
35     die $error if $error;
36 #  } else {
37     #should really fix the $cust_main record
38 #  }
39
40 }
41
42 $cust_main_county->taxnum('');
43 $cust_main_county->county('');
44 my $error = $cust_main_county->insert;
45 die $error if $error;
46
47 print $cgi->redirect(popurl(3). "browse/cust_main_county.cgi");
48
49 %>