X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-cust_main-search.cgi;h=c71953ba9307bff35203356b30f6e117050c523f;hb=9ab9e3293274cdba0ddbd2df21adb575f8b987ef;hp=26e68b5d87d9808581a46517bb4f772304165f2f;hpb=624b2d44625f69d71175c3348cae635d580c890b;p=freeside.git diff --git a/httemplate/misc/xmlhttp-cust_main-search.cgi b/httemplate/misc/xmlhttp-cust_main-search.cgi index 26e68b5d8..c71953ba9 100644 --- a/httemplate/misc/xmlhttp-cust_main-search.cgi +++ b/httemplate/misc/xmlhttp-cust_main-search.cgi @@ -2,10 +2,10 @@ % % my $custnum = $cgi->param('arg'); % my $cust_main = ''; -% if ( $custnum <= 2147483647 ) { +% if ( $custnum =~ /^(\d+)$/ and $1 <= 2147483647 ) { % $cust_main = qsearchs({ % 'table' => 'cust_main', -% 'hashref' => { 'custnum' => $custnum }, +% 'hashref' => { 'custnum' => $1 }, % 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, % }); % } @@ -22,10 +22,26 @@ % } 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>