X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fview%2Fcust_bill-ps.cgi;h=cc8020a3e9c12b82415e5a2e630540673b1b733e;hb=e41880cfb8d9835bca858ec13c96724b08fa0af7;hp=8485a150f6da98ba8b5f66555d398f6f9ef4884e;hpb=e6b504f1d05efe176bb91c40cca089b41d2d2f49;p=freeside.git diff --git a/httemplate/view/cust_bill-ps.cgi b/httemplate/view/cust_bill-ps.cgi index 8485a150f..cc8020a3e 100755 --- a/httemplate/view/cust_bill-ps.cgi +++ b/httemplate/view/cust_bill-ps.cgi @@ -1,14 +1,43 @@ -<% +<% $ps %> +<%init> -#untaint invnum +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('View invoices'); + +my( $invnum, $template, $notice_name ); my($query) = $cgi->keywords; -$query =~ /^((.+)-)?(\d+)$/; -my $templatename = $2; -my $invnum = $3; +if ( $query =~ /^((.+)-)?(\d+)(.pdf)?$/ ) { #probably not necessary anymore? + $template = $2; + $invnum = $3; + $notice_name = 'Invoice'; +} else { + $invnum = $cgi->param('invnum'); + $template = $cgi->param('template'); + $notice_name = ( $cgi->param('notice_name') || 'Invoice' ); +} + +my $conf = new FS::Conf; + +my %opt = ( + 'unsquelch_cdr' => $conf->exists('voip-cdr_email'), + 'template' => $template, + 'notice_name' => $notice_name, +); -my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); +my $cust_bill = qsearchs({ + 'select' => 'cust_bill.*', + 'table' => 'cust_bill', + 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', + 'hashref' => { 'invnum' => $invnum }, + 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, +}); die "Invoice #$invnum not found!" unless $cust_bill; +my $ps = $cust_bill->print_ps(\%opt); + http_header('Content-Type' => 'application/postscript' ); -%> -<%= $cust_bill->print_ps( '', $templatename) %> +http_header('Content-Disposition' => "filename=$invnum.ps" ); +http_header('Content-Length' => length($ps) ); +http_header('Cache-control' => 'max-age=60' ); + +