diff options
author | Mark Wells <mark@freeside.biz> | 2012-07-13 10:56:10 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2012-07-13 10:56:10 -0700 |
commit | 0ad946f751d3a953c8a41eea1d30ad362ba38ace (patch) | |
tree | 6780a5e8eaee29e65750cd19c090555062b84c22 /httemplate | |
parent | 26004f55ce70242d07fc8de51e24439e783e9e49 (diff) |
one-way check batches, #17623
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/edit/payment_gateway.html | 7 | ||||
-rw-r--r-- | httemplate/search/elements/cust_pay_batch_top.html | 2 | ||||
-rwxr-xr-x | httemplate/search/elements/cust_pay_or_refund.html | 9 | ||||
-rwxr-xr-x | httemplate/search/pay_batch.cgi | 92 |
4 files changed, 84 insertions, 26 deletions
diff --git a/httemplate/edit/payment_gateway.html b/httemplate/edit/payment_gateway.html index 2840df35b..e5897b035 100644 --- a/httemplate/edit/payment_gateway.html +++ b/httemplate/edit/payment_gateway.html @@ -19,8 +19,7 @@ <SCRIPT TYPE="text/javascript"> -% my $json = JSON->new->canonical; - var modulesForNamespace = <% $json->encode(\%modules_for_namespace) %>; + var modulesForNamespace = <% to_json(\%modules_for_namespace, {canonical=>1}) %>; function changeNamespace(what) { var ns = what.value; var select_module = document.getElementById('gateway_module'); @@ -68,7 +67,6 @@ my %modules = ( 'OpenECHO' => 'Business::OnlinePayment', 'PayConnect' => 'Business::OnlinePayment', 'PayflowPro' => 'Business::OnlinePayment', - 'Paymentech' => 'Business::BatchPayment', 'PaymenTech' => 'Business::OnlinePayment', 'PaymentsGateway' => 'Business::OnlinePayment', 'PayPal' => 'Business::OnlinePayment', @@ -90,6 +88,9 @@ my %modules = ( 'VirtualNet' => 'Business::OnlinePayment', 'WesternACH' => 'Business::OnlinePayment', 'WorldPay' => 'Business::OnlinePayment', + + 'KeyBank' => 'Business::BatchPayment', + 'Paymentech' => 'Business::BatchPayment', ); my %modules_for_namespace; diff --git a/httemplate/search/elements/cust_pay_batch_top.html b/httemplate/search/elements/cust_pay_batch_top.html index 005b76182..739e65b50 100644 --- a/httemplate/search/elements/cust_pay_batch_top.html +++ b/httemplate/search/elements/cust_pay_batch_top.html @@ -103,7 +103,7 @@ Batch is <% $statustext{$status} %><BR> % } </%def> <%shared> -my $show_gateways = FS::payment_gateway->count("gateway_namespace = 'Business::BatchPayment'"); +my $show_gateways = FS::payment_gateway->count("gateway_namespace = 'Business::BatchPayment' AND disabled IS NULL"); </%shared> <%init> my %opt = @_; diff --git a/httemplate/search/elements/cust_pay_or_refund.html b/httemplate/search/elements/cust_pay_or_refund.html index dc3cb2a99..c60411107 100755 --- a/httemplate/search/elements/cust_pay_or_refund.html +++ b/httemplate/search/elements/cust_pay_or_refund.html @@ -357,6 +357,15 @@ if ( $cgi->param('magic') ) { $orderby = "LOWER(company || ' ' || last || ' ' || first )"; + } elsif ( $cgi->param('magic') eq 'batchnum' ) { + + $cgi->param('batchnum') =~ /^(\d+)$/ + or die "illegal batchnum: ".$cgi->param('batchnum'); + + push @search, "batchnum = $1"; + + $orderby = "LOWER(company || ' ' || last || ' ' || first )"; + } else { die "unknown search magic: ". $cgi->param('magic'); } diff --git a/httemplate/search/pay_batch.cgi b/httemplate/search/pay_batch.cgi index 05415f36e..aeaa012f4 100755 --- a/httemplate/search/pay_batch.cgi +++ b/httemplate/search/pay_batch.cgi @@ -14,12 +14,13 @@ 'Type', 'First Download', 'Last Upload', - 'Items', - 'Unresolved', - 'Amount', + '', # requests + '', # req amt + '', # payments + '', # pay amt 'Status', ], - 'align' => 'rcllrrc', + 'align' => 'rcllrrrrc', 'fields' => [ 'batchnum', sub { FS::payby->shortname(shift->payby); @@ -47,33 +48,44 @@ } }, sub { - FS::cust_pay_batch->count( - 'batchnum = '.$_[0]->batchnum - ) + my $c = FS::cust_pay_batch->count('batchnum = '.$_[0]->batchnum); + $c ? "$c requested" : '' }, sub { - FS::cust_pay_batch->count( - 'status is null and batchnum = '. - $_[0]->batchnum - ) - }, - 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"; + or die dbh->errstr. "doing $st"; $sth->execute - or die "Error executing \"$st\": ". $sth->errstr; - $sth->fetchrow_arrayref->[0]; - }, + or die "Error executing \"$st\": ". $sth->errstr; + my $total = $sth->fetchrow_arrayref->[0]; + $total ? $money_char.sprintf('%.2f',$total) : ''; + }, + sub { + my $c = FS::cust_pay->count('batchnum = '.$_[0]->batchnum); + $c ? "$c paid" : '' + }, + sub { + my $st = "SELECT SUM(paid) from cust_pay WHERE batchnum=" . shift->batchnum; + my $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]; + $total ? $money_char.sprintf('%.2f',$total) : ''; + }, sub { $statusmap{shift->status}; }, ], 'links' => [ - $link, + '', '', - sub { shift->status eq 'O' ? $link : '' }, - sub { shift->status eq 'I' ? $link : '' }, + sub { shift->status eq 'O' ? $cpb_link : '' }, + sub { shift->status eq 'I' ? $cpb_link : '' }, + $cpb_link, + $cpb_link, + $pay_link, + $pay_link, ], 'size' => [ '', @@ -88,9 +100,42 @@ sub { shift->status eq 'I' ? "b" : '' }, ], 'html_init' => $html_init, + 'html_foot' => include('.upload_incoming'), ) - %> +<%def .upload_incoming> +% if ( FS::payment_gateway->count("gateway_namespace = 'Business::BatchPayment' AND disabled IS NULL") > 0 ) { +<& /elements/form-file_upload.html, + name => 'FileUpload', + action => $p.'misc/upload-batch.cgi', + num_files => 1, + fields => [ 'gatewaynum' ], + message => 'Incoming batch uploaded.', +&> +<BR> +<BR> +Upload incoming batch from gateway +<& /elements/select-table.html, + table => 'payment_gateway', + field => 'gatewaynum', + name_col => 'label', + value_col => 'gatewaynum', + order_by => 'ORDER BY gatewaynum', + empty_label => ' ', + hashref => + { 'gateway_namespace' => 'Business::BatchPayment', + 'disabled' => '' }, +&> +<BR> +<& '/elements/file-upload.html', + field => 'file', + label => 'Filename', + no_table => 1, +&> +<INPUT TYPE="submit" VALUE="Upload"> +</FORM> +% } +</%def> <%init> die "access denied" @@ -134,11 +179,14 @@ push @where, my $extra_sql = scalar(@where) ? 'WHERE ' . join(' AND ', @where) : ''; -my $link = [ "${p}search/cust_pay_batch.cgi?dcln=1;batchnum=", 'batchnum' ]; +my $cpb_link = [ "${p}search/cust_pay_batch.cgi?dcln=1;batchnum=", 'batchnum' ]; +my $pay_link = [ "${p}search/cust_pay.html?magic=batchnum;batchnum=", 'batchnum' ]; my $resolved = $cgi->param('resolved') || 0; $cgi->param('resolved' => !$resolved); my $html_init = '<A HREF="' . $cgi->self_url . '"><I>'. ($resolved ? 'Hide' : 'Show') . ' resolved batches</I></A><BR>'; +my $money_char = FS::Conf->new->config('money_char') || '$'; + </%init> |