From b68c4a4a92d9b03527f109235093fcc98b98dd2a Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Wed, 11 Feb 2015 11:56:28 -0800 Subject: [PATCH] multiple payment options, RT#23741 --- httemplate/elements/cust_payby.html | 309 ++++++++++++++++++++++++++++++++++++ 1 file changed, 309 insertions(+) create mode 100644 httemplate/elements/cust_payby.html diff --git a/httemplate/elements/cust_payby.html b/httemplate/elements/cust_payby.html new file mode 100644 index 000000000..20ad34311 --- /dev/null +++ b/httemplate/elements/cust_payby.html @@ -0,0 +1,309 @@ +% unless ( $opt{'js_only'} ) { + + + + + + +% ### +% # select +% ### + + + +% ### +% # card info +% ### + +% my $card_display = $sel_payby eq 'CARD' ? '' : 'STYLE="display:none"'; + + + + + + + + + +% ### +% # chek info +% ### + +% my $chek_display = $sel_payby eq 'CHEK' ? '' : 'STYLE="display:none"'; + + + +% 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'; +% +% #false laziness w/view/cust_main/billing.html and misc/payment.cgi +% my $routing_label = $echeck_country eq 'US' ? 'ABA/Routing #' +% : 'Routing #'; +% my $routing_size = $echeck_country eq 'CA' ? 4 : 10; +% my $routing_maxlength = $echeck_country eq 'CA' ? 3 : 9; +% my $bankname_size = $echeck_country eq 'CA' ? 13 : 20; + + + + + +% if ( $echeck_country eq 'CA' ) { + +% } + + + +% if ( $conf->exists('show_bankstate') ) { + +% } + +% ### +% # auto (maybe this should be first...) +% ### + +% #some fun javascript to enforce a single value for each weight + + + + +
+
+ <% mt('Type') |h %> +
> + +
<% mt('Card number') |h %> +
> + <& /elements/select-month_year.html, + 'prefix' => $name. '_paydate', + 'selected_date' => ( + ( $cgi->param($name.'_payby') || $cust_payby->payby ) =~ /^(CARD|DCRD)$/ + ? ( $cgi->param($name.'_paydate_month') + ? $cgi->param($name.'_paydate_month'). '-1-'. + $cgi->param($name.'_paydate_year') + : $cust_payby->paydate + ) + : '' + ), + 'onhhange' => $onchange, + &> +
Expiration date +
> + +
<% mt('CVV2') |h %> (<% mt('help') |h %>) +
> + +
<% mt('Exact name on card') |h %> +
> + +
<% mt('Account type') |h %> +
> + +
<% mt('Account #') |h %> (<% mt('help') |h %>) +
> + +
<% mt($routing_label) |h %> +
> + +
<% mt('Branch #') |h %> +
> + +
<% mt('Bank name') |h %> +
> + <& /elements/select-state.html, + 'prefix' => $name. '_pay', + 'empty' => emt('(choose)'), + 'state' => $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', + &> +
<% mt('Bank state') |h %> +
+ +
+ <% mt('Auto-charge') |h %> +
+ +% } +% unless ( $opt{'html_only'} ) { + +% } +<%init> + +my( %opt ) = @_; + +my $conf = new FS::Conf; + +my $echeck_country = $conf->config('echeck-country'); + +my $name = $opt{'element_name'} || $opt{'field'} || 'custpaybynum'; +my $id = $opt{'id'} || 'custpaybynum'; + +my $curr_value = $opt{'curr_value'} || $opt{'value'}; + +my $onchange = ''; +if ( $opt{'onchange'} ) { + $onchange = $opt{'onchange'}; + $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/; + $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange + #callbacks should act the same + #$onchange = 'onChange="'. $onchange. '"'; +} + +my $cust_payby; +if ( $curr_value ) { + $cust_payby = qsearchs('cust_payby', { 'custpaybynum' => $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 @payby = FS::payby->cust_payby; +my %conf_payby = map { $_=>1 } $conf->config('payby'); +@payby = grep $conf_payby{$_}, @payby if keys %conf_payby; +@payby = grep $_ !~ /^(DCRD|DCHK)$/, @payby; + +my %weight = ( + 1 => 'Primary', + 2 => 'Secondary', + 3 => 'Tertiary', + 4 => 'Fourth', + 5 => 'Fifth', + 6 => 'Sixth', + 7 => 'Seventh', +); + + -- 2.11.0