[freeside-commits] branch master updated. b49e60810267101b83b9b2133e5dfc90d1663cdc

Ivan ivan at 420.am
Thu Dec 22 15:30:28 PST 2016


The branch, master has been updated
       via  b49e60810267101b83b9b2133e5dfc90d1663cdc (commit)
      from  09af85fc0e7a48392c930c9672a99448cf9630d4 (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 b49e60810267101b83b9b2133e5dfc90d1663cdc
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Dec 22 15:30:25 2016 -0800

    package search on null dates, RT#73715

diff --git a/FS/FS/cust_pkg/Search.pm b/FS/FS/cust_pkg/Search.pm
index 89809de..3a8e6d0 100644
--- a/FS/FS/cust_pkg/Search.pm
+++ b/FS/FS/cust_pkg/Search.pm
@@ -450,7 +450,8 @@ sub search {
     ''                => {},
   );
 
-  if( exists($params->{'active'} ) ) {
+  if ( exists($params->{'active'} ) ) {
+
     # This overrides all the other date-related fields, and includes packages
     # that were active at some time during the interval.  It excludes:
     # - packages that were set up after the end of the interval
@@ -464,40 +465,51 @@ sub search {
       "(cust_pkg.cancel IS NULL OR cust_pkg.cancel >= $beginning )",
       "(cust_pkg.susp   IS NULL OR cust_pkg.susp   >= $beginning )",
       "NOT (".FS::cust_pkg->onetime_sql . ")";
-  }
-  else {
+
+  } else {
+
     my $exclude_change_from = 0;
     my $exclude_change_to = 0;
 
     foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end change_date cancel )) {
 
-      next unless exists($params->{$field});
+      if ( $params->{$field.'_null'} ) {
+
+        push @where, "cust_pkg.$field IS NULL";
+             # this should surely be obsoleted by now: OR cust_pkg.$field == 0 )
 
-      my($beginning, $ending) = @{$params->{$field}};
+      } else {
 
-      next if $beginning == 0 && $ending == 4294967295;
+        next unless exists($params->{$field});
+
+        my($beginning, $ending) = @{$params->{$field}};
+
+        next if $beginning == 0 && $ending == 4294967295;
+
+        push @where,
+          "cust_pkg.$field IS NOT NULL",
+          "cust_pkg.$field >= $beginning",
+          "cust_pkg.$field <= $ending";
+
+        $orderby ||= "ORDER BY cust_pkg.$field";
+
+        if ( $field eq 'setup' ) {
+          $exclude_change_from = 1;
+        } elsif ( $field eq 'cancel' ) {
+          $exclude_change_to = 1;
+        } elsif ( $field eq 'change_date' ) {
+          # if we are given setup and change_date ranges, and the setup date
+          # falls in _both_ ranges, then include the package whether it was 
+          # a change or not
+          $exclude_change_from = 0;
+        }
 
-      push @where,
-        "cust_pkg.$field IS NOT NULL",
-        "cust_pkg.$field >= $beginning",
-        "cust_pkg.$field <= $ending";
-
-      $orderby ||= "ORDER BY cust_pkg.$field";
-
-      if ( $field eq 'setup' ) {
-        $exclude_change_from = 1;
-      } elsif ( $field eq 'cancel' ) {
-        $exclude_change_to = 1;
-      } elsif ( $field eq 'change_date' ) {
-        # if we are given setup and change_date ranges, and the setup date
-        # falls in _both_ ranges, then include the package whether it was 
-        # a change or not
-        $exclude_change_from = 0;
       }
+
     }
 
     if ($exclude_change_from) {
-      push @where, "change_pkgnum IS NULL";
+      push @where, "cust_pkg.change_pkgnum IS NULL";
     }
     if ($exclude_change_to) {
       # a join might be more efficient here
@@ -506,6 +518,7 @@ sub search {
         WHERE cust_pkg.pkgnum = changed_to_pkg.change_pkgnum
       )";
     }
+
   }
 
   $orderby ||= 'ORDER BY bill';
diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi
index dbd346d..df1d7e5 100755
--- a/httemplate/search/cust_pkg.cgi
+++ b/httemplate/search/cust_pkg.cgi
@@ -203,6 +203,8 @@ my %disable = (
 
 foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end change_date cancel active )) {
 
+  $search_hash{$field.'_null'} = scalar( $cgi->param($field.'_null') );
+
   my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
 
   next if $beginning == 0 && $ending == 4294967295
diff --git a/httemplate/search/report_cust_pkg.html b/httemplate/search/report_cust_pkg.html
index 27aecec..556177c 100755
--- a/httemplate/search/report_cust_pkg.html
+++ b/httemplate/search/report_cust_pkg.html
@@ -80,6 +80,7 @@
 
                 what.form.<% $field %>_beginning_text.disabled = true;
                 what.form.<% $field %>_ending_text.disabled = true;
+                what.form.<% $field %>_null.disabled = true;
                 what.form.<% $field %>_beginning_text.style.backgroundColor = '#dddddd';
                 what.form.<% $field %>_ending_text.style.backgroundColor = '#dddddd';
 
@@ -90,15 +91,21 @@
 
 %             } else {
 
-                what.form.<% $field %>_beginning_text.disabled = false;
-                what.form.<% $field %>_ending_text.disabled = false;
-                what.form.<% $field %>_beginning_text.style.backgroundColor = '#ffffff';
-                what.form.<% $field %>_ending_text.style.backgroundColor = '#ffffff';
+                what.form.<% $field %>_null.disabled = false;
 
-                what.form.<% $field %>_beginning_button.style.display = '';
-                what.form.<% $field %>_ending_button.style.display = '';
-                what.form.<% $field %>_beginning_disabled.style.display = 'none';
-                what.form.<% $field %>_ending_disabled.style.display = 'none';
+                if ( ! what.form.<% $field %>_null.checked ) {
+
+                  what.form.<% $field %>_beginning_text.disabled = false;
+                  what.form.<% $field %>_ending_text.disabled = false;
+                  what.form.<% $field %>_beginning_text.style.backgroundColor = '#ffffff';
+                  what.form.<% $field %>_ending_text.style.backgroundColor = '#ffffff';
+
+                  what.form.<% $field %>_beginning_button.style.display = '';
+                  what.form.<% $field %>_ending_button.style.display = '';
+                  what.form.<% $field %>_beginning_disabled.style.display = 'none';
+                  what.form.<% $field %>_ending_disabled.style.display = 'none';
+
+                }
 
 %             }
 %           }
