diff options
author | mark <mark> | 2012-02-01 05:30:16 +0000 |
---|---|---|
committer | mark <mark> | 2012-02-01 05:30:16 +0000 |
commit | 33631ac48cd91bf9bee1cd7f25f2f23fc640cb65 (patch) | |
tree | c95612501c97a432b02228bb2ed418ddcddd5ede /httemplate/view | |
parent | 33622ee94a063863870d9ea208970226eeb7ecd7 (diff) |
print customer statements on the fly, #15864
Diffstat (limited to 'httemplate/view')
-rw-r--r-- | httemplate/view/cust_main/payment_history.html | 10 | ||||
-rwxr-xr-x | httemplate/view/cust_main_statement-pdf.cgi | 39 |
2 files changed, 48 insertions, 1 deletions
diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html index 63708e63c..b5b716199 100644 --- a/httemplate/view/cust_main/payment_history.html +++ b/httemplate/view/cust_main/payment_history.html @@ -123,8 +123,14 @@ </TD> <TD ALIGN="right" VALIGN="top"> -%# invoice reports +%# invoice reports, combined statement % if ( $curuser->access_right('List invoices') ) { +% if ( $conf->exists('cust_main-print_statement_link') +% and $num_cust_bill > 0 ) { + <A HREF="<% $p %>view/cust_main_statement-pdf.cgi?<% $custnum %>"><% + mt('Print a current statement') |h %></A> + <BR> +% } <A HREF="<% $p %>search/report_cust_bill.html?custnum=<% $custnum %>"><% mt('Invoice reports') |h %></A> % } <BR> @@ -410,12 +416,14 @@ foreach my $legacy_cust_bill ($cust_main->legacy_cust_bill) { } #invoices +my $num_cust_bill = 0; foreach my $cust_bill ($cust_main->cust_bill) { push @history, { 'date' => $cust_bill->_date, 'desc' => include('payment_history/invoice.html', $cust_bill, %opt ), 'charge' => $cust_bill->charged, }; + $num_cust_bill++; } #statements diff --git a/httemplate/view/cust_main_statement-pdf.cgi b/httemplate/view/cust_main_statement-pdf.cgi new file mode 100755 index 000000000..7a0e19838 --- /dev/null +++ b/httemplate/view/cust_main_statement-pdf.cgi @@ -0,0 +1,39 @@ +<%doc> +Like view/cust_statement-pdf.cgi, but for viewing/printing the implicit +statement containing all of a customer's invoices. Slightly redundant. +I don't see the need to create an equivalent to view/cust_statement.html +for this case, but one can be added if necessary. +</%doc> +<% $pdf %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('View invoices'); + +#untaint statement +my($query) = $cgi->keywords; +$query =~ /^((.+)-)?(\d+)$/; +my $templatename = $2 || 'statement'; #XXX configure... via event?? eh.. +my $custnum = $3; + +my $cust_main = qsearchs({ + 'select' => 'cust_main.*', + 'table' => 'cust_main', + 'hashref' => { 'custnum' => $custnum }, + 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, +}); +die "Customer #$custnum not found!" unless $cust_main; + +my $cust_statement = FS::cust_statement->new({ + 'custnum' => $custnum, + 'statementnum' => 'ALL', #magic + '_date' => time, +}); + +my $pdf = $cust_statement->print_pdf( '', $templatename ); + +http_header('Content-Type' => 'application/pdf' ); +http_header('Content-Length' => length($pdf) ); +http_header('Cache-control' => 'max-age=60' ); + +</%init> |