X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fsearch%2Freport_receivables.cgi;h=9c5c0e2d9fb209280b081dac467a52211b2faa0b;hp=6b96ba7a533878ee3a17bcf2681c5f0eee6e2150;hb=c3da5cf1caa244937d280e0f406927103beef148;hpb=cefb9727ed4cdfacf3b967485d58b25fbea98c6b diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index 6b96ba7a5..9c5c0e2d9 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -1,28 +1,39 @@ -<% - -use strict; -use vars qw( $cgi $user ); -use CGI; -use CGI::Carp qw( fatalsToBrowser ); -use FS::UID qw( cgisuidsetup getotaker ); - -$cgi = new CGI; -&cgisuidsetup($cgi); - -$user = getotaker; - -print $cgi->header( '-expires' => '-2m' ), - header('Current Receivables Report Results'); - -open (REPORT, "/usr/bin/freeside-receivables-report -v $user |"); - -print '
';
-while() {
-  print $_;
+<& elements/cust_main_dayranges.html,
+                 'title'       => emt('Accounts Receivable Aging Summary'),
+                 'range_sub'   => \&balance,
+                 'payment_links' => 1,
+&>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Receivables report')
+      or $FS::CurrentUser::CurrentUser->access_right('Financial reports');
+
+
+<%once>
+
+#Example:
+#
+# my $balance = balance(
+#   $start, $end, $offset,
+#   'no_as'  => 1, #set to true when using in a WHERE clause (supress AS clause)
+#                 #or 0 / omit when using in a SELECT clause as a column
+#                 #  ("AS balance_$start_$end")
+#   'sum'    => 1, #set to true to get a SUM() of the values, for totals
+#
+#   #obsolete? options for totals (passed to cust_main::balance_date_sql)
+#   'total'  => 1, #set to true to remove all customer comparison clauses
+#   'join'   => $join,   #JOIN clause
+#   'where'  => \@where, #WHERE clause hashref (elements "AND"ed together)
+# )
+
+sub balance {
+  my($start, $end, $cutoff) = @_; #, %opt ?
+
+  FS::cust_main->balance_date_sql( $start, $end, 
+        'cutoff' => $cutoff,
+        'unapplied_date'=>1,
+  );
 }
-print '
'; - -print ''; - -%> +