From 5b5da1ef2add35a9037a44ebade01dc4f64fc731 Mon Sep 17 00:00:00 2001 From: yashodha Date: Mon, 22 Apr 2013 20:27:18 +0530 Subject: [PATCH] CRM-12357 --- CRM/Activity/BAO/Activity.php | 19 ++++++------------- CRM/Campaign/BAO/Query.php | 2 +- CRM/Case/BAO/Case.php | 5 +++-- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 52b8ec88cb..99ffd5f6d7 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -759,24 +759,22 @@ LEFT JOIN civicrm_case_activity ON ( civicrm_case_activity.activity_id = tbl.ac INSERT INTO {$activityContactTempTable} ( activity_id, contact_id, record_type_id, contact_name ) SELECT ac.activity_id, ac.contact_id, - ac.record_type_id + ac.record_type_id, c.sort_name FROM civicrm_activity_contact ac -INNER JOIN {$activityTempTable} ON ( ac.activity_id = {$activityTempTable}.activity_id -INNER JOIN civicrm_contact c ON c.id = at.contact_id +INNER JOIN {$activityTempTable} ON ( ac.activity_id = {$activityTempTable}.activity_id {$notbulkActivityClause} ) +INNER JOIN civicrm_contact c ON c.id = ac.contact_id WHERE c.is_deleted = 0 - {$notbulkActivityClause} ) + "; CRM_Core_DAO::executeQuery($query); - CRM_Core_DAO::executeQuery($query); - // step 3: Combine all temp tables to get final query for activity selector $query = " SELECT {$activityTempTable}.*, {$activityContactTempTable}.contact_id, {$activityContactTempTable}.record_type_id, - {$activityContactTempTable}.contact_name, + {$activityContactTempTable}.contact_name FROM {$activityTempTable} INNER JOIN {$activityContactTempTable} on {$activityTempTable}.activity_id = {$activityContactTempTable}.activity_id "; @@ -1055,14 +1053,10 @@ INNER JOIN civicrm_contact contact ON ac.contact_id = contact.id civicrm_activity.status_id, civicrm_activity.subject, civicrm_activity.source_record_id, - sourceContact.sort_name as source_contact_name, civicrm_option_value.value as activity_type_id, civicrm_option_value.label as activity_type, null as case_id, null as case_subject, - civicrm_activity.campaign_id as campaign_id, - activityContact.contact_id as contact_id, - activityContact.record_type_id as record_type_id, - contact.sort_name as sort_name + civicrm_activity.campaign_id as campaign_id '; } @@ -1094,7 +1088,6 @@ INNER JOIN civicrm_contact contact ON ac.contact_id = contact.id civicrm_activity.subject, civicrm_activity.source_contact_id, civicrm_activity.source_record_id, - sourceContact.sort_name as source_contact_name, civicrm_option_value.value as activity_type_id, civicrm_option_value.label as activity_type, null as case_id, null as case_subject, diff --git a/CRM/Campaign/BAO/Query.php b/CRM/Campaign/BAO/Query.php index 8e05881dc8..57c40b62e4 100755 --- a/CRM/Campaign/BAO/Query.php +++ b/CRM/Campaign/BAO/Query.php @@ -218,7 +218,7 @@ class CRM_Campaign_BAO_Query { case self::CIVICRM_ACTIVITY: $surveyActivityTypes = CRM_Campaign_PseudoConstant::activityType(); $surveyKeys = "(" . implode(',', array_keys($surveyActivityTypes)) . ")"; - $from = " INNER JOIN civicrm_activity ON ( civicrm_activity.id = civicrm_activity_contact.activity_id + $from = " INNER JOIN civicrm_activity ON ( civicrm_activity.id = civicrm_activity_target.activity_id AND civicrm_activity.activity_type_id IN $surveyKeys ) "; break; diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index ce0bc025f5..e3e9326e2d 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -1001,7 +1001,8 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type $from = 'FROM civicrm_case_activity cca INNER JOIN civicrm_activity ca ON ca.id = cca.activity_id - INNER JOIN civicrm_contact cc ON cc.id = ca.source_contact_id + INNER JOIN civicrm_activity_contact cac ON cac.activity_id = ca.id + INNER JOIN civicrm_contact cc ON cc.id = cac.contact_id INNER JOIN civicrm_option_group cog ON cog.name = "activity_type" INNER JOIN civicrm_option_value cov ON cov.option_group_id = cog.id AND cov.value = ca.activity_type_id AND cov.is_active = 1 @@ -1009,7 +1010,7 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type LEFT OUTER JOIN civicrm_option_group og ON og.name="activity_status" LEFT OUTER JOIN civicrm_option_value ov ON ov.option_group_id=og.id AND ov.name="Scheduled" LEFT JOIN civicrm_activity_contact caa - ON caa.activity_id = ca.id AND caa.record_type_id = $assigneeID + ON caa.activity_id = ca.id AND caa.record_type_id = "$assigneeID" LEFT JOIN civicrm_contact acc ON acc.id = caa.contact_id '; $where = 'WHERE cca.case_id= %1 -- 2.25.1