1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
<% include( 'elements/search.html',
'title' => 'Invoice Batches',
'name_singular' => 'batch',
'query' => { 'table' => 'bill_batch',
'hashref' => $hashref,
#'extra_sql' => $extra_sql.
'order_by' => 'ORDER BY batchnum DESC',
},
'count_query' => $count_query,
'header' => [ 'Batch',
'Item Count',
'Status',
'',
],
'align' => 'rrcc',
'fields' => [ 'batchnum',
sub {
my $st = "SELECT COUNT(*) from cust_bill_batch WHERE batchnum=" . shift->batchnum;
my $sth = dbh->prepare($st)
or die dbh->errstr. "doing $st";
$sth->execute
or die "Error executing \"$st\": ". $sth->errstr;
$sth->fetchrow_arrayref->[0];
},
sub {
$statusmap{shift->status};
},
sub { shift->status eq 'O' ?
'Download and close' : 'Download'
},
],
'links' => [
$link,
$link,
$link,
$dlink,
],
'style' => [
'',
'',
'',
sub { shift->status eq 'O' ? "b" : '' },
],
'really_disable_download' => 1,
'agent_virt' => 1,
'agent_null_right' => [ 'Process global invoice batches', 'Configuration' ],
'agent_pos' => 1,
)
%>
<%init>
my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied"
unless $curuser->access_right('Process invoice batches')
|| $curuser->access_right('Process global invoice batches')
|| $curuser->access_right('Configuration'); #remove in 2.5
my %statusmap = ('O'=>'Open', 'R'=>'Closed');
my $hashref = {};
my $count_query = "SELECT COUNT(*) FROM bill_batch WHERE". # $extra_sql AND "
$curuser->agentnums_sql(
'null_right' => ['Process global invoice batches', 'Configuration' ],
);
#my $extra_sql = ''; # may add something here later
my $link = [ "${p}view/bill_batch.cgi?batchnum=", 'batchnum' ];
my $dlink = sub {
[ "${p}view/bill_batch.cgi?start_download=1;".
(shift->status eq 'O' ? 'close=1;' : '').
'batchnum=',
'batchnum']
};
</%init>
|