1 % if ( $sub eq 'custnum_search' ) {
2 % my $custnum = $cgi->param('arg');
4 % if ( $custnum =~ /^(\d+)$/ ) {
5 % $return = findbycustnum($1,0);
6 % $return = findbycustnum($1,1) if(!scalar(@$return));
8 <% objToJson($return) %>
9 % } elsif ( $sub eq 'smart_search' ) {
11 % my $string = $cgi->param('arg');
12 % my @cust_main = smart_search( 'search' => $string,
13 % 'no_fuzzy_on_exact' => 1, #pref?
15 % my $return = [ map [ $_->custnum, $_->name, $_->balance, $_->ucfirst_status, $_->statuscolor ], @cust_main ];
17 <% objToJson($return) %>
18 % } elsif ( $sub eq 'invnum_search' ) {
20 % my $string = $cgi->param('arg');
21 % my $inv = qsearchs('cust_bill', { 'invnum' => $string });
22 % my $return = $inv ? findbycustnum($inv->custnum,0) : [];
23 <% objToJson($return) %>
25 % elsif ( $sub eq 'exact_search' ) {
26 % # XXX possibly should query each element separately
27 % my $hashref = decode_json($cgi->param('arg'));
28 % my @cust_main = qsearch('cust_main', $hashref);
30 % foreach (@cust_main) {
32 % custnum => $_->custnum,
33 % name => $_->name_short,
34 % address1 => $_->address1,
38 <% objToJson($return) %>
42 my $conf = new FS::Conf;
44 my $sub = $cgi->param('sub');
49 my $hashref = { 'custnum' => $custnum };
50 $hashref = { 'agent_custid' => $custnum } if $agent;
52 'table' => 'cust_main',
53 'hashref' => $hashref,
54 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
56 return [ $c->custnum, $c->name, $c->balance, $c->ucfirst_status, $c->statuscolor ]