From f3e8e8538ccd51fe5be7b33d067fbcf877753254 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Fri, 7 Aug 2015 18:58:36 +0530 Subject: [PATCH] CRM-14706 -- Relationship contact reports with group and relation type filters fails --- CRM/Report/Form.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 8c03314d19..70ad58ce8b 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -3355,7 +3355,11 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } $clause = "{$field['dbAlias']} IN (" . implode(', ', $value) . ")"; - return " {$this->_aliases['civicrm_contact']}.id {$sqlOp} ( + $contactAlias = $this->_aliases['civicrm_contact']; + if (!empty($this->relationType) && $this->relationType == 'b_a') { + $contactAlias = $this->_aliases['civicrm_contact_b']; + } + return " {$contactAlias}.id {$sqlOp} ( SELECT DISTINCT {$this->_aliases['civicrm_group']}.contact_id FROM civicrm_group_contact {$this->_aliases['civicrm_group']} WHERE {$clause} AND {$this->_aliases['civicrm_group']}.status = 'Added' -- 2.25.1