<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'),
}
}
-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 } );