1 % my $batchnum = $cgi->param('download');
2 % if ( $batchnum =~ /^\d+$/ ) {
3 % $cgi->delete('download');
5 <HEAD><TITLE>Starting download...</TITLE>
6 <SCRIPT TYPE="text/javascript">
7 function refreshParent() {
8 window.top.setTimeout("window.top.location.href = '<% $cgi->self_url %>'", 2000);
9 window.top.location.replace('<%$p%>misc/download-bill_batch.html?<%$batchnum%>');
12 </HEAD><BODY onload="refreshParent();">
13 <& /elements/footer.html &>
16 <% include( 'elements/search.html',
17 'title' => 'Invoice Batches',
18 'name_singular' => 'batch',
19 'query' => { 'table' => 'bill_batch',
20 'hashref' => $hashref,
21 'extra_sql' => $extra_sql.
22 'ORDER BY batchnum DESC',
24 'count_query' => "$count_query $extra_sql",
25 'header' => [ 'Batch',
31 'fields' => [ 'batchnum',
33 my $st = "SELECT COUNT(*) from cust_bill_batch WHERE batchnum=" . shift->batchnum;
34 my $sth = dbh->prepare($st)
35 or die dbh->errstr. "doing $st";
37 or die "Error executing \"$st\": ". $sth->errstr;
38 $sth->fetchrow_arrayref->[0];
41 $statusmap{shift->status};
51 'really_disable_download' => 1,
59 unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
61 my %statusmap = ('O'=>'Open', 'R'=>'Closed');
63 my $count_query = 'SELECT COUNT(*) FROM bill_batch';
65 my $extra_sql = ''; # may add something here later
66 my $link = [ "${p}view/bill_batch.cgi?batchnum=", 'batchnum' ];
68 my $download_id = int(rand(1000000));
72 my $batchnum = $batch->batchnum;
73 my $close = ($batch->status eq 'O' ? ';close=1' : '');
74 my $html = qq!<FORM NAME="Download$batchnum" STYLE="display:inline">
75 <INPUT TYPE="hidden" NAME="batchnum" VALUE="$batchnum">
76 <INPUT TYPE="hidden" NAME="close" VALUE="1">
78 $html .= include('/elements/progress-init.html',
80 [ 'batchnum', 'close' ],
81 $p.'misc/process/bill_batch-print.html',
82 { url => $p."search/bill_batch.cgi?download=$batchnum" },
85 $html .= '<A href="#" onclick="batch'.$batchnum.'process();">' .
86 ($batch->status eq 'O' ? '<B>Download and close</B>' : 'Download');
87 $html .= '</A></FORM>';