1 % if($magic eq 'print') {
2 <% include('/elements/header.html', "Download Batch") %>
3 <FORM NAME="OneTrueForm">
4 <INPUT TYPE="hidden" NAME="batchnum" VALUE="<% $batchnum %>">
5 % $cgi->delete('magic');
6 <% include('/elements/progress-init.html',
9 $p.'misc/process/bill_batch-print.html',
10 {'url' => $cgi->self_url . ';magic=download'},
13 <SCRIPT TYPE="text/javascript">process();</SCRIPT>
14 <% include('/elements/footer.html') %>
17 % elsif($magic eq 'download') {
19 % $r->content_type('application/pdf');
20 % $r->headers_out->add('Content-Disposition' => 'attachment;filename="invoice_batch_'.$batchnum.'.pdf"');
23 % my $error = $batch->replace;
24 % warn "error deleting cached PDF: '$error'\n" if $error;
27 <% include('/search/elements/search.html',
29 "Batch $batchnum closed." :
30 "Invoice Batch $batchnum",
32 'query' => { 'table' => 'cust_bill_batch',
33 'select' => join(', ',
35 FS::UI::Web::cust_sql_fields(),
36 'cust_main.custnum AS cust_main_custnum',
40 'LEFT JOIN cust_bill USING ( invnum ) '.
41 'LEFT JOIN cust_main USING ( custnum )',
43 " WHERE batchnum = $batchnum",
45 'count_query' => "SELECT COUNT(*) FROM cust_bill_batch WHERE batchnum = $batchnum",
46 'html_init' => $html_init,
47 'header' => [ 'Invoice #',
52 'fields' => [ sub { shift->cust_bill->display_invnum },
53 sub { sprintf($money_char.'%.2f',
54 shift->cust_bill->charged ) },
55 sub { time2str('%b %d %Y',
56 shift->cust_bill->_date ) },
57 sub { shift->cust_bill->cust_main->name },
60 'links' => [ ($link) x 3, $clink,
62 'really_disable_download' => 1,
68 unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
70 my $conf = new FS::Conf;
72 my $batchnum = $cgi->param('batchnum');
74 $batch = FS::bill_batch->by_key($batchnum);
75 die "Batch '$batchnum' not found!\n" if !$batch;
77 my $magic = $cgi->param('magic');
80 my $close = $cgi->param('close');
81 $batch->close if $close;
84 $cgi->param('magic' => 'print');
85 $cgi->delete('close');
86 $html_init = '<A HREF="'.$cgi->self_url.'">Download this batch</A><BR>';
87 if($batch->status eq 'O') {
88 $cgi->param('close' => 1);
89 $cgi->delete('magic');
90 $html_init .= '<A HREF="'.$cgi->self_url.'">Close this batch</A><BR>';
95 my $link = [ "$p/view/cust_bill.cgi?", 'invnum' ];
96 my $clink = [ "$p/view/cust_main.cgi?", 'custnum' ];
97 my $money_char = $conf->config('money_char') || '$';