summaryrefslogtreecommitdiff
path: root/FS/FS/cust_main
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-10-05 20:03:49 -0700
committerMark Wells <mark@freeside.biz>2013-10-05 20:03:49 -0700
commit913b38d717fc7f2fae32722e9f30462fc9344fb3 (patch)
treeb2dfb6e63fef55d9521d07ed0c086568dbbc66d8 /FS/FS/cust_main
parent9f26e78e38c70af6d2de28808c119b0e2251fd41 (diff)
restore duplicate customer checking with 3.x locations, #16582
Diffstat (limited to 'FS/FS/cust_main')
-rw-r--r--FS/FS/cust_main/Search.pm26
1 files changed, 18 insertions, 8 deletions
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index f14f897..182527f 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).")
+ )";
+ }
}
##