3 Like view/cust_statement-pdf.cgi, but for viewing/printing the implicit
4 statement containing all of a customer's invoices. Slightly redundant.
5 I don't see the need to create an equivalent to view/cust_statement.html
6 for this case, but one can be added if necessary.
11 unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
13 my($query) = $cgi->keywords;
17 #mostly for the agent-virt, i guess. could probably bolt it onto the cust_bill
19 my $cust_main = qsearchs({
20 'select' => 'cust_main.*',
21 'table' => 'cust_main',
22 'hashref' => { 'custnum' => $custnum },
23 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
25 or die "Customer #$custnum not found!";
27 my $cust_bill = qsearchs({
28 'table' => 'cust_bill',
29 'hashref' => { 'custnum' => $custnum },
30 'order_by' => 'ORDER BY _date desc LIMIT 1',
32 or die "Customer #$custnum has no invoices!";
34 my $cust_statement = FS::cust_statement->new({
35 'custnum' => $custnum,
36 # 'statementnum' => 'ALL', #magic
37 'invnum' => $cust_bill->invnum,
41 my $pdf = $cust_statement->print_pdf({
42 'notice_name' => 'Statement',
47 http_header('Content-Type' => 'application/pdf' );
48 http_header('Content-Length' => length($pdf) );
49 http_header('Cache-control' => 'max-age=60' );