X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-cust_main-search.cgi;h=481bea264f5fc00fd70a486125fc4404378d26b5;hb=aaf8baf3662e16e9414de236a39f8801a8c41b01;hp=20707dab895e3b4caf4d7dad3b56bbc6257f432a;hpb=eaafe49123e402598d1e350c5654b7870073740d;p=freeside.git diff --git a/httemplate/misc/xmlhttp-cust_main-search.cgi b/httemplate/misc/xmlhttp-cust_main-search.cgi index 20707dab8..481bea264 100644 --- a/httemplate/misc/xmlhttp-cust_main-search.cgi +++ b/httemplate/misc/xmlhttp-cust_main-search.cgi @@ -1,24 +1,38 @@ % if ( $sub eq 'custnum_search' ) { % % my $custnum = $cgi->param('arg'); -% my $cust_main = qsearchs({ -% 'table' => 'cust_main', -% 'hashref' => { 'custnum' => $custnum }, -% 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, -% }); +% my $cust_main = ''; +% if ( $custnum =~ /^(\d+)$/ and $1 <= 2147483647 ) { +% $cust_main = qsearchs({ +% 'table' => 'cust_main', +% 'hashref' => { 'custnum' => $1 }, +% 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, +% }); +% } +% if ( ! $cust_main ) { +% $cust_main = qsearchs({ +% 'table' => 'cust_main', +% 'hashref' => { 'agent_custid' => $custnum }, +% 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, +% }); +% } % "<% $cust_main ? $cust_main->name : '' %>" % % } elsif ( $sub eq 'smart_search' ) { % % my $string = $cgi->param('arg'); -% my @cust_main = smart_search( 'search' => $string ); +% my @cust_main = smart_search( 'search' => $string, +% 'no_fuzzy_on_exact' => 1, #pref? +% ); % my $return = [ map [ $_->custnum, $_->name ], @cust_main ]; % <% objToJson($return) %> % } <%init> +my $conf = new FS::Conf; + my $sub = $cgi->param('sub');