don't link to deleted attachments if there aren't any
authorIvan Kohler <ivan@freeside.biz>
Sun, 13 Nov 2016 17:21:59 +0000 (09:21 -0800)
committerIvan Kohler <ivan@freeside.biz>
Sun, 13 Nov 2016 17:21:59 +0000 (09:21 -0800)
httemplate/view/cust_main/notes.html

index 6250200..c02af38 100755 (executable)
 <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>