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 'custnum' => $cust_main->custnum,
19 scalar($conf->config('manual_process-pkgpart', $cust_main->agentnum)),
20 'process-display' => scalar($conf->config('manual_process-display')),
21 'process-skip_first' => $conf->exists('manual_process-skip_first'),
22 'num_payments' => scalar($cust_main->cust_pay),
23 'surcharge_percentage' =>
25 ? scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum))
28 'surcharge_flatfee' =>
30 ? scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum))
35 % if ( $conf->exists('part_pkg-term_discounts') ) {
36 <& /elements/tr-select-discount_term.html,
37 'custnum' => $custnum,
38 'amount_id' => 'amount',
42 % my $disallow_no_auto_apply = 0;
43 % if ( $conf->exists("batch-enable")
44 % || grep $payby eq $_, $conf->config('batch-enable_payby')
47 % if ( grep $payby eq $_, $conf->config('realtime-disable_payby') ) {
48 % $disallow_no_auto_apply = 1;
50 <INPUT TYPE="hidden" NAME="batch" VALUE="1">
55 <TH ALIGN="right"> <% mt('Add to current batch') |h %></TH>
57 <INPUT TYPE="checkbox" NAME="batch" VALUE="1" ID="batch_checkbox" ONCHANGE="change_batch_checkbox()">
64 % unless ($disallow_no_auto_apply) {
65 % # false laziness with edit/cust_pay.cgi
67 <TR ID="apply_box_row">
68 <TH ALIGN="right"><% mt('Auto-apply to invoices') |h %></TH>
70 <SELECT NAME="apply" ID="apply_box">
71 <OPTION VALUE="yes" SELECTED><% mt('yes') |h %></OPTION>
72 <OPTION VALUE=""><% mt('not now') |h %></OPTION>
73 <OPTION VALUE="never"><% mt('never') |h %></OPTION>
78 % # this can go away if no_auto_apply handling gets added to batch payment processing
80 function change_batch_checkbox () {
81 if (document.getElementById('batch_checkbox').checked) {
82 document.getElementById('apply_box').disabled = true;
83 document.getElementById('apply_box_row').style.display = 'none';
85 document.getElementById('apply_box').disabled = false;
86 document.getElementById('apply_box_row').style.display = '';
93 <SCRIPT TYPE="text/javascript">
94 function cust_payby_changed (what) {
95 var custpaybynum = what.options[what.selectedIndex].value
96 if ( custpaybynum == '' || custpaybynum == '0' ) {
97 //what.form.payinfo.disabled = false;
98 $('#cust_payby').slideDown();
100 //what.form.payinfo.value = '';
101 //what.form.payinfo.disabled = true;
102 $('#cust_payby').slideUp();
107 % #can't quite handle CARD/CHEK on the same page yet, but very close
108 % #does it make sense from a UI/usability perspective?
110 % my @cust_payby = ();
111 % if ( $payby eq 'CARD' ) {
112 % @cust_payby = $cust_main->cust_payby('CARD','DCRD');
113 % } elsif ( $payby eq 'CHEK' ) {
114 % @cust_payby = $cust_main->cust_payby('CHEK','DCHK');
116 % die "unknown payby $payby";
119 % my $custpaybynum = length(scalar($cgi->param('custpaybynum')))
120 % ? scalar($cgi->param('custpaybynum'))
121 % : scalar(@cust_payby) && $cust_payby[0]->custpaybynum;
123 <& /elements/tr-select-cust_payby.html,
124 'cust_payby' => \@cust_payby,
125 'curr_value' => $custpaybynum,
126 'onchange' => 'cust_payby_changed(this)',
132 <% $custpaybynum ? 'STYLE="display:none"'
136 <TABLE class="fsinnerbox">
138 <& /elements/cust_payby_new.html,
139 'cust_payby' => \@cust_payby,
140 'curr_value' => $custpaybynum,
147 <INPUT TYPE="submit" NAME="process" VALUE="<% mt('Process payment') |h %>">
150 <& /elements/footer-cust_main.html &>
167 unless $FS::CurrentUser::CurrentUser->access_right('Process payment');
169 my %type = ( 'CARD' => 'credit card',
170 'CHEK' => 'electronic check (ACH)',
173 $cgi->param('payby') =~ /^(CARD|CHEK)$/
174 or die "unknown payby ". $cgi->param('payby');
177 $cgi->param('custnum') =~ /^(\d+)$/
178 or die "illegal custnum ". $cgi->param('custnum');
181 my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } );
182 die "unknown custnum $custnum" unless $cust_main;
184 my $balance = $cust_main->balance;
188 my $conf = new FS::Conf;
191 if ( $balance > 0 ) {
192 # when configured to do so, amount will only auto-fill with balance
193 # if balance represents a single invoice
195 unless $conf->exists('manual_process-single_invoice_amount')
196 && ($cust_main->open_cust_bill != 1);
199 my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32;