From 4b885f843d4d00ea63ab8b331f05ad5ba1c0863f Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 8 Dec 2017 10:59:44 +1300 Subject: [PATCH] CRM-19060 preliminary tidy up, remove redundant functions, use isTableSelected --- CRM/Report/Form.php | 16 ++-------- CRM/Report/Form/Member/Detail.php | 49 +++---------------------------- 2 files changed, 6 insertions(+), 59 deletions(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index f639f72e74..176bed40c1 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -2311,7 +2311,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } // include statistics columns only if set - if (!empty($field['statistics'])) { + if (!empty($field['statistics']) && !empty($this->_groupByArray)) { $select = $this->addStatisticsToSelect($field, $tableName, $fieldName, $select); } else { @@ -2645,19 +2645,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * Build group by clause. */ public function groupBy() { - if (!empty($this->_params['group_bys']) && - is_array($this->_params['group_bys']) - ) { - foreach ($this->_columns as $tableName => $table) { - if (array_key_exists('group_bys', $table)) { - foreach ($table['group_bys'] as $fieldName => $field) { - if (!empty($this->_params['group_bys'][$fieldName])) { - $this->_groupByArray[] = $field['dbAlias']; - } - } - } - } - } + $this->storeGroupByArray(); if (!empty($this->_groupByArray)) { $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $this->_groupByArray); diff --git a/CRM/Report/Form/Member/Detail.php b/CRM/Report/Form/Member/Detail.php index f9e860e2b0..b4a3299e92 100644 --- a/CRM/Report/Form/Member/Detail.php +++ b/CRM/Report/Form/Member/Detail.php @@ -29,19 +29,9 @@ * * @package CRM * @copyright CiviCRM LLC (c) 2004-2017 - * $Id$ - * */ class CRM_Report_Form_Member_Detail extends CRM_Report_Form { - protected $_addressField = FALSE; - - protected $_emailField = FALSE; - - protected $_phoneField = FALSE; - - protected $_contribField = FALSE; - protected $_summary = NULL; protected $_customGroupExtends = array( @@ -283,36 +273,6 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form { parent::preProcess(); } - public function select() { - $select = $this->_columnHeaders = array(); - - foreach ($this->_columns as $tableName => $table) { - if (array_key_exists('fields', $table)) { - foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { - if ($tableName == 'civicrm_email') { - $this->_emailField = TRUE; - } - elseif ($tableName == 'civicrm_phone') { - $this->_phoneField = TRUE; - } - elseif ($tableName == 'civicrm_contribution') { - $this->_contribField = TRUE; - } - $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - if (array_key_exists('title', $field)) { - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; - } - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - } - } - } - } - - $this->_selectClauses = $select; - $this->_select = "SELECT " . implode(', ', $select) . " "; - } - public function from() { $this->setFromBase('civicrm_contact'); $this->_from .= " @@ -332,8 +292,7 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form { {$this->_aliases['civicrm_address']}.is_primary = 1\n"; } - //used when email field is selected - if ($this->_emailField) { + if ($this->isTableSelected('civicrm_email')) { $this->_from .= " LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']} ON {$this->_aliases['civicrm_contact']}.id = @@ -341,15 +300,15 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form { {$this->_aliases['civicrm_email']}.is_primary = 1\n"; } //used when phone field is selected - if ($this->_phoneField) { + if ($this->isTableSelected('civicrm_phone')) { $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\n"; } - //used when contribution field is selected - if ($this->_contribField) { + //used when contribution field is selected. + if ($this->isTableSelected('civicrm_contribution')) { $this->_from .= " LEFT JOIN civicrm_membership_payment cmp ON {$this->_aliases['civicrm_membership']}.id = cmp.membership_id -- 2.25.1