[freeside-commits] branch master updated. ef5eceda8446cb44a5c5e2ad0d8ff979b9eb7bd8

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


The branch, master has been updated
       via  ef5eceda8446cb44a5c5e2ad0d8ff979b9eb7bd8 (commit)
      from  1ad6427250c2a45d450bb5045e0dc4907c53b450 (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 ef5eceda8446cb44a5c5e2ad0d8ff979b9eb7bd8
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Jul 14 21:11:57 2012 -0700

    fix 477 report part V, RT#18503

diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 8297d22..aed99e5 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -3599,20 +3599,40 @@ 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 = 'cust_location.zip';
+
+    $select = "DISTINCT substr($zip,1,5) as zip";
+    $orderby = "ORDER BY substr($zip,1,5)";
+    $addl_from .= 'LEFT JOIN cust_location ON (
+                     cust_location.locationnum = COALESCE(
+                                                   cust_pkg.locationnum,
+                                                   cust_main.ship_locationnum,
+                                                   cust_main.bill_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 |   40 ++++++++++++++++++++++++++++++----------
 1 files changed, 30 insertions(+), 10 deletions(-)




More information about the freeside-commits mailing list