From 9a2a98cdf1efe34105410eec2842d594fffde797 Mon Sep 17 00:00:00 2001 From: Deepak Srivastava Date: Thu, 20 Jun 2013 17:37:27 +0530 Subject: [PATCH] CRM-12867 ---------------------------------------- * CRM-12867: Changelog enhanced summary report: pagination erroneous count http://issues.civicrm.org/jira/browse/CRM-12867 --- CRM/Logging/ReportSummary.php | 28 +++++++++++++++++++++- CRM/Report/Form/Contact/LoggingSummary.php | 2 +- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CRM/Logging/ReportSummary.php b/CRM/Logging/ReportSummary.php index 679e7a4ce4..57217d8d24 100644 --- a/CRM/Logging/ReportSummary.php +++ b/CRM/Logging/ReportSummary.php @@ -209,10 +209,36 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { } } + // add computed log_type column so that we can do a group by after that, which will help + // alterDisplay() counts sync with pager counts + $sql = "SELECT DISTINCT log_type FROM civicrm_temp_civireport_logsummary"; + $dao = CRM_Core_DAO::executeQuery($sql); + $replaceWith = array(); + while($dao->fetch()){ + $type = $this->getLogType($dao->log_type); + if (!array_key_exists($type,$replaceWith)) + $replaceWith[$type] = array(); + $replaceWith[$type][] = $dao->log_type; + } + foreach ($replaceWith as $type => $tables) { + if (!empty($tables)) { + $replaceWith[$type] = implode("','", $tables); + } + } + + $sql = "ALTER TABLE civicrm_temp_civireport_logsummary ADD COLUMN log_civicrm_entity_log_type_label varchar(64)"; + CRM_Core_DAO::executeQuery($sql); + foreach ($replaceWith as $type => $in) { + $sql = "UPDATE civicrm_temp_civireport_logsummary SET log_civicrm_entity_log_type_label='{$type}', log_date=log_date WHERE log_type IN('$in')"; + CRM_Core_DAO::executeQuery($sql); + } + + // note the group by columns are same as that used in alterDisplay as $newRows - $key $this->limit(); $sql = "{$this->_select} FROM civicrm_temp_civireport_logsummary entity_log_civireport -ORDER BY entity_log_civireport.log_date DESC {$this->_limit}"; +GROUP BY log_civicrm_entity_log_date, log_civicrm_entity_log_type_label, log_civicrm_entity_log_conn_id, log_civicrm_entity_log_user_id, log_civicrm_entity_altered_contact_id +ORDER BY log_civicrm_entity_log_date DESC {$this->_limit}"; $sql = str_replace('modified_contact_civireport.display_name', 'entity_log_civireport.altered_contact', $sql); $sql = str_replace('modified_contact_civireport.id', 'entity_log_civireport.altered_contact_id', $sql); $sql = str_replace(array('modified_contact_civireport.', 'altered_by_contact_civireport.'), 'entity_log_civireport.', $sql); diff --git a/CRM/Report/Form/Contact/LoggingSummary.php b/CRM/Report/Form/Contact/LoggingSummary.php index bf997fb884..de85fdc7bf 100644 --- a/CRM/Report/Form/Contact/LoggingSummary.php +++ b/CRM/Report/Form/Contact/LoggingSummary.php @@ -206,7 +206,7 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary { $row['log_civicrm_entity_log_type'] . '_' . $row['log_civicrm_entity_log_conn_id'] . '_' . $row['log_civicrm_entity_log_user_id'] . '_' . - $row['log_civicrm_entity_id']; + $row['log_civicrm_entity_altered_contact_id']; $newRows[$key] = $row; unset($row['log_civicrm_entity_log_user_id']); -- 2.25.1