X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fview%2Fcust_bill-ps.cgi;h=cc8020a3e9c12b82415e5a2e630540673b1b733e;hb=3c54c844c665ed108c7892a154fd3972fab1f3e5;hp=03340a16f664ebec672de0973167000845623a87;hpb=eb9668a6f3181ee02cb335272c5ee4616e61fd09;p=freeside.git diff --git a/httemplate/view/cust_bill-ps.cgi b/httemplate/view/cust_bill-ps.cgi index 03340a16f..cc8020a3e 100755 --- a/httemplate/view/cust_bill-ps.cgi +++ b/httemplate/view/cust_bill-ps.cgi @@ -1,13 +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 $invnum = $1; +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 %> +http_header('Content-Disposition' => "filename=$invnum.ps" ); +http_header('Content-Length' => length($ps) ); +http_header('Cache-control' => 'max-age=60' ); + +