diff options
author | Mark Wells <mark@freeside.biz> | 2015-11-18 13:07:47 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2015-11-18 13:07:47 -0800 |
commit | b2fd002f3285b70311642f8ff0025598d42bd16e (patch) | |
tree | 8005ab27d04c8aaaa7e9bfd10a9ba0f48cafd967 /httemplate/REST | |
parent | 1daa37e733b9e972e5328503374130a423d02836 (diff) |
track customer invoice destination emails using contact_email, #25536
Diffstat (limited to 'httemplate/REST')
-rw-r--r-- | httemplate/REST/1.0/cust_main | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/httemplate/REST/1.0/cust_main b/httemplate/REST/1.0/cust_main index 4656bcb25..5401195fc 100644 --- a/httemplate/REST/1.0/cust_main +++ b/httemplate/REST/1.0/cust_main @@ -47,17 +47,23 @@ if ( $r->method eq 'GET' ) { if ( $cgi->param('cust_main_invoice_dest') ) { my $dest = dbh->quote(scalar($cgi->param('cust_main_invoice_dest'))); $extra_sql = " - WHERE EXISTS ( SELECT 1 FROM cust_main_invoice - WHERE cust_main.custnum = cust_main_invoice.custnum - AND dest = $dest + WHERE EXISTS ( SELECT 1 FROM cust_contact + JOIN contact USING (contactnum) + JOIN contact_email USING (contactnum) + WHERE cust_main.custnum = cust_contact.custnum + AND contact.invoice_dest = 'Y' + AND contact_email.emailaddress = $dest ) "; } elsif ( $cgi->param('cust_main_invoice_dest_substring') ) { my $dest = dbh->quote('%'. scalar($cgi->param('cust_main_invoice_dest_substring')). '%'); $extra_sql = " - WHERE EXISTS ( SELECT 1 FROM cust_main_invoice - WHERE cust_main.custnum = cust_main_invoice.custnum - AND dest ILIKE $dest + WHERE EXISTS ( SELECT 1 FROM cust_contact + JOIN contact USING (contactnum) + JOIN contact_email USING (contactnum) + WHERE cust_main.custnum = cust_contact.custnum + AND contact.invoice_dest = 'Y' + AND contact_email.emailaddress ILIKE $dest ) "; } |