X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_main.cgi;h=8fbf6364cb9bf6a0fcdc12c67f8121dd2c867dd5;hb=636dd1f25af52d35efe7a323a5765ff5adeadf83;hp=d66d1617202d0a21a7486af77ac13517a330fa6a;hpb=d11f7c132bb3f235980ecc9a98617fcb853f08f3;p=freeside.git diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index d66d16172..8fbf6364c 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)"; @@ -87,10 +94,10 @@ % if ( $cgi->param('otaker_on') ) { % die "access denied" % unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); -% $cgi->param('otaker') =~ /^(\w{1,32})$/ or eidiot "Illegal otaker\n"; +% $cgi->param('otaker') =~ /^(\w{1,32})$/ or errorpage("Illegal otaker"); % $search{otaker} = $1; % } elsif ( $cgi->param('agentnum_on') ) { -% $cgi->param('agentnum') =~ /^(\d+)$/ or eidiot "Illegal agentnum\n"; +% $cgi->param('agentnum') =~ /^(\d+)$/ or errorpage("Illegal agentnum"); % $search{agentnum} = $1; %# } else { %# die "unknown query..."; @@ -197,7 +204,9 @@ % 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 @@ -232,7 +241,7 @@ % -% eidiot "No matching customers found!\n"; +% errorpage("No matching customers found!"); %} else { % @@ -263,12 +272,12 @@ % $cgi->param('offset', 0); % print qq!( hide!; % } -% print ' cancelled customers )'; +% print ' canceled customers )'; % } % % if ( $cgi->param('referral_custnum') ) { % $cgi->param('referral_custnum') =~ /^(\d+)$/ -% or eidiot "Illegal referral_custnum\n"; +% or errorpage("Illegal referral_custnum"); % my $referral_custnum = $1; % my $cust_main = qsearchs('cust_main', { custnum => $referral_custnum } ); % print '
'. @@ -288,7 +297,7 @@ % print '