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 die "no taxclasses - add one first" unless @expansion;#XXX better err handling
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',$_);
52 $new->setfield('county',$_);
54 my $error = $new->insert;
58 unless ( qsearch( 'cust_main', {
59 'state' => $cust_main_county->state,
60 'county' => $cust_main_county->county,
61 'country' => $cust_main_county->country,
65 my $error = $cust_main_county->delete;
69 if ( $cgi->param('taxclass') ) {
70 print $cgi->redirect(popurl(3). "browse/cust_main_county.cgi?".
71 'state='. uri_escape($cust_main_county->state ).';'.
72 'county='. uri_escape($cust_main_county->county ).';'.
73 'country='. uri_escape($cust_main_county->country)