5 unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
8 my($query) = $cgi->keywords;
9 $query =~ /^((.+)-)?(\d+)(.pdf)?$/;
10 my $templatename = $2 || 'statement'; #XXX configure... via event?? eh..
11 my $statementnum = $3;
13 my $cust_statement = qsearchs({
14 'select' => 'cust_statement.*',
15 'table' => 'cust_statement',
16 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
17 'hashref' => { 'statementnum' => $statementnum },
18 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
20 die "Statement #$statementnum not found!" unless $cust_statement;
22 my $pdf = $cust_statement->print_pdf( '', $templatename);
24 http_header('Content-Type' => 'application/pdf' );
25 http_header('Content-Length' => length($pdf) );
26 http_header('Cache-control' => 'max-age=60' );