X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_event.pm;h=d2fcfc1e254fde0c57d260057cd58405425b7872;hb=cf49d3c860a2000cfc23a0e0db472a7d6fc58935;hp=10fb0acf74bba288cd92d8426b91645520797eae;hpb=d57a1feb48c55fecb95502e894575eebb306a58a;p=freeside.git diff --git a/FS/FS/cust_event.pm b/FS/FS/cust_event.pm index 10fb0acf7..d2fcfc1e2 100644 --- a/FS/FS/cust_event.pm +++ b/FS/FS/cust_event.pm @@ -315,16 +315,30 @@ sub join_sql { } -=item search_sql HASHREF +=item search_sql_where HASHREF Class method which returns an SQL WHERE fragment to search for parameters specified in HASHREF. Valid parameters are =over 4 -=item +=item agentnum -=item +=item custnum + +=item invnum + +=item pkgnum + +=item failed + +=item beginning + +=item ending + +=item payby + +=item =back @@ -333,19 +347,22 @@ specified in HASHREF. Valid parameters are #Note: validates all passed-in data; i.e. safe to use with unchecked CGI params. #sub -sub search_sql { +sub search_sql_where { my($class, $param) = @_; if ( $DEBUG ) { - warn "$me search_sql called with params: \n". + warn "$me search_sql_where called with params: \n". join("\n", map { " $_: ". $param->{$_} } keys %$param ). "\n"; } - my @search = (); + my @search = $class->cust_search_sql($param); - if ( $param->{'agentnum'} && $param->{'agentnum'} =~ /^(\d+)$/ ) { - push @search, "cust_main.agentnum = $1"; - #my $agent = qsearchs('agent', { 'agentnum' => $1 } ); - #die "unknown agentnum $1" unless $agent; + #eventpart + my @eventpart = ref($param->{'eventpart'}) + ? @{ $param->{'eventpart'} } + : split(',', $param->{'eventpart'}); + @eventpart = grep /^(\d+)$/, @eventpart; + if ( @eventpart ) { + push @search, 'eventpart IN ('. join(',', @eventpart). ')'; } if ( $param->{'beginning'} =~ /^(\d+)$/ ) { @@ -361,10 +378,6 @@ sub search_sql { "statustext != 'N/A'"; } - #if ( $param->{'part_event.payby'} =~ /^(\w+)$/ ) { - # push @search, "part_event.payby = '$1'"; - #} - if ( $param->{'custnum'} =~ /^(\d+)$/ ) { push @search, "cust_main.custnum = '$1'"; } @@ -379,13 +392,8 @@ sub search_sql { "tablenum = '$1'"; } - #here is the agent virtualization - push @search, - $FS::CurrentUser::CurrentUser->agentnums_sql( 'table' => 'cust_main' ); - my $where = 'WHERE '. join(' AND ', @search ); - join(' AND ', @search ); } @@ -440,7 +448,7 @@ sub process_re_X { sub re_X { my($method, $param, $job) = @_; - my $search_sql = FS::cust_event->search_sql($param); + my $search_sql = FS::cust_event->search_sql_where($param); #maybe not...? we do want the "re-" action to match the search more closely # # yuck! hardcoded *AND* sequential scans!