1 <& /elements/header-cust_main.html, view=>'payment_history', cust_main=>$cust_main &>
3 <h2><% emt("Process [_1] payment",$type{$payby}) %></h2>
5 <FORM NAME="OneTrueForm" ACTION="process/payment.cgi" METHOD="POST" onSubmit="document.OneTrueForm.process.disabled=true">
6 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
7 <INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>">
8 <INPUT TYPE="hidden" NAME="payunique" VALUE="<% $payunique %>">
9 <INPUT TYPE="hidden" NAME="balance" VALUE="<% $balance %>">
11 <& /elements/init_overlib.html &>
13 <TABLE class="fsinnerbox">
15 <& /elements/tr-select-payment_options.html,
16 'cust_main' => $cust_main,
18 scalar($conf->config('manual_process-pkgpart', $cust_main->agentnum)),
19 'process-display' => scalar($conf->config('manual_process-display')),
20 'process-skip_first' => $conf->exists('manual_process-skip_first'),
21 'num_payments' => scalar($cust_main->cust_pay),
22 'surcharge_percentage' =>
24 ? scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum))
27 'surcharge_flatfee' =>
29 ? scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum))
34 % if ( $conf->exists('part_pkg-term_discounts') ) {
35 <& /elements/tr-select-discount_term.html,
36 'custnum' => $custnum,
37 'amount_id' => 'amount',
41 % my $disallow_no_auto_apply = 0;
42 % if ( $conf->exists("batch-enable")
43 % || grep $payby eq $_, $conf->config('batch-enable_payby')
46 % if ( grep $payby eq $_, $conf->config('realtime-disable_payby') ) {
47 % $disallow_no_auto_apply = 1;
49 <INPUT TYPE="hidden" NAME="batch" VALUE="1">
54 <TH ALIGN="right"> <% mt('Add to current batch') |h %></TH>
56 <INPUT TYPE="checkbox" NAME="batch" VALUE="1" ID="batch_checkbox" ONCHANGE="change_batch_checkbox()">
63 % unless ($disallow_no_auto_apply) {
64 % # false laziness with edit/cust_pay.cgi
66 <TR ID="apply_box_row">
67 <TH ALIGN="right"><% mt('Auto-apply to invoices') |h %></TH>
69 <SELECT NAME="apply" ID="apply_box">
70 <OPTION VALUE="yes" SELECTED><% mt('yes') |h %></OPTION>
71 <OPTION VALUE=""><% mt('not now') |h %></OPTION>
72 <OPTION VALUE="never"><% mt('never') |h %></OPTION>
77 % # this can go away if no_auto_apply handling gets added to batch payment processing
79 function change_batch_checkbox () {
80 if (document.getElementById('batch_checkbox').checked) {
81 document.getElementById('apply_box').disabled = true;
82 document.getElementById('apply_box_row').style.display = 'none';
84 document.getElementById('apply_box').disabled = false;
85 document.getElementById('apply_box_row').style.display = '';
92 <SCRIPT TYPE="text/javascript">
93 function cust_payby_changed (what) {
94 var custpaybynum = what.options[what.selectedIndex].value
95 if ( custpaybynum == '' || custpaybynum == '0' ) {
96 //what.form.payinfo.disabled = false;
97 $('#cust_payby').slideDown();
99 //what.form.payinfo.value = '';
100 //what.form.payinfo.disabled = true;
101 $('#cust_payby').slideUp();
105 function enableAmountField() {
106 document.getElementById('amount').disabled = false;
111 % #can't quite handle CARD/CHEK on the same page yet, but very close
112 % #does it make sense from a UI/usability perspective?
114 % my @cust_payby = ();
115 % if ( $payby eq 'CARD' ) {
116 % @cust_payby = $cust_main->cust_payby('CARD','DCRD');
117 % } elsif ( $payby eq 'CHEK' ) {
118 % @cust_payby = $cust_main->cust_payby('CHEK','DCHK');
120 % die "unknown payby $payby";
123 % my $custpaybynum = length(scalar($cgi->param('custpaybynum')))
124 % ? scalar($cgi->param('custpaybynum'))
125 % : scalar(@cust_payby) && $cust_payby[0]->custpaybynum;
127 <& /elements/tr-select-cust_payby.html,
128 'cust_payby' => \@cust_payby,
129 'curr_value' => $custpaybynum,
130 'onchange' => 'cust_payby_changed(this)',
136 <% $custpaybynum ? 'STYLE="display:none"'
140 <TABLE class="fsinnerbox">
142 <& /elements/cust_payby_new.html,
143 'cust_payby' => \@cust_payby,
144 'curr_value' => $custpaybynum,
151 <INPUT TYPE="submit" NAME="process" ID="process" VALUE="<% mt('Process payment') |h %>" disabled="disabled" onclick="enableAmountField()">
154 <SCRIPT TYPE="text/javascript">
156 $(document).ready(function (){
158 $('<% $validate_select_fields %>').change(validate);
159 $('<% $validate_input_fields %>').keyup(validate);
164 $('#amount').val() > 0 && (
165 ( $('#custpaybynum').val() > 0 ) ||
166 % if ($payby eq "CHEK") {
167 ( $('input[name=payinfo1]').val().length > 0 &&
168 $('input[name=payinfo2]').val().length > 0 &&
169 $('input[name=payname]').val().length > 0 &&
170 $('select[name=paytype]').val().length > 0
173 % elsif ($payby eq "CARD") {
174 ( $('input[name=payinfo]').val().length > 0 &&
175 $('input[name=paycvv]').val().length > 0 &&
176 $('input[name=payname]').val().length > 0 &&
177 $('#city').val().length > 0 &&
178 $('#city').val().length > 0 &&
179 $('#state').val().length > 0 &&
180 $('#country').val().length > 0
185 $("#process").prop("disabled", false);
188 $("#process").prop("disabled", true);
194 <& /elements/footer-cust_main.html &>
211 unless $FS::CurrentUser::CurrentUser->access_right('Process payment');
213 my %type = ( 'CARD' => 'credit card',
214 'CHEK' => 'electronic check (ACH)',
217 $cgi->param('payby') =~ /^(CARD|CHEK)$/
218 or die "unknown payby ". $cgi->param('payby');
221 my $validate_select_fields = "#payment_option, #invoice, #custpaybynum, ";
222 my $validate_input_fields = "#amount, input[name=payname], ";
223 if ($payby eq "CHEK") {
224 $validate_input_fields .= "input[name=payinfo1], input[name=payinfo2]";
225 $validate_select_fields .= "select[name=paytype] ";
227 elsif ($payby eq "CARD") {
228 $validate_input_fields .= "input[name=payinfo], input[name=paycvv], input[name=address1], #city, #zip";
229 $validate_select_fields .= "#state, #country ";
232 $cgi->param('custnum') =~ /^(\d+)$/
233 or die "illegal custnum ". $cgi->param('custnum');
236 my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } );
237 die "unknown custnum $custnum" unless $cust_main;
239 my $balance = $cust_main->balance;
243 my $conf = new FS::Conf;
245 my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32;