fix use of agent_custid in quick payment entry, RT#10035
[freeside.git] / httemplate / misc / xmlhttp-cust_main-search.cgi
1 % if ( $sub eq 'custnum_search' ) {
2
3 %   my $custnum = $cgi->param('arg');
4 %   my $cust_main = '';
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,
10 %     });
11 %   }
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,
17 %     });
18 %   }
19 %     
20 "<% $cust_main ? $cust_main->name : '' %>"
21 %
22 % } elsif ( $sub eq 'smart_search' ) {
23 %
24 %   my $string = $cgi->param('arg');
25 %   my @cust_main = smart_search( 'search' => $string );
26 %   my $return = [ map [ $_->custnum, $_->name ], @cust_main ];
27 %     
28 <% objToJson($return) %>
29 % } 
30 <%init>
31
32 my $conf = new FS::Conf;
33
34 my $sub = $cgi->param('sub');
35
36 </%init>