@@ -109,6 +116,37 @@
 
       }
 
+%     foreach my $field (@date_fields) {
+
+        function <% $field %>_null_changed(what) {
+
+          if ( what.checked ) {
+            what.form.<% $field %>_beginning_text.disabled = true;
+            what.form.<% $field %>_ending_text.disabled = true;
+            what.form.<% $field %>_beginning_text.style.backgroundColor = '#dddddd';
+            what.form.<% $field %>_ending_text.style.backgroundColor = '#dddddd';
+            what.form.<% $field %>_beginning_button.style.display = 'none';
+            what.form.<% $field %>_ending_button.style.display = 'none';
+            what.form.<% $field %>_beginning_disabled.style.display = '';
+            what.form.<% $field %>_ending_disabled.style.display = '';
+
+          } else {
+            what.form.<% $field %>_beginning_text.disabled = false;
+            what.form.<% $field %>_ending_text.disabled = false;
+            what.form.<% $field %>_beginning_text.style.backgroundColor = '#ffffff';
+            what.form.<% $field %>_ending_text.style.backgroundColor = '#ffffff';
+
+            what.form.<% $field %>_beginning_button.style.display = '';
+            what.form.<% $field %>_ending_button.style.display = '';
+            what.form.<% $field %>_beginning_disabled.style.display = 'none';
+            what.form.<% $field %>_ending_disabled.style.display = 'none';
+
+          }
+
+        }
+
+%     }
+
     </SCRIPT>
 
     <& /elements/tr-select-pkg_class.html,
@@ -135,6 +173,7 @@
             <TD></TD>
             <TD>From date <i>(m/d/y)</i></TD>
             <TD>To date <i>(m/d/y)</i></TD>
+            <TD>Empty date</TD>
           </TR>
 %   my $noinit = 0;
 %   foreach my $field (@date_fields) {
@@ -152,6 +191,13 @@
             </TD>
 %     $noinit = 1;
 %     }
+            <TD ALIGN="center">
+              <& /elements/checkbox.html,
+                   'field'    => $field.'_null',
+                   'value'    => 'Y',
+                   'onchange' => $field.'_null_changed',
+              &>
+            </TD>
           </TR>
 %   } #foreach $field
         </TABLE>

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

Summary of changes:
 FS/FS/cust_pkg/Search.pm               |   59 ++++++++++++++++++------------
 httemplate/search/cust_pkg.cgi         |    2 ++
 httemplate/search/report_cust_pkg.html |   62 +++++++++++++++++++++++++++-----
 3 files changed, 92 insertions(+), 31 deletions(-)




More information about the freeside-commits mailing list