diff options
author | Ivan Kohler <ivan@freeside.biz> | 2016-11-16 17:08:18 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2016-11-16 17:08:18 -0800 |
commit | c67eaf049134e6f7ab9fe8d33d043d7d397008f3 (patch) | |
tree | bb13fd19b73adfdeb31f095b7feca115fbcf1d15 /FS | |
parent | 29d80a8582103ead0b5910391cabc45cb85fa836 (diff) |
when searching locaitons, don't search historic locations by default, RT#73412
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/cust_main/Search.pm | 21 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 11 |
2 files changed, 32 insertions, 0 deletions
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm index e02114016..14dd4b469 100644 --- a/FS/FS/cust_main/Search.pm +++ b/FS/FS/cust_main/Search.pm @@ -695,6 +695,21 @@ sub search { push @where, FS::cust_main->$method(); } + my $current = ''; + unless ( $params->{location_history} ) { + $current = ' + AND ( cust_location.locationnum IN ( cust_main.bill_locationnum, + cust_main.ship_locationnum + ) + OR cust_location.locationnum IN ( + SELECT locationnum FROM cust_pkg + WHERE cust_pkg.custnum = cust_main.custnum + AND locationnum IS NOT NULL + AND '. FS::cust_pkg->ncancelled_recurring_sql.' + ) + )'; + } + ## # address ## @@ -714,6 +729,7 @@ sub search { SELECT 1 FROM cust_location WHERE cust_location.custnum = cust_main.custnum AND (".join(' OR ',@orwhere).") + $current )"; } } @@ -727,6 +743,7 @@ sub search { SELECT 1 FROM cust_location WHERE cust_location.custnum = cust_main.custnum AND cust_location.city = $city + $current )"; } @@ -739,6 +756,7 @@ sub search { SELECT 1 FROM cust_location WHERE cust_location.custnum = cust_main.custnum AND cust_location.county = $county + $current )"; } @@ -751,6 +769,7 @@ sub search { SELECT 1 FROM cust_location WHERE cust_location.custnum = cust_main.custnum AND cust_location.state = $state + $current )"; } @@ -763,6 +782,7 @@ sub search { SELECT 1 FROM cust_location WHERE cust_location.custnum = cust_main.custnum AND cust_location.zip LIKE $zip + $current )"; } @@ -775,6 +795,7 @@ sub search { SELECT 1 FROM cust_location WHERE cust_location.custnum = cust_main.custnum AND cust_location.country = '$country' + $current )"; } diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 714d29259..4e9ede303 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -5072,6 +5072,17 @@ sub cancel_sql { "cust_pkg.cancel IS NOT NULL AND cust_pkg.cancel != 0"; } +=item ncancelled_recurring_sql + +Returns an SQL expression identifying un-cancelled, recurring packages. + +=cut + +sub ncancelled_recurring_sql { + $_[0]->recurring_sql(). + " AND ( cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0 ) "; +} + =item status_sql Returns an SQL expression to give the package status as a string. |