X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-cust_main-search.cgi;h=26e68b5d87d9808581a46517bb4f772304165f2f;hb=2ab068f449eb97a10e18d20e9dab5ab9faa017e7;hp=67512fad9310a50a9346f6a6c6b9243734721592;hpb=c648976f0b7975f2328ebd7ba8c711fad0ca4195;p=freeside.git diff --git a/httemplate/misc/xmlhttp-cust_main-search.cgi b/httemplate/misc/xmlhttp-cust_main-search.cgi index 67512fad9..26e68b5d8 100644 --- a/httemplate/misc/xmlhttp-cust_main-search.cgi +++ b/httemplate/misc/xmlhttp-cust_main-search.cgi @@ -1,22 +1,36 @@ -% -% my $sub = $cgi->param('sub'); -% -% if ( $sub eq 'custnum_search' ) { +% if ( $sub eq 'custnum_search' ) { % -% my $custnum = $cgi->param('arg'); -% my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); -% +% my $custnum = $cgi->param('arg'); +% my $cust_main = ''; +% if ( $custnum <= 2147483647 ) { +% $cust_main = qsearchs({ +% 'table' => 'cust_main', +% 'hashref' => { 'custnum' => $custnum }, +% '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 ]; +% } 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'); +