RT# 75095 - Added Ooma integration to one time charges
[freeside.git] / httemplate / misc / xmlhttp-cust_main-email_search.html
1 <% encode_json(\@result) %>\
2 <%init>
3 die 'access denied'
4   unless $FS::CurrentUser::CurrentUser->access_right('Edit customer');
5
6 my $sub = $cgi->param('sub');
7 my $email = $cgi->param('arg');
8 my @where = (
9   'contact_email.emailaddress LIKE '.dbh->quote('%'.$email.'%'),
10   $FS::CurrentUser::CurrentUser->agentnums_sql(table => 'cust_main'),
11 );
12 my @cust_main = qsearch({
13   'table'     => 'cust_main',
14   'select'    => 'cust_main.*',
15   'addl_from' => ' JOIN cust_contact USING (custnum) '.
16                  ' JOIN contact_email USING (contactnum)',
17   'extra_sql' => 'WHERE '.join(' AND ', @where),
18 });
19
20 my @result = map {
21   [ $_->custnum,
22     $_->name,
23     $_->dest,
24     $_->invoice_noemail,
25     $_->message_noemail,
26   ]
27 } @cust_main;
28
29 </%init>