summaryrefslogtreecommitdiff
path: root/httemplate/misc/xmlhttp-cust_main-email_search.html
blob: 0d830826c9115b4eb19012dccc739963600a90e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<% encode_json(\@result) %>\
<%init>
die 'access denied'
  unless $FS::CurrentUser::CurrentUser->access_right('Edit customer');

my $sub = $cgi->param('sub');
my $email = $cgi->param('arg');
my @where = (
  "cust_main_invoice.dest != 'POST'",
  "cust_main_invoice.dest LIKE ".dbh->quote('%'.$email.'%'),
  $FS::CurrentUser::CurrentUser->agentnums_sql(table => 'cust_main'),
);
my @cust_main = qsearch({
  'table'     => 'cust_main',
  'select'    => 'cust_main.*, cust_main_invoice.dest',
  'addl_from' => 'JOIN cust_main_invoice USING (custnum)',
  'extra_sql' => 'WHERE '.join(' AND ', @where),
});

my @result = map {
  [ $_->custnum,
    $_->name,
    $_->dest,
    $_->invoice_noemail,
    $_->message_noemail,
  ]
} @cust_main;

</%init>