diff options
author | ivan <ivan> | 2011-08-15 20:59:06 +0000 |
---|---|---|
committer | ivan <ivan> | 2011-08-15 20:59:06 +0000 |
commit | 6011535409e784cde658c0042b2f665c83975a91 (patch) | |
tree | f91d43becb3391dfc7181cf9681a42f41162f3fc /httemplate/view/elements | |
parent | fee2489219be414439be6cffac38b834005a41e6 (diff) |
consolate cust_bill-(ps|pdf).cgi into elements/cust_bill-typeset
Diffstat (limited to 'httemplate/view/elements')
-rw-r--r-- | httemplate/view/elements/cust_bill-typeset | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/httemplate/view/elements/cust_bill-typeset b/httemplate/view/elements/cust_bill-typeset new file mode 100644 index 000000000..00f503fbb --- /dev/null +++ b/httemplate/view/elements/cust_bill-typeset @@ -0,0 +1,52 @@ +<% $content %>\ +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('View invoices'); + +my $type = shift; + +my( $invnum, $template, $notice_name ); +my($query) = $cgi->keywords; +if ( $query =~ /^((.+)-)?(\d+)(.pdf)?$/ ) { #probably not necessary anymore? + $template = $2; + $invnum = $3; + $notice_name = 'Invoice'; +} else { + $invnum = $cgi->param('invnum'); + $invnum =~ s/\.pdf//i; #probably not necessary anymore + $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({ + '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 $method = "print_$type"; + +my $content = $cust_bill->$method(\%opt); + +my %mime = ( 'pdf' => 'application/pdf', + 'ps' => 'application/postscript', + ); + +http_header('Content-Type' => $mime{$type} ); +http_header('Content-Disposition' => "filename=$invnum.$type" ); +http_header('Content-Length' => length($content) ); +http_header('Cache-control' => 'max-age=60' ); + +</%init> |