This commit was generated by cvs2svn to compensate for changes in r3921,
[freeside.git] / httemplate / edit / process / cust_main_county-collapse.cgi
1 <%
2
3 my($query) = $cgi->keywords;
4 $query =~ /^(\d+)$/ or die "Illegal taxnum!";
5 my $taxnum = $1;
6 my $cust_main_county = qsearchs('cust_main_county', { 'taxnum' => $taxnum } )
7   or die "Unknown taxnum $taxnum";
8
9 #really should do this in a .pm & start transaction
10
11 foreach my $delete ( qsearch('cust_main_county', {
12                     'country' => $cust_main_county->country,
13                     'state' => $cust_main_county->state  
14                  } ) ) {
15 #  unless ( qsearch('cust_main',{
16 #    'state'  => $cust_main_county->getfield('state'),
17 #    'county' => $cust_main_county->getfield('county'),
18 #    'country' =>  $cust_main_county->getfield('country'),
19 #  } ) ) {
20     my $error = $delete->delete;
21     die $error if $error;
22 #  } else {
23     #should really fix the $cust_main record
24 #  }
25
26 }
27
28 $cust_main_county->taxnum('');
29 $cust_main_county->county('');
30 my $error = $cust_main_county->insert;
31 die $error if $error;
32
33 print $cgi->redirect(popurl(3). "browse/cust_main_county.cgi");
34
35 %>