fix "tax credited" links on tax report for the taxclass + not taxclass in same region...
[freeside.git] / httemplate / misc / download-bill_batch.html
1 <%init>
2 die "access denied"
3   unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
4 my ($batchnum) = $cgi->keywords;
5 $batchnum =~ /^\d+$/ or die "invalid batchnum '$batchnum'";
6 my $batch = FS::bill_batch->by_key($batchnum)
7   or die "Batch $batchnum not found";
8
9 # send the batch
10 my $content = $batch->pdf;
11 $m->clear_buffer;
12 $r->content_type('application/pdf');
13 $r->headers_out->add( 'Content-Disposition' => 
14   'attachment;filename="invoice_batch_'.$batchnum.'.pdf"');
15 my $cookie = CGI::Cookie->new(
16   -name => "bill_batch_download",
17   -value => $batchnum,
18   -expires => '+1d',
19 );
20 $r->headers_out->add( 'Set-Cookie' => $cookie->as_string );
21 $m->print($content);
22
23 $batch->pdf('');
24 my $error = $batch->replace;
25 warn "error deleting cached PDF: '$error'\n" if $error;
26 </%init>