[freeside-commits] branch FREESIDE_4_BRANCH updated. 8d0311978235dffa845531d8f920636fbfee40e6

Jonathan Prykop jonathan at 420.am
Mon May 9 15:58:32 PDT 2016


The branch, FREESIDE_4_BRANCH has been updated
       via  8d0311978235dffa845531d8f920636fbfee40e6 (commit)
      from  1645243c8025b67946ea48964268390be4bd7701 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8d0311978235dffa845531d8f920636fbfee40e6
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon May 9 17:50:27 2016 -0500

    RT#41124: Backend Unti Search

diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi
index d590fde..99c7f90 100755
--- a/httemplate/edit/process/cust_main.cgi
+++ b/httemplate/edit/process/cust_main.cgi
@@ -76,8 +76,8 @@ if ( ($cgi->param('same') || '') eq 'Y' ) {
 # but explicitly avoid setting ship_ fields
 
 my $new = new FS::cust_main ( {
-  map { ( $_, scalar($cgi->param($_)) ) } (fields('cust_main')),
-  map { ( "ship_$_", '' ) } (FS::cust_main->location_fields)
+  (map { ( $_, scalar($cgi->param($_)) ) } (fields('cust_main'))),
+  (map { ( "ship_$_", '' ) } (FS::cust_main->location_fields))
 } );
 
 warn Dumper( $new ) if $DEBUG > 1;
diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi
index c501c50..76cbe49 100755
--- a/httemplate/search/cust_main.cgi
+++ b/httemplate/search/cust_main.cgi
@@ -700,12 +700,20 @@ sub address2search {
       or errorpage(emt("Illegal address2"));
   my $address2 = $1;
 
-  push @cust_main, qsearch( 'cust_main',
-                            { 'address2' => { 'op'    => 'ILIKE',
-                                              'value' => $address2 } } );
-  push @cust_main, qsearch( 'cust_main',
-                            { 'ship_address2' => { 'op'    => 'ILIKE',
-                                                   'value' => $address2 } } );
+  # matching at the start or end of an address, but not in the middle
+  my @where;
+  foreach my $toggle (0,1) {
+    push @where, 'LOWER(cust_location.address2) LIKE LOWER('
+                 . dbh->quote($toggle ? $address2 . '%' : '%' . $address2)
+                 . ')';
+  }
+
+  push @cust_main, qsearch({
+    'debug'     => 1,
+    'table'     => 'cust_main',
+    'addl_from' => 'JOIN cust_location ON (cust_location.locationnum IN (cust_main.bill_locationnum, cust_main.ship_locationnum))',
+    'extra_sql' => 'WHERE ' . join(' OR ', at where),
+  });
 
   \@cust_main;
 }

-----------------------------------------------------------------------

Summary of changes:
 httemplate/edit/process/cust_main.cgi |    4 ++--
 httemplate/search/cust_main.cgi       |   20 ++++++++++++++------
 2 files changed, 16 insertions(+), 8 deletions(-)




More information about the freeside-commits mailing list