From b8cab202b750510b9231f9bc6b2c2a084d273a12 Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Fri, 29 Nov 2013 18:31:11 +0530 Subject: [PATCH] CRM-13812#COMMENT-54485 --- CRM/Activity/BAO/Activity.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index d46b1e3be7..8fd6b5aad1 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -676,6 +676,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { $tableFields = array( 'activity_id' => 'int unsigned', 'activity_date_time' => 'datetime', + 'source_record_id' => 'int unsigned', 'status_id' => 'int unsigned', 'subject' => 'varchar(255)', 'source_contact_name' => 'varchar(255)', @@ -710,6 +711,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { $insertSQL = "INSERT INTO {$activityTempTable} (" . implode(',', $insertValueSQL) . " ) "; $order = $limit = $groupBy = ''; + $groupBy = " GROUP BY tbl.activity_id "; if (!empty($input['sort'])) { if (is_a($input['sort'], 'CRM_Utils_Sort')) { @@ -1055,13 +1057,14 @@ LEFT JOIN civicrm_case_activity ON ( civicrm_case_activity.activity_id = tbl.a $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $sourceJoin = " -INNER JOIN civicrm_activity_contact ac ON ac.activity_id = civicrm_activity.id AND record_type_id = {$sourceID} +INNER JOIN civicrm_activity_contact ac ON ac.activity_id = civicrm_activity.id INNER JOIN civicrm_contact contact ON ac.contact_id = contact.id "; if (!$input['count']) { $sourceSelect = ', civicrm_activity.activity_date_time, + civicrm_activity.source_record_id, civicrm_activity.status_id, civicrm_activity.subject, contact.sort_name as source_contact_name, @@ -1071,6 +1074,9 @@ INNER JOIN civicrm_contact contact ON ac.contact_id = contact.id civicrm_activity.campaign_id as campaign_id '; + $sourceJoin .= " +LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND src.record_type_id = {$sourceID} AND src.contact_id = contact.id) +"; } $sourceClause = " @@ -1096,9 +1102,9 @@ INNER JOIN civicrm_contact contact ON ac.contact_id = contact.id if (!$input['count']) { $caseSelect = ', civicrm_activity.activity_date_time, + civicrm_activity.source_record_id, civicrm_activity.status_id, civicrm_activity.subject, - ac.contact_id, contact.sort_name as source_contact_name, civicrm_option_value.value as activity_type_id, civicrm_option_value.label as activity_type, -- 2.25.1