% errorpage(emt("No matching customers found!"));
% } # errorpage quits, so we don't need an 'else' below
-<& /elements/header.html, emt("Customer Search Results"), '' &>
+<& /elements/header.html, mt("Customer Search Results"), '' &>
% $total ||= scalar(@cust_main);
<% mt("[_1] matching customers found",$total) |h %>
% my $refcustlabel = "$referral_custnum: " .
% ( $cust_main->company || $cust_main->last. ', '. $cust_main->first );
referrals of
- <A HREF="<% popurl(2)."view/cust_main.cgi?$referral_custnum" %>"><% $refcustlabel %></A>
+ <A HREF="<% popurl(2)."view/cust_main.cgi?$referral_custnum" %>"><% $refcustlabel |h %></A>
<SELECT NAME="referral_depth" SIZE="1" onChange="changed(this)">';
% my $max = 8;
<TR>
<TH CLASS="grid" BGCOLOR="#cccccc"><% mt('#') |h %></TH>
<TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Status') |h %></TH>
- <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('(bill) name') |h %></TH>
- <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('company') |h %></TH>
-
-%if ( defined dbdef->table('cust_main')->column('ship_last') ) {
- <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('(service) name') |h %></TH>
- <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('company') |h %></TH>
-%}
+ <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Name') |h %></TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Company') |h %></TH>
%foreach my $addl_header ( @addl_headers ) {
<TH CLASS="grid" BGCOLOR="#cccccc"><% $addl_header %></TH>
% $cust_main->company,
% );
%
-% my(@lol_cust_svc);
-% my($rowspan)=0;#scalar( @{$all_pkgs{$custnum}} );
-% foreach ( @{$all_pkgs{$custnum}} ) {
-% 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;
+% my $rows = 0;
+% foreach my $part_svc ( $cust_pkg->part_svc ) {
+% my $svcpart = $part_svc->svcpart;
+% my $num_cust_svc = $cust_pkg->num_cust_svc($svcpart);
+% 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
+% $cust_svc_by_svcpart{$svcpart} =
+% [ 'summarize', $part_svc, $num_cust_svc ];
+% $rows += 2;
+% }
+% elsif ( $num_cust_svc ) {
+% $cust_svc_by_svcpart{$svcpart} = [ $cust_pkg->cust_svc($svcpart) ];
+% $rows += $num_cust_svc;
+% } #if summarize
+% } #foreach $part_svc
+% $rows ||= 1; # in case the package has no services
+% push @all_cust_svc, \%cust_svc_by_svcpart;
+% push @pkg_rowspans, $rows;
+% } #foreach $cust_pkg
+% my $rowspan = List::Util::sum(@pkg_rowspans) || 1;
%
% my $view;
% if ( defined $cgi->param('quickpay') && $cgi->param('quickpay') eq 'yes' ) {
% $view = $p. 'view/cust_main.cgi?'. $custnum;
% }
% my $pcompany = $company
-% ? qq!<A HREF="$view"><FONT SIZE=-1>$company</FONT></A>!
+% ? qq!<A HREF="$view"><FONT SIZE=-1>!. encode_entities($company). '</FONT></A>'
% : '<FONT SIZE=-1> </FONT>';
%
-% my $status = $cust_main->status;
-% my $statuscol = $cust_main->statuscolor;
+% my $status_label = $cust_main->status_label;
+% my $statuscolor = $cust_main->statuscolor;
<TR>
- <TD CLASS="grid" ALIGN="right" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>>
+ <TD CLASS="grid" ALIGN="right" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>>
<A HREF="<% $view %>"><FONT SIZE=-1><% $cust_main->display_custnum %></FONT></A>
</TD>
- <TD CLASS="grid" ALIGN="center" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>>
- <FONT SIZE="-1" COLOR="#<% $statuscol %>"><B><% ucfirst($status) %></B></FONT>
+ <TD CLASS="grid" ALIGN="center" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>>
+ <FONT SIZE="-1" COLOR="#<% $statuscolor %>"><B><% $status_label %></B></FONT>
</TD>
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>>
- <A HREF="<% $view %>"><FONT SIZE=-1><% "$last, $first" %></FONT></A>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>>
+ <A HREF="<% $view %>"><FONT SIZE=-1><% "$last, $first" |h %></FONT></A>
</TD>
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>>
<% $pcompany %>
</TD>
-% if ( defined dbdef->table('cust_main')->column('ship_last') ) {
-% my($ship_last,$ship_first,$ship_company)=(
-% $cust_main->ship_last || $cust_main->getfield('last'),
-% $cust_main->ship_last ? $cust_main->ship_first : $cust_main->first,
-% $cust_main->ship_last ? $cust_main->ship_company : $cust_main->company,
-% );
-% my $pship_company = $ship_company
-% ? qq!<A HREF="$view"><FONT SIZE=-1>$ship_company</FONT></A>!
-% : '<FONT SIZE=-1> </FONT>';
-%
-
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>>
- <A HREF="<% $view %>"><FONT SIZE=-1><% "$ship_last, $ship_first" %></FONT></A>
- </TD>
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>>
- <% $pship_company %></A>
- </TD>
-% }
-%
% foreach my $addl_col ( @addl_cols ) {
% if ( $addl_col eq 'tickets' ) {
% if ( @custom_priorities ) {
- <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right>
+ <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %> ALIGN=right>
<FONT SIZE=-1>
<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
% foreach my $priority ( @custom_priorities, '' ) {
<TH ALIGN=right STYLE="border-top: dashed 1px black">
<FONT SIZE=-1>
% } else {
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %> ALIGN=right>
<FONT SIZE=-1>
% }
% my $ahref = '';
</FONT></TD>
% } else {
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %> ALIGN=right><FONT SIZE=-1>
<% $cust_main->get($addl_col) %>
</FONT></TD>
% my $pkgnum = $_->pkgnum;
% my $part_pkg = $_->part_pkg;
%
-% my $pkg_comment = $part_pkg->pkg_comment(nopkgpart => 1);
+% my $pkg_comment = $part_pkg->pkg_comment( cust_pkg=>$_, nopkgpart=>1 );
% my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
% ? ''
% : ';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 $rowspan = scalar(@cust_svc) || 1;
+% # cust_svc stuff, built earlier
+% my %cust_svc_by_svcpart = %{ shift @all_cust_svc };
+% my $pkg_rowspan = shift @pkg_rowspans;
- <% $n1 %><TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN="<% $rowspan%>">
- <A HREF="<% $pkgview %>"><FONT SIZE=-1><% $pkg_comment %></FONT></A>
+ <% $n1 %><TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN="<% $pkg_rowspan%>">
+ <A HREF="<% $pkgview %>"><FONT SIZE=-1><% $pkg_comment |h %></FONT></A>
</TD>
% my $n2 = '';
-% foreach my $cust_svc ( @cust_svc ) {
-% my($label, $value, $svcdb) = $cust_svc->label;
-% my($svcnum) = $cust_svc->svcnum;
-% my($sview) = $p.'view';
- <% $n2 %>
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+% my $td = '<TD CLASS="grid" BGCOLOR="'.$bgcolor.'">';
+%
+% foreach my $svcpart ( sort keys %cust_svc_by_svcpart ) { #sort order?
+% my $these = $cust_svc_by_svcpart{$svcpart};
+% if ( $these->[0] eq 'summarize' ) {
+% my $part_svc = $these->[1];
+% my $num_cust_svc = $these->[2];
+ <% $n2 %>
+% # summarize
+% # link opens a new search for this pkgnum/svcpart combo
+% my $href = $p.'search/cust_pkg_svc.html?svcpart='.$svcpart.
+% ';pkgnum='.$pkgnum;
+ <% $td %>
+ <A HREF="<% $href %>"><% $part_svc->svc %></A>
+ </TD>
+ <% $td %>
+ <A HREF="<% $href %>"><B>(<% mt("view all [_1]", $num_cust_svc) |h %>)</B></A>
+ </TD>
+ </TR><TR>
+ <% $td %></TD>
+ <% $td %><& /elements/search-cust_svc.html,
+ 'svcpart' => $svcpart,
+ 'pkgnum' => $pkgnum,
+ 'svcdb' => $part_svc->svcdb,
+ &></TD>
+% $n2="</TR><TR>";
+% }
+% elsif ( scalar @$these ) { # do not summarize
+% foreach my $cust_svc ( @$these ) {
+ <% $n2 %>
+ <% $td %>
<% FS::UI::Web::svc_link($m, $cust_svc->part_svc, $cust_svc) %>
</TD>
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <% $td %>
<% FS::UI::Web::svc_label_link($m, $cust_svc->part_svc, $cust_svc) %>
</TD>
-% $n2="</TR><TR>";
-% }
+% $n2="</TR><TR>";
+% } #foreach $cust_svc
+% }
+% } # foreach $svcpart
%
-% unless ( @cust_svc ) {
+% unless ( %cust_svc_by_svcpart ) {
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>" COLSPAN=2> </TD>
% }
%
% }
%
% unless ( @{$all_pkgs{$custnum}} ) {
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" COLSPAN=3> </TD>!;
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" COLSPAN=3> </TD>
% }
%
</TR>
my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied"
- unless $curuser->access_right('List customers');
+ unless $curuser->access_right('List all customers');
my $conf = new FS::Conf;
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 $limit = '';
$limit .= "LIMIT $maxrecords" if $maxrecords;
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');
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'),
- 'no_fuzzy_on_exact' => 1, #pref?
- );
+ push @cust_main, smart_search(
+ 'search' => scalar($cgi->param('search_cust')),
+ '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
my($card)=$cgi->param('card');
$card =~ s/\D//g;
- $card =~ /^(\d{13,16})$/ or errorpage(emt("Illegal card number"));
+ $card =~ /^(\d{13,16}|\d{8,9})$/ or errorpage(emt("Illegal card number"));
my($payinfo)=$1;
[ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}),