X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fview%2Fcust_main_statement-pdf.cgi;h=79110ee2034b2accc4c6677d9b75c8904f3e895d;hb=929783d1045757abbe5c84ff2439547b0f8eca23;hp=7a0e198387bd23a600f49adaba94b87a184f162a;hpb=33631ac48cd91bf9bee1cd7f25f2f23fc640cb65;p=freeside.git diff --git a/httemplate/view/cust_main_statement-pdf.cgi b/httemplate/view/cust_main_statement-pdf.cgi index 7a0e19838..79110ee20 100755 --- a/httemplate/view/cust_main_statement-pdf.cgi +++ b/httemplate/view/cust_main_statement-pdf.cgi @@ -1,39 +1,51 @@ +<% $pdf %>\ <%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. -<% $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; +$query =~ /^(\d+)$/; +my $custnum = $1; +#mostly for the agent-virt, i guess. could probably bolt it onto the cust_bill +# search 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; +}) + or die "Customer #$custnum not found!"; + +my $cust_bill = qsearchs({ + 'table' => 'cust_bill', + 'hashref' => { 'custnum' => $custnum }, + 'order_by' => 'ORDER BY _date desc LIMIT 1', +}) + or die "Customer #$custnum has no invoices!"; my $cust_statement = FS::cust_statement->new({ 'custnum' => $custnum, - 'statementnum' => 'ALL', #magic +# 'statementnum' => 'ALL', #magic + 'invnum' => $cust_bill->invnum, '_date' => time, }); -my $pdf = $cust_statement->print_pdf( '', $templatename ); +my $pdf = $cust_statement->print_pdf({ + 'notice_name' => 'Statement', + 'no_date' => 1, + 'no_number' => 1, +}); -http_header('Content-Type' => 'application/pdf' ); +http_header('Content-Type' => 'application/pdf' ); http_header('Content-Length' => length($pdf) ); -http_header('Cache-control' => 'max-age=60' ); +http_header('Cache-control' => 'max-age=60' );