X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-cust_main-search.cgi;h=c71953ba9307bff35203356b30f6e117050c523f;hb=9ab9e3293274cdba0ddbd2df21adb575f8b987ef;hp=20707dab895e3b4caf4d7dad3b56bbc6257f432a;hpb=eaafe49123e402598d1e350c5654b7870073740d;p=freeside.git diff --git a/httemplate/misc/xmlhttp-cust_main-search.cgi b/httemplate/misc/xmlhttp-cust_main-search.cgi index 20707dab8..c71953ba9 100644 --- a/httemplate/misc/xmlhttp-cust_main-search.cgi +++ b/httemplate/misc/xmlhttp-cust_main-search.cgi @@ -1,24 +1,52 @@ % if ( $sub eq 'custnum_search' ) { % % my $custnum = $cgi->param('arg'); -% my $cust_main = qsearchs({ -% 'table' => 'cust_main', -% 'hashref' => { 'custnum' => $custnum }, -% 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, -% }); +% 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 ]; +% my @cust_main = smart_search( 'search' => $string, +% 'no_fuzzy_on_exact' => 1, #pref? +% ); +% my $return = [ map [ $_->custnum, $_->name, $_->balance ], @cust_main ]; % <% objToJson($return) %> +% } elsif ( $sub eq 'invnum_search' ) { +% +% my $string = $cgi->param('arg'); +% my $inv = qsearchs('cust_bill', { 'invnum' => $string }); +% my $return = []; +% if ( $inv ) { +% my $cust_main = qsearchs({ +% 'table' => 'cust_main', +% 'hashref' => { 'custnum' => $inv->custnum }, +% 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, +% }); +% $return = [ $cust_main->custnum, $cust_main->name, $cust_main->balance ]; +% } +<% objToJson($return) %> % } <%init> +my $conf = new FS::Conf; + my $sub = $cgi->param('sub');