+%my $curuser = $FS::CurrentUser::CurrentUser;
+%
%die "access denied"
-% unless $FS::CurrentUser::CurrentUser->access_right('List customers');
+% unless $curuser->access_right('List customers');
%
%my $conf = new FS::Conf;
%my $maxrecords = $conf->config('maxsearchrecordsperpage');
% if ( $cgi->param('browse') ) {
% my $query = $cgi->param('browse');
% if ( $query eq 'custnum' ) {
-% $sortby=\*custnum_sort;
-% $orderby = "ORDER BY 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";
+% } else {
+% $sortby=\*custnum_sort;
+% $orderby = "ORDER BY custnum";
+% }
% } elsif ( $query eq 'last' ) {
% $sortby=\*last_sort;
% $orderby = "ORDER BY LOWER(last || ' ' || first)";
% 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' => $cgi->param('search_cust'),
+% 'no_fuzzy_on_exact' => 1, #pref?
+% );
% }
%
% @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main
% $cgi->param('offset', 0);
% print qq!( <a href="!. $cgi->self_url. qq!">hide!;
% }
-% print ' cancelled customers</a> )';
+% print ' canceled customers</a> )';
% }
%
% if ( $cgi->param('referral_custnum') ) {
% my $statuscol = $cust_main->statuscolor;
<TR>
- <TD CLASS="grid" ALIGN="right" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% $custnum %></FONT></A></TD>
+ <TD CLASS="grid" ALIGN="right" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><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>
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% "$last, $first" %></FONT></A></TD>
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><% $pcompany %></TD>
%# my $part_pkg = qsearchs( 'part_pkg', { pkgpart => $_->pkgpart } );
% my $part_pkg = $_->part_pkg;
%
-% my $pkg = $part_pkg->pkg;
-% my $comment = $part_pkg->comment;
-% my $pkgview = "${p}view/cust_main.cgi?$custnum#cust_pkg$pkgnum";
+% my $pkg_comment = $part_pkg->pkg_comment(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(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } );
% my $rowspan = scalar(@cust_svc) || 1;
%
-% print $n1, qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ROWSPAN=$rowspan><A HREF="$pkgview"><FONT SIZE=-1>$pkg - $comment</FONT></A></TD>!;
+% print $n1, qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ROWSPAN=$rowspan><A HREF="$pkgview"><FONT SIZE=-1>$pkg_comment</FONT></A></TD>!;
%
% my($n2)='';
% foreach my $cust_svc ( @cust_svc ) {
% || lc($a->first) cmp lc($b->first);;
%}
%
+%sub display_custnum_sort {
+% $a->display_custnum <=> $b->display_custnum;
+%}
+%
%sub custnum_sort {
% $a->getfield('custnum') <=> $b->getfield('custnum');
%}
% }
%
% if ( $last_type{'Fuzzy'} || $last_type{'All'} ) {
-% push @cust_main, FS::cust_main->fuzzy_search( { 'last' => $last } );
+% push @cust_main, FS::cust_main::Search->fuzzy_search( { 'last' => $last } );
% }
%
% #if ($last_type{'Sound-alike'}) {
% }
%
% if ( $company_type{'Fuzzy'} || $company_type{'All'} ) {
-% push @cust_main, FS::cust_main->fuzzy_search( { 'company' => $company } );
+% push @cust_main, FS::cust_main::Search->fuzzy_search( { 'company' => $company } );
% }
%
% if ($company_type{'Sound-alike'}) {