[freeside-commits] branch master updated. e4364530d5de0f2dc115d7a9441960e989bca757

Ivan ivan at 420.am
Fri Mar 4 16:56:33 PST 2016


The branch, master has been updated
       via  e4364530d5de0f2dc115d7a9441960e989bca757 (commit)
      from  900d4d72315d52f8838f397522e0cae238f38811 (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 e4364530d5de0f2dc115d7a9441960e989bca757
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Mar 4 16:56:33 2016 -0800

    improve search for one large customer, RT#39822

diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi
index 11cd3a3..96f5af9 100755
--- a/httemplate/search/cust_main.cgi
+++ b/httemplate/search/cust_main.cgi
@@ -4,6 +4,7 @@
 %  } else {
     <% $cgi->redirect(popurl(2). "view/cust_main.cgi?". $cust_main[0]->custnum) %>
 %  }
+%  $m->abort;
 %} elsif ( scalar(@cust_main) == 0 ) {
 %  errorpage(emt("No matching customers found!"));
 % } # errorpage quits, so we don't need an 'else' below
@@ -496,36 +497,34 @@ if ( $cgi->param('browse')
   @cust_main = grep { !$saw{$_->custnum}++ } @cust_main;
 }
 
-my $pkgs_method = $conf->exists('hidecancelledpackages')
-                    ? 'ncancelled_pkgs'
-                    : 'all_pkgs';
-
-#false laziness w/httemplate/view/cust_main/packages.html
-my $select = join(',',
-               'cust_pkg.*',
-               'part_pkg.*',
-               'setup_option.optionvalue AS _opt_setup_fee',
-               'recur_option.optionvalue AS _opt_recur_fee',
-             );
-
-my $addl_from = qq{
-    LEFT JOIN part_pkg USING ( pkgpart )
-    LEFT JOIN part_pkg_option AS setup_option
-      ON (     cust_pkg.pkgpart = setup_option.pkgpart
-           AND setup_option.optionname = 'setup_fee' )
-    LEFT JOIN part_pkg_option AS recur_option
-      ON (     cust_pkg.pkgpart = recur_option.pkgpart
-           AND recur_option.optionname = 'recur_fee' )
-};
-
-local($FS::cust_pkg::cache_enabled) = 1; #for $cust_pkg->part_pkg
-my %all_pkgs = map { $_->custnum =>
-                       [ $_->$pkgs_method({ select    => $select,
-                                            addl_from => $addl_from,
-                                         })
-                       ];
-                   }
-                 @cust_main;
+my %all_pkgs = ();
+if ( scalar(@cust_main) > 1 || $cgi->param('referral_custnum') ) {
+
+  my $pkgs_method = $conf->exists('hidecancelledpackages')
+                      ? 'ncancelled_pkgs'
+                      : 'all_pkgs';
+
+  #false laziness w/httemplate/view/cust_main/packages.html
+  my $select = join(',',
+                 'cust_pkg.*',
+                 'part_pkg.*',
+                 'setup_option.optionvalue AS _opt_setup_fee',
+                 'recur_option.optionvalue AS _opt_recur_fee',
+               );
+
+  my $addl_from = ' LEFT JOIN part_pkg USING ( pkgpart ) '.
+                  FS::part_pkg->join_options_sql;
+
+  local($FS::cust_pkg::cache_enabled) = 1; #for $cust_pkg->part_pkg
+  %all_pkgs = map { $_->custnum =>
+                      [ $_->$pkgs_method({ select    => $select,
+                                           addl_from => $addl_from,
+                                        })
+                      ];
+                  }
+                @cust_main;
+
+}
 
 sub last_sort {
   lc($a->getfield('last')) cmp lc($b->getfield('last'))

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

Summary of changes:
 httemplate/search/cust_main.cgi |   59 +++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 30 deletions(-)




More information about the freeside-commits mailing list