X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_main.cgi;h=658069b08eb4915099e8f0d5b6d53115f64d959c;hb=3a02c437eadd9a39f7e56056ca987a4846650209;hp=d66d1617202d0a21a7486af77ac13517a330fa6a;hpb=9509e5bfb7f9331303153cac24d7bfecbe2ea9f1;p=freeside.git diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index d66d16172..658069b08 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..."; @@ -232,7 +239,7 @@ % -% eidiot "No matching customers found!\n"; +% errorpage("No matching customers found!"); %} else { % @@ -268,7 +275,7 @@ % % 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 +295,7 @@ % print '