factor out the range-handling portions of receivables report, start on a similar...
[freeside.git] / httemplate / search / unapplied_cust_pay.html
1 <% include( 'elements/cust_main_dayranges.html',
2                  #'title'       => 'Prepaid Balance Aging Summary', #???
3                  'title'       => 'Unapplied Payments Aging Summary',
4                  'range_sub'   => \&unapplied_payments,
5           );
6 <%init>
7
8 die "access denied"
9   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
10
11 </%init>
12 <%once>
13
14 #Example:
15 #
16 # my $balance = balance(
17 #   $start, $end, 
18 #   'no_as'  => 1, #set to true when using in a WHERE clause (supress AS clause)
19 #                 #or 0 / omit when using in a SELECT clause as a column
20 #                 #  ("AS balance_$start_$end")
21 #   'sum'    => 1, #set to true to get a SUM() of the values, for totals
22 #
23 #   #obsolete? options for totals (passed to cust_main::balance_date_sql)
24 #   'total'  => 1, #set to true to remove all customer comparison clauses
25 #   'join'   => $join,   #JOIN clause
26 #   'where'  => \@where, #WHERE clause hashref (elements "AND"ed together)
27 # )
28
29 #sub balance {
30 sub unapplied_payments {
31   my($start, $end, %opt) = @_;
32
33 #XXX fill-in
34 #  #handle start and end ranges (86400 = 24h * 60m * 60s)
35 #  my $str2time = str2time_sql;
36 #  my $closing = str2time_sql_closing;
37 #  $start = $start ? "( $str2time now() $closing - ".($start * 86400). ' )' : '';
38 #  $end   = $end   ? "( $str2time now() $closing - ".($end   * 86400). ' )' : '';
39 #
40 #  #$opt{'unapplied_date'} = 1;
41 #
42 #  FS::cust_main->balance_date_sql( $start, $end, %opt ).
43
44 }
45
46 </%once>