summaryrefslogtreecommitdiff
path: root/httemplate/misc/xmlhttp-cust_main-search.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/misc/xmlhttp-cust_main-search.cgi')
-rw-r--r--httemplate/misc/xmlhttp-cust_main-search.cgi36
1 files changed, 36 insertions, 0 deletions
diff --git a/httemplate/misc/xmlhttp-cust_main-search.cgi b/httemplate/misc/xmlhttp-cust_main-search.cgi
new file mode 100644
index 0000000..26e68b5
--- /dev/null
+++ b/httemplate/misc/xmlhttp-cust_main-search.cgi
@@ -0,0 +1,36 @@
+% if ( $sub eq 'custnum_search' ) {
+%
+% 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 ];
+%
+<% objToJson($return) %>
+% }
+<%init>
+
+my $conf = new FS::Conf;
+
+my $sub = $cgi->param('sub');
+
+</%init>