1 <% include('/elements/header-popup.html', 'Addition successful' ) %>
3 <SCRIPT TYPE="text/javascript">
4 window.top.location.reload();
12 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
14 $cgi->param('taxnum') =~ /^(\d+)$/ or die "Illegal taxnum!";
16 my $cust_main_county = qsearchs('cust_main_county',{'taxnum'=>$taxnum})
17 or die ("Unknown taxnum!");
20 if ( $cgi->param('taxclass') ) {
21 my $sth = dbh->prepare('SELECT taxclass FROM part_pkg_taxclass')
23 $sth->execute or die $sth->errstr;
24 @expansion = map $_->[0], @{$sth->fetchall_arrayref};
25 errorpage "No taxclasses - add one first" unless @expansion;
27 @expansion = split /[\n\r]{1,2}/, $cgi->param('expansion');
29 #warn scalar(@expansion);
30 #warn "$_: $expansion[$_]\n" foreach (0..$#expansion);
33 unless ( /^\s*([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]+)\s*$/ ) {
34 $cgi->param('error', "Illegal item in expansion: $_");
35 print $cgi->redirect(popurl(2). "cust_main_county-expand.cgi?". $cgi->query_string );
43 foreach ( @expansion) {
44 my(%hash)=$cust_main_county->hash;
45 my($new)=new FS::cust_main_county \%hash;
46 $new->setfield('taxnum','');
47 if ( $cgi->param('taxclass') ) {
48 $new->setfield('taxclass', $_);
49 } elsif ( ! $cust_main_county->state ) {
50 $new->setfield('state',$_);
51 } elsif ( ! $cust_main_county->county ) {
52 $new->setfield('county',$_);
54 #uppercase cities in the US to try and agree with USPS validation
55 $new->setfield('city', $new->country eq 'US' ? uc($_) : $_ );
57 my $error = $new->insert;
61 unless ( qsearch( 'cust_main', {
62 'city' => $cust_main_county->city,
63 'county' => $cust_main_county->county,
64 'state' => $cust_main_county->state,
65 'country' => $cust_main_county->country,
69 my $error = $cust_main_county->delete;
73 if ( $cgi->param('taxclass') ) {
74 print $cgi->redirect(popurl(3). "browse/cust_main_county.cgi?".
75 'city='. uri_escape($cust_main_county->city ).';'.
76 'county='. uri_escape($cust_main_county->county ).';'.
77 'state='. uri_escape($cust_main_county->state ).';'.
78 'country='. uri_escape($cust_main_county->country)