% my $notecount = scalar($cust_main->notes(0));
% if ( ! $conf->exists('cust_main-disable_notes') || $notecount) {
-% unless ( $view eq 'notes' && $cust_main->comments !~ /[^\s\n\r]/ ) {
-<P>
- <A NAME="cust_main_note"><FONT SIZE="+2"><% mt('Notes') |h %></FONT></A>
-</P>
-
-% }
-
-<BR>
-
% # actually display notes
<& notes/notes.html, 'cust_main' => $cust_main &>
<BR>
<A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
($view ? ";show=$view" : '') . '#notes'
%>"><I>(<% mt('Show active attachments') |h %>)</I></A>
-% } elsif($curuser->access_right('View deleted attachments')) {
+% } elsif ( $curuser->access_right('View deleted attachments')
+% && FS::Record->scalar_sql(
+% 'SELECT 1 FROM cust_attachment WHERE custnum = ? '.
+% ' AND disabled IS NOT NULL AND disabled > 0 LIMIT 1',
+% $custnum )
+% )
+% {
<A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
($view ? ";show=$view" : '') . ';show_deleted=1#notes'
%>"><I>(<% mt('Show deleted attachments') |h %>)</I></A>