3 # process/cust_main_county-expand.cgi: Expand counties (process form)
5 # ivan@sisd.com 97-dec-16
7 # Changes to allow page to work at a relative position in server
8 # Added import of datasrc from UID.pm for Pg6.3
9 # Default tax to 0.0 if using Pg6.3
10 # bmccane@maxbaud.net 98-apr-3
12 # lose background, FS::CGI
13 # undo default tax to 0.0 if using Pg6.3: comes from pre-expanded record
15 #ivan@sisd.com 98-sep-2
19 use CGI::Carp qw(fatalsToBrowser);
20 use FS::UID qw(cgisuidsetup datasrc);
21 use FS::Record qw(qsearch qsearchs);
22 use FS::cust_main_county;
23 use FS::CGI qw(eidiot);
25 my($req)=new CGI::Request; # create form object
27 &cgisuidsetup($req->cgi);
29 $req->param('taxnum') =~ /^(\d+)$/ or die "Illegal taxnum!";
31 my($cust_main_county)=qsearchs('cust_main_county',{'taxnum'=>$taxnum})
32 or die ("Unknown taxnum!");
35 if ( $req->param('delim') eq 'n' ) {
36 @counties=split(/\n/,$req->param('counties'));
37 } elsif ( $req->param('delim') eq 's' ) {
38 @counties=split(/\s+/,$req->param('counties'));
44 /^\s*([\w\- ]+)\s*$/ or eidiot("Illegal county");
49 foreach ( @counties) {
50 my(%hash)=$cust_main_county->hash;
51 my($new)=create FS::cust_main_county \%hash;
52 $new->setfield('taxnum','');
53 $new->setfield('county',$_);
54 #if (datasrc =~ m/Pg/)
56 # $new->setfield('tax',0.0);
58 my($error)=$new->insert;
62 unless ( qsearch('cust_main',{
63 'state' => $cust_main_county->getfield('state'),
64 'county' => $cust_main_county->getfield('county'),
66 my($error)=($cust_main_county->delete);
70 $req->cgi->redirect("../../edit/cust_main_county.cgi");