<% 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 %>">
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 %> ) {
<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 %>
</TABLE>
<BR>
-<CENTER><INPUT TYPE="submit" VALUE="Apply"></CENTER>
+<CENTER><INPUT TYPE="submit" VALUE="Apply" NAME="submit" ID="submit" DISABLED></CENTER>
</FORM>
$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
$desc .= ' <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>';
}
$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
'<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>';
}