CRM-12274
authoryashodha <yashodha.chaku@webaccess.co.in>
Mon, 15 Apr 2013 19:25:51 +0000 (00:55 +0530)
committeryashodha <yashodha.chaku@webaccess.co.in>
Mon, 15 Apr 2013 19:26:16 +0000 (00:56 +0530)
CRM/Campaign/BAO/Query.php

index 7cfb65353f043600ce4f3afd6b0df4ada7e92971..3d1359febfcc3978e2d91c01f3544d6909564e24 100755 (executable)
@@ -95,7 +95,7 @@ class CRM_Campaign_BAO_Query {
     //all below tables are require to fetch  result.
 
     //1. get survey activity target table in.
-    $query->_select['survey_activity_target_contact_id'] = 'civicrm_activity_contact.contact_id as survey_activity_target_contact_id';
+    $query->_select['survey_activity_target_contact_id'] = 'civicrm_activity_target.contact_id as survey_activity_target_contact_id';
     $query->_select['survey_activity_target_id'] = 'civicrm_activity_target.id as survey_activity_target_id';
     $query->_element['survey_activity_target_id'] = 1;
     $query->_element['survey_activity_target_contact_id'] = 1;
@@ -158,10 +158,10 @@ class CRM_Campaign_BAO_Query {
         $query->_qill[$grouping][] = ts('Survey - %1', array(1 => CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $value, 'title')));
 
         $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_activity.source_record_id',
-          $op, $value, "Integer"
+          $op, $value, 'Integer'
         );
         $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_survey.id',
-          $op, $value, "Integer"
+          $op, $value, 'Integer'
         );
         return;
 
@@ -170,7 +170,7 @@ class CRM_Campaign_BAO_Query {
 
         $query->_qill[$grouping][] = ts('Survey Status - %1', array(1 => $activityStatus[$value]));
         $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_activity.status_id',
-          $op, $value, "Integer"
+          $op, $value, 'Integer'
         );
         return;
 
@@ -189,8 +189,8 @@ class CRM_Campaign_BAO_Query {
           }
         }
         $query->_qill[$grouping][] = ts('Survey Interviewer - %1', array(1 => $surveyInterviewerName));
-        $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_activity_assignment.assignee_contact_id',
-          $op, $value, "Integer"
+        $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_activity_assignment.contact_id',
+          $op, $value, 'Integer'
         );
         return;
     }
@@ -206,8 +206,8 @@ class CRM_Campaign_BAO_Query {
 
     switch ($name) {
       case self::CIVICRM_ACTIVITY_TARGET:
-        $from = " INNER JOIN civicrm_activity_contact
-   ON ( civicrm_activity_contact.contact_id = contact_a.id AND civicrm_activity_contact.record_type = 'Target') ";
+        $from = " INNER JOIN civicrm_activity_contact civicrm_activity_target
+   ON ( civicrm_activity_target.contact_id = contact_a.id AND civicrm_activity_target.record_type = 'Target') ";
         break;
 
       case self::CIVICRM_ACTIVITY:
@@ -219,7 +219,8 @@ class CRM_Campaign_BAO_Query {
 
       case self::CIVICRM_ACTIVITY_ASSIGNMENT:
         $from = "
-INNER JOIN civicrm_activity_assignment ON ( civicrm_activity.id = civicrm_activity_assignment.activity_id ) ";
+INNER JOIN  civicrm_activity_contact civicrm_activity_assignment ON ( civicrm_activity.id = civicrm_activity_assignment.activity_id AND
+civicrm_activity_assignment.record_type = 'Assignee' ) ";
         break;
 
       case 'civicrm_survey':