summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2016-11-16 17:11:39 -0800
committerIvan Kohler <ivan@freeside.biz>2016-11-16 17:11:39 -0800
commitf27699473b63c43706a6da94de6ebf8e901e2882 (patch)
treef43837657a85423b43cb930d2712a63a98e7c751
parentdfb455957729b0a09e085853d3657b4b1d486cef (diff)
when searching locaitons, don't search historic locations by default, RT#73412
-rw-r--r--FS/FS/cust_main/Search.pm21
-rw-r--r--FS/FS/cust_pkg.pm11
-rwxr-xr-xhttemplate/search/cust_main.html3
-rwxr-xr-xhttemplate/search/report_cust_main.html4
4 files changed, 38 insertions, 1 deletions
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index e021140..14dd4b4 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 4de2faa..bcb5176 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -5079,6 +5079,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.
diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html
index 672c201..1aa3390 100755
--- a/httemplate/search/cust_main.html
+++ b/httemplate/search/cust_main.html
@@ -41,7 +41,8 @@ my %search_hash = ();
#scalars
my @scalars = qw (
- agentnum salesnum status address city county state zip country
+ agentnum salesnum status
+ address city county state zip country location_history
invoice_terms
no_censustract with_geocode with_email tax no_tax POST no_POST
custbatch usernum
diff --git a/httemplate/search/report_cust_main.html b/httemplate/search/report_cust_main.html
index b6be023..69bbe85 100755
--- a/httemplate/search/report_cust_main.html
+++ b/httemplate/search/report_cust_main.html
@@ -197,6 +197,10 @@
</TD>
</TR>
+ <TR>
+ <TH ALIGN="right" VALIGN="center"><% mt('Search historical addresses') %></TH>
+ <TD><INPUT TYPE="checkbox" NAME="location_history" VALUE="1"></TD>
+
</TABLE>
<BR>