5 unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
8 my($query) = $cgi->keywords;
9 $query =~ /^((.+)-)?(\d+)(.pdf)?$/;
10 my $templatename = $2;
13 my $cust_bill = qsearchs({
14 'select' => 'cust_bill.*',
15 'table' => 'cust_bill',
16 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
17 'hashref' => { 'invnum' => $invnum },
18 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
20 die "Invoice #$invnum not found!" unless $cust_bill;
22 my $pdf = $cust_bill->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' );