1 <% include('elements/search.html',
2 'title' => 'Batch payment details',
3 'name' => 'batch details',
5 'count_query' => $count_query,
6 'html_init' => $pay_batch ?
7 include('elements/cust_pay_batch_top.html',
8 'pay_batch' => $pay_batch
31 $cpb->[3] . ', ' . $cpb->[4];
37 my $cardnum = shift->[6];
38 'x'x(length($cardnum)-4). substr($cardnum,(length($cardnum)-4));
41 shift->[7] =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/;
42 my( $mon, $year ) = ( $2, $1 );
43 $mon = "0$mon" if length($mon) == 1;
53 'align' => 'lllllllrl',
54 'links' => [ ['', sub{'#';}],
55 ["${p}view/cust_bill.cgi?", sub{shift->[1];},],
56 ["${p}view/cust_main.cgi?", sub{shift->[2];},],
57 ["${p}view/cust_main.cgi?", sub{shift->[2];},],
63 my $conf = new FS::Conf;
66 unless $FS::CurrentUser::CurrentUser->access_right('Financial reports')
67 || $FS::CurrentUser::CurrentUser->access_right('Process batches')
68 || ( $cgi->param('custnum')
69 && ( $conf->exists('batch-enable')
70 || $conf->config('batch-enable_payby')
74 my( $count_query, $sql_query );
77 my $orderby = 'paybatchnum';
79 my( $pay_batch, $batchnum ) = ( '', '');
80 if ( $cgi->param('batchnum') && $cgi->param('batchnum') =~ /^(\d+)$/ ) {
81 push @search, "batchnum = $1";
82 $pay_batch = qsearchs('pay_batch', { 'batchnum' => $1 } );
83 die "Batch $1 not found!" unless $pay_batch;
84 $batchnum = $pay_batch->batchnum;
87 if ( $cgi->param('custnum') && $cgi->param('custnum') =~ /^(\d+)$/ ) {
88 push @search, "custnum = $1";
91 if ( $cgi->param('status') && $cgi->param('status') =~ /^(\w)$/ ) {
92 push @search, "pay_batch.status = '$1'";
95 if ( $cgi->param('payby') ) {
96 $cgi->param('payby') =~ /^(CARD|CHEK)$/
97 or die "illegal payby " . $cgi->param('payby');
99 push @search, "cust_pay_batch.payby = '$1'";
102 if ( not $cgi->param('dcln') ) {
103 push @search, "cpb.status IS DISTINCT FROM 'Approved'";
106 my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
108 push @search, "pay_batch.upload >= $beginning" if ($beginning);
109 push @search, "pay_batch.upload <= $ending" if ($ending < 4294967295);#2^32-1
110 $orderby = "pay_batch.download,paybatchnum";
113 push @search, $FS::CurrentUser::CurrentUser->agentnums_sql;
114 my $search = ' WHERE ' . join(' AND ', @search);
116 $count_query = 'SELECT COUNT(*) FROM cust_pay_batch AS cpb ' .
117 'LEFT JOIN cust_main USING ( custnum ) ' .
118 'LEFT JOIN pay_batch USING ( batchnum )' .
122 $sql_query = "SELECT paybatchnum,invnum,custnum,cpb.last,cpb.first," .
123 "cpb.payname,cpb.payinfo,cpb.exp,amount,cpb.status " .
124 "FROM cust_pay_batch AS cpb " .
125 'LEFT JOIN cust_main USING ( custnum ) ' .
126 'LEFT JOIN pay_batch USING ( batchnum ) ' .
127 "$search ORDER BY $orderby";
131 $html_init = include('elements/cust_pay_batch_top.html',
132 'pay_batch' => $pay_batch);