X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_main.cgi;h=93f960f5c8bd5d96f18e2ad1802b1cb1ea1a4357;hb=9b05a3660eabd3215bdebf9429eb490b41570436;hp=1ddafae0b4df92391811ab133a87c0ffdf8798e8;hpb=f144c3a14169d99fd93f265da690d9ce38dbae68;p=freeside.git
diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi
index 1ddafae0b..93f960f5c 100755
--- a/httemplate/search/cust_main.cgi
+++ b/httemplate/search/cust_main.cgi
@@ -1,5 +1,7 @@
+%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');
@@ -62,8 +64,13 @@
% 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)";
@@ -263,7 +270,7 @@
% $cgi->param('offset', 0);
% print qq!( hide!;
% }
-% print ' cancelled customers )';
+% print ' canceled customers )';
% }
%
% if ( $cgi->param('referral_custnum') ) {
@@ -379,7 +386,7 @@
% my $statuscol = $cust_main->statuscolor;
- ><% $custnum %> |
+ ><% $cust_main->display_custnum %> |
><% ucfirst($status) %> |
><% "$last, $first" %> |
><% $pcompany %> |
@@ -478,14 +485,17 @@
%# 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!$pkg - $comment | !;
+% print $n1, qq!$pkg_comment | !;
%
% my($n2)='';
% foreach my $cust_svc ( @cust_svc ) {
@@ -538,6 +548,10 @@
% || 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');
%}
@@ -620,7 +634,7 @@
% }
%
% 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'}) {
@@ -667,7 +681,7 @@
% }
%
% 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'}) {