Update Recur.php - add AND email is_primary = 1
authorKarin Gerritsen <karin@semper-it.com>
Wed, 3 Jun 2015 01:23:43 +0000 (19:23 -0600)
committerKarin Gerritsen <karin@semper-it.com>
Wed, 3 Jun 2015 01:23:43 +0000 (19:23 -0600)
to avoid duplicate results for contacts who have multiple email addresses in their contact record.

CRM/Report/Form/Contribute/Recur.php

index 5b0f8afc59c67480c47c0788062369a2a2bc3a4f..c2278f0d9702d2e9ef0b7431acc338dd21437805 100644 (file)
@@ -234,11 +234,12 @@ class CRM_Report_Form_Contribute_Recur extends CRM_Report_Form {
         ON {$this->_aliases['civicrm_contribution_recur']}.id = {$this->_aliases['civicrm_contribution']}.contribution_recur_id";
     $this->_from .= "
       LEFT JOIN civicrm_email  {$this->_aliases['civicrm_email']}
-        ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id";
+        ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
+        {$this->_aliases['civicrm_email']}.is_primary = 1)";
     $this->_from .= "
       LEFT  JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
         ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
-       {$this->_aliases['civicrm_phone']}.is_primary = 1)";
+        {$this->_aliases['civicrm_phone']}.is_primary = 1)";
   }
 
   public function groupBy() {