[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 262b110b9cb124f62acec0f3cbd23826d6140f4b

Ivan ivan at 420.am
Sat Jul 14 21:12:24 PDT 2012


The branch, FREESIDE_2_3_BRANCH has been updated
       via  262b110b9cb124f62acec0f3cbd23826d6140f4b (commit)
      from  067e40e7a339956badfde459412477659b963c69 (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 262b110b9cb124f62acec0f3cbd23826d6140f4b
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Jul 14 21:12:02 2012 -0700

    fix 477 report part V, RT#18503

diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 650fc1e..10472fc 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -3491,20 +3491,34 @@ sub search {
                   'LEFT JOIN part_pkg  USING ( pkgpart  ) '.
                   'LEFT JOIN pkg_class ON ( part_pkg.classnum = pkg_class.classnum ) ';
 
-  my $count_query = "SELECT COUNT(*) FROM cust_pkg $addl_from $extra_sql";
+  my $select;
+  my $count_query;
+  if ( $params->{'select_zip5'} ) {
+    my $zip = 'COALESCE(cust_location.zip, cust_main.ship_zip, cust_main.zip)';
+
+    $select = "DISTINCT substr($zip,1,5) as zip";
+    $orderby = "ORDER BY substr($zip,1,5)";
+    $addl_from .= 'LEFT JOIN cust_location ON ( locationnum )';
+    $count_query = "SELECT COUNT( DISTINCT substr($zip,1,5) )";
+  } else {
+    $select = join(', ',
+                         'cust_pkg.*',
+                         ( map "part_pkg.$_", qw( pkg freq ) ),
+                         'pkg_class.classname',
+                         'cust_main.custnum AS cust_main_custnum',
+                         FS::UI::Web::cust_sql_fields(
+                           $params->{'cust_fields'}
+                         ),
+                  );
+    $count_query = 'SELECT COUNT(*)';
+  }
+
+  $count_query .= " FROM cust_pkg $addl_from $extra_sql";
 
   my $sql_query = {
     'table'       => 'cust_pkg',
     'hashref'     => {},
-    'select'      => join(', ',
-                                'cust_pkg.*',
-                                ( map "part_pkg.$_", qw( pkg freq ) ),
-                                'pkg_class.classname',
-                                'cust_main.custnum AS cust_main_custnum',
-                                FS::UI::Web::cust_sql_fields(
-                                  $params->{'cust_fields'}
-                                ),
-                     ),
+    'select'      => $select,
     'extra_sql'   => $extra_sql,
     'order_by'    => $orderby,
     'addl_from'   => $addl_from,

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

Summary of changes:
 FS/FS/cust_pkg.pm |   34 ++++++++++++++++++++++++----------
 1 files changed, 24 insertions(+), 10 deletions(-)




More information about the freeside-commits mailing list