%= include("/elements/header.html","Credit card batch details", menubar( 'Main Menu' => $p,)) %>
<%
die "No batch specified (bad URL)!" unless $cgi->keywords;
my($query) = $cgi->keywords;
$query =~ /^(\d+)$/;
my $batchnum = $1;
my $pay_batch = qsearchs('pay_batch',{'batchnum'=>$batchnum});
die "Batch not found!" unless $pay_batch;
%>
<%
my $statement = "SELECT SUM(amount) from cust_pay_batch WHERE batchnum=".
$batchnum;
my $sth = dbh->prepare($statement) or die dbh->errstr. "doing $statement";
$sth->execute or die "Error executing \"$statement\": ". $sth->errstr;
my $total = $sth->fetchrow_arrayref->[0];
my $c_statement = "SELECT COUNT(*) from cust_pay_batch WHERE batchnum=".
$batchnum;
my $c_sth = dbh->prepare($c_statement)
or die dbh->errstr. "doing $c_statement";
$c_sth->execute or die "Error executing \"$c_statement\": ". $c_sth->errstr;
my $cards = $c_sth->fetchrow_arrayref->[0];
%>
<%= $cards %> credit card payments batched
$<%= sprintf("%.2f", $total) %> total in batch
<%= &table() %>
# |
inv# |
Customer |
Card name |
Card |
Exp |
Amount |
Status |
<%
foreach my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum }
qsearch('cust_pay_batch', {'batchnum'=>$batchnum} )
) {
my $cardnum = $cust_pay_batch->payinfo;
#$cardnum =~ s/.{4}$/xxxx/;
$cardnum = 'x'x(length($cardnum)-4). substr($cardnum,(length($cardnum)-4));
$cust_pay_batch->exp =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/;
my( $mon, $year ) = ( $2, $1 );
$mon = "0$mon" if $mon < 10;
my $exp = "$mon/$year";
%>
<%= $cust_pay_batch->paybatchnum %> |
<%= $cust_pay_batch->invnum %> |
<%= $cust_pay_batch->custnum %> |
<%= $cust_pay_batch->get('last'). ', '. $cust_pay_batch->first %> |
<%= $cust_pay_batch->payname %> |
<%= $cardnum %> |
<%= $exp %> |
$<%= $cust_pay_batch->amount %> |
<%= $cust_pay_batch->status %> |
<% } %>