2 % $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(2). "part_pkg_taxclass.html?". $cgi->query_string ) %>
5 <% $cgi->redirect(popurl(3). "browse/cust_main_county.cgi?taxclass=". uri_escape($part_pkg_taxclass->taxclass) ) %>
10 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
12 my $part_pkg_taxclass = new FS::part_pkg_taxclass {
13 'taxclass' => $cgi->param('taxclass'),
16 #maybe this whole thing should be in a transaction. at some point, no biggie
17 #none of the follow-up stuff will fail unless there's a more serious problem
18 #than a hanging record in part_pkg_taxclass...
20 my $error = $part_pkg_taxclass->insert;
23 #auto-add the new taxclass to any regions that have taxclasses already
25 my $sth = dbh->prepare("
26 SELECT country, state, county FROM cust_main_county
27 WHERE taxclass IS NOT NULL AND taxclass != ''
28 GROUP BY country, state, county
29 ") or die dbh->errstr;
30 $sth->execute or die $sth->errstr;
32 while ( my $row = $sth->fetchrow_hashref ) {
33 warn "inserting for $row";
34 my $cust_main_county = new FS::cust_main_county {
35 'country' => $row->{country},
36 'state' => $row->{state},
37 'county' => $row->{county},
39 'taxclass' => $part_pkg_taxclass->taxclass,
45 $error = $cust_main_county->insert;