This commit was generated by cvs2svn to compensate for changes in r6252,
[freeside.git] / httemplate / view / cust_bill-pdf.cgi
1 <% $pdf %>
2 <%init>
3
4 die "access denied"
5   unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
6
7 #untaint invnum
8 my($query) = $cgi->keywords;
9 $query =~ /^((.+)-)?(\d+)(.pdf)?$/;
10 my $templatename = $2;
11 my $invnum = $3;
12
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,
19 });
20 die "Invoice #$invnum not found!" unless $cust_bill;
21
22 my $pdf = $cust_bill->print_pdf( '', $templatename);
23
24 http_header('Content-Type' => 'application/pdf' );
25 http_header('Content-Length' => length($pdf) );
26 http_header('Cache-control' => 'max-age=60' );
27
28 </%init>