3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
35 class CRM_Report_Form_Activity
extends CRM_Report_Form
{
36 protected $_selectAliasesTotal = array();
38 protected $_customGroupExtends = array(
42 protected $_nonDisplayFields = array();
44 function __construct() {
45 // There could be multiple contacts. We not clear on which contact id to display.
46 // Lets hide it for now.
47 $this->_exposeContactID
= FALSE;
49 $config = CRM_Core_Config
::singleton();
50 $campaignEnabled = in_array("CiviCampaign", $config->enableComponents
);
51 if ($campaignEnabled) {
52 $getCampaigns = CRM_Campaign_BAO_Campaign
::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
53 $this->activeCampaigns
= $getCampaigns['campaigns'];
54 asort($this->activeCampaigns
);
55 $this->engagementLevels
= CRM_Campaign_PseudoConstant
::engagementLevel();
57 $this->activityTypes
= CRM_Core_PseudoConstant
::activityType(TRUE, FALSE, FALSE, 'label', TRUE);
58 asort($this->activityTypes
);
60 $this->_columns
= array(
63 'dao' => 'CRM_Contact_DAO_Contact',
68 'name' => 'sort_name',
69 'title' => ts('Source Contact Name'),
70 'alias' => 'civicrm_contact_source',
75 'name' => 'sort_name',
76 'title' => ts('Assignee Contact Name'),
77 'alias' => 'civicrm_contact_assignee',
78 'dbAlias' => "civicrm_contact_assignee.sort_name",
83 'name' => 'sort_name',
84 'title' => ts('Target Contact Name'),
85 'alias' => 'civicrm_contact_target',
86 'dbAlias' => "civicrm_contact_target.sort_name",
89 'contact_source_id' =>
92 'alias' => 'civicrm_contact_source',
93 'dbAlias' => "civicrm_contact_source.id",
98 'contact_assignee_id' =>
101 'alias' => 'civicrm_contact_assignee',
102 'dbAlias' => "civicrm_contact_assignee.id",
103 'no_display' => TRUE,
107 'contact_target_id' =>
110 'alias' => 'civicrm_contact_target',
111 'dbAlias' => "civicrm_contact_target.id",
112 'no_display' => TRUE,
121 'name' => 'sort_name',
122 'alias' => 'civicrm_contact_source',
123 'title' => ts('Source Contact Name'),
124 'operator' => 'like',
125 'type' => CRM_Report_Form
::OP_STRING
,
127 'contact_assignee' =>
129 'name' => 'sort_name',
130 'alias' => 'civicrm_contact_assignee',
131 'title' => ts('Assignee Contact Name'),
132 'operator' => 'like',
133 'type' => CRM_Report_Form
::OP_STRING
,
137 'name' => 'sort_name',
138 'alias' => 'civicrm_contact_target',
139 'title' => ts('Target Contact Name'),
140 'operator' => 'like',
141 'type' => CRM_Report_Form
::OP_STRING
,
145 'name' => 'current_user',
146 'title' => ts('Limit To Current User'),
147 'type' => CRM_Utils_Type
::T_INT
,
148 'operatorType' => CRM_Report_Form
::OP_SELECT
,
149 'options' => array('0' => ts('No'), '1' => ts('Yes')),
152 'grouping' => 'contact-fields',
156 'dao' => 'CRM_Core_DAO_Email',
159 'contact_source_email' =>
162 'title' => ts('Source Contact Email'),
163 'alias' => 'civicrm_email_source',
165 'contact_assignee_email' =>
168 'title' => ts('Assignee Contact Email'),
169 'alias' => 'civicrm_email_assignee',
171 'contact_target_email' =>
174 'title' => ts('Target Contact Email'),
175 'alias' => 'civicrm_email_target',
180 'source_contact_email' =>
183 'title' => ts('Source Contact Email'),
184 'dbAlias' => 'civicrm_email_contact_source_email',
188 'civicrm_activity' =>
190 'dao' => 'CRM_Activity_DAO_Activity',
195 'no_display' => TRUE,
196 'title' => ts('Activity ID'),
199 'source_record_id' =>
201 'no_display' => TRUE,
204 'activity_type_id' =>
205 array('title' => ts('Activity Type'),
207 'type' => CRM_Utils_Type
::T_STRING
,
209 'activity_subject' =>
210 array('title' => ts('Subject'),
213 'activity_date_time' =>
214 array('title' => ts('Activity Date'),
218 array('title' => ts('Activity Status'),
220 'type' => CRM_Utils_Type
::T_STRING
,
223 array('title' => ts('Duration'),
224 'type' => CRM_Utils_Type
::T_INT
,
227 'title' => ts('Activity Details'),
231 'activity_date_time' => array(
232 'default' => 'this.month',
233 'operatorType' => CRM_Report_Form
::OP_DATE
,
235 'activity_subject' =>
236 array('title' => ts('Activity Subject')),
237 'activity_type_id' =>
238 array('title' => ts('Activity Type'),
239 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
240 'options' => $this->activityTypes
,
243 array('title' => ts('Activity Status'),
244 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
245 'options' => CRM_Core_PseudoConstant
::activityStatus(),
248 'title' => ts('Activity Details'),
249 'type' => CRM_Utils_Type
::T_TEXT
,
252 'order_bys' => array(
253 'activity_date_time' =>
254 array('title' => ts('Activity Date'), 'default_weight' => '1', 'dbAlias' => 'civicrm_activity_activity_date_time'),
255 'activity_type_id' =>
256 array('title' => ts('Activity Type'), 'default_weight' => '2', 'dbAlias' => 'civicrm_activity_activity_type_id'),
258 'grouping' => 'activity-fields',
259 'alias' => 'activity',
261 'civicrm_activity_contact' =>
263 'dao' => 'CRM_Activity_DAO_ActivityContact',
266 // so we have $this->_alias populated
269 ) +
$this->addAddressFields(FALSE, TRUE);
271 if ($campaignEnabled) {
272 // Add display column and filter for Survey Results, Campaign and Engagement Index if CiviCampaign is enabled
274 $this->_columns
['civicrm_activity']['fields']['result'] = array(
275 'title' => 'Survey Result',
276 'default' => 'false',
278 $this->_columns
['civicrm_activity']['filters']['result'] = array('title' => ts('Survey Result'),
279 'operator' => 'like',
280 'type' => CRM_Utils_Type
::T_STRING
,
282 if (!empty($this->activeCampaigns
)) {
283 $this->_columns
['civicrm_activity']['fields']['campaign_id'] = array(
284 'title' => 'Campaign',
285 'default' => 'false',
287 $this->_columns
['civicrm_activity']['filters']['campaign_id'] = array('title' => ts('Campaign'),
288 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
289 'options' => $this->activeCampaigns
,
292 if (!empty($this->engagementLevels
)) {
293 $this->_columns
['civicrm_activity']['fields']['engagement_level'] = array(
294 'title' => 'Engagement Index',
295 'default' => 'false',
297 $this->_columns
['civicrm_activity']['filters']['engagement_level'] = array('title' => ts('Engagement Index'),
298 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
299 'options' => $this->engagementLevels
,
303 $this->_groupFilter
= TRUE;
304 $this->_tagFilter
= TRUE;
305 parent
::__construct();
308 function select($recordType = NULL) {
309 if (!array_key_exists("contact_{$recordType}", $this->_params
['fields']) && $recordType != 'final') {
310 $this->_nonDisplayFields
[] = "civicrm_contact_contact_{$recordType}";
311 $this->_params
['fields']["contact_{$recordType}"] = 1;
315 if ($recordType == 'final' && !empty($this->_nonDisplayFields
)) {
316 foreach ($this->_nonDisplayFields
as $fieldName) {
317 unset($this->_columnHeaders
[$fieldName]);
321 if (empty($this->_selectAliasesTotal
)) {
322 $this->_selectAliasesTotal
= $this->_selectAliases
;
325 $removeKeys = array();
326 if ($recordType == 'target') {
327 foreach ($this->_selectClauses
as $key => $clause) {
328 if (strstr($clause, 'civicrm_contact_assignee.') ||
329 strstr($clause, 'civicrm_contact_source.') ||
330 strstr($clause, 'civicrm_email_assignee.') ||
331 strstr($clause, 'civicrm_email_source.')
333 $removeKeys[] = $key;
334 unset($this->_selectClauses
[$key]);
337 } else if ($recordType == 'assignee') {
338 foreach ($this->_selectClauses
as $key => $clause) {
339 if (strstr($clause, 'civicrm_contact_target.') ||
340 strstr($clause, 'civicrm_contact_source.') ||
341 strstr($clause, 'civicrm_email_target.') ||
342 strstr($clause, 'civicrm_email_source.')
344 $removeKeys[] = $key;
345 unset($this->_selectClauses
[$key]);
348 } else if ($recordType == 'source') {
349 foreach ($this->_selectClauses
as $key => $clause) {
350 if (strstr($clause, 'civicrm_contact_target.') ||
351 strstr($clause, 'civicrm_contact_assignee.') ||
352 strstr($clause, 'civicrm_email_target.') ||
353 strstr($clause, 'civicrm_email_assignee.')
355 $removeKeys[] = $key;
356 unset($this->_selectClauses
[$key]);
359 } else if ($recordType == 'final') {
360 $this->_selectClauses
= $this->_selectAliasesTotal
;
361 foreach ($this->_selectClauses
as $key => $clause) {
362 if (strstr($clause, 'civicrm_contact_contact_target') ||
363 strstr($clause, 'civicrm_contact_contact_assignee') ||
364 strstr($clause, 'civicrm_contact_contact_source') ) {
365 $this->_selectClauses
[$key] = "GROUP_CONCAT($clause SEPARATOR ';') as $clause";
371 foreach ($removeKeys as $key) {
372 unset($this->_selectAliases
[$key]);
375 $this->_select
= "SELECT " . implode(', ', $this->_selectClauses
) . " ";
379 function from($recordType) {
380 $activityContacts = CRM_Core_OptionGroup
::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
381 $assigneeID = CRM_Utils_Array
::key('Activity Assignees', $activityContacts);
382 $targetID = CRM_Utils_Array
::key('Activity Targets', $activityContacts);
383 $sourceID = CRM_Utils_Array
::key('Activity Source', $activityContacts);
385 if ($recordType == 'target') {
387 FROM civicrm_activity {$this->_aliases['civicrm_activity']}
388 INNER JOIN civicrm_activity_contact {$this->_aliases['civicrm_activity_contact']}
389 ON {$this->_aliases['civicrm_activity']}.id = {$this->_aliases['civicrm_activity_contact']}.activity_id AND
390 {$this->_aliases['civicrm_activity_contact']}.record_type_id = {$targetID}
391 INNER JOIN civicrm_contact civicrm_contact_target
392 ON {$this->_aliases['civicrm_activity_contact']}.contact_id = civicrm_contact_target.id
395 if ($this->isTableSelected('civicrm_email')) {
397 LEFT JOIN civicrm_email civicrm_email_target
398 ON {$this->_aliases['civicrm_activity_contact']}.contact_id = civicrm_email_target.contact_id AND
399 civicrm_email_target.is_primary = 1";
401 $this->_aliases
['civicrm_contact'] = 'civicrm_contact_target';
404 if ($recordType == 'assignee') {
406 FROM civicrm_activity {$this->_aliases['civicrm_activity']}
407 INNER JOIN civicrm_activity_contact {$this->_aliases['civicrm_activity_contact']}
408 ON {$this->_aliases['civicrm_activity']}.id = {$this->_aliases['civicrm_activity_contact']}.activity_id AND
409 {$this->_aliases['civicrm_activity_contact']}.record_type_id = {$assigneeID}
410 INNER JOIN civicrm_contact civicrm_contact_assignee
411 ON {$this->_aliases['civicrm_activity_contact']}.contact_id = civicrm_contact_assignee.id
414 if ($this->isTableSelected('civicrm_email')) {
416 LEFT JOIN civicrm_email civicrm_email_assignee
417 ON {$this->_aliases['civicrm_activity_contact']}.contact_id = civicrm_email_assignee.contact_id AND
418 civicrm_email_assignee.is_primary = 1";
420 $this->_aliases
['civicrm_contact'] = 'civicrm_contact_assignee';
423 if ($recordType == 'source') {
425 FROM civicrm_activity {$this->_aliases['civicrm_activity']}
426 INNER JOIN civicrm_activity_contact {$this->_aliases['civicrm_activity_contact']}
427 ON {$this->_aliases['civicrm_activity']}.id = {$this->_aliases['civicrm_activity_contact']}.activity_id AND
428 {$this->_aliases['civicrm_activity_contact']}.record_type_id = {$sourceID}
429 INNER JOIN civicrm_contact civicrm_contact_source
430 ON {$this->_aliases['civicrm_activity_contact']}.contact_id = civicrm_contact_source.id
433 if ($this->isTableSelected('civicrm_email')) {
435 LEFT JOIN civicrm_email civicrm_email_source
436 ON {$this->_aliases['civicrm_activity_contact']}.contact_id = civicrm_email_source.contact_id AND
437 civicrm_email_source.is_primary = 1";
439 $this->_aliases
['civicrm_contact'] = 'civicrm_contact_source';
441 $this->addAddressFromClause();
444 function where($recordType = NULL) {
445 $this->_where
= " WHERE {$this->_aliases['civicrm_activity']}.is_test = 0 AND
446 {$this->_aliases['civicrm_activity']}.is_deleted = 0 AND
447 {$this->_aliases['civicrm_activity']}.is_current_revision = 1";
450 foreach ($this->_columns
as $tableName => $table) {
451 if (array_key_exists('filters', $table)) {
453 foreach ($table['filters'] as $fieldName => $field) {
455 if ($fieldName != 'contact_' . $recordType &&
456 (strstr($fieldName, '_target') ||
457 strstr($fieldName, '_assignee') ||
458 strstr($fieldName, '_source')
463 if (CRM_Utils_Array
::value('type', $field) & CRM_Utils_Type
::T_DATE
) {
464 $relative = CRM_Utils_Array
::value("{$fieldName}_relative", $this->_params
);
465 $from = CRM_Utils_Array
::value("{$fieldName}_from", $this->_params
);
466 $to = CRM_Utils_Array
::value("{$fieldName}_to", $this->_params
);
468 $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
471 $op = CRM_Utils_Array
::value("{$fieldName}_op", $this->_params
);
472 if ($op && ($op != 'nnll' ||
$op != 'nll')) {
473 $clause = $this->whereClause($field,
475 CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
),
476 CRM_Utils_Array
::value("{$fieldName}_min", $this->_params
),
477 CRM_Utils_Array
::value("{$fieldName}_max", $this->_params
)
482 if ($field['name'] == 'current_user') {
483 if (CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
) == 1) {
485 $session = CRM_Core_Session
::singleton();
486 if ($contactID = $session->get('userID')) {
487 $clause = "{$this->_aliases['civicrm_activity_contact']}.activity_id IN
488 (SELECT activity_id FROM civicrm_activity_contact WHERE contact_id = {$contactID})";
498 if (!empty($clause)) {
499 $clauses[] = $clause;
505 if (empty($clauses)) {
506 $this->_where
.= " ";
509 $this->_where
.= " AND " . implode(' AND ', $clauses);
512 if ($this->_aclWhere
) {
513 $this->_where
.= " AND {$this->_aclWhere} ";
518 $this->_groupBy
= "GROUP BY {$this->_aliases['civicrm_activity']}.id";
521 function buildACLClause($tableAlias = 'contact_a') {
522 //override for ACL( Since Contact may be source
523 //contact/assignee or target also it may be null )
525 if (CRM_Core_Permission
::check('view all contacts')) {
526 $this->_aclFrom
= $this->_aclWhere
= NULL;
530 $session = CRM_Core_Session
::singleton();
531 $contactID = $session->get('userID');
535 $contactID = CRM_Utils_Type
::escape($contactID, 'Integer');
537 CRM_Contact_BAO_Contact_Permission
::cache($contactID);
539 foreach ($tableAlias as $k => $alias) {
540 $clauses[] = " INNER JOIN civicrm_acl_contact_cache aclContactCache_{$k} ON ( {$alias}.id = aclContactCache_{$k}.contact_id OR {$alias}.id IS NULL ) AND aclContactCache_{$k}.user_id = $contactID ";
543 $this->_aclFrom
= implode(" ", $clauses);
544 $this->_aclWhere
= NULL;
547 function add2group($groupID) {
548 if (CRM_Utils_Array
::value("contact_target_op", $this->_params
) == 'nll') {
549 CRM_Core_Error
::fatal(ts('Current filter criteria didn\'t have any target contact to add to group'));
552 $query = "{$this->_select}
553 FROM civireport_activity_temp_target tar
554 GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy}";
555 $select = 'AS addtogroup_contact_id';
556 $query = str_ireplace('AS civicrm_contact_contact_target_id', $select, $query);
557 $dao = CRM_Core_DAO
::executeQuery($query);
559 $contactIDs = array();
560 // Add resulting contacts to group
561 while ($dao->fetch()) {
562 if ($dao->addtogroup_contact_id
) {
563 $contact_id = explode(';', $dao->addtogroup_contact_id
);
564 if ($contact_id[0]) {
565 $contactIDs[$contact_id[0]] = $contact_id[0];
570 if ( !empty($contactIDs) ) {
571 CRM_Contact_BAO_GroupContact
::addContactsToGroup($contactIDs, $groupID);
572 CRM_Core_Session
::setStatus(ts("Listed contact(s) have been added to the selected group."), ts('Contacts Added'), 'success');
575 CRM_Core_Session
::setStatus(ts("The listed records(s) cannot be added to the group."));
579 function postProcess() {
580 $this->beginPostProcess();
582 //Assign those recordtype to array which have filter operator as 'Is not empty' or 'Is empty'
583 $nullFilters = array();
584 foreach (array('target', 'source', 'assignee') as $type) {
585 if (CRM_Utils_Array
::value("contact_{$type}_op", $this->_params
) == 'nnll' ||
!empty($this->_params
["contact_{$type}_value"])) {
586 $nullFilters[] = " civicrm_contact_contact_{$type} IS NOT NULL ";
588 else if (CRM_Utils_Array
::value("contact_{$type}_op", $this->_params
) == 'nll') {
589 $nullFilters[] = " civicrm_contact_contact_{$type} IS NULL ";
593 // 1. fill temp table with target results
594 $this->buildACLClause(array('civicrm_contact_target'));
595 $this->select('target');
596 $this->from('target');
597 $this->customDataFrom();
598 $this->where('target');
599 $insertCols = implode(',', $this->_selectAliases
);
600 $tempQuery = "CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COLLATE utf8_unicode_ci AS
601 {$this->_select} {$this->_from} {$this->_where} ";
602 CRM_Core_DAO
::executeQuery($tempQuery);
604 // 2. add new columns to hold assignee and source results
605 // fixme: add when required
607 ALTER TABLE civireport_activity_temp_target
608 ADD COLUMN civicrm_contact_contact_assignee VARCHAR(128),
609 ADD COLUMN civicrm_contact_contact_source VARCHAR(128),
610 ADD COLUMN civicrm_contact_contact_assignee_id VARCHAR(128),
611 ADD COLUMN civicrm_contact_contact_source_id VARCHAR(128),
612 ADD COLUMN civicrm_email_contact_assignee_email VARCHAR(128),
613 ADD COLUMN civicrm_email_contact_source_email VARCHAR(128)";
614 CRM_Core_DAO
::executeQuery($tempQuery);
616 // 3. fill temp table with assignee results
617 $this->buildACLClause(array('civicrm_contact_assignee'));
618 $this->select('assignee');
619 $this->from('assignee');
620 $this->customDataFrom();
621 $this->where('assignee');
622 $insertCols = implode(',', $this->_selectAliases
);
623 $tempQuery = "INSERT INTO civireport_activity_temp_target ({$insertCols})
625 {$this->_from} {$this->_where}";
626 CRM_Core_DAO
::executeQuery($tempQuery);
628 // 4. fill temp table with source results
629 $this->buildACLClause(array('civicrm_contact_source'));
630 $this->select('source');
631 $this->from('source');
632 $this->customDataFrom();
633 $this->where('source');
634 $insertCols = implode(',', $this->_selectAliases
);
635 $tempQuery = "INSERT INTO civireport_activity_temp_target ({$insertCols})
637 {$this->_from} {$this->_where}";
638 CRM_Core_DAO
::executeQuery($tempQuery);
640 // 5. show final result set from temp table
642 $this->select('final');
644 if (!empty($nullFilters)) {
645 $this->_having
= "HAVING " . implode(' AND ', $nullFilters);
649 $sql = "{$this->_select}
650 FROM civireport_activity_temp_target tar
651 GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy} {$this->_limit}";
652 $this->buildRows($sql, $rows);
654 // format result set.
655 $this->formatDisplay($rows);
657 // assign variables to templates
658 $this->doTemplateAssignment($rows);
660 // do print / pdf / instance stuff if needed
661 $this->endPostProcess($rows);
664 function alterDisplay(&$rows) {
665 // custom code to alter rows
668 $activityType = CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
669 $activityStatus = CRM_Core_PseudoConstant
::activityStatus();
671 $seperator = CRM_Core_DAO
::VALUE_SEPARATOR
;
672 $context = CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'report');
675 if (CRM_Core_Permission
::check('access CiviCRM')) {
677 $onHover = ts('View Contact Summary for this Contact');
678 $onHoverAct = ts('View Activity Record');
681 foreach ($rows as $rowNum => $row) {
682 // if we have an activity type, format the View Activity link for use in various columns
683 if ($viewLinks && array_key_exists('civicrm_activity_activity_type_id', $row)) {
684 // Check for target contact id(s) and use the first contact id in that list for view activity link if found,
685 // else use source contact id
686 if (!empty($rows[$rowNum]['civicrm_contact_contact_target_id'])) {
687 $targets = explode(';', $rows[$rowNum]['civicrm_contact_contact_target_id']);
691 $cid = $rows[$rowNum]['civicrm_contact_contact_source_id'];
694 $actActionLinks = CRM_Activity_Selector_Activity
::actionLinks($row['civicrm_activity_activity_type_id'],
695 CRM_Utils_Array
::value('civicrm_activity_source_record_id', $rows[$rowNum]),
697 $rows[$rowNum]['civicrm_activity_id']
700 $actLinkValues = array(
701 'id' => $rows[$rowNum]['civicrm_activity_id'],
705 $actUrl = CRM_Utils_System
::url($actActionLinks[CRM_Core_Action
::VIEW
]['url'],
706 CRM_Core_Action
::replace($actActionLinks[CRM_Core_Action
::VIEW
]['qs'], $actLinkValues), TRUE
710 if (array_key_exists('civicrm_contact_contact_source', $row)) {
711 if ($value = $row['civicrm_contact_contact_source_id']) {
713 $url = CRM_Utils_System
::url("civicrm/contact/view",
714 'reset=1&cid=' . $value,
717 $rows[$rowNum]['civicrm_contact_contact_source_link'] = $url;
718 $rows[$rowNum]['civicrm_contact_contact_source_hover'] = $onHover;
724 if (array_key_exists('civicrm_contact_contact_assignee', $row)) {
725 $assigneeNames = explode(';', $row['civicrm_contact_contact_assignee']);
726 if ($value = $row['civicrm_contact_contact_assignee_id']) {
727 $assigneeContactIds = explode(';', $value);
730 foreach ($assigneeContactIds as $id => $value) {
731 if (isset($value) && isset($assigneeNames[$id])) {
732 $url = CRM_Utils_System
::url("civicrm/contact/view",
733 'reset=1&cid=' . $value,
736 $link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$assigneeNames[$id]}</a>";
739 $rows[$rowNum]['civicrm_contact_contact_assignee'] = implode('; ', $link);
745 if (array_key_exists('civicrm_contact_contact_target', $row)) {
746 $targetNames = explode(';', $row['civicrm_contact_contact_target']);
747 if ($value = $row['civicrm_contact_contact_target_id']) {
748 $targetContactIds = explode(';', $value);
751 foreach ($targetContactIds as $id => $value) {
752 if (isset($value) && isset($targetNames[$id])) {
753 $url = CRM_Utils_System
::url("civicrm/contact/view",
754 'reset=1&cid=' . $value,
757 $link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$targetNames[$id]}</a>";
760 $rows[$rowNum]['civicrm_contact_contact_target'] = implode('; ', $link);
766 if (array_key_exists('civicrm_activity_activity_type_id', $row)) {
767 if ($value = $row['civicrm_activity_activity_type_id']) {
768 $rows[$rowNum]['civicrm_activity_activity_type_id'] = $activityType[$value];
770 $rows[$rowNum]['civicrm_activity_activity_type_id_link'] = $actUrl;
771 $rows[$rowNum]['civicrm_activity_activity_type_id_hover'] = $onHoverAct;
777 if (array_key_exists('civicrm_activity_status_id', $row)) {
778 if ($value = $row['civicrm_activity_status_id']) {
779 $rows[$rowNum]['civicrm_activity_status_id'] = $activityStatus[$value];
784 if (array_key_exists('civicrm_activity_details', $row)) {
785 if ($value = $row['civicrm_activity_details']) {
786 $fullDetails = $rows[$rowNum]['civicrm_activity_details'];
787 $rows[$rowNum]['civicrm_activity_details'] = substr($fullDetails, 0, strrpos(substr($fullDetails, 0, 80), ' '));
789 $rows[$rowNum]['civicrm_activity_details'] .= " <a href='{$actUrl}' title='{$onHoverAct}'>(more)</a>";
795 if (array_key_exists('civicrm_activity_campaign_id', $row)) {
796 if ($value = $row['civicrm_activity_campaign_id']) {
797 $rows[$rowNum]['civicrm_activity_campaign_id'] = $this->activeCampaigns
[$value];
802 if (array_key_exists('civicrm_activity_engagement_level', $row)) {
803 if ($value = $row['civicrm_activity_engagement_level']) {
804 $rows[$rowNum]['civicrm_activity_engagement_level'] = $this->engagementLevels
[$value];
809 if (array_key_exists('civicrm_activity_activity_date_time', $row) && array_key_exists('civicrm_activity_status_id', $row)) {
810 if (CRM_Utils_Date
::overdue($rows[$rowNum]['civicrm_activity_activity_date_time']) &&
811 $activityStatus[$row['civicrm_activity_status_id']] != 'Completed'
813 $rows[$rowNum]['class'] = "status-overdue";
818 $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'activity', 'List all activities for this ') ?
TRUE : $entryFound;