summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xhttemplate/edit/part_pkg.cgi52
-rwxr-xr-xhttemplate/edit/process/part_pkg.cgi9
-rw-r--r--httemplate/edit/process/quick-charge.cgi2
-rw-r--r--httemplate/elements/select-taxclass.html42
-rw-r--r--httemplate/view/cust_main/quick-charge.html41
5 files changed, 76 insertions, 70 deletions
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 @@
-<!-- mason kludge -->
<%
if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) {
@@ -120,42 +119,31 @@ Tax information
<TR>
<TD ALIGN="right">Setup fee tax exempt</TD>
<TD>
-<%
-
-print '<INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y"';
-print ' CHECKED' if $hashref->{setuptax} eq "Y";
-print '>';
+ <INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y" <%= $hashref->{setuptax} eq 'Y' ? ' CHECKED' : '' %>>
+ </TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right">Recurring fee tax exempt</TD>
+ <TD>
+ <INPUT TYPE="checkbox" NAME="recurtax" VALUE="Y" <%= $hashref->{recurtax} eq 'Y' ? ' CHECKED' : '' %>>
+ </TD>
+ </TR>
-print <<END;
-</TD></TR>
-<TR><TD ALIGN="right">Recurring fee tax exempt</TD><TD>
-END
+<% my $conf = new FS::Conf; %>
+<% if ( $conf->exists('enable_taxclasses') ) { %>
-print '<INPUT TYPE="checkbox" NAME="recurtax" VALUE="Y"';
-print ' CHECKED' if $hashref->{recurtax} eq "Y";
-print '>';
+ <TR>
+ <TD align="right">Tax class</TD>
+ <TD>
+ <%= include('/elements/select-taxclass.html', $hashref->{taxclass} ) %>
+ </TD>
+ </TR>
-print '</TD></TR>';
+<% } else { %>
-my $conf = new FS::Conf;
-#false laziness w/ view/cust_main.cgi quick order
-if ( $conf->exists('enable_taxclasses') ) {
- print '<TR><TD ALIGN="right">Tax class</TD><TD><SELECT NAME="taxclass">';
- my $sth = dbh->prepare('SELECT DISTINCT taxclass FROM cust_main_county')
- or die dbh->errstr;
- $sth->execute or die $sth->errstr;
- foreach my $taxclass ( map $_->[0], @{$sth->fetchall_arrayref} ) {
- print qq!<OPTION VALUE="$taxclass"!;
- print ' SELECTED' if $taxclass eq $hashref->{taxclass};
- print qq!>$taxclass</OPTION>!;
- }
- print '</SELECT></TD></TR>';
-} else {
- print
- '<INPUT TYPE="hidden" NAME="taxclass" VALUE="'. $hashref->{taxclass}. '">';
-}
+ <%= include('/elements/select-taxclass.html', $hashref->{taxclass} ) %>
-%>
+<% } %>
</TABLE>
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') ) { %>
+
+ <SELECT NAME="taxclass">
+
+ <% if ( $conf->exists('require_taxclasses') ) { %>
+
+ <OPTION VALUE="(select)">Select tax class
+
+ <% } else { %>
+
+ <OPTION VALUE="">
+
+ <% } %>
+
+ <%
+ 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 ) { %>
+
+ <OPTION VALUE="<%= $taxclass %>"<%= $taxclass eq $selected_taxclass ? ' SELECTED' : '' %>><%= $taxclass %>
+
+ <% } %>
+
+ </SELECT>
+
+<% } else { %>
+
+ <INPUT TYPE="hidden" NAME="taxclass" VALUE="<%= $selected_taxclass %>">';
+
+<% } %>
+
+
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;
%>
<FORM ACTION="<%=$p%>edit/process/quick-charge.cgi" METHOD="POST">
-<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $cust_main->custnum %>">
-Description:<INPUT TYPE="text" NAME="pkg">
-Amount:<INPUT TYPE="text" NAME="amount" SIZE=6>
-<% #false laziness w/ edit/part_pkg.cgi %>
-<% if ( $conf->exists('enable_taxclasses') ) { %>
-
- <SELECT NAME="taxclass">
-
- <% if ( $conf->exists('require_taxclasses') ) { %>
-
- <OPTION VALUE="(select)">Select tax class
- <% } else { %>
-
- <OPTION VALUE="">
-
- <% } %>
+<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $cust_main->custnum %>">
- <%
- 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 ) { %>
-
- <OPTION VALUE="<%= $taxclass %>"<%= 0 ? ' SELECTED' : '' %>><%= $taxclass %>
-
- <% } %>
+Description:<INPUT TYPE="text" NAME="pkg">
- </SELECT>
+Amount:<INPUT TYPE="text" NAME="amount" SIZE=6>
-<% } else { %>
+<%= include('/elements/select-taxclass.html') %>
- <INPUT TYPE="hidden" NAME="taxclass" VALUE="">';
-
-<% } %>
-
<INPUT TYPE="submit" VALUE="One-time charge">
+
</FORM>