diff options
author | jeff <jeff> | 2006-08-26 23:15:14 +0000 |
---|---|---|
committer | jeff <jeff> | 2006-08-26 23:15:14 +0000 |
commit | 6af1b1bfa25e5ececef5e0dcd38b55917121cee2 (patch) | |
tree | cb81deb99bee814a037fd866fa10981ae459472f /httemplate | |
parent | 62ee3858ef853cb2b4f1a6cd98f8a608e7d11d7d (diff) |
batch refactor continued
Diffstat (limited to 'httemplate')
-rwxr-xr-x | httemplate/browse/cust_pay_batch.cgi | 97 | ||||
-rwxr-xr-x | httemplate/edit/cust_bill_pay.cgi | 2 | ||||
-rwxr-xr-x | httemplate/edit/cust_credit.cgi | 4 | ||||
-rwxr-xr-x | httemplate/edit/cust_credit_bill.cgi | 8 | ||||
-rwxr-xr-x | httemplate/edit/part_bill_event.cgi | 9 | ||||
-rwxr-xr-x | httemplate/edit/process/cust_main.cgi | 3 | ||||
-rwxr-xr-x | httemplate/edit/process/cust_refund.cgi | 8 | ||||
-rwxr-xr-x | httemplate/misc/bill.cgi | 4 | ||||
-rw-r--r-- | httemplate/misc/download-batch.cgi | 44 | ||||
-rw-r--r-- | httemplate/misc/process/payment.cgi | 7 | ||||
-rwxr-xr-x | httemplate/search/cust_pay_batch.cgi | 145 | ||||
-rwxr-xr-x | httemplate/search/pay_batch.cgi | 93 | ||||
-rw-r--r-- | httemplate/search/pay_batch.html | 27 | ||||
-rw-r--r-- | httemplate/search/report_cust_pay_batch.html | 37 |
14 files changed, 337 insertions, 151 deletions
diff --git a/httemplate/browse/cust_pay_batch.cgi b/httemplate/browse/cust_pay_batch.cgi deleted file mode 100755 index e40e95870..000000000 --- a/httemplate/browse/cust_pay_batch.cgi +++ /dev/null @@ -1,97 +0,0 @@ -<!-- mason kludge --> -<% 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; -% -% - - -<FORM ACTION="<%$p%>misc/download-batch.cgi" METHOD="POST"> -Download batch in format <SELECT NAME="format"> -<OPTION VALUE="">Default batch mode</OPTION> -<OPTION VALUE="csv-td_canada_trust-merchant_pc_batch">CSV file for TD Canada Trust Merchant PC Batch</OPTION> -<OPTION VALUE="PAP">80 byte file for TD Canada Trust PAP Batch</OPTION> -<OPTION VALUE="BoM">Bank of Montreal ECA batch</OPTION> -</SELECT><INPUT TYPE="hidden" NAME="batchnum" VALUE="<% $batchnum %>"><INPUT TYPE="submit" VALUE="Download"></FORM> -<BR><BR> - -<FORM ACTION="<%$p%>misc/upload-batch.cgi" METHOD="POST" ENCTYPE="multipart/form-data"> -Upload results<BR> -Filename <INPUT TYPE="file" NAME="batch_results"><BR> -Format <SELECT NAME="format"> -<OPTION VALUE="">Default batch mode</OPTION> -<OPTION VALUE="csv-td_canada_trust-merchant_pc_batch">CSV results from TD Canada Trust Merchant PC Batch</OPTION> -<OPTION VALUE="PAP">264 byte results for TD Canada Trust PAP Batch</OPTION> -<OPTION VALUE="BoM">Bank of Montreal ECA results</OPTION> -</SELECT><BR> -<INPUT TYPE="submit" VALUE="Upload"></FORM> -<BR> -% -% 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<BR> -$<% sprintf("%.2f", $total) %> total in batch<BR> - -<BR> -<% &table() %> - <TR> - <TH>#</TH> - <TH><font size=-1>inv#</font></TH> - <TH COLSPAN=2>Customer</TH> - <TH>Card name</TH> - <TH>Card</TH> - <TH>Exp</TH> - <TH>Amount</TH> - <TH>Status</TH> - </TR> -% -%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"; -% -% - - - <TR> - <TD><% $cust_pay_batch->paybatchnum %></TD> - <TD><A HREF="../view/cust_bill.cgi?<% $cust_pay_batch->invnum %>"><% $cust_pay_batch->invnum %></TD> - <TD><A HREF="../view/cust_main.cgi?<% $cust_pay_batch->custnum %>"><% $cust_pay_batch->custnum %></TD> - <TD><% $cust_pay_batch->get('last'). ', '. $cust_pay_batch->first %></TD> - <TD><% $cust_pay_batch->payname %></TD> - <TD><% $cardnum %></TD> - <TD><% $exp %></TD> - <TD align="right">$<% $cust_pay_batch->amount %></TD> - <TD><% $cust_pay_batch->status %></TD> - </TR> -% } - - - </TABLE> - </BODY> -</HTML> diff --git a/httemplate/edit/cust_bill_pay.cgi b/httemplate/edit/cust_bill_pay.cgi index 498d477cd..90292ebc1 100755 --- a/httemplate/edit/cust_bill_pay.cgi +++ b/httemplate/edit/cust_bill_pay.cgi @@ -36,6 +36,7 @@ function changed(what) { <BR>Invoice #<SELECT NAME="invnum" SIZE=1 onChange="changed(this)"> <OPTION VALUE=""> +% foreach my $cust_bill ( @cust_bill ) { % foreach my $cust_bill ( @cust_bill ) { <OPTION<% $cust_bill->invnum eq $invnum ? ' SELECTED' : '' %> VALUE="<% $cust_bill->invnum %>"><% $cust_bill->invnum %> - <% time2str("%D", $cust_bill->_date) %> - $<% $cust_bill->owed %> @@ -83,3 +84,4 @@ my @cust_bill = sort { $a->_date <=> $b->_date qsearch('cust_bill', { 'custnum' => $cust_pay->custnum } ); </%init> + diff --git a/httemplate/edit/cust_credit.cgi b/httemplate/edit/cust_credit.cgi index 13d062c74..803798ef8 100755 --- a/httemplate/edit/cust_credit.cgi +++ b/httemplate/edit/cust_credit.cgi @@ -25,6 +25,9 @@ Credit <TD ALIGN="right">Amount</TD> <TD BGCOLOR="#ffffff">$<INPUT TYPE="text" NAME="amount" VALUE="<% $amount %>" SIZE=8 MAXLENGTH=8></TD> </TR> +% +%#print qq! <INPUT TYPE="checkbox" NAME="refund" VALUE="$refund">Also post refund!; +% % %#print qq! <INPUT TYPE="checkbox" NAME="refund" VALUE="$refund">Also post refund!; @@ -78,3 +81,4 @@ my $otaker = getotaker; my $p1 = popurl(1); </%init> + diff --git a/httemplate/edit/cust_credit_bill.cgi b/httemplate/edit/cust_credit_bill.cgi index 249ba31d0..26c1126b1 100755 --- a/httemplate/edit/cust_credit_bill.cgi +++ b/httemplate/edit/cust_credit_bill.cgi @@ -21,6 +21,12 @@ Credit #<B><% $crednum %></B> <SCRIPT> function changed(what) { cust_bill = what.options[what.selectedIndex].value; +% foreach my $cust_bill ( @cust_bill ) { +% my $invnum = $cust_bill->invnum; +% my $changeto = $cust_bill->owed < $cust_credit->credited +% ? $cust_bill->owed +% : $cust_credit->credited; +% % foreach my $cust_bill ( @cust_bill ) { @@ -38,6 +44,7 @@ function changed(what) { <BR>Invoice #<SELECT NAME="invnum" SIZE=1 onChange="changed(this)"> <OPTION VALUE=""> +% foreach my $cust_bill ( @cust_bill ) { % foreach my $cust_bill ( @cust_bill ) { <OPTION<% $cust_bill->invnum eq $invnum ? ' SELECTED' : '' %> VALUE="<% $cust_bill->invnum %>"><% $cust_bill->invnum %> - <% time2str("%D",$cust_bill->_date) %> - $<% $cust_bill->owed %> @@ -90,3 +97,4 @@ my @cust_bill = sort { $a->_date <=> $b->_date qsearch('cust_bill', { 'custnum' => $cust_credit->custnum } ); </%init> + diff --git a/httemplate/edit/part_bill_event.cgi b/httemplate/edit/part_bill_event.cgi index a58f07883..243975558 100755 --- a/httemplate/edit/part_bill_event.cgi +++ b/httemplate/edit/part_bill_event.cgi @@ -216,10 +216,16 @@ Invoice Event #<% $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %> % % 'batch-card' => { % 'name' => 'Add card to the pending credit card batch', -% 'code' => '$cust_bill->batch_card();', +% 'code' => '$cust_bill->batch_card(%options);', % 'weight' => 40, % }, % +% 'retriable' => { +% 'name' => 'Mark batched card event as retriable', +% 'code' => '$cust_pay_batch->retriable();', +% 'weight' => 60, +% }, +% % 'send' => { % 'name' => 'Send invoice (email/print/fax)', % 'code' => '$cust_bill->send();', @@ -430,3 +436,4 @@ Invoice Event #<% $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %> </BODY> </HTML> + diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index 2d698c7b0..20c051b92 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -126,7 +126,7 @@ % my $berror = $new->bill; % $new->apply_payments; % $new->apply_credits; -% $berror ||= $new->collect; +% $berror ||= $new->collect 'realtime' => 1; % warn "Warning, error billing during backend-realtime: $berror" if $berror; % % } @@ -152,3 +152,4 @@ %} % + diff --git a/httemplate/edit/process/cust_refund.cgi b/httemplate/edit/process/cust_refund.cgi index fadfffb62..3a58d9aa5 100755 --- a/httemplate/edit/process/cust_refund.cgi +++ b/httemplate/edit/process/cust_refund.cgi @@ -1,4 +1,4 @@ -% + % % %$cgi->param('custnum') =~ /^(\d*)$/ or die "Illegal custnum!"; %my $custnum = $1; @@ -7,11 +7,7 @@ % %my $error = ''; %if ( $cgi->param('payby') =~ /^(CARD|CHEK)$/ ) { -% my %payby2bop = ( -% 'CARD' => 'CC', -% 'CHEK' => 'ECHECK', -% ); -% my $bop = $payby2bop{$1}; +% my $bop = FS::payby::$payby2bop{$1}; % $cgi->param('refund') =~ /^(\d*)(\.\d{2})?$/ % or die "illegal refund amount ". $cgi->param('refund'); % my $refund = "$1$2"; diff --git a/httemplate/misc/bill.cgi b/httemplate/misc/bill.cgi index 1532a44eb..6e4cc265d 100755 --- a/httemplate/misc/bill.cgi +++ b/httemplate/misc/bill.cgi @@ -1,5 +1,4 @@ % -% %#untaint custnum %my($query) = $cgi->keywords; %$query =~ /^(\d*)$/; @@ -7,6 +6,8 @@ %my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum}); %die "Can't find customer!\n" unless $cust_main; % +%my $conf = new FS::Conf; +% %my $error = $cust_main->bill( %# 'time'=>$time % ); @@ -23,6 +24,7 @@ % #'report_badcard'=> 'yes', % #'retry_card' => 'yes', % 'retry' => 'yes', +% 'realtime' => $conf->exists('realtime-backend'), % ); %} %#&eidiot($error) if $error; diff --git a/httemplate/misc/download-batch.cgi b/httemplate/misc/download-batch.cgi index 038aa2049..ad88092d3 100644 --- a/httemplate/misc/download-batch.cgi +++ b/httemplate/misc/download-batch.cgi @@ -1,17 +1,9 @@ % -% %my $conf=new FS::Conf; % %#http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes %http_header('Content-Type' => 'text/plain' ); % -%my $batchnum; -%if ( $cgi->param('batchnum') =~ /^(\d+)$/ ) { -% $batchnum = $1; -%} else { -% die "No batch number (bad URL) \n"; -%} -% %my $format; %if ( $cgi->param('format') =~ /^([\w\- ]+)$/ ) { % $format = $1; @@ -23,12 +15,11 @@ %local $FS::UID::AutoCommit = 0; %my $dbh = dbh; % -%my $pay_batch = qsearchs('pay_batch', {'batchnum'=>$batchnum, 'status'=>'O'} ); +%my $pay_batch = qsearchs('pay_batch', {'status'=>''} ); %die "No pending batch. \n" unless $pay_batch; % %my %batchhash = $pay_batch->hash; %$batchhash{'status'} = 'I'; -%$batchhash{'download'} = time unless $batchhash{'download'}; %my $new = new FS::pay_batch \%batchhash; %my $error = $new->replace($pay_batch); %die "error updating batch status: $error\n" if $error; @@ -36,10 +27,8 @@ %my $batchtotal=0; %my $batchcount=0; % -%my (@date)=localtime($new->download); -%my $jdate = sprintf("%03d", $date[5] % 100).sprintf("%03d", $date[7] + 1); -%my $cdate = sprintf("%02d", $date[3]).sprintf("%02d", $date[4] + 1). -% sprintf("%02d", $date[5] % 100); +%my (@date)=localtime(); +%my $jdate = sprintf("%03d", $date[5] % 100).sprintf("%03d", $date[7]); % %if ($format eq "BoM") { % @@ -51,16 +40,6 @@ %> % % -%}elsif ($format eq "PAP"){ -% -% my($origid,$datacenter,$typecode,$shortname,$longname,$mybank,$myacct) = -% $conf->config("batchconfig-$format"); -% -<% sprintf( "H%10sD%3s%06u%-15s%09u%-12s%04u%19s\n",$origid,$typecode,$cdate,$shortname,$mybank,$myacct,$pay_batch->batchnum,"") - - %> -% -% %}elsif ($format eq "csv-td_canada_trust-merchant_pc_batch"){ %# 1; %}else{ @@ -84,14 +63,7 @@ % % my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo ); % -<% sprintf( "D%010.0f%09u%-12s%-29s%-19s\n",$cust_pay_batch->amount*100,$aba,$account,$cust_pay_batch->payname,$cust_pay_batch->paybatchnum) %> -% -% -% } elsif ($format eq "PAP"){ -% -% my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo ); -% -<% sprintf( "D%-23s%06u%-19s%09u%-12s%010.0f\n",$cust_pay_batch->payname,$cdate,$cust_pay_batch->paybatchnum,$aba,$account,$cust_pay_batch->amount*100) %> +<% sprintf( "D%010u%09u%-12s%-29s%-19s\n",$cust_pay_batch->amount*100,$aba,$account,$cust_pay_batch->payname,$cust_pay_batch->invnum %> % % % } elsif ($format eq "csv-td_canada_trust-merchant_pc_batch") { @@ -109,16 +81,10 @@ %if ($format eq "BoM") { % % -<% sprintf( "YD%08u%014.0f%56s\n",$batchcount,$batchtotal*100,"" ). +<% sprintf( "YD%08u%014u%56s\n",$batchcount,$batchtotal*100,"" ). sprintf( "Z%014u%05u%014u%05u%41s\n",$batchtotal*100,$batchcount,"0","0","" ) %> % % -%} elsif ($format eq "PAP"){ -% -% -<% sprintf( "T%08u%014.0f%57s\n",$batchcount,$batchtotal*100,"" ) %> -% -% %} elsif ($format eq "csv-td_canada_trust-merchant_pc_batch"){ % #1; %} else { diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi index 188d1dd04..e1fade4e2 100644 --- a/httemplate/misc/process/payment.cgi +++ b/httemplate/misc/process/payment.cgi @@ -1,5 +1,4 @@ % -% %#some false laziness w/MyAccount::process_payment % %$cgi->param('custnum') =~ /^(\d+)$/ @@ -25,10 +24,6 @@ %$cgi->param('payby') =~ /^(CARD|CHEK)$/ % or die "illegal payby ". $cgi->param('payby'); %my $payby = $1; -%my %payby2bop = ( -% 'CARD' => 'CC', -% 'CHEK' => 'ECHECK', -%); %my %payby2fields = ( % 'CARD' => [ qw( address1 address2 city state zip ) ], % 'CHEK' => [ qw( ss ) ], @@ -87,7 +82,7 @@ % die "unknown payby $payby"; %} % -%my $error = $cust_main->realtime_bop( $payby2bop{$payby}, $amount, +%my $error = $cust_main->realtime_bop( $FS::payby::payby2bop->{$payby}, $amount, % 'quiet' => 1, % 'payinfo' => $payinfo, % 'paydate' => "$year-$month-01", diff --git a/httemplate/search/cust_pay_batch.cgi b/httemplate/search/cust_pay_batch.cgi new file mode 100755 index 000000000..1b0bf6abf --- /dev/null +++ b/httemplate/search/cust_pay_batch.cgi @@ -0,0 +1,145 @@ +% +% +%my ($count_query, $sql_query, $batchnum); +%my $hashref = {}; +%my @search = (); +%my $orderby = 'paybatchnum'; +% +%if ( $cgi->param('batchnum') && $cgi->param('batchnum') =~ /^(\d+)$/ ) { +% push @search, "batchnum = $1"; +% my $pay_batch = qsearchs('pay_batch', { 'batchnum' => $1 } ); +% die "Batch $1 not found!" unless $pay_batch; +% $batchnum = $pay_batch->batchnum; +%} +% +%if ( $cgi->param('payby') ) { +% $cgi->param('payby') =~ /^(CARD|CHEK)$/ +% or die "illegal payby " . $cgi->param('payby'); +% +% push @search, "cust_pay_batch.payby = '$1'"; +%} +% +%if ( not $cgi->param('dcln') ) { +% push @search, "cpb.status IS DISTINCT FROM 'Approved'"; +%} +% +%my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); +%unless ($batchnum){ +% push @search, "pay_batch.upload >= $beginning" if ($beginning); +% push @search, "pay_batch.upload <= $ending" if ($ending < 4294967295);#2^32-1 +% $orderby = "pay_batch.download,paybatchnum"; +%} +% +%push @search, $FS::CurrentUser::CurrentUser->agentnums_sql; +%my $search = ' WHERE ' . join(' AND ', @search); +% +%$count_query = 'SELECT COUNT(*) FROM cust_pay_batch AS cpb ' . +% 'LEFT JOIN cust_main USING ( custnum ) ' . +% 'LEFT JOIN pay_batch USING ( batchnum )' . +% $search; +% +%#grr +%$sql_query = "SELECT paybatchnum,invnum,custnum,cpb.last,cpb.first," . +% "cpb.payname,cpb.payinfo,cpb.exp,amount,cpb.status " . +% "FROM cust_pay_batch AS cpb " . +% 'LEFT JOIN cust_main USING ( custnum ) ' . +% 'LEFT JOIN pay_batch USING ( batchnum ) ' . +% "$search ORDER BY $orderby"; +% +%my $html_init = <<EOF; +%<FORM ACTION="$p/misc/download-batch.cgi" METHOD="POST"> +%Download batch in format <SELECT NAME="format"> +%<OPTION VALUE="">Default batch mode</OPTION> +%<OPTION VALUE="csv-td_canada_trust-merchant_pc_batch">CSV file for TD Canada Trust Merchant PC Batch</OPTION> +%<OPTION VALUE="PAP">80 byte file for TD Canada Trust PAP Batch</OPTION> +%<OPTION VALUE="BoM">Bank of Montreal ECA batch</OPTION> +%</SELECT><INPUT TYPE="hidden" NAME="batchnum" VALUE="$batchnum"><INPUT TYPE="submit" VALUE="Download"></FORM> +%<BR><BR> +% +%<FORM ACTION="$p/misc/upload-batch.cgi" METHOD="POST" ENCTYPE="multipart/form-data"> +%Upload results<BR> +%Filename <INPUT TYPE="file" NAME="batch_results"><BR> +%Format <SELECT NAME="format"> +%<OPTION VALUE="">Default batch mode</OPTION> +%<OPTION VALUE="csv-td_canada_trust-merchant_pc_batch">CSV results from TD Canada Trust Merchant PC Batch</OPTION> +%<OPTION VALUE="PAP">264 byte results for TD Canada Trust PAP Batch</OPTION> +%<OPTION VALUE="BoM">Bank of Montreal ECA results</OPTION> +%</SELECT><BR> +%<INPUT TYPE="submit" VALUE="Upload"></FORM> +%<BR> +%EOF +% +%if ($batchnum) { +% my $sth = dbh->prepare($count_query) or die dbh->errstr. "doing $count_query"; +% $sth->execute or die "Error executing \"$count_query\": ". $sth->errstr; +% my $cards = $sth->fetchrow_arrayref->[0]; +% +% my $st = "SELECT SUM(amount) from cust_pay_batch WHERE batchnum=". $batchnum; +% $sth = dbh->prepare($st) or die dbh->errstr. "doing $st"; +% $sth->execute or die "Error executing \"$st\": ". $sth->errstr; +% my $total = $sth->fetchrow_arrayref->[0]; +% +% $html_init .= "$cards credit card payments batched<BR>\$" . +% sprintf("%.2f", $total) ." total in batch<BR>"; +%} +% +% +<% include('elements/search.html', + 'title' => 'Batch payment details', + 'name' => 'batch details', + 'menubar' => ['Main Menu' => $p,], + 'query' => $sql_query, + 'count_query' => $count_query, + 'html_init' => $batchnum ? $html_init : '', + 'header' => [ '#', + 'Inv #', + 'Customer', + 'Customer', + 'Card Name', + 'Card', + 'Exp', + 'Amount', + 'Status', + ], + 'fields' => [ sub { + shift->[0]; + }, + sub { + shift->[1]; + }, + sub { + shift->[2]; + }, + sub { + my $cpb = shift; + $cpb->[3] . ', ' . $cpb->[4]; + }, + sub { + shift->[5]; + }, + sub { + my $cardnum = shift->[6]; + 'x'x(length($cardnum)-4). substr($cardnum,(length($cardnum)-4)); + }, + sub { + shift->[7] =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/; + my( $mon, $year ) = ( $2, $1 ); + $mon = "0$mon" if $mon < 10; + "$mon/$year"; + }, + sub { + shift->[8]; + }, + sub { + shift->[9]; + }, + ], + 'align' => 'lllllllrl', + 'links' => [ ['', sub{'#';}], + ["${p}view/cust_bill.cgi?", sub{shift->[1];},], + ["${p}view/cust_main.cgi?", sub{shift->[2];},], + ["${p}view/cust_main.cgi?", sub{shift->[2];},], + ], + ) +%> + diff --git a/httemplate/search/pay_batch.cgi b/httemplate/search/pay_batch.cgi new file mode 100755 index 000000000..fcfa8bef2 --- /dev/null +++ b/httemplate/search/pay_batch.cgi @@ -0,0 +1,93 @@ +% +% +%my %statusmap = ('I'=>'In Transit', 'O'=>'Open', 'R'=>'Resolved'); +%my $hashref = {}; +%my $count_query = 'SELECT COUNT(*) FROM pay_batch'; +% +%my($begin, $end) = ( '', '' ); +% +%my @where; +%if ( $cgi->param('beginning') +% && $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/ ) { +% $begin = str2time($1); +% push @where, "download >= $begin"; +%} +%if ( $cgi->param('ending') +% && $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/ ) { +% $end = str2time($1) + 86399; +% push @where, "download < $end"; +%} +% +%my @status; +%if ( $cgi->param('open') ) { +% push @status, "O"; +%} +% +%if ( $cgi->param('intransit') ) { +% push @status, "I"; +%} +% +%if ( $cgi->param('resolved') ) { +% push @status, "R"; +%} +% +%push @where, +% scalar(@status) ? q!(status='! . join(q!' OR status='!, @status) . q!')! +% : q!status='X'!; # kludgy, X is unused at present +% +%my $extra_sql = scalar(@where) ? 'WHERE ' . join(' AND ', @where) : ''; +% +% +<% include( 'elements/search.html', + 'title' => 'Credit Card Batches', + 'menubar' => [ 'Main Menu' => $p, ], + 'name' => 'batches', + 'query' => { 'table' => 'pay_batch', + 'hashref' => $hashref, + 'extra_sql' => "$extra_sql ORDER BY batchnum DESC", + }, + 'count_query' => "$count_query $extra_sql", + 'header' => [ 'Batch', + 'First Download', + 'Last Upload', + 'Item Count', + 'Amount', + 'Status', + ], + 'align' => 'lllrrl', + 'fields' => [ 'batchnum', + sub { + my $_date = shift->download; + $_date ? time2str("%a %b %e %T %Y", $_date) : '' + }, + sub { + my $_date = shift->upload; + $_date ? time2str("%a %b %e %T %Y", $_date) : '' + }, + sub { + my $st = "SELECT COUNT(*) from cust_pay_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 { + my $st = "SELECT SUM(amount) from cust_pay_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}; + }, + ], + 'links' => [ [ "${p}search/cust_pay_batch.cgi?batchnum=", 'batchnum',], + ], + ) + +%> + + diff --git a/httemplate/search/pay_batch.html b/httemplate/search/pay_batch.html new file mode 100644 index 000000000..a966f68f5 --- /dev/null +++ b/httemplate/search/pay_batch.html @@ -0,0 +1,27 @@ +<% include('/elements/header.html', 'Batch criteria' ) %> + +<FORM ACTION="pay_batch.cgi" METHOD="GET"> +<INPUT TYPE="hidden" NAME="magic" VALUE="_date"> + +<TABLE> + <% include( '/elements/tr-input-beginning_ending.html' ) %> + <TR> + <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="open" VALUE="1" CHECKED></TD> + <TD>Show open batches</TD> + </TR> + <TR> + <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="intransit" VALUE="1" CHECKED></TD> + <TD>Show in-transit batches</TD> + </TR> + <TR> + <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="resolved" VALUE="1" CHECKED></TD> + <TD>Show resolved batches</TD> + </TR> +</TABLE> + +<BR> +<INPUT TYPE="submit" VALUE="Get Batches"> + +</FORM> + +<% include('/elements/footer.html') %> diff --git a/httemplate/search/report_cust_pay_batch.html b/httemplate/search/report_cust_pay_batch.html new file mode 100644 index 000000000..0dc4bc1b7 --- /dev/null +++ b/httemplate/search/report_cust_pay_batch.html @@ -0,0 +1,37 @@ +<% include('/elements/header.html', 'Batch payment report' ) %> + +<FORM ACTION="cust_pay_batch.cgi" METHOD="GET"> + +<TABLE> + + <TR> + <TD ALIGN="right">Payments of type: </TD> + <TD> + <SELECT NAME="payby"> + <OPTION VALUE="">all</OPTION> + <OPTION VALUE="CARD">credit card</OPTION> + <OPTION VALUE="CHEK">electronic check / ACH</OPTION> + </SELECT> + </TD> + </TR> + + <% include( '/elements/tr-select-agent.html', + $cgi->param('agentnum'), + 'label' => 'for agent: ', + ) + %> + + <% include( '/elements/tr-input-beginning_ending.html' ) %> + + <TR> + <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="dcln" VALUE="1" CHECKED></TD> + <TD>Include approved items</TD> + </TR> +</TABLE> + +<BR> +<INPUT TYPE="submit" VALUE="Get Report"> + +</FORM> + +<% include('/elements/footer.html') %> |