diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-07-31 13:17:55 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-07-31 13:17:55 -0700 |
commit | 6c284750de8fe49d7d4cdc6a9a4fb618697780e2 (patch) | |
tree | b857e8d1d948d20fb425b0505d553e425a809414 /FS | |
parent | 5592cab603e6fda46268ca5addb1b036662e1576 (diff) |
search by state (and county, country), RT#30312
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Misc.pm | 2 | ||||
-rw-r--r-- | FS/FS/cust_main/Search.pm | 36 |
2 files changed, 37 insertions, 1 deletions
diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm index 380f8959d..f597058ef 100644 --- a/FS/FS/Misc.pm +++ b/FS/FS/Misc.pm @@ -548,7 +548,7 @@ sub states_hash { #it could throw a fatal "Invalid country code" error (for example "AX") my $subcountry = eval { new Locale::SubCountry($country) } - or return ( '', '(n/a)' ); + or return (); # ( '', '(n/a)' ); #"i see your schwartz is as big as mine!" map { ( $_->[0] => $_->[1] ) } diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm index 046e95993..0c00477f6 100644 --- a/FS/FS/cust_main/Search.pm +++ b/FS/FS/cust_main/Search.pm @@ -727,6 +727,30 @@ sub search { } ## + # county + ## + if ( $params->{'county'} =~ /\S/ ) { + my $county = dbh->quote($params->{'county'}); + push @where, "EXISTS( + SELECT 1 FROM cust_location + WHERE cust_location.custnum = cust_main.custnum + AND cust_location.county = $county + )"; + } + + ## + # state + ## + if ( $params->{'state'} =~ /\S/ ) { + my $state = dbh->quote($params->{'state'}); + push @where, "EXISTS( + SELECT 1 FROM cust_location + WHERE cust_location.custnum = cust_main.custnum + AND cust_location.state = $state + )"; + } + + ## # zipcode ## if ( $params->{'zip'} =~ /\S/ ) { @@ -738,6 +762,18 @@ sub search { )"; } + ## + # country + ## + if ( $params->{'country'} =~ /^(\w\w)$/ ) { + my $country = uc($1); + push @where, "EXISTS( + SELECT 1 FROM cust_location + WHERE cust_location.custnum = cust_main.custnum + AND cust_location.country = '$country' + )"; + } + ### # refnum ### |