RT# 77160 - added date search on customer timespan report
authorChristopher Burger <burgerc@freeside.biz>
Fri, 27 Jul 2018 22:14:31 +0000 (18:14 -0400)
committerChristopher Burger <burgerc@freeside.biz>
Mon, 30 Jul 2018 12:40:16 +0000 (08:40 -0400)
httemplate/search/cust_timespan.html
httemplate/search/elements/search.html
httemplate/search/report_cust_timespan.html

index 3886361..13fc6a1 100644 (file)
@@ -11,6 +11,7 @@
                   'header'      => \@header,
                   'fields'      => \@fields,
                   'links'       => \@links,
+                  'disable_maxselect' => '1',
 
 &>
 <%init>
@@ -84,7 +85,11 @@ my $active_pkg_sql = 'select pkgnum from cust_pkg where cust_pkg.custnum = cust_
 
 ## sql to get the first active date, last cancel date, and last reason.
 my $active_date = 'select min(setup) from cust_pkg left join part_pkg using (pkgpart) where cust_pkg.custnum = cust_main.custnum and part_pkg.freq > \'0\'';
-my $cancel_date = 'select max(cancel) from cust_pkg where cust_pkg.custnum = cust_main.custnum';
+
+## set cancel date range here
+my($beginning_date, $ending_date) = FS::UI::Web::parse_beginning_ending($cgi, '');
+my $cancel_date = 'select max(cancel) from cust_pkg left join part_pkg using (pkgpart) where cust_pkg.custnum = cust_main.custnum and part_pkg.freq > \'0\' and (cancel >= '.$beginning_date.' and cancel <= '.$ending_date.')';
+
 my $cancel_reason = 'select reason.reason from cust_pkg
        left join cust_pkg_reason on (cust_pkg.pkgnum = cust_pkg_reason.pkgnum)
        left join reason on (cust_pkg_reason.reasonnum = reason.reasonnum)
index 8eeb0bb..4cf187a 100644 (file)
@@ -385,14 +385,15 @@ unless ( $type =~ /^(csv|xml|\w*.xls)$/) {
     #setup some pagination things if we're in html mode
 
     my $conf = new FS::Conf;
-    $confmax = $conf->config('maxsearchrecordsperpage') || 100;
-    if ( $cgi->param('maxrecords') =~ /^(\d+)$/ ) {
-      $maxrecords = $1;
-    } else {
-      $maxrecords ||= $confmax;
-    }
-
     $opt{'disable_maxselect'} ||= $conf->exists('disable_maxselect');
+    unless ($opt{'disable_maxselect'}) {
+      $confmax = $conf->config('maxsearchrecordsperpage') || 100;
+      if ( $cgi->param('maxrecords') =~ /^(\d+)$/ ) {
+        $maxrecords = $1;
+      } else {
+        $maxrecords ||= $confmax;
+      }
+    }
 
     $limit = $maxrecords ? "LIMIT $maxrecords" : '';
 
index 4ff3bb8..27dd940 100644 (file)
@@ -20,6 +20,8 @@
        'curr_value' => scalar( $cgi->param('cust_status') ),
   &>
 
+  <& /elements/tr-input-beginning_ending.html &>
+
 </FORM>
 
 </TABLE>