X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_main.cgi;h=62231a12013c3ca2a5a4c391551d071f8d403bfc;hp=c501c50eaf720125075029b650569b750d70f1ec;hb=6d821bf9a2419a177014cf882178370a0cdc748f;hpb=df21571ae9b56b8645c53053fdabc78ca6eeffed diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index c501c50ea..62231a120 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -129,7 +129,10 @@ % 'select' => 'part_svc.*, COUNT(*) AS num_cust_svc', % 'table' => 'part_svc', % 'addl_from' => 'LEFT JOIN cust_svc USING ( svcpart )', -% 'extra_sql' => 'WHERE pkgnum = ? GROUP BY part_svc.svcpart', +% 'extra_sql' => 'WHERE pkgnum = ? '. +% ' GROUP BY '. join(', ', +% map "part_svc.$_", fields('part_svc') +% ), % 'extra_param' => [ [$cust_pkg->pkgnum,'int'] ], % }) % ) { @@ -700,12 +703,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 ',@where), + }); \@cust_main; }