Merge branch 'master' of git.freeside.biz:/home/git/freeside
authorIvan Kohler <ivan@freeside.biz>
Thu, 17 Nov 2016 01:10:12 +0000 (17:10 -0800)
committerIvan Kohler <ivan@freeside.biz>
Thu, 17 Nov 2016 01:10:12 +0000 (17:10 -0800)
FS/FS/cust_main/Search.pm
FS/FS/cust_pkg.pm
httemplate/elements/popup-topreload.html [new file with mode: 0644]
httemplate/search/cust_main.html
httemplate/search/report_cust_main.html

index e021140..14dd4b4 100644 (file)
@@ -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
     )";
   }
 
index 714d292..4e9ede3 100644 (file)
@@ -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.
diff --git a/httemplate/elements/popup-topreload.html b/httemplate/elements/popup-topreload.html
new file mode 100644 (file)
index 0000000..00d5cdf
--- /dev/null
@@ -0,0 +1,21 @@
+<%doc>
+
+Example:
+
+  <& /elements/popup-topreload, mt('Action completed') &>
+
+</%doc>
+<& /elements/header-popup.html, encode_entities($message) &>
+  <script src="<% $fsurl %>elements/js.cookie.js"></script>
+  <SCRIPT TYPE="text/javascript">
+    Cookies.set('freeside_status', <% $message |js_string %>,{
+                  expires: 0.0035
+    });
+    topreload();
+  </SCRIPT>
+<& /elements/footer-popup.html &>
+<%init>
+
+my $message = shift;
+
+</%init>
index 672c201..1aa3390 100755 (executable)
@@ -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
index b6be023..69bbe85 100755 (executable)
       </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>