X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FSearch.pm;h=182527ff9bd2fd10a0386530b32428274c9b9bfe;hb=fe4515eb37d76849dd08c62782d86bc7ba311dcd;hp=b022985a02abf55c8d51771a8746454dbfd185ba;hpb=23f2db6452f097640447b9b35dd106f408dbc20b;p=freeside.git diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm index b022985a0..182527ff9 100644 --- a/FS/FS/cust_main/Search.pm +++ b/FS/FS/cust_main/Search.pm @@ -610,14 +610,24 @@ sub search { ## # address ## - if ( $params->{'address'} =~ /\S/ ) { - my $address = dbh->quote('%'. lc($params->{'address'}). '%'); - push @where, "EXISTS( - SELECT 1 FROM cust_location - WHERE cust_location.custnum = cust_main.custnum - AND (LOWER(cust_location.address1) LIKE $address OR - LOWER(cust_location.address2) LIKE $address) - )"; + if ( $params->{'address'} ) { + # allow this to be an arrayref + my @values = ($params->{'address'}); + @values = @{$values[0]} if ref($values[0]); + my @orwhere; + foreach (grep /\S/, @values) { + my $address = dbh->quote('%'. lc($_). '%'); + push @orwhere, + "LOWER(cust_location.address1) LIKE $address", + "LOWER(cust_location.address2) LIKE $address"; + } + if (@orwhere) { + push @where, "EXISTS( + SELECT 1 FROM cust_location + WHERE cust_location.custnum = cust_main.custnum + AND (".join(' OR ',@orwhere).") + )"; + } } ## @@ -668,7 +678,9 @@ sub search { # parse with hardcoded tax location checkbox ## - push @where, "ship_location.geocode is not null" + my $tax_prefix = FS::Conf->new->exists('tax-ship_location') ? 'ship_' + : 'bill_'; + push @where, "${tax_prefix}location.geocode is not null" if $params->{'with_geocode'}; ##