optimize CDR rating after timed rate perf regression, RT#15739
[freeside.git] / httemplate / view / legacy_cust_bill-pdf.cgi
1 <% $content %>\
2 <%init>
3
4 die "access denied"
5   unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
6
7 my $legacyinvnum;
8 my($query) = $cgi->keywords;
9 if ( $query =~ /^(\d+)(.pdf)?$/ ) { #.pdf probably not necessary anymore?
10   $legacyinvnum = $1;
11 } else {
12   $legacyinvnum = $cgi->param('legacyinvnum');
13   $legacyinvnum =~ s/\.pdf//i; #probably not necessary anymore
14 }
15
16 my $legacy_cust_bill = qsearchs({
17   'select'    => 'legacy_cust_bill.*',
18   'table'     => 'legacy_cust_bill',
19   'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
20   'hashref'   => { 'legacyinvnum' => $legacyinvnum },
21   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
22 });
23 die "Legacy invoice #$legacyinvnum not found!" unless $legacy_cust_bill;
24
25 my $content = $legacy_cust_bill->content_pdf;
26
27 #maybe should name the file after legacyid if present, but have to clean it
28 #my $filename = $legacy_cust_bill->legacyid
29
30 http_header('Content-Type' => 'application/pdf' );
31 http_header('Content-Disposition' => "filename=$legacyinvnum.pdf" );
32 http_header('Content-Length' => length($content) );
33 #http_header('Cache-control' => 'max-age=60' );
34
35 </%init>