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:12:12 -0800 |
| commit | ded0cb9e764cd806a13aaf6ddb8cdfe0f3215999 (patch) | |
| tree | 3edbfb27d1f72bc7326893035d01fe0a35e9e42c /httemplate/REST | |
| parent | f4ebbb57fd21146b936e73fbcf34b76adf664904 (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 ) "; } |
