1 <% include( 'elements/search.html',
2 'title' => 'Invoice Batches',
3 'name_singular' => 'batch',
4 'query' => { 'table' => 'bill_batch',
6 #'extra_sql' => $extra_sql.
7 'order_by' => 'ORDER BY batchnum DESC',
9 'count_query' => $count_query,
10 'header' => [ 'Batch',
16 'fields' => [ 'batchnum',
18 my $st = "SELECT COUNT(*) from cust_bill_batch WHERE batchnum=" . shift->batchnum;
19 my $sth = dbh->prepare($st)
20 or die dbh->errstr. "doing $st";
22 or die "Error executing \"$st\": ". $sth->errstr;
23 $sth->fetchrow_arrayref->[0];
26 $statusmap{shift->status};
28 sub { shift->status eq 'O' ?
29 'Download and close' : 'Download'
42 sub { shift->status eq 'O' ? "b" : '' },
44 'really_disable_download' => 1,
46 'agent_null_right' => [ 'Process global invoice batches', 'Configuration' ],
54 my $curuser = $FS::CurrentUser::CurrentUser;
57 unless $curuser->access_right('Process invoice batches')
58 || $curuser->access_right('Process global invoice batches')
59 || $curuser->access_right('Configuration'); #remove in 2.5
61 my %statusmap = ('O'=>'Open', 'R'=>'Closed');
63 my $count_query = "SELECT COUNT(*) FROM bill_batch WHERE". # $extra_sql AND "
64 $curuser->agentnums_sql(
65 'null_right' => ['Process global invoice batches', 'Configuration' ],
68 #my $extra_sql = ''; # may add something here later
69 my $link = [ "${p}view/bill_batch.cgi?batchnum=", 'batchnum' ];
71 [ "${p}view/bill_batch.cgi?start_download=1;".
72 (shift->status eq 'O' ? 'close=1;' : '').