stray closing /TABLE in the no-ticket case
[freeside.git] / httemplate / edit / cust_refund.cgi
index 59417b4..32da454 100755 (executable)
@@ -10,7 +10,7 @@
     <% 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 %>">
     </TD>
   </TR>
 % } 
-
-%
-%  #false laziness w/FS/FS/cust_main::realtime_refund_bop
-%  if ( $cust_pay->paybatch =~ /^(\w+):(\w+)(:(\w+))?$/ ) {
-%    my ( $processor, $auth, $order_number ) = ( $1, $2, $4 );
-%  
-
-
+% if ( $cust_pay->processor ) {
     <TR>
-      <TD ALIGN="right">Processor</TD><TD BGCOLOR="#ffffff"><% $processor %></TD>
+      <TD ALIGN="right">Processor</TD>
+      <TD BGCOLOR="#ffffff"><% $cust_pay->processor %></TD>
     </TR>
-% if ( length($auth) ) { 
+% if ( length($cust_pay->auth) ) { 
 
       <TR>
-        <TD ALIGN="right">Authorization</TD><TD BGCOLOR="#ffffff"><% $auth %></TD>
+        <TD ALIGN="right">Authorization</TD>
+        <TD BGCOLOR="#ffffff"><% $cust_pay->auth %></TD>
       </TR>
 % } 
-% if ( length($order_number) ) { 
+% if ( length($cust_pay->order_number) ) { 
 
       <TR>
-        <TD ALIGN="right">Order number</TD><TD BGCOLOR="#ffffff"><% $order_number %></TD>
+        <TD ALIGN="right">Order number</TD>
+        <TD BGCOLOR="#ffffff"><% $cust_pay->order_number %></TD>
       </TR>
 % } 
-% } 
+% } # if ($cust_pay->processor)
 
   </TABLE>
-% } 
+% }  #if $cust_pay
 
 
 <BR>Refund
@@ -98,7 +94,7 @@
 
   <TR>
     <TD ALIGN="right">Amount</TD>
-    <TD BGCOLOR="#ffffff">$<INPUT TYPE="text" NAME="refund" VALUE="<% $refund %>" SIZE=8 MAXLENGTH=8> by <B><% FS::payby->payname($payby) %></B></TD>
+    <TD BGCOLOR="#ffffff">$<INPUT TYPE="text" NAME="refund" VALUE="<% $refund %>" SIZE=8 MAXLENGTH=9> by <B><% FS::payby->payname($payby) %></B></TD>
   </TR>
 
 % if ( $payby eq 'BILL' ) { 
     <INPUT TYPE="hidden" NAME="payinfo" VALUE="">
 % }
 
-  <TR>
-    <TD ALIGN="right">Reason</TD>
-    <TD BGCOLOR="#ffffff"><INPUT TYPE="text" NAME="reason" VALUE="<% $reason %>"></TD>
-  </TR>
+<& /elements/tr-select-reason.html,
+              'field'          => 'reasonnum',
+              'reason_class'   => 'F',
+              'control_button' => "confirm_refund_button",
+              'cgi'            => $cgi,
+&>
+
 </TABLE>
 
 <BR>
-<INPUT TYPE="submit" NAME="submit" VALUE="Post refund">
+<INPUT TYPE="submit" NAME="submitButton" ID="confirm_refund_button" VALUE="<% mt('Post refund') |h %>" DISABLED>
 
 </FORM>
 
 
 <%init>
 
-die "access denied"
-  unless $FS::CurrentUser::CurrentUser->access_right('Refund payment');
-
 my $conf = new FS::Conf;
 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
 
@@ -143,6 +139,9 @@ my $payinfo = $cgi->param('payinfo');
 my $reason  = $cgi->param('reason');
 my $link    = $cgi->param('popup') ? 'popup' : '';
 
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->refund_access_right($payby);
+
 my( $paynum, $cust_pay ) = ( '', '' );
 if ( $cgi->param('paynum') =~ /^(\d+)$/ ) {
   $paynum = $1;