Merge branch 'master' of git+ssh://git.freeside.biz/home/git/freeside
authorDavid Houghton <houghton@freeside.biz>
Wed, 10 Sep 2014 19:54:31 +0000 (15:54 -0400)
committerDavid Houghton <houghton@freeside.biz>
Wed, 10 Sep 2014 19:54:31 +0000 (15:54 -0400)
Making my local master match the remote.

FS/FS/cust_main/Search.pm
httemplate/search/elements/search.html

index 0c00477..bb5891d 100644 (file)
@@ -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;
-
   }
 
   ###
index 8f62720..e6309ea 100644 (file)
@@ -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 });
                            }