1 % if ( $sub eq 'custnum_search' ) {
3 % my $custnum = $cgi->param('arg');
5 % if ( $custnum =~ /^(\d+)$/ and $1 <= 2147483647 ) {
6 % $cust_main = qsearchs({
7 % 'table' => 'cust_main',
8 % 'hashref' => { 'custnum' => $1 },
9 % 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
12 % if ( ! $cust_main ) {
13 % $cust_main = qsearchs({
14 % 'table' => 'cust_main',
15 % 'hashref' => { 'agent_custid' => $custnum },
16 % 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
20 "<% $cust_main ? $cust_main->name : '' %>"
22 % } elsif ( $sub eq 'smart_search' ) {
24 % my $string = $cgi->param('arg');
25 % my @cust_main = smart_search( 'search' => $string,
26 % 'no_fuzzy_on_exact' => 1, #pref?
28 % my $return = [ map [ $_->custnum, $_->name ], @cust_main ];
30 <% objToJson($return) %>
34 my $conf = new FS::Conf;
36 my $sub = $cgi->param('sub');