5 unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
8 my($query) = $cgi->keywords;
9 if ( $query =~ /^(\d+)(.pdf)?$/ ) { #.pdf probably not necessary anymore?
12 $legacyinvnum = $cgi->param('legacyinvnum');
13 $legacyinvnum =~ s/\.pdf//i; #probably not necessary anymore
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,
23 die "Legacy invoice #$legacyinvnum not found!" unless $legacy_cust_bill;
25 my $content = $legacy_cust_bill->content_pdf;
27 #maybe should name the file after legacyid if present, but have to clean it
28 #my $filename = $legacy_cust_bill->legacyid
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' );