[freeside-commits] branch FREESIDE_3_BRANCH updated. a36d5bbb21a67515e6560547669bd80fc2b3a8d9

Ivan ivan at 420.am
Wed Nov 16 17:11:49 PST 2016


The branch, FREESIDE_3_BRANCH has been updated
       via  a36d5bbb21a67515e6560547669bd80fc2b3a8d9 (commit)
      from  ac15bb65127bdb70398d4043a314b98eb1877fcd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a36d5bbb21a67515e6560547669bd80fc2b3a8d9
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Nov 16 17:11:47 2016 -0800

    when searching locaitons, don't search historic locations by default, RT#73412

diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index 66b73dd..677a3e5 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -701,6 +701,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
   ##
@@ -720,6 +735,7 @@ sub search {
         SELECT 1 FROM cust_location 
         WHERE cust_location.custnum = cust_main.custnum
           AND (".join(' OR ', at orwhere).")
+          $current
         )";
     }
   }
@@ -733,6 +749,7 @@ sub search {
       SELECT 1 FROM cust_location
       WHERE cust_location.custnum = cust_main.custnum
         AND cust_location.city = $city
+        $current
     )";
   }
 
@@ -745,6 +762,7 @@ sub search {
       SELECT 1 FROM cust_location
       WHERE cust_location.custnum = cust_main.custnum
         AND cust_location.county = $county
+        $current
     )";
   }
 
@@ -757,6 +775,7 @@ sub search {
       SELECT 1 FROM cust_location
       WHERE cust_location.custnum = cust_main.custnum
         AND cust_location.state = $state
+        $current
     )";
   }
 
@@ -769,6 +788,7 @@ sub search {
       SELECT 1 FROM cust_location
       WHERE cust_location.custnum = cust_main.custnum
         AND cust_location.zip LIKE $zip
+        $current
     )";
   }
 
@@ -781,6 +801,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 b5506f6..ee9afa3 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -5042,6 +5042,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 503e782..040d6c3 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
   paydate_year paydate_month 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 f029ea6..81d5d58 100755
--- a/httemplate/search/report_cust_main.html
+++ b/httemplate/search/report_cust_main.html
@@ -340,6 +340,10 @@
         <TD><INPUT TYPE="checkbox" NAME="cancelled_pkgs"></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>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cust_main/Search.pm               |   21 +++++++++++++++++++++
 FS/FS/cust_pkg.pm                       |   11 +++++++++++
 httemplate/search/cust_main.html        |    3 ++-
 httemplate/search/report_cust_main.html |    4 ++++
 4 files changed, 38 insertions(+), 1 deletion(-)




More information about the freeside-commits mailing list