<% small_custview($custnum, $conf->config('countrydefault')) %>
% }
-<FORM NAME="RefundForm" ACTION="<% $p1 %>process/cust_refund.cgi" METHOD=POST onSubmit="document.RefundForm.submit.disabled=true">
+<FORM NAME="RefundForm" ACTION="<% $p1 %>process/cust_refund.cgi" METHOD=POST onSubmit="document.RefundForm.submitButton.disabled=true">
<INPUT TYPE="hidden" NAME="popup" VALUE="<% $link %>">
<INPUT TYPE="hidden" NAME="refundnum" VALUE="">
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
% }
<BR>Payment
- <% ntable("#cccccc", 2) %>
+ <TABLE class="fsinnerbox">
<TR>
<TD ALIGN="right">Amount</TD><TD BGCOLOR="#ffffff">$<% $cust_pay->paid %></TD>
<BR>Refund
-<% ntable("#cccccc", 2) %>
+
+<TABLE class="fsinnerbox">
<TR>
<TD ALIGN="right">Date</TD>
<TD ALIGN="right">Check #</TD>
<TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD>
</TR>
+ </TABLE>
+% }
+% elsif ($payby eq 'CHEK' || $payby eq 'CARD') {
+%
+<SCRIPT TYPE="text/javascript">
+ function cust_payby_changed (what) {
+ var custpaybynum = what.options[what.selectedIndex].value
+ if ( custpaybynum == '' || custpaybynum == '0' ) {
+ //what.form.payinfo.disabled = false;
+ $('#cust_payby').slideDown();
+ } else {
+ //what.form.payinfo.value = '';
+ //what.form.payinfo.disabled = true;
+ $('#cust_payby').slideUp();
+ }
+ }
+</SCRIPT>
+% my @cust_payby = ();
+% if ( $payby eq 'CARD' ) {
+% @cust_payby = $cust_main->cust_payby('CARD','DCRD');
+% } elsif ( $payby eq 'CHEK' ) {
+% @cust_payby = $cust_main->cust_payby('CHEK','DCHK');
% } else {
+% die "unknown payby $payby";
+% }
+%
+% my $custpaybynum = length(scalar($cgi->param('custpaybynum')))
+% ? scalar($cgi->param('custpaybynum'))
+% : scalar(@cust_payby) && $cust_payby[0]->custpaybynum;
+
+% if ($cust_pay) {
+ <INPUT TYPE="hidden" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10>
+% }
+% else {
+ <& /elements/tr-select-cust_payby.html,
+ 'cust_payby' => \@cust_payby,
+ 'curr_value' => $custpaybynum,
+ 'onchange' => 'cust_payby_changed(this)',
+ &>
+% }
+
+% if ( $conf->exists("batch-enable")
+% || grep $payby eq $_, $conf->config('batch-enable_payby')
+% ) {
+% if ( grep $payby eq $_, $conf->config('realtime-disable_payby') ) {
+ <INPUT TYPE="hidden" NAME="batch" VALUE="1">
+% } else {
+ <TR>
+ <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="batch" VALUE="1" ID="batch" <% ($batchnum || $batch) ? 'checked' : '' %> ></TD>
+ <TH ALIGN="left"> <% mt('Add to current batch') |h %></TH>
+ </TR>
+% }
+% }
+
+ </TABLE>
+<P>
+
+% if ( !$cust_pay ) {
+<DIV ID="cust_payby"
+ <% $custpaybynum ? 'STYLE="display:none"'
+ : ''
+ %>
+>
+<TABLE class="fsinnerbox">
+
+ <& /elements/cust_payby_new.html,
+ 'cust_payby' => \@cust_payby,
+ 'curr_value' => $custpaybynum,
+ &>
+
+</TABLE>
+</DIV>
+% } # end if cust_pay
+
+% } else {
<INPUT TYPE="hidden" NAME="payinfo" VALUE="">
+ </TABLE>
% }
+<P>
+<TABLE class="fsinnerbox">
<& /elements/tr-select-reason.html,
'field' => 'reasonnum',
'reason_class' => 'F',
- 'control_button' => "document.getElementById('confirm_refund_button')",
+ 'control_button' => "confirm_refund_button",
'cgi' => $cgi,
&>
</TABLE>
<BR>
-<INPUT TYPE="submit" ID="confirm_refund_button" VALUE="<% mt('Post refund') |h %>" DISABLED>
+<INPUT TYPE="submit" NAME="submitButton" ID="confirm_refund_button" VALUE="<% mt('Post refund') |h %>" DISABLED>
</FORM>
my $payinfo = $cgi->param('payinfo');
my $reason = $cgi->param('reason');
my $link = $cgi->param('popup') ? 'popup' : '';
-
-my @rights = ();
-push @rights, 'Post refund' if $payby =~ /^(BILL|CASH|MCRD)$/;
-push @rights, 'Post check refund' if $payby eq 'BILL';
-push @rights, 'Post cash refund ' if $payby eq 'CASH';
-push @rights, 'Refund payment' if $payby =~ /^(CARD|CHEK)$/;
-push @rights, 'Refund credit card payment' if $payby eq 'CARD';
-push @rights, 'Refund Echeck payment' if $payby eq 'CHEK';
+my $batch = $cgi->param('batch');
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right(\@rights);
+ unless $FS::CurrentUser::CurrentUser->refund_access_right($payby);
-my( $paynum, $cust_pay ) = ( '', '' );
+my( $paynum, $cust_pay, $batchnum ) = ( '', '', '' );
if ( $cgi->param('paynum') =~ /^(\d+)$/ ) {
$paynum = $1;
$cust_pay = qsearchs('cust_pay', { paynum=>$paynum } )
or die "unknown payment # $paynum";
$refund ||= $cust_pay->unrefunded;
+ $batchnum = $cust_pay->batchnum;
if ( $custnum ) {
die "payment # $paynum is not for specified customer # $custnum"
unless $custnum == $cust_pay->custnum;
}
die "no custnum or paynum specified!" unless $custnum;
+my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } );
+die "unknown custnum $custnum" unless $cust_main;
+
my $_date = time;
my $p1 = popurl(1);