[freeside-commits] branch FREESIDE_2_3_BRANCH updated. e47385088a470b799d2b39ae04e0ccf9e49ef094

Ivan ivan at 420.am
Wed Mar 7 22:25:59 PST 2012


The branch, FREESIDE_2_3_BRANCH has been updated
       via  e47385088a470b799d2b39ae04e0ccf9e49ef094 (commit)
      from  9447c8caea95ea4d8e595e0ab3624ba09cae3f0e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e47385088a470b799d2b39ae04e0ccf9e49ef094
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Mar 7 22:25:56 2012 -0800

    agent-virt package summary report, RT#16534

diff --git a/httemplate/search/cust_pkg_summary.cgi b/httemplate/search/cust_pkg_summary.cgi
index fc71c81..cea4cdc 100644
--- a/httemplate/search/cust_pkg_summary.cgi
+++ b/httemplate/search/cust_pkg_summary.cgi
@@ -21,8 +21,11 @@
   </TR>
 </TABLE>
 <%init>
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
 die "access denied"
-  unless $FS::CurrentUser::CurrentUser->access_right('List packages');
+  unless $curuser->access_right('List packages');
 
 my $title = 'Package Summary Report';
 my ($begin, $end) = FS::UI::Web::parse_beginning_ending($cgi);
@@ -61,7 +64,19 @@ if( !$begin ) {
   splice @head, 1, 1;
 }
 
-foreach my $part_pkg (qsearch('part_pkg', {} )) {
+my $agentnums_sql = $curuser->agentnums_sql(
+                      'null'       => 1,
+                      'table'      => 'part_pkg',
+                    );
+
+my $extra_sql = " WHERE $agentnums_sql";
+
+foreach my $part_pkg (qsearch({ 'table'     => 'part_pkg',
+                                'hashref'   => {},
+                                'extra_sql' => $extra_sql,
+                             })
+                     )
+{
   my @row = ();
   next if !$part_pkg->freq; # exclude one-time packages
   push @row, $part_pkg->pkg;
@@ -70,10 +85,15 @@ foreach my $part_pkg (qsearch('part_pkg', {} )) {
     if($cond) {
       my $result = qsearchs({ 
                             'table'     => 'h_cust_pkg',
+                            'addl_from' => $addl_from.
+                                           ' LEFT JOIN cust_main USING ( custnum )',
+
                             'hashref'   => {},
                             'select'    => 'count(*)',
-                            'addl_from' => $addl_from,
-                            'extra_sql' => 'WHERE pkgpart = '.$part_pkg->pkgpart.$cond,
+                            'extra_sql' => 'WHERE pkgpart = '.$part_pkg->pkgpart.$cond.
+                                           ' AND '. $curuser->agentnums_sql(
+                                                      'table' => 'cust_main',
+                                                    ),
                             });
       $row[$i] = $result->getfield('count');
       $totals[$i] += $row[$i];

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

Summary of changes:
 httemplate/search/cust_pkg_summary.cgi |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)




More information about the freeside-commits mailing list