diff options
author | Justin DeVuyst <justin@devuyst.com> | 2017-02-22 15:39:41 -0500 |
---|---|---|
committer | Justin DeVuyst <justin@devuyst.com> | 2017-02-22 15:39:41 -0500 |
commit | 06f4ee7c977486d06aa1e638e0e2a4a29518a2c7 (patch) | |
tree | b0763a2637bc717188bc55494a78a56aaee31f3e | |
parent | 5f2c3a88d92952d13a5231a230e332e1a8e94016 (diff) |
Agent virtualize the attachment report. See RT#24899.24899_agent_virt_attach_report
-rwxr-xr-x | httemplate/browse/cust_attachment.html | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/httemplate/browse/cust_attachment.html b/httemplate/browse/cust_attachment.html index f81ec1b..268bd4a 100755 --- a/httemplate/browse/cust_attachment.html +++ b/httemplate/browse/cust_attachment.html @@ -11,10 +11,7 @@ <INPUT TYPE="hidden" NAME="orderby" VALUE="$orderby"> <INPUT TYPE="hidden" NAME="show_deleted" VALUE="$disabled">! , - '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,15 +87,25 @@ else { } } -my $hashref = $disabled ? - { disabled => { op => '>', value => 0 } } : - { disabled => '' }; - -my $count_query = 'SELECT COUNT(*) FROM cust_attachment WHERE '. ($disabled ? - 'disabled > 0' : 'disabled IS NULL'); - my $orderby = $cgi->param('orderby') || 'custnum'; +my ( $query, $count_query, ) = do { + my @agentnums = $curuser->agentnums; + { + 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 agentnum IN (' . join( ',', @agentnums, 'NULL', ) . ')', + }, + 'SELECT COUNT(*) FROM cust_attachment' + . ' JOIN cust_main USING (custnum)' + . ' WHERE agentnum in (' . join( ',', @agentnums, 'NULL', ) . ')' + . ( $disabled ? 'and disabled > 0' : '' ); +}; + my $sub_cust = sub { my $c = qsearchs('cust_main', { custnum => shift->custnum } ); return $c ? encode_entities($c->name) : '<FONT COLOR="red"><B>(not found)</B></FONT>'; |