diff options
Diffstat (limited to 'httemplate/view/legacy_cust_bill-pdf.cgi')
-rwxr-xr-x | httemplate/view/legacy_cust_bill-pdf.cgi | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/httemplate/view/legacy_cust_bill-pdf.cgi b/httemplate/view/legacy_cust_bill-pdf.cgi new file mode 100755 index 000000000..c6ecfb17f --- /dev/null +++ b/httemplate/view/legacy_cust_bill-pdf.cgi @@ -0,0 +1,35 @@ +<% $content %>\ +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('View invoices'); + +my $legacyinvnum; +my($query) = $cgi->keywords; +if ( $query =~ /^(\d+)(.pdf)?$/ ) { #.pdf probably not necessary anymore? + $legacyinvnum = $1; +} else { + $legacyinvnum = $cgi->param('legacyinvnum'); + $legacyinvnum =~ s/\.pdf//i; #probably not necessary anymore +} + +my $legacy_cust_bill = qsearchs({ + 'select' => 'legacy_cust_bill.*', + 'table' => 'legacy_cust_bill', + 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', + 'hashref' => { 'legacyinvnum' => $legacyinvnum }, + 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, +}); +die "Legacy invoice #$legacyinvnum not found!" unless $legacy_cust_bill; + +my $content = $legacy_cust_bill->content_pdf; + +#maybe should name the file after legacyid if present, but have to clean it +#my $filename = $legacy_cust_bill->legacyid + +http_header('Content-Type' => 'application/pdf' ); +http_header('Content-Disposition' => "filename=$legacyinvnum.pdf" ); +http_header('Content-Length' => length($content) ); +#http_header('Cache-control' => 'max-age=60' ); + +</%init> |