From 70723170e55a4dbdcf69a227da79ec51e4f4c285 Mon Sep 17 00:00:00 2001 From: Justin DeVuyst Date: Fri, 3 Mar 2017 19:23:15 -0500 Subject: [PATCH] Agent virtualize the attachment report. See RT#24899. --- httemplate/browse/cust_attachment.html | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/httemplate/browse/cust_attachment.html b/httemplate/browse/cust_attachment.html index f81ec1b6b..bc9597f24 100755 --- a/httemplate/browse/cust_attachment.html +++ b/httemplate/browse/cust_attachment.html @@ -11,10 +11,7 @@ ! , - 'query' => { 'table' => 'cust_attachment', - 'hashref' => $hashref, - 'order_by' => 'ORDER BY '.$orderby, - }, + 'query' => $query, 'count_query' => $count_query, 'header' => [ selflink('#',orderby => 'attachnum'), selflink('Customer',orderby => 'custnum'), @@ -90,14 +87,20 @@ 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 } : undef, }, + 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 } ); -- 2.11.0