From: jitendrapurohit Date: Fri, 8 Jan 2016 11:39:24 +0000 (+0530) Subject: make code generic X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ecf1e543e496941038955aa7d8b36d08efde56b9;p=civicrm-core.git make code generic --- diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 7b4608b021..777b75a9ff 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -4482,4 +4482,20 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a } } + /* + * CRM-17793 - Alter DateTime section header to group by date from the datetime field. + * @param $tempTable + * @param $columnName + */ + public function alterSectionHeaderForDateTime($tempTable, $columnName) { + $tempQuery = "ALTER TABLE {$tempTable} ADD COLUMN {$columnName}_date VARCHAR(128)"; + CRM_Core_DAO::executeQuery($tempQuery); + $updateQuery = "UPDATE {$tempTable} SET {$columnName}_date = date({$columnName})"; + CRM_Core_DAO::executeQuery($updateQuery); + $this->_select .= ", {$columnName}_date"; + $this->_sections["{$columnName}_date"] = $this->_sections["{$columnName}"]; + unset($this->_sections["{$columnName}"]); + $this->assign('sections', $this->_sections); + } + } diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php index a7eaebf57b..672d16edcb 100644 --- a/CRM/Report/Form/Activity.php +++ b/CRM/Report/Form/Activity.php @@ -821,8 +821,10 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; $this->_having = "HAVING " . implode(' AND ', $nullFilters); } $this->orderBy(); - if (!empty($this->_sections) && key($this->_sections) == 'civicrm_activity_activity_date_time') { - $this->alterSectionHeaderForDateTime(); + foreach ($this->_sections as $alias => $section) { + if (!empty($section) && $section['name'] == 'activity_date_time') { + $this->alterSectionHeaderForDateTime('civireport_activity_temp_target', $section['tplField']); + } } $this->limit(); $sql = "{$this->_select} @@ -1062,19 +1064,4 @@ GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy} {$this->_limit}" } } - /* - * Alter DateTime section header to group by date from the datetime field. - * - */ - public function alterSectionHeaderForDateTime() { - $tempQuery = "ALTER TABLE civireport_activity_temp_target ADD COLUMN civicrm_activity_activity_date VARCHAR(128)"; - CRM_Core_DAO::executeQuery($tempQuery); - $updateQuery = "UPDATE civireport_activity_temp_target SET civicrm_activity_activity_date = date(civicrm_activity_activity_date_time)"; - CRM_Core_DAO::executeQuery($updateQuery); - $this->_select .= ', civicrm_activity_activity_date'; - $this->_sections['civicrm_activity_activity_date'] = $this->_sections['civicrm_activity_activity_date_time']; - unset($this->_sections['civicrm_activity_activity_date_time']); - $this->assign('sections', $this->_sections); - } - }