3 %my %statusmap = ('I'=>'In Transit', 'O'=>'Open', 'R'=>'Resolved');
5 %my $count_query = 'SELECT COUNT(*) FROM pay_batch';
7 %my($begin, $end) = ( '', '' );
10 %if ( $cgi->param('beginning')
11 % && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) {
12 % $begin = str2time($1);
13 % push @where, "download >= $begin";
15 %if ( $cgi->param('ending')
16 % && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) {
17 % $end = str2time($1) + 86399;
18 % push @where, "download < $end";
22 %if ( $cgi->param('open') ) {
26 %if ( $cgi->param('intransit') ) {
30 %if ( $cgi->param('resolved') ) {
35 % scalar(@status) ? q!(status='! . join(q!' OR status='!, @status) . q!')!
36 % : q!status='X'!; # kludgy, X is unused at present
38 %my $extra_sql = scalar(@where) ? 'WHERE ' . join(' AND ', @where) : '';
41 <% include( 'elements/search.html',
42 'title' => 'Credit Card Batches',
43 'menubar' => [ 'Main Menu' => $p, ],
45 'query' => { 'table' => 'pay_batch',
46 'hashref' => $hashref,
47 'extra_sql' => "$extra_sql ORDER BY batchnum DESC",
49 'count_query' => "$count_query $extra_sql",
50 'header' => [ 'Batch',
58 'fields' => [ 'batchnum',
60 my $_date = shift->download;
61 $_date ? time2str("%a %b %e %T %Y", $_date) : ''
64 my $_date = shift->upload;
65 $_date ? time2str("%a %b %e %T %Y", $_date) : ''
68 my $st = "SELECT COUNT(*) from cust_pay_batch WHERE batchnum=" . shift->batchnum;
69 my $sth = dbh->prepare($st)
70 or die dbh->errstr. "doing $st";
72 or die "Error executing \"$st\": ". $sth->errstr;
73 $sth->fetchrow_arrayref->[0];
76 my $st = "SELECT SUM(amount) from cust_pay_batch WHERE batchnum=" . shift->batchnum;
77 my $sth = dbh->prepare($st)
78 or die dbh->errstr. "doing $st";
80 or die "Error executing \"$st\": ". $sth->errstr;
81 $sth->fetchrow_arrayref->[0];
84 $statusmap{shift->status};
87 'links' => [ [ "${p}search/cust_pay_batch.cgi?batchnum=", 'batchnum',],