rearrange flow of batch download, #947
[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 $m->print($content);
16
17 $batch->pdf('');
18 my $error = $batch->replace;
19 warn "error deleting cached PDF: '$error'\n" if $error;
20 </%init>