summaryrefslogtreecommitdiff
path: root/httemplate/misc/xmlhttp-cust_main-search.cgi
blob: 615a4bb1ee5989d5787869b64dca2f9260546338 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
% if ( $sub eq 'custnum_search' ) {
% 
%   my $custnum = $cgi->param('arg');
%   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 $return = [ map [ $_->custnum, $_->name ], @cust_main ];
%     
<% objToJson($return) %>
% } 
<%init>

my $conf = new FS::Conf;

my $sub = $cgi->param('sub');

</%init>