diff options
author | David Houghton <houghton@freeside.biz> | 2014-09-10 15:54:31 -0400 |
---|---|---|
committer | David Houghton <houghton@freeside.biz> | 2014-09-10 15:54:31 -0400 |
commit | 55a9939e17ab945d00336317b9842f17cc27ba6e (patch) | |
tree | 4fd48c9f05bd91cf9a5c5a0ae2c743dfd6f7fc2c | |
parent | 15b214cb34630925ff42e4252b74403fff77e7c0 (diff) | |
parent | 67622d2fde244b52fdca6a4ba4b98e2453f7986a (diff) |
Merge branch 'master' of git+ssh://git.freeside.biz/home/git/freeside
Making my local master match the remote.
-rw-r--r-- | FS/FS/cust_main/Search.pm | 13 | ||||
-rw-r--r-- | httemplate/search/elements/search.html | 2 |
2 files changed, 8 insertions, 7 deletions
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm index 0c00477f6..bb5891d5d 100644 --- a/FS/FS/cust_main/Search.pm +++ b/FS/FS/cust_main/Search.pm @@ -477,11 +477,12 @@ sub smart_search { push @cust_main, qsearch({ 'table' => 'cust_main', + 'addl_from' => ' JOIN cust_payby USING (custnum)', 'hashref' => {}, - 'extra_sql' => " WHERE ( payinfo LIKE '$like_search' - OR paymask = '$mask_search' + 'extra_sql' => " WHERE ( cust_payby.payinfo LIKE '$like_search' + OR cust_payby.paymask = '$mask_search' ) ". - " AND payby IN ('CARD','DCRD') ". + " AND cust_payby.payby IN ('CARD','DCRD') ". " AND $agentnums_sql", #agent virtulization }); @@ -896,10 +897,10 @@ sub search { : ( $params->{'payby'} ); @payby = grep /^([A-Z]{4})$/, @payby; - - push @where, '( '. join(' OR ', map "cust_main.payby = '$_'", @payby). ' )' + my $in_payby = 'IN(' . join(',', map {"'$_'"} @payby) . ')'; + push @where, "EXISTS( SELECT 1 FROM cust_payby WHERE payby $in_payby ". + "AND cust_payby.custnum = cust_main.custnum)" if @payby; - } ### diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 8f6272030..e6309eab8 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -432,7 +432,7 @@ if ( ref($opt{query}) ) { } #eval "use FS::$opt{'query'};"; - my @param = qw( select table addl_from hashref extra_sql order_by ); + my @param = qw( select table addl_from hashref extra_sql order_by debug ); $rows = [ qsearch( [ map { my $query = $_; ({ map { $_ => $query->{$_} } @param }); } |