finish UI improvements wrt refunds: now you have to post a check or cash refund expli...
authorivan <ivan>
Sun, 5 Oct 2008 06:07:36 +0000 (06:07 +0000)
committerivan <ivan>
Sun, 5 Oct 2008 06:07:36 +0000 (06:07 +0000)
httemplate/edit/elements/ApplicationCommon.html
httemplate/view/cust_main/payment_history/credit.html
httemplate/view/cust_main/payment_history/payment.html

index 0e6c499..a485d37 100644 (file)
@@ -43,7 +43,7 @@ Examples:
 
 <% include('/elements/error.html') %>
 
-<FORM ACTION="<% $p1. $opt{'form_action'} %>" METHOD=POST>
+<FORM ACTION="<% $p1. $opt{'form_action'} %>" NAME="ApplicationForm" ID="ApplicationForm" METHOD=POST>
 
 <% $src_thing %> #<B><% $src_pkeyvalue %></B><BR>
 <INPUT TYPE="hidden" NAME="<% $src_pkey %>" VALUE="<% $src_pkeyvalue %>">
@@ -79,6 +79,13 @@ Examples:
 function changed(what) {
   dst = what.options[what.selectedIndex].value;
 
+  if ( dst == '' ) {
+    what.form.submit.disabled=true;
+    return true;
+  }
+
+  what.form.submit.disabled=false;
+
 % foreach my $dst ( @dst ) {
 
     if ( dst == <% $dst->$dst_pkey %> ) {
@@ -97,7 +104,7 @@ Apply to:
 <TR>
   <TD ALIGN="right"><% $dst_thing %>: </TD>
   <TD><SELECT NAME="<% $dst_pkey %>" SIZE=1 onChange="changed(this)">
-<OPTION VALUE="">
+<OPTION VALUE="">Select <% $dst_thing %>
 
 % foreach my $dst ( @dst ) { 
   <OPTION<% $dst->$dst_pkey eq $dst_pkeyvalue ? ' SELECTED' : '' %> VALUE="<% $dst->$dst_pkey %>">#<% $dst->$dst_pkey %> - <% time2str("%D", $dst->_date) %> - $<% $dst->$dst_unapplied %>
@@ -115,7 +122,7 @@ Apply to:
 </TABLE>
 
 <BR>
-<CENTER><INPUT TYPE="submit" VALUE="Apply"></CENTER>
+<CENTER><INPUT TYPE="submit" VALUE="Apply" NAME="submit" ID="submit" DISABLED></CENTER>
 
 </FORM>
 
index fd43c1a..2deb275 100644 (file)
@@ -16,25 +16,30 @@ if (    scalar(@cust_credit_bill)   == 0
   $pre = '<B><FONT COLOR="#FF0000">Unapplied ';
   $post = '</FONT></B>';
   if ( $curuser->access_right('Apply credit') ) {
-    $apply = ' ('. include( '/elements/popup_link.html',
-                              'label'    => 'apply',
-                              'action'   => "${p}edit/cust_credit_bill.cgi?".
-                                            $cust_credit->crednum,
-                              'actionlabel' => 'Apply credit',
-                              'width'    => 392,
-                              #default# 'height' => 336,
-                          ).
-              ')';
-    #XXX if there are any open refunds
-    $apply.= ' ('. include( '/elements/popup_link.html',
-                              'label'    => 'apply to refund',
-                              'action'   => "${p}edit/cust_credit_refund.cgi?".
-                                            $cust_credit->crednum,
-                              'actionlabel' => 'Apply credit to refund',
-                              'width'    => 392,
-                              #default# 'height' => 336,
-                          ).
-              ')';
+    if ( $cust_credit->cust_main->total_owed > 0 ) {
+      $apply = ' ('.
+               include( '/elements/popup_link.html',
+                          'label'    => 'apply',
+                          'action'   => "${p}edit/cust_credit_bill.cgi?".
+                                        $cust_credit->crednum,
+                          'actionlabel' => 'Apply credit',
+                          'width'    => 392,
+                          #default# 'height' => 336,
+                      ).
+                ')';
+    }
+    if ( $cust_credit->cust_main->total_unapplied_refunds > 0 ) {
+      $apply.= ' ('.
+               include( '/elements/popup_link.html',
+                          'label'    => 'apply to refund',
+                          'action'   => "${p}edit/cust_credit_refund.cgi?".
+                                        $cust_credit->crednum,
+                          'actionlabel' => 'Apply credit to refund',
+                          'width'    => 392,
+                          #default# 'height' => 336,
+                      ).
+               ')';
+    }
   }
 } elsif (    scalar(@cust_credit_bill)   == 1
           && scalar(@cust_credit_refund) == 0
@@ -70,25 +75,30 @@ if (    scalar(@cust_credit_bill)   == 0
     $desc .= '&nbsp;&nbsp;<B><FONT COLOR="#FF0000">$'.
              $cust_credit->credited. ' unapplied</FONT></B>';
     if ( $curuser->access_right('Apply credit') ) {
-      $apply = ' ('. include( '/elements/popup_link.html',
-                                'label'       => 'apply',
-                                'action'      => "${p}edit/cust_credit_bill.cgi?".
-                                                 $cust_credit->crednum,
-                                'actionlabel' => 'Apply credit',
-                                'width'       => 392,
-                                #default# 'height' => 336,
-                            ).
-               ')';
-      #XXX if there are any open refunds
-      $apply.= ' ('. include( '/elements/popup_link.html',
-                                'label'       => 'apply to refund',
-                                'action'      => "${p}edit/cust_credit_refund.cgi?".
-                                                 $cust_credit->crednum,
-                                'actionlabel' => 'Apply credit to refund',
-                                'width'       => 392,
-                                #default# 'height' => 336,
-                            ).
-               ')';
+      if ( $cust_credit->cust_main->total_owed > 0 ) {
+        $apply = ' ('.
+                 include( '/elements/popup_link.html',
+                            'label'       => 'apply',
+                            'action'      => "${p}edit/cust_credit_bill.cgi?".
+                                             $cust_credit->crednum,
+                            'actionlabel' => 'Apply credit',
+                            'width'       => 392,
+                            #default# 'height' => 336,
+                        ).
+                 ')';
+      }
+      if ( $cust_credit->cust_main->total_unapplied_refunds > 0 ) {
+        $apply.= ' ('.
+                 include( '/elements/popup_link.html',
+                            'label'       => 'apply to refund',
+                            'action'      => "${p}edit/cust_credit_refund.cgi?".
+                                             $cust_credit->crednum,
+                            'actionlabel' => 'Apply credit to refund',
+                            'width'       => 392,
+                            #default# 'height' => 336,
+                        ).
+                 ')';
+      }
     }
     $desc .= '<BR>';
   }
index b9a0694..346c0d0 100644 (file)
@@ -40,25 +40,30 @@ if (    scalar(@cust_bill_pay)   == 0
   $pre = '<B><FONT COLOR="#FF0000">Unapplied ';
   $post = '</FONT></B>';
   if ( $curuser->access_right('Apply payment') ) {
-    $apply = ' ('. include( '/elements/popup_link.html',
-                              'label'       => 'apply',
-                              'action'      => "${p}edit/cust_bill_pay.cgi?".
-                                               $cust_pay->paynum,
-                              'actionlabel' => 'Apply payment',
-                              'width'       => 392,
-                              #default# 'height' => 336,
-                          ).
-              ')';
-    #XXX if there are any open refunds
-    $apply.= ' ('. include( '/elements/popup_link.html',
-                              'label'       => 'apply to refund',
-                              'action'      => "${p}edit/cust_pay_refund.cgi?".
-                                               $cust_pay->paynum,
-                              'actionlabel' => 'Apply payment to refund',
-                              'width'       => 392,
-                              #default# 'height' => 336,
-                          ).
-              ')';
+    if ( $cust_pay->cust_main->total_owed > 0 ) {
+      $apply = ' ('.
+               include( '/elements/popup_link.html',
+                          'label'       => 'apply',
+                          'action'      => "${p}edit/cust_bill_pay.cgi?".
+                                           $cust_pay->paynum,
+                          'actionlabel' => 'Apply payment',
+                          'width'       => 392,
+                          #default# 'height' => 336,
+                      ).
+                ')';
+    }
+    if ( $cust_pay->cust_main->total_unapplied_refunds > 0 ) {
+      $apply.= ' ('.
+               include( '/elements/popup_link.html',
+                          'label'       => 'apply to refund',
+                          'action'      => "${p}edit/cust_pay_refund.cgi?".
+                                           $cust_pay->paynum,
+                          'actionlabel' => 'Apply payment to refund',
+                          'width'       => 392,
+                          #default# 'height' => 336,
+                      ).
+               ')';
+    }
   }
 } elsif (    scalar(@cust_bill_pay)   == 1
           && scalar(@cust_pay_refund) == 0
@@ -95,25 +100,30 @@ if (    scalar(@cust_bill_pay)   == 0
              '<B><FONT COLOR="#FF0000">$'.
              $cust_pay->unapplied. ' unapplied</FONT></B>';
     if ( $curuser->access_right('Apply payment') ) {
-      $apply = ' ('. include( '/elements/popup_link.html',
-                                'label'      => 'apply',
-                                'action'     => "${p}edit/cust_bill_pay.cgi?".
-                                                $cust_pay->paynum,
-                                'actionlabel' => 'Apply payment',
-                                'width'      => 392,
-                                #default# 'height' => 336,
-                           ).
-               ')';
-      #XXX if there are any open refunds
-      $apply.= ' ('. include( '/elements/popup_link.html',
-                                'label'      => 'apply to refund',
-                                'action'     => "${p}edit/cust_pay_refund.cgi?".
-                                                $cust_pay->paynum,
-                                'actionlabel' => 'Apply payment to refund',
-                                'width'      => 392,
-                                #default# 'height' => 336,
-                           ).
-               ')';
+      if ( $cust_pay->cust_main->total_owed > 0 ) {
+        $apply = ' ('.
+                 include( '/elements/popup_link.html',
+                            'label'      => 'apply',
+                            'action'     => "${p}edit/cust_bill_pay.cgi?".
+                                            $cust_pay->paynum,
+                            'actionlabel' => 'Apply payment',
+                            'width'      => 392,
+                            #default# 'height' => 336,
+                        ).
+                 ')';
+      }
+      if ( $cust_pay->cust_main->total_unapplied_refunds > 0 ) {
+        $apply.= ' ('.
+                 include( '/elements/popup_link.html',
+                            'label'      => 'apply to refund',
+                            'action'     => "${p}edit/cust_pay_refund.cgi?".
+                                            $cust_pay->paynum,
+                            'actionlabel' => 'Apply payment to refund',
+                            'width'      => 392,
+                            #default# 'height' => 336,
+                        ).
+                 ')';
+      }
     }
     $desc .= '<BR>';
   }