my @loc_param = qw( district city county state country );
if ( $cgi->param('out') ) {
+ # probably don't need this part
my ( $loc_sql, @param ) = FS::cust_pkg->location_sql( 'ornull' => 1 );
while ( $loc_sql =~ /\?/ ) { #easier to do our own substitution
#hacky, could be more efficient. care if it is ever used for more than the
# tax-report_groups filtering kludge
+ # (does that even still exist? if so, correct this (or location_sql itself)
+ # to work with modern cust_location links)
my $locs_sql =
' ( '. join(' OR ', map {
} else {
- my %ph = map { $_ => dbh->quote( scalar($cgi->param($_)) ) } @loc_param;
-
- my ( $loc_sql, @param ) = FS::cust_pkg->location_sql;
- while ( $loc_sql =~ /\?/ ) { #easier to do our own substitution
- $loc_sql =~ s/\?/$ph{shift(@param)}/e;
+ my @loc_where;
+ foreach (@loc_param) {
+ if ( length($cgi->param($_)) ) {
+ my $quoted = dbh->quote($cgi->param($_));
+ push @loc_where, "(COALESCE(cust_location.$_, '') = $quoted)";
+ }
}
+ my $loc_sql = join(' AND ', @loc_where);
- push @where, $loc_sql;
+ #my %ph = map { $_ => dbh->quote( scalar($cgi->param($_)) ) } @loc_param;
+ #
+ #my ( $loc_sql, @param ) = FS::cust_pkg->location_sql;
+ #while ( $loc_sql =~ /\?/ ) { #easier to do our own substitution
+ # $loc_sql =~ s/\?/$ph{shift(@param)}/e;
+ #}
+ push @where, $loc_sql;
+warn $loc_sql;
}
my($title, $name);