+if ($unapplied > 0) {
+ if ( $opt{'Apply payment'} ) {
+ if ( $opt{total_owed} > 0 ) {
+ $apply = ' ('.
+ include( '/elements/popup_link.html',
+ 'label' => emt('apply'),
+ 'action' => "${p}edit/cust_bill_pay.cgi?".
+ $cust_pay->paynum,
+ 'actionlabel' => emt('Apply payment'),
+ %cust_bill_pay_width,
+ %cust_bill_pay_height,
+ ).
+ ')';
+ }
+ if ( $opt{total_unapplied_refunds} > 0 ) {
+ $apply.= ' ('.
+ include( '/elements/popup_link.html',
+ 'label' => emt('apply refund'),
+ 'style' => 'white-space: nowrap',
+ 'action' => "${p}edit/cust_pay_refund.cgi?".
+ $cust_pay->paynum,
+ 'actionlabel' => emt('Apply payment to refund'),
+ 'width' => 392,
+ ).
+ ')';
+ }
+ $apply .= ' (auto‑apply: '
+ . ($cust_pay->no_auto_apply ? 'no' : 'yes')
+ . ' | '
+ . include( '/elements/popup_link.html',
+ 'label' => emt($cust_pay->no_auto_apply ? 'yes' : 'no'),
+ 'action' => "${p}edit/process/cust_pay-no_auto_apply.cgi?paynum="
+ . $cust_pay->paynum
+ . '&no_auto_apply='
+ . ($cust_pay->no_auto_apply ? '' : 'Y'),
+ 'actionlabel' => emt('Toggle Auto-Apply'),
+ 'width' => 392,
+ 'height' => 200,
+ )
+ . ')';
+ } else { # end if $opt('Apply payment')
+ $apply .= ' (no auto-apply)' if $cust_pay->no_auto_apply;
+ }
+} # end if $unapplied > 0
+