X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_main.cgi;h=aca2558851abf6c97be5be5346800a614d3cef28;hb=ba56e454035928299203d26ab5f57698ac80657e;hp=2c09c692cd03e1a000bf27d7a4721106116fc43d;hpb=f3e0ac2b009c4edd5692cb587ff709dac2223ebe;p=freeside.git diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 2c09c692c..aca255885 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -119,9 +119,12 @@ % foreach my $cust_pkg ( @{$all_pkgs{$custnum}} ) { % my %cust_svc_by_svcpart; % my $rows = 0; -% foreach my $part_svc ( $cust_pkg->part_svc ) { +% 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 $svcpart = $part_svc->svcpart; -% my $num_cust_svc = $cust_pkg->num_cust_svc($svcpart); +% my $num_cust_svc = $part_svc->num_cust_svc; % if ( $large_pkg_size > 0 and $num_cust_svc >= $large_pkg_size ) { % # don't retrieve the cust_svc records, just stash the % # part_svc and num_cust_svc for later @@ -130,7 +133,7 @@ % $rows += 2; % } % elsif ( $num_cust_svc ) { -% $cust_svc_by_svcpart{$svcpart} = [ $cust_pkg->cust_svc($svcpart) ]; +% $cust_svc_by_svcpart{$svcpart} = $part_svc->cust_pkg_svc; % $rows += $num_cust_svc; % } #if summarize % } #foreach $part_svc @@ -234,7 +237,7 @@ % my $part_pkg = $_->part_pkg; % % my $pkg_comment = $part_pkg->pkg_comment(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 @@ -317,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; @@ -341,7 +346,12 @@ if ( $cgi->param('browse') if ( $query eq 'custnum' ) { if ( $conf->exists('cust_main-default_agent_custid') ) { $sortby=\*display_custnum_sort; - $orderby = "ORDER BY CASE WHEN agent_custid IS NOT NULL AND agent_custid != '' THEN CAST(agent_custid AS BIGINT) ELSE custnum END"; + $orderby = "ORDER BY CASE WHEN agent_custid IS NOT NULL + AND agent_custid != '' + AND agent_custid ". regexp_sql. " '^[0-9]+\$' + THEN CAST(agent_custid AS BIGINT) + ELSE custnum + END"; } else { $sortby=\*custnum_sort; $orderby = "ORDER BY custnum"; @@ -393,6 +403,7 @@ if ( $cgi->param('browse') push @qual, FS::cust_main->cancel_sql if $cgi->param('cancelled'); push @qual, FS::cust_main->prospect_sql if $cgi->param('prospect'); + push @qual, FS::cust_main->ordered_sql if $cgi->param('ordered'); push @qual, FS::cust_main->active_sql if $cgi->param('active'); push @qual, FS::cust_main->inactive_sql if $cgi->param('inactive'); push @qual, FS::cust_main->susp_sql if $cgi->param('suspended'); @@ -470,11 +481,13 @@ if ( $cgi->param('browse') $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )"; push @cust_main, smart_search( 'search' => scalar($cgi->param('search_cust')), - 'no_fuzzy_on_exact' => ! $curuser->option('enable_fuzzy_on_exact'), + 'no_fuzzy_on_exact' => ! ( $curuser->option('enable_fuzzy_on_exact') + || $conf->exists('enable_fuzzy_on_exact') + ), ); } - @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main + @cust_main = grep { $_->num_ncancelled_pkgs || ! $_->num_pkgs } @cust_main if ! $cgi->param('cancelled') && ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me @@ -486,12 +499,35 @@ if ( $cgi->param('browse') @cust_main = grep { !$saw{$_->custnum}++ } @cust_main; } -my %all_pkgs; -if ( $conf->exists('hidecancelledpackages' ) ) { - %all_pkgs = map { $_->custnum => [ $_->ncancelled_pkgs ] } @cust_main; -} else { - %all_pkgs = map { $_->custnum => [ $_->all_pkgs ] } @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' ) +}; + +my %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'))