2 Like view/cust_statement-pdf.cgi, but for viewing/printing the implicit
3 statement containing all of a customer's invoices. Slightly redundant.
4 I don't see the need to create an equivalent to view/cust_statement.html
5 for this case, but one can be added if necessary.
11 unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
14 my($query) = $cgi->keywords;
15 $query =~ /^((.+)-)?(\d+)$/;
16 my $templatename = $2 || 'statement'; #XXX configure... via event?? eh..
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 die "Customer #$custnum not found!" unless $cust_main;
26 my $cust_bill = ($cust_main->cust_bill)[-1]
27 or die "Customer #$custnum has no invoices!";
29 my $cust_statement = FS::cust_statement->new({
30 'custnum' => $custnum,
31 # 'statementnum' => 'ALL', #magic
32 'invnum' => $cust_bill->invnum,
37 my $pdf = $cust_statement->print_pdf( '', $templatename );
39 http_header('Content-Type' => 'application/pdf' );
40 http_header('Content-Length' => length($pdf) );
41 http_header('Cache-control' => 'max-age=60' );