summaryrefslogtreecommitdiff
path: root/httemplate/misc/xmlhttp-cust_main-email_search.html
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-03-25 15:47:34 -0700
committerMark Wells <mark@freeside.biz>2013-03-25 15:47:34 -0700
commitdfc85a4245f2d15f258d840b98f0508c50228e40 (patch)
tree0c4b59b89ab068e2ccd34d05abe49542ef8efaf6 /httemplate/misc/xmlhttp-cust_main-email_search.html
parent6bf3df8177a22d2275b1a68045ab5ff2e831af42 (diff)
email opt-out flag, #19312
Diffstat (limited to 'httemplate/misc/xmlhttp-cust_main-email_search.html')
-rw-r--r--httemplate/misc/xmlhttp-cust_main-email_search.html29
1 files changed, 29 insertions, 0 deletions
diff --git a/httemplate/misc/xmlhttp-cust_main-email_search.html b/httemplate/misc/xmlhttp-cust_main-email_search.html
new file mode 100644
index 000000000..d8c8ef44c
--- /dev/null
+++ b/httemplate/misc/xmlhttp-cust_main-email_search.html
@@ -0,0 +1,29 @@
+<% JSON::to_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>