push @where, "cust_main.agentnum = $1";
}
+#classnum
+# not specified: all classes
+# 0: empty class
+# N: classnum
if ( $cgi->param('classnum') =~ /^(\d+)$/ ) {
if ( $1 == 0 ) {
push @where, "classnum IS NULL";
}
}
+push @where, map ' taxclass = '.dbh->quote($_), $cgi->param('taxclass')
+ if $cgi->param('taxclass')
+ && ! $cgi->param('istax'); #no part_pkg.taxclass in this case
+ #(should we save a taxclass or a link to taxnum
+ # in cust_bill_pkg or something like
+ # cust_bill_pkg_tax_location?)
+
#sub _where {
# my $table = shift;
# my $prefix = @_ ? shift : '';
}
-} elsif ( $cgi->param('country' ) ) {
+} elsif ( $cgi->param('country') ) {
my %ph = map { $_ => dbh->quote( $cgi->param($_) ) }
qw( county state country );
#warn "neither nottax nor istax parameters specified";
}
- push @where, ' taxclass = '. dbh->quote( $cgi->param('taxclass') )
- if $cgi->param('taxclass')
- && ! $cgi->param('istax'); #no part_pkg.taxclass in this case
- #(should we save a taxclass or a link to taxnum
- # in cust_bill_pkg or something like
- # cust_bill_pkg_tax_location?)
-
if ( $cgi->param('taxclassNULL') ) {
my %hash = ( 'country' => scalar($cgi->param('country')) );
}
- } elsif ( scalar( grep( /locationtaxid/, $cgi->param ) ) ) {
+} elsif ( scalar( grep( /locationtaxid/, $cgi->param ) ) ) {
# this should really be shoved out to FS::cust_pkg->location_sql or something
# along with the code in report_newtax.cgi
}
-if ($cgi->param('itemdesc')) {
- if ($cgi->param('itemdesc') eq 'Tax') {
+if ( $cgi->param('itemdesc') ) {
+ if ( $cgi->param('itemdesc') eq 'Tax' ) {
push @where, "(itemdesc='Tax' OR itemdesc is null)";
- }else{
+ } else {
push @where, 'itemdesc='. dbh->quote($cgi->param('itemdesc'));
}
}
+
+if ( $cgi->param('report_group') =~ /^(=|!=) (.*)$/ && $cgi->param('istax') ) {
+ my ( $group_op, $group_value ) = ( $1, $2 );
+ if ( $group_op eq '=' ) {
+ #push @where, 'itemdesc LIKE '. dbh->quote($group_value.'%');
+ push @where, 'itemdesc = '. dbh->quote($group_value);
+ } elsif ( $group_op eq '!=' ) {
+ push @where, '( itemdesc != '. dbh->quote($group_value) .' OR itemdesc IS NULL )';
+ } else {
+ die "guru meditation #00de: group_op $group_op\n";
+ }
+
+}
+
push @where, 'cust_bill_pkg.pkgnum != 0' if $cgi->param('nottax');
push @where, 'cust_bill_pkg.pkgnum = 0' if $cgi->param('istax');