X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Fcust_attachment.html;h=7330c05a4b5a852d9d5adbad7405a0122ccd04dd;hb=5027e0e807b38364fc10c992ea50a2ad7d934986;hp=0fdc745a2cb21843a28b6e5ce96708cff022bf79;hpb=fc195fd7a0a2ca670cfdd62ef646436b58795c21;p=freeside.git
diff --git a/httemplate/browse/cust_attachment.html b/httemplate/browse/cust_attachment.html
index 0fdc745a2..7330c05a4 100755
--- a/httemplate/browse/cust_attachment.html
+++ b/httemplate/browse/cust_attachment.html
@@ -11,10 +11,7 @@
!
,
- 'query' => { 'table' => 'cust_attachment',
- 'hashref' => $hashref,
- 'extra_sql' => 'ORDER BY '.$orderby,
- },
+ 'query' => $query,
'count_query' => $count_query,
'header' => [ selflink('#',orderby => 'attachnum'),
selflink('Customer',orderby => 'custnum'),
@@ -62,6 +59,8 @@
<%init>
my $curuser = $FS::CurrentUser::CurrentUser;
+die "access denied" if !$curuser->access_right('View attachments')
+ or !$curuser->access_right('Browse attachments');
my $conf = new FS::Conf;
@@ -88,18 +87,24 @@ else {
}
}
-my $hashref = $disabled ?
- { disabled => { op => '>', value => 0 } } :
- { disabled => '' };
+my $orderby = $cgi->param('orderby') || 'custnum';
-my $count_query = 'SELECT COUNT(*) FROM cust_attachment WHERE '. ($disabled ?
- 'disabled > 0' : 'disabled IS NULL');
+my $query = {
+ table => 'cust_attachment',
+ hashref => { disabled => $disabled ? { op => '>', value => 0 } : '', },
+ order_by => "ORDER BY $orderby",
+ addl_from => 'JOIN cust_main USING (custnum)',
+ extra_sql => ' AND ' . $curuser->agentnums_sql,
+};
-my $orderby = $cgi->param('orderby') || 'custnum';
+my $count_query = 'SELECT COUNT(*) FROM cust_attachment'
+ . ' JOIN cust_main USING (custnum)'
+ . ' WHERE ' . $curuser->agentnums_sql
+ . ' AND disabled ' . ( $disabled ? '> 0' : 'IS NULL' );
my $sub_cust = sub {
my $c = qsearchs('cust_main', { custnum => shift->custnum } );
- return $c ? $c->name : '(not found)';
+ return $c ? encode_entities($c->name) : '(not found)';
};
my $sub_date = sub {