From 6c375156081be5d2023001ed8eaac9b6db568e95 Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 9 Aug 2006 06:43:02 +0000 Subject: batch refactor --- httemplate/browse/cust_pay_batch.cgi | 33 ++++++++++++++++------ httemplate/browse/pay_batch.cgi | 54 ++++++++++++++++++++++++++++++++++++ httemplate/docs/schema.html | 4 +++ httemplate/misc/download-batch.cgi | 37 ++++++++++++++++++++---- 4 files changed, 115 insertions(+), 13 deletions(-) create mode 100755 httemplate/browse/pay_batch.cgi (limited to 'httemplate') diff --git a/httemplate/browse/cust_pay_batch.cgi b/httemplate/browse/cust_pay_batch.cgi index c7f0afe76..98ea2f5a2 100755 --- a/httemplate/browse/cust_pay_batch.cgi +++ b/httemplate/browse/cust_pay_batch.cgi @@ -1,12 +1,24 @@ -<%= include("/elements/header.html","Pending credit card batch", menubar( 'Main Menu' => $p,)) %> +<%= 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; + +%>
Download batch in format
+ + +

@@ -15,25 +27,28 @@ Filename
Format

<% - my $statement = "SELECT SUM(amount) from cust_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"; + 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 pending batch
+$<%= sprintf("%.2f", $total) %> total in batch

<%= &table() %> @@ -45,11 +60,12 @@ $<%= sprintf("%.2f", $total) %> total in pending batch
Card Exp Amount + Status <% foreach my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum } - qsearch('cust_pay_batch', {} ) + qsearch('cust_pay_batch', {'batchnum'=>$batchnum} ) ) { my $cardnum = $cust_pay_batch->payinfo; #$cardnum =~ s/.{4}$/xxxx/; @@ -71,6 +87,7 @@ foreach my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum } <%= $cardnum %> <%= $exp %> $<%= $cust_pay_batch->amount %> + <%= $cust_pay_batch->status %> <% } %> diff --git a/httemplate/browse/pay_batch.cgi b/httemplate/browse/pay_batch.cgi new file mode 100755 index 000000000..66c86d676 --- /dev/null +++ b/httemplate/browse/pay_batch.cgi @@ -0,0 +1,54 @@ + +<%= include("/elements/header.html","Credit card batches", menubar( 'Main Menu' => $p,)) %> + +

+ +<% + my %statusmap = ('I'=>'In Transit', 'O'=>'Open', 'R'=>'Resolved'); +%> + +
+<%= &table() %> + + Batch + First Download + Last Upload + Item Count + Amount + Status + + +<% +foreach my $pay_batch ( sort { $b->batchnum <=> $a->batchnum } + qsearch('pay_batch', {} ) +) { + + my $statement = "SELECT SUM(amount) from cust_pay_batch WHERE batchnum=" . + $pay_batch->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=" . + $pay_batch->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]; + +%> + + + <%= $pay_batch->batchnum %> + <%= $pay_batch->download ? time2str("%a %b %e %T %Y", $pay_batch->download) : '' %> + <%= $pay_batch->upload ? time2str("%a %b %e %T %Y", $pay_batch->upload) : '' %> + <%= $cards %> + <%= $total %> + <%= $statusmap{$pay_batch->status} %> + + +<% } %> + + + + diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html index d9e35efc7..cd4914a6c 100644 --- a/httemplate/docs/schema.html +++ b/httemplate/docs/schema.html @@ -203,11 +203,14 @@
  • cust_pay_batch - Pending batch members
  • cust_pkg - Customer billing items