add "payment expiration before" to customer report, RT#6447
authorivan <ivan>
Fri, 6 Nov 2009 00:25:13 +0000 (00:25 +0000)
committerivan <ivan>
Fri, 6 Nov 2009 00:25:13 +0000 (00:25 +0000)
FS/FS/cust_main.pm
httemplate/search/cust_main.html
httemplate/search/report_cust_main.html

index 1247245..5d6826f 100644 (file)
@@ -8259,6 +8259,10 @@ listref of start date, end date
 
 listref
 
 
 listref
 
+=item paydate_year
+
+=item paydate_month
+
 =item current_balance
 
 listref (list returned by FS::UI::Web::parse_lt_gt($cgi, 'current_balance'))
 =item current_balance
 
 listref (list returned by FS::UI::Web::parse_lt_gt($cgi, 'current_balance'))
@@ -8360,6 +8364,23 @@ sub search_sql {
     push @where, '( '. join(' OR ', map "cust_main.payby = '$_'", @payby). ' )';
   }
 
     push @where, '( '. join(' OR ', map "cust_main.payby = '$_'", @payby). ' )';
   }
 
+  ###
+  # paydate_year / paydate_month
+  ###
+
+  if ( $params->{'paydate_year'} =~ /^(\d{4})$/ ) {
+    my $year = $1;
+    $params->{'paydate_month'} =~ /^(\d\d?)$/
+      or die "paydate_year without paydate_month?";
+    my $month = $1;
+
+    push @where,
+      'paydate IS NOT NULL',
+      "paydate != ''",
+      "CAST(paydate AS timestamp) < CAST('$year-$month-01' AS timestamp )"
+;
+  }
+
   ##
   # amounts
   ##
   ##
   # amounts
   ##
index 186467e..d6586e8 100755 (executable)
@@ -45,7 +45,7 @@ my %search_hash = ();
 #scalars
 my @scalars = qw (
   agentnum status cancelled_pkgs cust_fields flattened_pkgs custbatch
 #scalars
 my @scalars = qw (
   agentnum status cancelled_pkgs cust_fields flattened_pkgs custbatch
-  no_censustract
+  no_censustract paydate_year paydate_month
 );
 
 for my $param ( @scalars ) {
 );
 
 for my $param ( @scalars ) {
index 92df58c..4369a68 100755 (executable)
 %   }
 
     <% include( '/elements/tr-select-payby.html',
 %   }
 
     <% include( '/elements/tr-select-payby.html',
-                  'payby_type' => 'cust',
-                  'multiple'   => 1,
-                  'curr_value' => { map { $_ => 1 } FS::payby->cust_payby },
+                  'payby_type'   => 'cust',
+                  'multiple'     => 1,
+                  'all_selected' => 1,
               )
     %>
               )
     %>
+
+    <TR>
+      <TD ALIGN="right">Payment expiration before</TD>
+      <TD>
+        <SELECT NAME="paydate_month" DISABLED>
+%         foreach my $month ( 1 .. 12 ) {
+            <OPTION VALUE="<% $month %>"><% $month %></OPTION>
+%         }
+        </SELECT>
+        /
+        <SELECT NAME="paydate_year" onChange="paydate_year_changed(this);">
+          <OPTION VALUE=""></OPTION>
+%         my $lastyear = (localtime(time))[5] + 1899;
+%         foreach my $year ( $lastyear .. $lastyear+12 ) {
+            <OPTION VALUE="<% $year %>"><% $year %></OPTION>
+%         }
+        </SELECT>
+      </TD>
+    </TR>
+
+    <SCRIPT TYPE="text/javascript">
+      function paydate_year_changed(what) {
+        var value = what.options[what.selectedIndex].value;
+        var month_select = what.form.paydate_month;
+        if ( value == '' ) {
+          month_select.disabled = true;
+        } else {
+          month_select.disabled = false;
+        }
+      }
+    </SCRIPT>
     
     <% include( '/elements/tr-input-lessthan_greaterthan.html',
                   label   => 'Current balance',
     
     <% include( '/elements/tr-input-lessthan_greaterthan.html',
                   label   => 'Current balance',