diff options
author | ivan <ivan> | 2009-06-30 19:38:57 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-06-30 19:38:57 +0000 |
commit | 443150b6184876c967adffa199c20f53d5b76075 (patch) | |
tree | 69cb79e2d3e8dc593916f81c24c60f55e9eba937 /httemplate/edit | |
parent | a70239efdaeddf0b20fea7f5126a2e3f0a962eb6 (diff) |
disabling a taxclass, RT#5472
Diffstat (limited to 'httemplate/edit')
-rw-r--r-- | httemplate/edit/part_pkg_taxclass.html | 43 | ||||
-rw-r--r-- | httemplate/edit/process/part_pkg_taxclass.html | 58 |
2 files changed, 28 insertions, 73 deletions
diff --git a/httemplate/edit/part_pkg_taxclass.html b/httemplate/edit/part_pkg_taxclass.html index e76705722..ad030449f 100644 --- a/httemplate/edit/part_pkg_taxclass.html +++ b/httemplate/edit/part_pkg_taxclass.html @@ -1,32 +1,23 @@ -<% include('/elements/header.html', "$action taxclass") %> - -<% include('/elements/error.html') %> - -<FORM ACTION="<% $p1 %>process/part_pkg_taxclass.html" METHOD=POST> - -<INPUT TYPE="hidden" NAME="taxclassnum" VALUE=""> - -Tax class <INPUT TYPE="text" NAME="taxclass" VALUE="<% $taxclass |h %>"> - -<BR><BR> -<INPUT TYPE="submit" VALUE="<% $action %> taxclass"> - -</FORM> - -<% include('/elements/footer.html') %> - +<% include('elements/edit.html', + 'name_singular' => 'tax class', + 'table' => 'part_pkg_taxclass', + 'labels' => { + 'taxclassnum' => 'Tax class', + 'taxclass' => 'Tax class', + 'disabled' => 'Disabled', + }, + 'fields' => [ 'taxclass', + { 'field' => 'disabled', + 'type' => 'checkbox', + 'value' => 'Y', + }, + ], + 'viewall_dir' => 'browse', + ) +%> <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); -my $taxclass = ''; -if ( $cgi->param('error') ) { - $taxclass = $cgi->param('taxclass'); -} - -my $action = 'Add'; - -my $p1 = popurl(1); - </%init> diff --git a/httemplate/edit/process/part_pkg_taxclass.html b/httemplate/edit/process/part_pkg_taxclass.html index 8f149bb94..b37279fb3 100644 --- a/httemplate/edit/process/part_pkg_taxclass.html +++ b/httemplate/edit/process/part_pkg_taxclass.html @@ -1,53 +1,17 @@ -% if ( $error ) { -% $cgi->param('error', $error); -<% $cgi->redirect(popurl(2). "part_pkg_taxclass.html?". $cgi->query_string ) %> -%} else { -<% $cgi->redirect(popurl(3). "browse/cust_main_county.cgi?taxclass=". uri_escape($part_pkg_taxclass->taxclass) ) %> -%} +<% include( 'elements/process.html', + 'table' => 'part_pkg_taxclass', + 'redirect' => sub { + my( $cgi, $part_pkg_taxclass ) = @_; + + popurl(3). 'browse/cust_main_county.cgi?'. + 'taxclass='. uri_escape($part_pkg_taxclass->taxclass). + ';dummy='; + }, + ) +%> <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); -my $part_pkg_taxclass = new FS::part_pkg_taxclass { - 'taxclass' => $cgi->param('taxclass'), -}; - -#maybe this whole thing should be in a transaction. at some point, no biggie -#none of the follow-up stuff will fail unless there's a more serious problem -#than a hanging record in part_pkg_taxclass... - -my $error = $part_pkg_taxclass->insert; - -unless ( $error ) { - #auto-add the new taxclass to any regions that have taxclasses already - - my $sth = dbh->prepare(" - SELECT country, state, county FROM cust_main_county - WHERE taxclass IS NOT NULL AND taxclass != '' - GROUP BY country, state, county - ") or die dbh->errstr; - $sth->execute or die $sth->errstr; - - while ( my $row = $sth->fetchrow_hashref ) { - warn "inserting for $row"; - my $cust_main_county = new FS::cust_main_county { - 'country' => $row->{country}, - 'state' => $row->{state}, - 'county' => $row->{county}, - 'tax' => 0, - 'taxclass' => $part_pkg_taxclass->taxclass, - #exempt_amount - #taxname - #setuptax - #recurtax - }; - $error = $cust_main_county->insert; - #last if $error; - die $error if $error; - } - - -} - </%init> |