CRM-12357
authoryashodha <yashodha.chaku@webaccess.co.in>
Mon, 22 Apr 2013 14:57:18 +0000 (20:27 +0530)
committeryashodha <yashodha.chaku@webaccess.co.in>
Mon, 22 Apr 2013 14:57:18 +0000 (20:27 +0530)
CRM/Activity/BAO/Activity.php
CRM/Campaign/BAO/Query.php
CRM/Case/BAO/Case.php

index 52b8ec88cb02353d229c1edcd25ef31902a07390..99ffd5f6d77250e7480a91aa150b59add0e5ba8a 100644 (file)
@@ -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,
index 8e05881dc8f34f41e8a1fb80b5d930b4e1df0a49..57c40b62e418b55392abc8025853ac0bc9c79beb 100755 (executable)
@@ -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;
 
index ce0bc025f5f6c71b6b8989dca76792b1bc871de5..e3e9326e2d5b5a913813b670ec0e2497848280aa 100644 (file)
@@ -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