X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=inline;f=httemplate%2Felements%2Fcust_payby.html;h=6404bcb33d975635e4dc7c9e639db4d791c0ea44;hb=12aceb11a398b7b69bb494e8e26fa03afd088400;hp=20ad343115d1ece4a026bffb529bf31f93a42ca3;hpb=b68c4a4a92d9b03527f109235093fcc98b98dd2a;p=freeside.git
diff --git a/httemplate/elements/cust_payby.html b/httemplate/elements/cust_payby.html
index 20ad34311..6404bcb33 100644
--- a/httemplate/elements/cust_payby.html
+++ b/httemplate/elements/cust_payby.html
@@ -11,7 +11,8 @@
|
>
@@ -107,15 +116,17 @@
<% mt('Account type') |h %>
|
-
-% my( $account, $aba ) = split('@',
-% ( $cgi->param($name.'_payby') || $cust_payby->payby ) =~ /^(CHEK|DCHK)$/
-% ? $cgi->param($name.'_payinfo')
-% : $cust_payby->payinfo
-% );
-% my $branch = '';
-% ($branch,$aba) = split('\.',$aba)
-% if $echeck_country eq 'CA';
+
+% my ( $account, $aba, $branch ) = ( '', '', '' );
+% if ( $cgi->param($name.'_payby') =~ /^(CHEK|DCHK)$/ ) {
+% $account = $cgi->param($name.'_payinfo1');
+% $aba = $cgi->param($name.'_payinfo2');
+% $branch = $cgi->param($name.'_payinfo3');
+% } elsif ( $cust_payby->payby =~ /^(CHEK|DCHK)$/ ) {
+% ( $account, $aba ) = split('@', $cust_payby->payinfo);
+% ( $branch, $aba ) = split('\.',$aba)
+% if $echeck_country eq 'CA';
+% }
%
% #false laziness w/view/cust_main/billing.html and misc/payment.cgi
% my $routing_label = $echeck_country eq 'US' ? 'ABA/Routing #'
@@ -177,11 +188,11 @@
<& /elements/select-state.html,
'prefix' => $name. '_pay',
'empty' => emt('(choose)'),
- 'state' => $cgi->param($name.'_paystate')
- || $cust_payby->paystate,
+ 'state' => ( scalar($cgi->param($name.'_paystate'))
+ || $cust_payby->paystate ),
#was cust_main->country in 3.x, but this will do until/unlesss
# someone needs to track foreign bank states
- 'country' => scalar($conf->config('countrydefault')) || 'US',
+ 'country' => ( scalar($conf->config('countrydefault')) || 'US' ),
&>
<% mt('Bank state') |h %>
@@ -213,52 +224,59 @@
% }
-% unless ( $opt{'html_only'} ) {
+% unless ( $opt{'html_only'} || $payby_changed_init ) {
+% $payby_changed_init = 1;
% }
+<%once>
+my $payby_changed_init = 0;
+%once>
<%init>
my( %opt ) = @_;
@@ -287,9 +305,18 @@ if ( $curr_value ) {
} else {
$cust_payby = new FS::cust_payby {};
}
-my $sel_payby = $cust_payby->payby;
-$sel_payby = 'CARD' if $sel_payby eq 'DCRD' || $sel_payby eq '';
-$sel_payby = 'CHEK' if $sel_payby eq 'DCHK';
+my $sel_payby = $cgi->param($name.'_payby') || $cust_payby->payby;
+# convert DCRD to CARD + no weight, and the same for DCHK/CHEK
+if ($sel_payby eq 'DCRD') {
+ $sel_payby = 'CARD';
+ $cust_payby->weight('');
+} elsif ($sel_payby eq 'DCHK') {
+ $sel_payby = 'CHEK';
+ $cust_payby->weight('');
+} elsif (!$sel_payby) {
+ # default
+ $sel_payby = 'CARD';
+}
my @payby = FS::payby->cust_payby;
my %conf_payby = map { $_=>1 } $conf->config('payby');