}
$sourceContactId = self::getActivityContact($activity->id, $sourceID);
- $defaults['source_contact_id'] =
- $activity->source_contact_id = $sourceContactId;
+ $defaults['source_contact_id'] = $sourceContactId;
if ($sourceContactId &&
!CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
IFNULL(gender_id,'') AS gender_id,
IFNULL(state_province_id,'') AS state_province_id,
IFNULL(country_id,'') as country_id,IFNULL(iso_code,'') as country_iso, IFNULL(civicrm_country.name,'') as country
- FROM civicrm_activity a, civicrm_survey, civicrm_contact
+ FROM (civicrm_activity a, civicrm_survey, civicrm_contact )
+ LEFT JOIN civicrm_activity_contact ac ON ( ac.activity_id = a.id AND ac.record_type_id = %3 )
LEFT JOIN civicrm_address ON civicrm_address.contact_id = civicrm_contact.id AND civicrm_address.is_primary = 1
LEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id
WHERE
- a.source_contact_id = civicrm_contact.id AND
+ ac.contact_id = civicrm_contact.id AND
a.activity_type_id = civicrm_survey.activity_type_id AND
civicrm_survey.id = %1 AND
a.source_record_id = %1 ";
}
$sql .= " ORDER BY a.activity_date_time";
+ $activityContacts = CRM_Core_PseudoConstant::activityContacts('name');
+ $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
+ $params[3] = array($sourceID, 'Integer');
+
$fields = array(
'id', 'survey_id', 'contact_id',
'activity_date_time', 'activity_type_id',
'state_province_id', 'country_iso', 'country',
);
-
$dao = CRM_Core_DAO::executeQuery($sql, $params);
while ($dao->fetch()) {
$row = array();