X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_main.cgi;h=fa2b42db8034c0ba5438437092a5bcc64c71b121;hb=3efb80a017b146aae2247bb745855b7357f1c4cd;hp=8fbf6364cb9bf6a0fcdc12c67f8121dd2c867dd5;hpb=7cab86a7efe11b58590691d3b1d0b37b6a730c8e;p=freeside.git diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 8fbf6364c..fa2b42db8 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -5,6 +5,7 @@ % %my $conf = new FS::Conf; %my $maxrecords = $conf->config('maxsearchrecordsperpage'); +%my $large_pkg_size = $conf->config('cust_pkg-large_pkg_size') || 0; % %#my $cache; % @@ -83,6 +84,10 @@ % push @select, FS::TicketSystem->sql_num_customer_tickets. " as tickets"; % push @addl_headers, 'Tickets'; % push @addl_cols, 'tickets'; +% } elsif ( $query eq 'uspsunvalid' ) { +% $search{'country'} = 'US'; +% $sortby=\*custnum_sort; +% $orderby = "ORDER BY custnum"; % } else { % die "unknown browse field $query"; % } @@ -132,6 +137,10 @@ % $addl_qual .= ( $addl_qual ? ' AND ' : '' ). % $FS::CurrentUser::CurrentUser->agentnums_sql; % +% if ( $cgi->param('browse') && $cgi->param('browse') eq 'uspsunvalid' ) { +% $addl_qual .= ' AND ( length(zip) < 9 OR upper(address1) != address1 OR upper(city) != city ) '; +% } +% % if ( $addl_qual ) { % $qual .= ' AND ' if $qual; % $qual .= $addl_qual; @@ -204,7 +213,7 @@ % if ( $cgi->param('search_cust') ) { % $sortby = \*company_sort; % $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )"; -% push @cust_main, smart_search( 'search' => $cgi->param('search_cust'), +% push @cust_main, smart_search( 'search' => scalar($cgi->param('search_cust')), % 'no_fuzzy_on_exact' => 1, #pref? % ); % } @@ -364,16 +373,31 @@ % $cust_main->company, % ); % -% my(@lol_cust_svc); -% my($rowspan)=0;#scalar( @{$all_pkgs{$custnum}} ); -% foreach ( @{$all_pkgs{$custnum}} ) { -% #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } ); -% my @cust_svc = $_->cust_svc; -% push @lol_cust_svc, \@cust_svc; -% $rowspan += scalar(@cust_svc) || 1; +% my @all_cust_svc; +% my @pkg_rowspans; +% foreach my $cust_pkg ( @{$all_pkgs{$custnum}} ) { +% my %cust_svc_by_svcpart; +% foreach my $svc ( $cust_pkg->cust_svc ) { +% push @{ $cust_svc_by_svcpart{$svc->svcpart} ||= [] }, $svc; +% } +% push @all_cust_svc, \%cust_svc_by_svcpart; +% if ( !keys %cust_svc_by_svcpart ) { +% # no services +% push @pkg_rowspans, 1; +% } +% else { +% my $rows = 0; +% foreach (values %cust_svc_by_svcpart) { +% # summarizing takes two rows per svcpart, +% # full display takes one per cust_svc +% $rows += ( $large_pkg_size > 0 && $large_pkg_size <= scalar @$_ ) ? +% 2 : scalar @$_; +% } +% push @pkg_rowspans, $rows; +% } % } +% my $rowspan = List::Util::sum(@pkg_rowspans) || 1; % -% #my($rowspan) = scalar(@{$all_pkgs{$custnum}}); % my $view; % if ( defined $cgi->param('quickpay') && $cgi->param('quickpay') eq 'yes' ) { % $view = $p. 'edit/cust_pay.cgi?quickpay=yes;custnum='. $custnum; @@ -388,10 +412,10 @@ % my $statuscol = $cust_main->statuscolor; - ><% $cust_main->display_custnum %> - ><% ucfirst($status) %> - ><% "$last, $first" %> - ><% $pcompany %> + ><% $cust_main->display_custnum %> + ><% ucfirst($status) %> + ><% "$last, $first" %> + ><% $pcompany %> % % if ( defined dbdef->table('cust_main')->column('ship_last') ) { % my($ship_last,$ship_first,$ship_company)=( @@ -405,8 +429,8 @@ % - ><% "$ship_last, $ship_first" %> - ><% $pship_company %> + ><% "$ship_last, $ship_first" %> + ><% $pship_company %> % } % % foreach my $addl_col ( @addl_cols ) { @@ -414,7 +438,7 @@ % if ( @custom_priorities ) { - ALIGN=right> + ALIGN=right> % foreach my $priority ( @custom_priorities, '' ) { @@ -446,7 +470,7 @@ % } else { - % @@ -493,25 +517,55 @@ % : ';show=packages'; % my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment % my $pkgview = "${p}view/cust_main.cgi?custnum=$custnum$show;fragment=$frag#$frag"; -% my @cust_svc = @{shift @lol_cust_svc}; -% #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } ); -% my $rowspan = scalar(@cust_svc) || 1; -% -% print $n1, qq!!; -% -% my($n2)=''; -% foreach my $cust_svc ( @cust_svc ) { -% my($label, $value, $svcdb) = $cust_svc->label; -% my($svcnum) = $cust_svc->svcnum; -% my($sview) = $p.'view'; -% print $n2, -% qq! !. -% qq! !; -% $n2=""; -% } -% -% unless ( @cust_svc ) { -% print qq!!; +% # cust_svc stuff, built earlier +% my %cust_svc_by_svcpart = %{ shift @all_cust_svc }; +% my $pkg_rowspan = shift @pkg_rowspans; + + <% $n1 %> + +% my $n2 = ''; +% my $td = ' + <% $td %> + (view all <% $num_cust_svc %>) + + + <% $td %> + <% $td %><& /elements/search-cust_svc.html, + 'svcpart' => $svcpart, + 'pkgnum' => $pkgnum, + &> +% $n2=""; +% } +% else { # do not summarize +% foreach my $cust_svc ( @$these ) { + <% $n2 %> + <% $td %> + <% FS::UI::Web::svc_link($m, $cust_svc->part_svc, $cust_svc) %> + + <% $td %> + <% FS::UI::Web::svc_label_link($m, $cust_svc->part_svc, $cust_svc) %> + +% $n2 = ""; +% } # foreach $cust_svc +% } +% } # foreach $svcpart +% +% unless ( %cust_svc_by_svcpart ) { + % } % % #print qq!\n!;
ALIGN=right> + ALIGN=right> % } % % my $ahref = ''; @@ -474,7 +498,7 @@ % } else { - ALIGN=right> + ALIGN=right> <% $cust_main->get($addl_col) %> $pkg_comment!. FS::UI::Web::svc_link($m, $cust_svc->part_svc, $cust_svc) . qq!!. FS::UI::Web::svc_label_link($m, $cust_svc->part_svc, $cust_svc) . qq!
  + <% $pkg_comment %>'; +% +% foreach my $svcpart ( sort keys %cust_svc_by_svcpart ) { #sort order? +% my $these = $cust_svc_by_svcpart{$svcpart}; +% my $num_cust_svc = scalar @$these; # always at least 1 +% if ( $large_pkg_size > 0 && $num_cust_svc >= $large_pkg_size ) { + <% $n2 %> +% # summarize +% # link opens a new search for this pkgnum/svcnum combo +% my $href = $p.'search/cust_pkg_svc.html?svcpart='.$svcpart. +% ';pkgnum='.$pkgnum; + <% $td %> + <% $these->[0]->part_svc->svc %> +