2 # <!-- $Id: cust_main_county-expand.cgi,v 1.3 2001-08-31 07:17:33 ivan Exp $ -->
5 use vars qw ( $cgi $taxnum $cust_main_county @expansion $expansion );
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;
17 $cgi->param('taxnum') =~ /^(\d+)$/ or die "Illegal taxnum!";
19 $cust_main_county = qsearchs('cust_main_county',{'taxnum'=>$taxnum})
20 or die ("Unknown taxnum!");
22 if ( $cgi->param('delim') eq 'n' ) {
23 @expansion=split(/\n/,$cgi->param('expansion'));
24 } elsif ( $cgi->param('delim') eq 's' ) {
25 @expansion=split(' ',$cgi->param('expansion'));
31 unless ( /^\s*([\w\- ]+)\s*$/ ) {
32 $cgi->param('error', "Illegal item in expansion");
33 print $cgi->redirect(popurl(2). "cust_main_county-expand.cgi?". $cgi->query_string );
39 foreach ( @expansion) {
40 my(%hash)=$cust_main_county->hash;
41 my($new)=new FS::cust_main_county \%hash;
42 $new->setfield('taxnum','');
43 if ( ! $cust_main_county->state ) {
44 $new->setfield('state',$_);
46 $new->setfield('county',$_);
48 #if (datasrc =~ m/Pg/)
50 # $new->setfield('tax',0.0);
52 my($error)=$new->insert;
56 unless ( qsearch( 'cust_main', {
57 'state' => $cust_main_county->state,
58 'county' => $cust_main_county->county,
59 'country' => $cust_main_county->country,
63 my($error)=($cust_main_county->delete);
67 print $cgi->redirect(popurl(3). "browse/cust_main_county.cgi");