X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_main.cgi;h=da6c89d44704cd4192000ebeaa5eac6a60513f73;hb=4f2b07d0a7380717871aa951483a8285ea32e03e;hp=c501c50eaf720125075029b650569b750d70f1ec;hpb=df21571ae9b56b8645c53053fdabc78ca6eeffed;p=freeside.git diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index c501c50ea..da6c89d44 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'] ], % }) % ) { @@ -498,7 +501,7 @@ if ( $cgi->param('browse') ); } - @cust_main = grep { $_->num_ncancelled_pkgs || ! $_->num_pkgs } @cust_main + @cust_main = grep { $_->status ne 'cancelled' } @cust_main if ! $cgi->param('cancelled') && ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me @@ -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; }