import torrus 1.0.9
[freeside.git] / httemplate / edit / process / tax_class.html
1 % if ( $error ) {
2 %  $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(2). "tax_class.html?". $cgi->query_string ) %>
4 %} else {
5 <% $cgi->redirect(popurl(3). "browse/tax_rate.cgi?taxclassnum=". uri_escape($tax_class->taxclassnum) ) %>
6 %}
7 <%init>
8
9 die "access denied"
10   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
11
12 my $tax_class = new FS::tax_class {
13   'taxclass' => $cgi->param('taxclass'),
14   'description' => $cgi->param('description'),
15 };
16
17 #maybe this whole thing should be in a transaction.  at some point, no biggie
18 #none of the follow-up stuff will fail unless there's a more serious problem
19 #than a hanging record in tax_class...
20
21 my $error = $tax_class->insert;
22
23 # all of this is highly dubious at the moment
24
25 #unless ( $error ) {
26 #  #auto-add the new taxclass to any regions that have taxclasses already
27 #
28 #  my $sth = dbh->prepare("
29 #    SELECT geocode FROM tax_rate
30 #      WHERE taxclass IS NOT NULL AND taxclass != ''
31 #      GROUP BY geocode
32 #  ") or die dbh->errstr;
33 #  $sth->execute or die $sth->errstr;
34 #
35 #  while ( my $row = $sth->fetchrow_hashref ) {
36 #    warn "inserting for $row";
37 #    my $cust_main_county = new FS::tax_rate {
38 #      'geocode'     => $row->{geocode},
39 #      'tax'         => 0,
40 #      'taxclassnum' => $tax_class->taxclassnum,
41 #    };
42 #    $error = $cust_main_county->insert;
43 #    #last if $error;
44 #    die $error if $error;
45 #  }
46 #
47 #}
48
49 </%init>