RT# 83082 - fixed so CC refunds cant go to batch
[freeside.git] / httemplate / edit / cust_refund.cgi
index f3dec98..009ce73 100755 (executable)
     <TD ALIGN="right">Date</TD><TD BGCOLOR="#ffffff"><% time2str($date_format, $cust_pay->_date) %></TD>
   </TR>
 
+% if ( $cust_payby ) {
   <TR>
-    <TD ALIGN="right">Method</TD><TD BGCOLOR="#ffffff"><% $payby %> # <% $paymask %></TD>
+    <TD ALIGN="right">Method</TD><TD BGCOLOR="#ffffff">
+      <% $payby %> # <% $paymask %>
+      <INPUT TYPE="hidden" NAME="custpaybynum" VALUE="<% $cust_payby->custpaybynum %>">
+    </TD>
   </TR>
+% }
 
 % unless ( $paydate || $cust_pay->payby ne 'CARD' ) {  # possibly other reasons: i.e. card has since expired
   <TR>
 %                      ? scalar($cgi->param('custpaybynum'))
 %                      : scalar(@cust_payby) && $cust_payby[0]->custpaybynum;
 
-% if ($cust_pay) {
-  <INPUT TYPE="hidden" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10>
-% }
-% else {
+% if ( !$cust_payby ) {
   <& /elements/tr-select-cust_payby.html,
      'cust_payby' => \@cust_payby,
      'curr_value' => $custpaybynum,
   &>
 % }
 
-% if ( $conf->exists("batch-enable")
+% if ($payby eq "CARD" || $payby eq "DCRD") {
+          <INPUT TYPE="hidden" NAME="batch" VALUE="">
+% }
+% elsif ( $conf->exists("batch-enable")
 %      || grep $payby eq $_, $conf->config('batch-enable_payby')
 % ) {
 %     if ( grep $payby eq $_, $conf->config('realtime-disable_payby') ) {
     </TABLE>
 <P>
 
-%   if ( !$cust_pay ) {
+%   if ( !$cust_payby ) {
 <DIV ID="cust_payby"
   <% $custpaybynum ? 'STYLE="display:none"'
                    : ''
 
 </TABLE>
 </DIV>
-%   } # end if cust_pay
+%   } # end if cust_payby
 
 %  } else {
     <INPUT TYPE="hidden" NAME="payinfo" VALUE="">
@@ -221,7 +226,7 @@ my $batch   = $cgi->param('batch');
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->refund_access_right($payby);
 
-my( $paynum, $cust_pay, $batchnum ) = ( '', '', '' );
+my( $paynum, $cust_pay, $batchnum, $cust_payby ) = ( '', '', '', '' );
 if ( $cgi->param('paynum') =~ /^(\d+)$/ ) {
   $paynum = $1;
   $cust_pay = qsearchs('cust_pay', { paynum=>$paynum } )
@@ -233,7 +238,13 @@ if ( $cgi->param('paynum') =~ /^(\d+)$/ ) {
       unless $custnum == $cust_pay->custnum;
   } else {
     $custnum = $cust_pay->custnum;
+    $cgi->param(-name=>"custnum", -value=>$custnum) unless $cgi->param("custnum");
   }
+  # get custpayby
+  $cust_payby = qsearchs(
+    'cust_payby', { paymask => $cust_pay->paymask, custnum => $custnum }
+  );
+
 }
 die "no custnum or paynum specified!" unless $custnum;