3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Report_Form_ActivitySummary
extends CRM_Report_Form
{
19 protected $_emailField = FALSE;
20 protected $_phoneField = FALSE;
21 protected $_tempTableName;
22 protected $_tempDurationSumTableName;
25 * This report has not been optimised for group filtering.
27 * The functionality for group filtering has been improved but not
28 * all reports have been adjusted to take care of it. This report has not
29 * and will run an inefficient query until fixed.
35 protected $groupFilterNotOptimised = TRUE;
40 public function __construct() {
42 'civicrm_contact' => [
43 'dao' => 'CRM_Contact_DAO_Contact',
50 'title' => ts('Contact Name'),
56 'title' => ts('Contact Name'),
62 'title' => ts('Contact'),
67 'title' => ts('Contact Name'),
70 'grouping' => 'contact-fields',
73 'dao' => 'CRM_Core_DAO_Email',
76 'title' => ts('Email'),
81 'title' => ts('Email'),
84 'grouping' => 'contact-fields',
87 'dao' => 'CRM_Core_DAO_Email',
90 'title' => ts('Phone'),
93 'grouping' => 'contact-fields',
95 'civicrm_activity' => [
96 'dao' => 'CRM_Activity_DAO_Activity',
98 'activity_type_id' => [
99 'title' => ts('Activity Type'),
101 'type' => CRM_Utils_Type
::T_STRING
,
104 'title' => ts('Activity Status'),
106 'type' => CRM_Utils_Type
::T_STRING
,
109 'title' => ts('Duration'),
113 'title' => ts('Priority'),
115 'type' => CRM_Utils_Type
::T_STRING
,
118 'title' => ts('Total Activities'),
121 'count' => ts('Count'),
126 'activity_date_time' => [
127 'operatorType' => CRM_Report_Form
::OP_DATE
,
129 'activity_type_id' => [
130 'title' => ts('Activity Type'),
132 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
133 'options' => CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, FALSE, 'label', TRUE),
136 'title' => ts('Activity Status'),
137 'type' => CRM_Utils_Type
::T_STRING
,
138 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
139 'options' => CRM_Core_PseudoConstant
::activityStatus(),
142 'title' => ts('Activity Priority'),
143 'type' => CRM_Utils_Type
::T_INT
,
144 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
145 'options' => CRM_Core_PseudoConstant
::get('CRM_Activity_DAO_Activity', 'priority_id'),
149 'activity_date_time' => [
150 'title' => ts('Activity Date'),
153 'activity_type_id' => [
154 'title' => ts('Activity Type'),
158 'title' => ts('Activity Status'),
163 'activity_date_time' => [
164 'title' => ts('Activity Date'),
166 'activity_type_id' => [
167 'title' => ts('Activity Type'),
170 'grouping' => 'activity-fields',
171 'alias' => 'activity',
174 $this->_groupFilter
= TRUE;
176 parent
::__construct();
179 public function select() {
181 $this->_columnHeaders
= [];
182 foreach ($this->_columns
as $tableName => $table) {
183 if (array_key_exists('group_bys', $table)) {
184 foreach ($table['group_bys'] as $fieldName => $field) {
185 if (!empty($this->_params
['group_bys'][$fieldName])) {
186 //include column in report when selected in group by but not in column section.
187 if (empty($this->_params
['fields'][$fieldName])) {
188 $this->_params
['fields'][$fieldName] = TRUE;
190 if (isset($this->_params
['group_bys_freq']) && !empty($this->_params
['group_bys_freq'][$fieldName])) {
191 switch ($this->_params
['group_bys_freq'][$fieldName]) {
193 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start";
195 $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
196 $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
197 $field['title'] = 'Week';
201 $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start";
202 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
203 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
204 $field['title'] = 'Year';
208 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start";
209 $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
210 $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
211 $field['title'] = 'Month';
215 $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start";
216 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
217 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
218 $field['title'] = 'Quarter';
221 $this->_interval
= $field['title'];
222 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['title'] = $field['title'] . ' Beginning';
223 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['type'] = $field['type'];
224 $this->_columnHeaders
["{$tableName}_{$fieldName}_start"]['group_by'] = $this->_params
['group_bys_freq'][$fieldName];
226 // just to make sure these values are transferred to rows.
227 // since we need that for calculation purpose,
228 // e.g making subtotals look nicer or graphs
229 $this->_columnHeaders
["{$tableName}_{$fieldName}_interval"] = ['no_display' => TRUE];
230 $this->_columnHeaders
["{$tableName}_{$fieldName}_subtotal"] = ['no_display' => TRUE];
235 if (array_key_exists('fields', $table)) {
236 foreach ($table['fields'] as $fieldName => $field) {
237 if (!empty($field['required']) ||
!empty($this->_params
['fields'][$fieldName])) {
238 if ($tableName == 'civicrm_email' ||
in_array('email', CRM_Utils_Array
::collect('column', $this->_params
['order_bys']))) {
239 $this->_emailField
= TRUE;
241 if ($tableName == 'civicrm_phone') {
242 $this->_phoneField
= TRUE;
244 if (!empty($field['statistics'])) {
245 foreach ($field['statistics'] as $stat => $label) {
246 switch (strtolower($stat)) {
248 $select[] = "COUNT(DISTINCT({$field['dbAlias']})) as {$tableName}_{$fieldName}_{$stat}";
249 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['type'] = CRM_Utils_Type
::T_INT
;
250 $this->_columnHeaders
["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
251 $this->_statFields
[] = "{$tableName}_{$fieldName}_{$stat}";
256 elseif ($fieldName == 'activity_type_id') {
257 if (empty($this->_params
['group_bys']['activity_type_id'])) {
258 $select[] = "GROUP_CONCAT(DISTINCT {$field['dbAlias']} ORDER BY {$field['dbAlias']} ) as {$tableName}_{$fieldName}";
261 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
263 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = $field['type'] ??
NULL;
264 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = $field['title'] ??
NULL;
265 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['no_display'] = $field['no_display'] ??
NULL;
268 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
269 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['type'] = $field['type'] ??
NULL;
270 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['title'] = $field['title'] ??
NULL;
271 $this->_columnHeaders
["{$tableName}_{$fieldName}"]['no_display'] = $field['no_display'] ??
NULL;
277 $this->_selectClauses
= $select;
279 $this->_select
= "SELECT " . implode(', ', $select) . " ";
283 * Generate from clause.
285 public function from() {
286 $activityContacts = CRM_Activity_BAO_ActivityContact
::buildOptions('record_type_id', 'validate');
287 $assigneeID = CRM_Utils_Array
::key('Activity Assignees', $activityContacts);
288 $targetID = CRM_Utils_Array
::key('Activity Targets', $activityContacts);
289 $sourceID = CRM_Utils_Array
::key('Activity Source', $activityContacts);
292 FROM civicrm_activity {$this->_aliases['civicrm_activity']}
294 LEFT JOIN civicrm_activity_contact target_activity
295 ON {$this->_aliases['civicrm_activity']}.id = target_activity.activity_id AND
296 target_activity.record_type_id = {$targetID}
297 LEFT JOIN civicrm_activity_contact assignment_activity
298 ON {$this->_aliases['civicrm_activity']}.id = assignment_activity.activity_id AND
299 assignment_activity.record_type_id = {$assigneeID}
300 LEFT JOIN civicrm_activity_contact source_activity
301 ON {$this->_aliases['civicrm_activity']}.id = source_activity.activity_id AND
302 source_activity.record_type_id = {$sourceID}
303 LEFT JOIN civicrm_contact contact_civireport
304 ON target_activity.contact_id = contact_civireport.id
305 LEFT JOIN civicrm_contact civicrm_contact_assignee
306 ON assignment_activity.contact_id = civicrm_contact_assignee.id
307 LEFT JOIN civicrm_contact civicrm_contact_source
308 ON source_activity.contact_id = civicrm_contact_source.id
310 LEFT JOIN civicrm_option_value
311 ON ( {$this->_aliases['civicrm_activity']}.activity_type_id = civicrm_option_value.value )
312 LEFT JOIN civicrm_option_group
313 ON civicrm_option_group.id = civicrm_option_value.option_group_id
314 LEFT JOIN civicrm_case_activity
315 ON civicrm_case_activity.activity_id = {$this->_aliases['civicrm_activity']}.id
316 LEFT JOIN civicrm_case
317 ON civicrm_case_activity.case_id = civicrm_case.id
318 LEFT JOIN civicrm_case_contact
319 ON civicrm_case_contact.case_id = civicrm_case.id ";
321 $this->joinPhoneFromContact();
323 $this->joinEmailFromContact();
327 * Generate from clause for when calculating activity durations.
329 public function activityDurationFrom() {
330 $activityContacts = CRM_Activity_BAO_ActivityContact
::buildOptions('record_type_id', 'validate');
331 $targetID = CRM_Utils_Array
::key('Activity Targets', $activityContacts);
333 FROM civicrm_activity {$this->_aliases['civicrm_activity']}
334 LEFT JOIN civicrm_activity_contact target_activity
335 ON {$this->_aliases['civicrm_activity']}.id = target_activity.activity_id AND
336 target_activity.record_type_id = {$targetID}
337 LEFT JOIN civicrm_contact contact_civireport
338 ON target_activity.contact_id = contact_civireport.id
341 // Email table is needed if sorting by Email.
342 $this->joinEmailFromContact();
346 * Generate where clause.
348 * @param bool $durationMode
350 public function where($durationMode = FALSE) {
351 $optionGroupClause = '';
352 if (!$durationMode) {
353 $optionGroupClause = 'civicrm_option_group.name = "activity_type" AND ';
355 $this->_where
= " WHERE {$optionGroupClause}
356 {$this->_aliases['civicrm_activity']}.is_test = 0 AND
357 {$this->_aliases['civicrm_activity']}.is_deleted = 0 AND
358 {$this->_aliases['civicrm_activity']}.is_current_revision = 1";
361 foreach ($this->_columns
as $tableName => $table) {
362 if (array_key_exists('filters', $table)) {
364 foreach ($table['filters'] as $fieldName => $field) {
366 if (CRM_Utils_Array
::value('type', $field) & CRM_Utils_Type
::T_DATE
) {
367 $relative = $this->_params
["{$fieldName}_relative"] ??
NULL;
368 $from = $this->_params
["{$fieldName}_from"] ??
NULL;
369 $to = $this->_params
["{$fieldName}_to"] ??
NULL;
371 $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type']);
374 $op = $this->_params
["{$fieldName}_op"] ??
NULL;
376 $clause = $this->whereClause($field,
378 CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
),
379 CRM_Utils_Array
::value("{$fieldName}_min", $this->_params
),
380 CRM_Utils_Array
::value("{$fieldName}_max", $this->_params
)
385 if (!empty($clause)) {
386 $clauses[] = $clause;
392 if (empty($clauses)) {
393 $this->_where
.= " ";
396 $this->_where
.= " AND " . implode(' AND ', $clauses);
399 if ($this->_aclWhere
&& !$durationMode) {
400 $this->_where
.= " AND ({$this->_aclWhere} OR civicrm_contact_source.is_deleted=0 OR civicrm_contact_assignee.is_deleted=0)";
405 * Build the report query.
407 * @param bool $applyLimit
411 public function buildQuery($applyLimit = TRUE) {
412 $this->buildGroupTempTable();
415 $this->customDataFrom();
416 $this->buildPermissionClause();
421 // Order by & Section columns not selected for display need to be included in SELECT.
422 $unselectedColumns = array_merge($this->unselectedOrderByColumns(), $this->unselectedSectionColumns());
423 foreach ($unselectedColumns as $alias => $field) {
424 $clause = $this->getSelectClauseWithGroupConcatIfNotGroupedBy($field['table_name'], $field['name'], $field);
426 $clause = "{$field['dbAlias']} as {$alias}";
428 $this->_select
.= ", $clause ";
431 if ($applyLimit && empty($this->_params
['charts'])) {
434 CRM_Utils_Hook
::alterReportVar('sql', $this, $this);
436 // build temporary table column names base on column headers of result
438 foreach ($this->_columnHeaders
as $fieldName => $dontCare) {
439 $dbColumns[] = $fieldName . ' VARCHAR(128)';
442 // Order by & Section columns not selected for display need to be included in temp table.
443 foreach ($unselectedColumns as $alias => $section) {
444 $dbColumns[] = $alias . ' VARCHAR(128)';
447 // create temp table to store main result
448 $this->_tempTableName
= $this->createTemporaryTable('tempTable', "
449 id int unsigned NOT NULL AUTO_INCREMENT, " . implode(', ', $dbColumns) . ' , PRIMARY KEY (id)',
452 // build main report query
453 $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
454 $this->addToDeveloperTab($sql);
456 // store the result in temporary table
458 $insertQuery = "INSERT INTO {$this->_tempTableName} ( " . implode(',', array_merge(array_keys($this->_columnHeaders
), array_keys($unselectedColumns))) . " )
460 CRM_Core_DAO
::disableFullGroupByMode();
461 CRM_Core_DAO
::executeQuery($insertQuery);
462 CRM_Core_DAO
::reenableFullGroupByMode();
464 // now build the query for duration sum
465 $this->activityDurationFrom();
467 $this->groupBy(FALSE);
469 // build the query to calulate duration sum
470 $sql = "SELECT SUM(activity_civireport.duration) as civicrm_activity_duration_total {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
472 // create temp table to store duration
473 $this->_tempDurationSumTableName
= $this->createTemporaryTable('tempDurationSumTable', "
474 id int unsigned NOT NULL AUTO_INCREMENT, civicrm_activity_duration_total VARCHAR(128), PRIMARY KEY (id)",
477 // store the result in temporary table
478 $insertQuery = "INSERT INTO {$this->_tempDurationSumTableName} (civicrm_activity_duration_total)
480 CRM_Core_DAO
::disableFullGroupByMode();
481 CRM_Core_DAO
::executeQuery($insertQuery);
482 CRM_Core_DAO
::reenableFullGroupByMode();
484 $sql = "SELECT {$this->_tempTableName}.*, {$this->_tempDurationSumTableName}.civicrm_activity_duration_total
485 FROM {$this->_tempTableName} INNER JOIN {$this->_tempDurationSumTableName}
486 ON ({$this->_tempTableName}.id = {$this->_tempDurationSumTableName}.id)";
488 // finally add duration total to column headers
489 $this->_columnHeaders
['civicrm_activity_duration_total'] = ['no_display' => 1];
491 // reset the sql building to default, which is used / called during other actions like "add to group"
501 * @param bool $includeSelectCol
503 public function groupBy($includeSelectCol = TRUE) {
504 $this->_groupBy
= [];
505 if (!empty($this->_params
['group_bys']) &&
506 is_array($this->_params
['group_bys'])) {
507 foreach ($this->_columns
as $tableName => $table) {
508 if (array_key_exists('group_bys', $table)) {
509 foreach ($table['group_bys'] as $fieldName => $field) {
510 if (!empty($this->_params
['group_bys'][$fieldName])) {
511 if (!empty($field['chart'])) {
512 $this->assign('chartSupported', TRUE);
514 if (!empty($table['group_bys'][$fieldName]['frequency']) &&
515 !empty($this->_params
['group_bys_freq'][$fieldName])
518 $append = "YEAR({$field['dbAlias']}),";
519 if (in_array(strtolower($this->_params
['group_bys_freq'][$fieldName]),
524 $this->_groupBy
[] = "$append {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})";
528 $this->_groupBy
[] = $field['dbAlias'];
534 $groupBy = $this->_groupBy
;
535 $this->_groupBy
= "GROUP BY " . implode(', ', $this->_groupBy
);
538 $groupBy = "{$this->_aliases['civicrm_activity']}.id";
539 $this->_groupBy
= "GROUP BY {$this->_aliases['civicrm_activity']}.id ";
541 if ($includeSelectCol) {
542 $this->_groupBy
= CRM_Contact_BAO_Query
::getGroupByFromSelectColumns($this->_selectClauses
, $groupBy);
553 public static function formRule($fields, $files, $self) {
555 $contactFields = ['sort_name', 'email', 'phone'];
556 if (!empty($fields['group_bys'])) {
557 if (!empty($fields['group_bys']['activity_date_time'])) {
558 if (!empty($fields['group_bys']['sort_name'])) {
559 $errors['fields'] = ts("Please do not select GroupBy 'Activity Date' with GroupBy 'Contact'");
562 foreach ($fields['fields'] as $fieldName => $val) {
563 if (in_array($fieldName, $contactFields)) {
564 $errors['fields'] = ts("Please do not select any Contact Fields with GroupBy 'Activity Date'");
572 // don't allow add to group action unless contact fields are selected.
573 if (isset($fields['_qf_ActivitySummary_submit_group'])) {
574 $contactFieldSelected = FALSE;
575 foreach ($fields['fields'] as $fieldName => $val) {
576 if (in_array($fieldName, $contactFields)) {
577 $contactFieldSelected = TRUE;
582 if (!$contactFieldSelected) {
583 $errors['fields'] = ts('You cannot use "Add Contacts to Group" action unless contacts fields are selected.');
594 public function statistics(&$rows) {
595 $statistics = parent
::statistics($rows);
596 $totalType = $totalActivity = $totalDuration = 0;
598 $query = "SELECT {$this->_tempTableName}.civicrm_activity_activity_type_id,
599 {$this->_tempTableName}.civicrm_activity_id_count,
600 {$this->_tempDurationSumTableName}.civicrm_activity_duration_total
601 FROM {$this->_tempTableName} INNER JOIN {$this->_tempDurationSumTableName}
602 ON ({$this->_tempTableName}.id = {$this->_tempDurationSumTableName}.id)";
604 $actDAO = CRM_Core_DAO
::executeQuery($query);
606 $activityTypesCount = [];
607 while ($actDAO->fetch()) {
608 if (!in_array($actDAO->civicrm_activity_activity_type_id
, $activityTypesCount)) {
609 $activityTypesCount[] = $actDAO->civicrm_activity_activity_type_id
;
612 $totalActivity +
= $actDAO->civicrm_activity_id_count
;
613 $totalDuration +
= $actDAO->civicrm_activity_duration_total
;
616 $totalType = count($activityTypesCount);
618 $statistics['counts']['type'] = [
619 'title' => ts('Total Types'),
620 'value' => $totalType,
622 $statistics['counts']['activities'] = [
623 'title' => ts('Total Number of Activities'),
624 'value' => $totalActivity,
626 $statistics['counts']['duration'] = [
627 'title' => ts('Total Duration (in Minutes)'),
628 'value' => $totalDuration,
633 public function modifyColumnHeaders() {
634 //CRM-16719 modify name of column
635 if (!empty($this->_columnHeaders
['civicrm_activity_status_id'])) {
636 $this->_columnHeaders
['civicrm_activity_status_id']['title'] = ts('Status');
641 * Alter display of rows.
643 * Iterate through the rows retrieved via SQL and make changes for display purposes,
644 * such as rendering contacts as links.
647 * Rows generated by SQL, with an array for each row.
649 public function alterDisplay(&$rows) {
651 $activityType = CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
652 $activityStatus = CRM_Core_PseudoConstant
::activityStatus();
653 $priority = CRM_Core_PseudoConstant
::get('CRM_Activity_DAO_Activity', 'priority_id');
654 $onHover = ts('View Contact Summary for this Contact');
655 foreach ($rows as $rowNum => $row) {
656 // make count columns point to activity detail report
657 if (!empty($row['civicrm_activity_id_count'])) {
659 $urlParams = ['activity_type_id', 'gid', 'status_id', 'contact_id'];
660 foreach ($urlParams as $field) {
661 if (!empty($row['civicrm_activity_' . $field])) {
662 $url[] = "{$field}_op=in&{$field}_value={$row['civicrm_activity_'.$field]}";
664 elseif (!empty($this->_params
[$field . '_value'])) {
665 $val = implode(",", $this->_params
[$field . '_value']);
666 $url[] = "{$field}_op=in&{$field}_value={$val}";
669 $date_suffixes = ['relative', 'from', 'to'];
670 foreach ($date_suffixes as $suffix) {
671 if (!empty($this->_params
['activity_date_time_' . $suffix])) {
674 CRM_Utils_Array
::value("activity_date_time_relative", $this->_params
),
675 CRM_Utils_Array
::value("activity_date_time_from", $this->_params
),
676 CRM_Utils_Array
::value("activity_date_time_to", $this->_params
)
678 $url[] = "activity_date_time_from={$from}&activity_date_time_to={$to}";
682 // reset date filter on activity reports.
683 $url[] = "resetDateFilter=1";
684 $url = implode('&', $url);
685 $url = CRM_Report_Utils_Report
::getNextUrl('activity', "reset=1&force=1&{$url}",
688 $this->_drilldownReport
);
689 $rows[$rowNum]['civicrm_activity_id_count_link'] = $url;
690 $rows[$rowNum]['civicrm_activity_id_count_hover'] = ts('List all activity(s) for this row.');
694 if (array_key_exists('civicrm_contact_sort_name', $row) && $this->_outputMode
!= 'csv') {
695 if ($value = $row['civicrm_contact_id']) {
697 // unset the name, email and phone fields if the contact is the same as the previous contact
698 if (isset($previousContact) && $previousContact == $value) {
699 $rows[$rowNum]['civicrm_contact_sort_name'] = "";
701 if (array_key_exists('civicrm_email_email', $row)) {
702 $rows[$rowNum]['civicrm_email_email'] = "";
704 if (array_key_exists('civicrm_phone_phone', $row)) {
705 $rows[$rowNum]['civicrm_phone_phone'] = "";
709 $url = CRM_Utils_System
::url('civicrm/contact/view',
710 'reset=1&cid=' . $value,
714 $rows[$rowNum]['civicrm_contact_sort_name'] = "<a href='$url'>" . $row['civicrm_contact_sort_name'] .
718 // store the contact ID of this contact
719 $previousContact = $value;
724 if (array_key_exists('civicrm_activity_activity_type_id', $row)) {
725 if ($value = $row['civicrm_activity_activity_type_id']) {
727 $value = explode(',', $value);
728 foreach ($value as $key => $id) {
729 $value[$key] = $activityType[$id];
732 $rows[$rowNum]['civicrm_activity_activity_type_id'] = implode(' , ', $value);
737 if (array_key_exists('civicrm_activity_status_id', $row)) {
738 if ($value = $row['civicrm_activity_status_id']) {
739 $rows[$rowNum]['civicrm_activity_status_id'] = $activityStatus[$value];
744 if (array_key_exists('civicrm_activity_priority_id', $row)) {
745 if ($value = $row['civicrm_activity_priority_id']) {
746 $rows[$rowNum]['civicrm_activity_priority_id'] = $priority[$value];
751 if (array_key_exists('civicrm_activity_duration', $row)) {
752 if ($value = $row['civicrm_activity_duration']) {
753 $rows[$rowNum]['civicrm_activity_duration'] = $rows[$rowNum]['civicrm_activity_duration_total'];