summaryrefslogtreecommitdiff
path: root/httemplate/misc
diff options
context:
space:
mode:
authormark <mark>2011-07-30 23:20:37 +0000
committermark <mark>2011-07-30 23:20:37 +0000
commit873ec8e0528b7a944aec88936538fe9a04cd0b3f (patch)
treea23fc0f4fa9bd45cc4d0ea8c18edca5ae4e66302 /httemplate/misc
parentb1c1559dec0570bc401ccd0e29e66a9bf6f151e1 (diff)
rearrange flow of batch download, #947
Diffstat (limited to 'httemplate/misc')
-rw-r--r--httemplate/misc/download-bill_batch.html20
1 files changed, 20 insertions, 0 deletions
diff --git a/httemplate/misc/download-bill_batch.html b/httemplate/misc/download-bill_batch.html
new file mode 100644
index 000000000..00d9236f3
--- /dev/null
+++ b/httemplate/misc/download-bill_batch.html
@@ -0,0 +1,20 @@
+<%init>
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
+my ($batchnum) = $cgi->keywords;
+$batchnum =~ /^\d+$/ or die "invalid batchnum '$batchnum'";
+my $batch = FS::bill_batch->by_key($batchnum)
+ or die "Batch $batchnum not found";
+
+# send the batch
+my $content = $batch->pdf;
+$m->clear_buffer;
+$r->content_type('application/pdf');
+$r->headers_out->add( 'Content-Disposition' =>
+ 'attachment;filename="invoice_batch_'.$batchnum.'.pdf"');
+$m->print($content);
+
+$batch->pdf('');
+my $error = $batch->replace;
+warn "error deleting cached PDF: '$error'\n" if $error;
+</%init>