[freeside-commits] branch 24899_agent_virt_attach_report created. 06f4ee7c977486d06aa1e638e0e2a4a29518a2c7

Justin DeVuyst justin at 420.am
Wed Feb 22 12:48:05 PST 2017


The branch, 24899_agent_virt_attach_report has been created
        at  06f4ee7c977486d06aa1e638e0e2a4a29518a2c7 (commit)

- Log -----------------------------------------------------------------
commit 06f4ee7c977486d06aa1e638e0e2a4a29518a2c7
Author: Justin DeVuyst <justin at devuyst.com>
Date:   Wed Feb 22 15:39:41 2017 -0500

    Agent virtualize the attachment report.  See RT#24899.

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>';

-----------------------------------------------------------------------




More information about the freeside-commits mailing list