optimize Reports->Customers->List Customers, RT#20173
[freeside.git] / httemplate / search / cust_main.cgi
index d2a797c..2e81a4a 100755 (executable)
 %    foreach my $cust_pkg ( @{$all_pkgs{$custnum}} ) {
 %      my %cust_svc_by_svcpart;
 %      my $rows = 0;
+%      local($FS::part_pkg::cache_enabled) = 1; #for $cust_pkg->part_svc
 %      foreach my $part_svc (
 %        $cust_pkg->part_svc( summarize_size=>$large_pkg_size )
 %      ) {
 %      my $part_pkg = $_->part_pkg;
 %
 %      my $pkg_comment = $part_pkg->pkg_comment( cust_pkg=>$_, nopkgpart=>1 );
-%      my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
+%      my $show = $default_customer_view =~ /^(jumbo|packages)$/
 %                   ? ''
 %                   : ';show=packages';
 %      my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment
@@ -319,6 +320,8 @@ my $maxrecords = $conf->config('maxsearchrecordsperpage');
 # summarize more than this many services of the same svcpart
 my $large_pkg_size = $conf->config('cust_pkg-large_pkg_size') || 0;
 
+my $default_customer_view = $curuser->default_customer_view;
+
 my $limit = '';
 $limit .= "LIMIT $maxrecords" if $maxrecords;
 
@@ -498,8 +501,13 @@ my $pkgs_method = $conf->exists('hidecancelledpackages')
                     : 'all_pkgs';
 
 #false laziness w/httemplate/view/cust_main/packages.html
-my $select = '*, setup_option.optionvalue AS _opt_setup_fee, '.
-                'recur_option.optionvalue AS _opt_recur_fee',
+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