From 9099266ea857bcfd56f8528e535a95142872fac5 Mon Sep 17 00:00:00 2001 From: William Mortada Date: Fri, 14 Oct 2016 16:30:25 +0100 Subject: [PATCH] CRM-19503 Fix errors in Activity Summary Report --- CRM/Report/Form.php | 5 +++++ CRM/Report/Form/ActivitySummary.php | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 481828d252..33e3df18a7 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -441,6 +441,11 @@ class CRM_Report_Form extends CRM_Core_Form { */ protected $rollupRow = array(); + /** + * @var string Database attributes - character set and collation + */ + protected $_databaseAttributes = 'DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci'; + /** * SQL being run in this report. * diff --git a/CRM/Report/Form/ActivitySummary.php b/CRM/Report/Form/ActivitySummary.php index 5044a5dab0..0c6a643199 100644 --- a/CRM/Report/Form/ActivitySummary.php +++ b/CRM/Report/Form/ActivitySummary.php @@ -348,7 +348,13 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { } else { $this->_from = " - FROM civicrm_activity {$this->_aliases['civicrm_activity']} {$this->_aclFrom} "; + FROM civicrm_activity {$this->_aliases['civicrm_activity']} + LEFT JOIN civicrm_activity_contact target_activity + ON {$this->_aliases['civicrm_activity']}.id = target_activity.activity_id AND + target_activity.record_type_id = {$targetID} + LEFT JOIN civicrm_contact contact_civireport + ON target_activity.contact_id = contact_civireport.id + {$this->_aclFrom}"; } } @@ -537,7 +543,8 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { // create temp table to store main result $tempQuery = "CREATE TEMPORARY TABLE {$this->_tempTableName} ( - id int unsigned NOT NULL AUTO_INCREMENT, " . implode(', ', $dbColumns) . ' , PRIMARY KEY (id))'; + id int unsigned NOT NULL AUTO_INCREMENT, " . implode(', ', $dbColumns) . ' , PRIMARY KEY (id))' + . $this->_databaseAttributes; CRM_Core_DAO::executeQuery($tempQuery); // build main report query @@ -560,7 +567,8 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { // create temp table to store duration $this->_tempDurationSumTableName = CRM_Core_DAO::createTempTableName('civicrm_activity'); $tempQuery = "CREATE TEMPORARY TABLE {$this->_tempDurationSumTableName} ( - id int unsigned NOT NULL AUTO_INCREMENT, civicrm_activity_duration_total VARCHAR(128), PRIMARY KEY (id))"; + id int unsigned NOT NULL AUTO_INCREMENT, civicrm_activity_duration_total VARCHAR(128), PRIMARY KEY (id))" + . $this->_databaseAttributes; CRM_Core_DAO::executeQuery($tempQuery); // store the result in temporary table -- 2.25.1