From d1a885c65ac10e19bed0333a380dafeb42c2cef1 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 8 Oct 2005 00:47:20 +0000 Subject: [PATCH] fix tax class selection in package add/edit too --- httemplate/edit/part_pkg.cgi | 52 +++++++++++------------------ httemplate/edit/process/part_pkg.cgi | 9 ++++- httemplate/edit/process/quick-charge.cgi | 2 +- httemplate/elements/select-taxclass.html | 42 +++++++++++++++++++++++ httemplate/view/cust_main/quick-charge.html | 41 +++-------------------- 5 files changed, 76 insertions(+), 70 deletions(-) create mode 100644 httemplate/elements/select-taxclass.html diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index e6e10e73f..2c3808fe1 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -1,4 +1,3 @@ - <% if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) { @@ -120,42 +119,31 @@ Tax information Setup fee tax exempt -<% - -print '{setuptax} eq "Y"; -print '>'; + {setuptax} eq 'Y' ? ' CHECKED' : '' %>> + + + + Recurring fee tax exempt + + {recurtax} eq 'Y' ? ' CHECKED' : '' %>> + + -print < -Recurring fee tax exempt -END +<% my $conf = new FS::Conf; %> +<% if ( $conf->exists('enable_taxclasses') ) { %> -print '{recurtax} eq "Y"; -print '>'; + + Tax class + + <%= include('/elements/select-taxclass.html', $hashref->{taxclass} ) %> + + -print ''; +<% } else { %> -my $conf = new FS::Conf; -#false laziness w/ view/cust_main.cgi quick order -if ( $conf->exists('enable_taxclasses') ) { - print 'Tax class'; -} else { - print - ''; -} + <%= include('/elements/select-taxclass.html', $hashref->{taxclass} ) %> -%> +<% } %> diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 1a7f52838..0d0a13491 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -29,12 +29,18 @@ my %pkg_svc = map { $_ => scalar($cgi->param("pkg_svc$_")) } my $error; my $custnum = ''; -if ( $pkgpart ) { +if ( $cgi->param('taxclass') eq '(select)' ) { + + $error = 'Must select a tax class'; + +} elsif ( $pkgpart ) { + $error = $new->replace( $old, pkg_svc => \%pkg_svc, primary_svc => scalar($cgi->param('pkg_svc_primary')), ); } else { + $error = $new->insert( pkg_svc => \%pkg_svc, primary_svc => scalar($cgi->param('pkg_svc_primary')), cust_pkg => $cgi->param('pkgnum'), @@ -42,6 +48,7 @@ if ( $pkgpart ) { ); $pkgpart = $new->pkgpart; } + if ( $error ) { $cgi->param('error', $error ); print $cgi->redirect(popurl(2). "part_pkg.cgi?". $cgi->query_string ); diff --git a/httemplate/edit/process/quick-charge.cgi b/httemplate/edit/process/quick-charge.cgi index 9d9aa980a..928e3daad 100644 --- a/httemplate/edit/process/quick-charge.cgi +++ b/httemplate/edit/process/quick-charge.cgi @@ -13,7 +13,7 @@ my( $error, $cust_main); if ( $cgi->param('taxclass') eq '(select)' ) { - $error = "Must select a tax class"; + $error = 'Must select a tax class'; } else { my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) diff --git a/httemplate/elements/select-taxclass.html b/httemplate/elements/select-taxclass.html new file mode 100644 index 000000000..e8889d59d --- /dev/null +++ b/httemplate/elements/select-taxclass.html @@ -0,0 +1,42 @@ +<% + my $conf = new FS::Conf; + my $selected_taxclass = scalar(@_) ? shift : ''; +%> + +<% if ( $conf->exists('enable_taxclasses') ) { %> + + + +<% } else { %> + + '; + +<% } %> + + diff --git a/httemplate/view/cust_main/quick-charge.html b/httemplate/view/cust_main/quick-charge.html index 9e4fb8c6e..2fe3d5f3d 100644 --- a/httemplate/view/cust_main/quick-charge.html +++ b/httemplate/view/cust_main/quick-charge.html @@ -1,49 +1,18 @@ <% my( $cust_main ) = @_; - my $conf = new FS::Conf; %>
- -Description: -Amount: -<% #false laziness w/ edit/part_pkg.cgi %> -<% if ( $conf->exists('enable_taxclasses') ) { %> - - - <% - my $sth = dbh->prepare('SELECT DISTINCT taxclass FROM cust_main_county') - or die dbh->errstr; - $sth->execute or die $sth->errstr; - my %taxclasses = map { $_->[0] => 1 } @{$sth->fetchall_arrayref}; - my @taxclasses = grep $_, keys %taxclasses; - %> - - <% foreach my $taxclass ( @taxclasses ) { %> - -
-- 2.11.0