Merge pull request #6496 from totten/master-regen-leak
[civicrm-core.git] / CRM / Report / Form / ActivitySummary.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2015
32 * $Id$
33 *
34 */
35 class CRM_Report_Form_ActivitySummary extends CRM_Report_Form {
36
37 protected $_emailField = FALSE;
38 protected $_phoneField = FALSE;
39
40 /**
41 */
42 /**
43 */
44 public function __construct() {
45 $this->_columns = array(
46 'civicrm_contact' => array(
47 'dao' => 'CRM_Contact_DAO_Contact',
48 'fields' => array(
49 'id' => array(
50 'required' => TRUE,
51 'no_display' => TRUE,
52 ),
53 'sort_name' => array(
54 'title' => ts('Contact Name'),
55 'default' => TRUE,
56 'no_repeat' => TRUE,
57 ),
58 ),
59 'filters' => array(
60 'sort_name' => array(
61 'title' => ts('Contact Name'),
62 ),
63 ),
64 'group_bys' => array(
65 'sort_name' => array(
66 'name' => 'id',
67 'title' => ts('Contact'),
68 'default' => TRUE,
69 ),
70 ),
71 'order_bys' => array(
72 'sort_name' => array(
73 'title' => ts('Contact Name'),
74 ),
75 ),
76 'grouping' => 'contact-fields',
77 ),
78 'civicrm_email' => array(
79 'dao' => 'CRM_Core_DAO_Email',
80 'fields' => array(
81 'email' => array(
82 'title' => 'Email',
83 'default' => TRUE,
84 ),
85 ),
86 'order_bys' => array(
87 'email' => array(
88 'title' => ts('Email'),
89 ),
90 ),
91 'grouping' => 'contact-fields',
92 ),
93 'civicrm_phone' => array(
94 'dao' => 'CRM_Core_DAO_Email',
95 'fields' => array(
96 'phone' => array(
97 'title' => 'Phone',
98 ),
99 ),
100 'grouping' => 'contact-fields',
101 ),
102 'civicrm_activity' => array(
103 'dao' => 'CRM_Activity_DAO_Activity',
104 'fields' => array(
105 'activity_type_id' => array(
106 'title' => ts('Activity Type'),
107 'required' => TRUE,
108 'type' => CRM_Utils_Type::T_STRING,
109 ),
110 'status_id' => array(
111 'title' => ts('Activity Status'),
112 'default' => TRUE,
113 'type' => CRM_Utils_Type::T_STRING,
114 ),
115 'duration' => array(
116 'title' => 'Duration',
117 'statistics' => array(
118 'sum' => ts('Duration'),
119 ),
120 ),
121 'id' => array(
122 'title' => 'Total Activities',
123 'required' => TRUE,
124 'statistics' => array(
125 'count' => ts('Count'),
126 ),
127 ),
128 ),
129 'filters' => array(
130 'activity_date_time' => array(
131 'operatorType' => CRM_Report_Form::OP_DATE,
132 ),
133 'activity_type_id' => array(
134 'title' => ts('Activity Type'),
135 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
136 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE),
137 ),
138 'status_id' => array(
139 'title' => ts('Activity Status'),
140 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
141 'options' => CRM_Core_PseudoConstant::activityStatus(),
142 ),
143 'priority_id' => array(
144 'title' => ts('Priority'),
145 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
146 'options' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'),
147 ),
148 ),
149 'group_bys' => array(
150 'activity_date_time' => array(
151 'title' => ts('Activity Date'),
152 'frequency' => TRUE,
153 ),
154 'activity_type_id' => array(
155 'title' => ts('Activity Type'),
156 'default' => TRUE,
157 ),
158 'status_id' => array(
159 'title' => ts('Activity Status'),
160 'default' => TRUE,
161 ),
162 ),
163 'order_bys' => array(
164 'activity_date_time' => array(
165 'title' => ts('Activity Date'),
166 ),
167 'activity_type_id' => array(
168 'title' => ts('Activity Type'),
169 ),
170 ),
171 'grouping' => 'activity-fields',
172 'alias' => 'activity',
173 ),
174 );
175 $this->_groupFilter = TRUE;
176
177 parent::__construct();
178 }
179
180 public function select() {
181 $select = array();
182 $this->_columnHeaders = array();
183 foreach ($this->_columns as $tableName => $table) {
184 if (array_key_exists('group_bys', $table)) {
185 foreach ($table['group_bys'] as $fieldName => $field) {
186 if (!empty($this->_params['group_bys'][$fieldName])) {
187 //include column in report when selected in group by but not in column section.
188 if (empty($this->_params['fields'][$fieldName])) {
189 $this->_params['fields'][$fieldName] = TRUE;
190 }
191 if (isset($this->_params['group_bys_freq']) && !empty($this->_params['group_bys_freq'][$fieldName])) {
192 switch ($this->_params['group_bys_freq'][$fieldName]) {
193 case 'YEARWEEK':
194 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start";
195
196 $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
197 $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
198 $field['title'] = 'Week';
199 break;
200
201 case 'YEAR':
202 $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start";
203 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
204 $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
205 $field['title'] = 'Year';
206 break;
207
208 case 'MONTH':
209 $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start";
210 $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
211 $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
212 $field['title'] = 'Month';
213 break;
214
215 case 'QUARTER':
216 $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start";
217 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal";
218 $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval";
219 $field['title'] = 'Quarter';
220 break;
221 }
222 $this->_interval = $field['title'];
223 $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['title'] = $field['title'] . ' Beginning';
224 $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['type'] = $field['type'];
225 $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['group_by'] = $this->_params['group_bys_freq'][$fieldName];
226
227 // just to make sure these values are transferred to rows.
228 // since we need that for calculation purpose,
229 // e.g making subtotals look nicer or graphs
230 $this->_columnHeaders["{$tableName}_{$fieldName}_interval"] = array('no_display' => TRUE);
231 $this->_columnHeaders["{$tableName}_{$fieldName}_subtotal"] = array('no_display' => TRUE);
232 }
233 }
234 }
235 }
236 if (array_key_exists('fields', $table)) {
237 foreach ($table['fields'] as $fieldName => $field) {
238 if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) {
239 if ($tableName == 'civicrm_email') {
240 $this->_emailField = TRUE;
241 }
242 if ($tableName == 'civicrm_phone') {
243 $this->_phoneField = TRUE;
244 }
245 if (!empty($field['statistics'])) {
246 foreach ($field['statistics'] as $stat => $label) {
247 switch (strtolower($stat)) {
248 case 'count':
249 $select[] = "COUNT(DISTINCT({$field['dbAlias']})) as {$tableName}_{$fieldName}_{$stat}";
250 $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['type'] = CRM_Utils_Type::T_INT;
251 $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
252 $this->_statFields[] = "{$tableName}_{$fieldName}_{$stat}";
253 break;
254
255 case 'sum':
256 $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
257 $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['type'] = CRM_Utils_Type::T_INT;
258 $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
259 $this->_statFields[] = "{$tableName}_{$fieldName}_{$stat}";
260 break;
261 }
262 }
263 }
264 elseif ($fieldName == 'activity_type_id') {
265 if (empty($this->_params['group_bys']['activity_type_id'])) {
266 $select[] = "GROUP_CONCAT(DISTINCT {$field['dbAlias']} ORDER BY {$field['dbAlias']} ) as {$tableName}_{$fieldName}";
267 }
268 else {
269 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
270 }
271 $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field);
272 $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field);
273 $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field);
274 }
275 else {
276 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
277 $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field);
278 $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field);
279 $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field);
280 }
281 }
282 }
283 }
284 }
285
286 $this->_select = "SELECT " . implode(', ', $select) . " ";
287 }
288
289 public function from() {
290 $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
291 $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
292 $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
293 $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
294
295 $this->_from = "
296 FROM civicrm_activity {$this->_aliases['civicrm_activity']}
297
298 LEFT JOIN civicrm_activity_contact target_activity
299 ON {$this->_aliases['civicrm_activity']}.id = target_activity.activity_id AND
300 target_activity.record_type_id = {$targetID}
301 LEFT JOIN civicrm_activity_contact assignment_activity
302 ON {$this->_aliases['civicrm_activity']}.id = assignment_activity.activity_id AND
303 assignment_activity.record_type_id = {$assigneeID}
304 LEFT JOIN civicrm_activity_contact source_activity
305 ON {$this->_aliases['civicrm_activity']}.id = source_activity.activity_id AND
306 source_activity.record_type_id = {$sourceID}
307 LEFT JOIN civicrm_contact contact_civireport
308 ON target_activity.contact_id = contact_civireport.id
309 LEFT JOIN civicrm_contact civicrm_contact_assignee
310 ON assignment_activity.contact_id = civicrm_contact_assignee.id
311 LEFT JOIN civicrm_contact civicrm_contact_source
312 ON source_activity.contact_id = civicrm_contact_source.id
313 {$this->_aclFrom}
314 LEFT JOIN civicrm_option_value
315 ON ( {$this->_aliases['civicrm_activity']}.activity_type_id = civicrm_option_value.value )
316 LEFT JOIN civicrm_option_group
317 ON civicrm_option_group.id = civicrm_option_value.option_group_id
318 LEFT JOIN civicrm_case_activity
319 ON civicrm_case_activity.activity_id = {$this->_aliases['civicrm_activity']}.id
320 LEFT JOIN civicrm_case
321 ON civicrm_case_activity.case_id = civicrm_case.id
322 LEFT JOIN civicrm_case_contact
323 ON civicrm_case_contact.case_id = civicrm_case.id ";
324
325 if ($this->_emailField) {
326 $this->_from .= "
327 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
328 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
329 {$this->_aliases['civicrm_email']}.is_primary = 1 ";
330 }
331
332 if ($this->_phoneField) {
333 $this->_from .= "
334 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
335 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
336 {$this->_aliases['civicrm_phone']}.is_primary = 1 ";
337 }
338 }
339
340 public function where() {
341 $this->_where = " WHERE civicrm_option_group.name = 'activity_type' AND
342 {$this->_aliases['civicrm_activity']}.is_test = 0 AND
343 {$this->_aliases['civicrm_activity']}.is_deleted = 0 AND
344 {$this->_aliases['civicrm_activity']}.is_current_revision = 1";
345
346 $clauses = array();
347 foreach ($this->_columns as $tableName => $table) {
348 if (array_key_exists('filters', $table)) {
349
350 foreach ($table['filters'] as $fieldName => $field) {
351 $clause = NULL;
352 if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
353 $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
354 $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
355 $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
356
357 $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
358 }
359 else {
360 $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
361 if ($op) {
362 $clause = $this->whereClause($field,
363 $op,
364 CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
365 CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
366 CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
367 );
368 }
369 }
370
371 if (!empty($clause)) {
372 $clauses[] = $clause;
373 }
374 }
375 }
376 }
377
378 if (empty($clauses)) {
379 $this->_where .= " ";
380 }
381 else {
382 $this->_where .= " AND " . implode(' AND ', $clauses);
383 }
384
385 if ($this->_aclWhere) {
386 $this->_where .= " AND {$this->_aclWhere} ";
387 }
388 }
389
390 public function groupBy() {
391 $this->_groupBy = array();
392 if (is_array($this->_params['group_bys']) &&
393 !empty($this->_params['group_bys'])
394 ) {
395 foreach ($this->_columns as $tableName => $table) {
396 if (array_key_exists('group_bys', $table)) {
397 foreach ($table['group_bys'] as $fieldName => $field) {
398 if (!empty($this->_params['group_bys'][$fieldName])) {
399 if (!empty($field['chart'])) {
400 $this->assign('chartSupported', TRUE);
401 }
402 if (!empty($table['group_bys'][$fieldName]['frequency']) &&
403 !empty($this->_params['group_bys_freq'][$fieldName])
404 ) {
405
406 $append = "YEAR({$field['dbAlias']}),";
407 if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]),
408 array('year')
409 )) {
410 $append = '';
411 }
412 $this->_groupBy[] = "$append {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})";
413 $append = TRUE;
414 }
415 else {
416 $this->_groupBy[] = $field['dbAlias'];
417 }
418 }
419 }
420 }
421 }
422
423 $this->_groupBy = "GROUP BY " . implode(', ', $this->_groupBy);
424 }
425 else {
426 $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contact']}.id ";
427 }
428 }
429
430 /**
431 * @param $fields
432 * @param $files
433 * @param $self
434 *
435 * @return array
436 */
437 public static function formRule($fields, $files, $self) {
438 $errors = array();
439 $contactFields = array('sort_name', 'email', 'phone');
440 if (!empty($fields['group_bys'])) {
441 if (!empty($fields['group_bys']['activity_date_time'])) {
442 if (!empty($fields['group_bys']['sort_name'])) {
443 $errors['fields'] = ts("Please do not select GroupBy 'Activity Date' with GroupBy 'Contact'");
444 }
445 else {
446 foreach ($fields['fields'] as $fieldName => $val) {
447 if (in_array($fieldName, $contactFields)) {
448 $errors['fields'] = ts("Please do not select any Contact Fields with GroupBy 'Activity Date'");
449 break;
450 }
451 }
452 }
453 }
454 }
455 return $errors;
456 }
457
458 public function postProcess() {
459 // get the acl clauses built before we assemble the query
460 $this->buildACLClause($this->_aliases['civicrm_contact']);
461 parent::postProcess();
462 }
463
464 /**
465 * @param $rows
466 *
467 * @return array
468 */
469 public function statistics(&$rows) {
470 $statistics = parent::statistics($rows);
471 $totalType = $totalActivity = $totalDuration = 0;
472
473 $actSQL = "SELECT
474 COUNT(DISTINCT {$this->_aliases['civicrm_activity']}.activity_type_id ) as civicrm_activity_activity_type_id_count,
475 COUNT({$this->_aliases['civicrm_activity']}.activity_type_id ) as civicrm_activity_activity_type_count,
476 SUM({$this->_aliases['civicrm_activity']}.duration ) as civicrm_activity_activity_duration
477 {$this->_from} {$this->_where}";
478
479 $actDAO = CRM_Core_DAO::executeQuery($actSQL);
480
481 while ($actDAO->fetch()) {
482 $totalType += $actDAO->civicrm_activity_activity_type_id_count;
483 $totalActivity += $actDAO->civicrm_activity_activity_type_count;
484 $totalDuration += $actDAO->civicrm_activity_activity_duration;
485 }
486
487 $statistics['counts']['type'] = array(
488 'title' => ts('Total Types'),
489 'value' => $totalType,
490 );
491 $statistics['counts']['activities'] = array(
492 'title' => ts('Total Number of Activities'),
493 'value' => $totalActivity,
494 );
495 $statistics['counts']['duration'] = array(
496 'title' => ts('Total Duration (in Minutes)'),
497 'value' => $totalDuration,
498 );
499 return $statistics;
500 }
501
502 public function modifyColumnHeaders() {
503 //CRM-16719 modify name of column
504 if (!empty($this->_columnHeaders['civicrm_activity_status_id'])) {
505 $this->_columnHeaders['civicrm_activity_status_id']['title'] = "Status";
506 }
507 }
508
509 /**
510 * Alter display of rows.
511 *
512 * Iterate through the rows retrieved via SQL and make changes for display purposes,
513 * such as rendering contacts as links.
514 *
515 * @param array $rows
516 * Rows generated by SQL, with an array for each row.
517 */
518 public function alterDisplay(&$rows) {
519 $entryFound = FALSE;
520 $activityType = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
521 $activityStatus = CRM_Core_PseudoConstant::activityStatus();
522 $flagContact = 0;
523 $onHover = ts('View Contact Summary for this Contact');
524 foreach ($rows as $rowNum => $row) {
525 // make count columns point to activity detail report
526 if (!empty($row['civicrm_activity_id_count'])) {
527 $url = array();
528 $urlParams = array('activity_type_id', 'gid', 'status_id', 'contact_id');
529 foreach ($urlParams as $field) {
530 if (!empty($row['civicrm_activity_' . $field])) {
531 $url[] = "{$field}_op=in&{$field}_value={$row['civicrm_activity_'.$field]}";
532 }
533 elseif (!empty($this->_params[$field . '_value'])) {
534 $val = implode(",", $this->_params[$field . '_value']);
535 $url[] = "{$field}_op=in&{$field}_value={$val}";
536 }
537 }
538 $date_suffixes = array('relative', 'from', 'to');
539 while (list(, $suffix) = each($date_suffixes)) {
540 if (!empty($this->_params['activity_date_time_' . $suffix])) {
541 list($from, $to)
542 = $this->getFromTo(
543 CRM_Utils_Array::value("activity_date_time_relative", $this->_params),
544 CRM_Utils_Array::value("activity_date_time_from", $this->_params),
545 CRM_Utils_Array::value("activity_date_time_to", $this->_params)
546 );
547 $url[] = "activity_date_time_from={$from}&activity_date_time_to={$to}";
548 break;
549 }
550 }
551 $url = implode('&', $url);
552 $url = CRM_Report_Utils_Report::getNextUrl('activity', "reset=1&force=1&{$url}",
553 $this->_absoluteUrl,
554 $this->_id,
555 $this->_drilldownReport);
556 $rows[$rowNum]['civicrm_activity_id_count_link'] = $url;
557 $rows[$rowNum]['civicrm_activity_id_count_hover'] = ts('List all activity(s) for this row.');
558 $entryFound = TRUE;
559 }
560
561 if (array_key_exists('civicrm_contact_sort_name', $row) && $this->_outputMode != 'csv') {
562 if ($value = $row['civicrm_contact_id']) {
563
564 if ($rowNum == 0) {
565 $priviousContact = $value;
566 }
567 else {
568 if ($priviousContact == $value) {
569 $flagContact = 1;
570 $priviousContact = $value;
571 }
572 else {
573 $flagContact = 0;
574 $priviousContact = $value;
575 }
576 }
577
578 if ($flagContact == 1) {
579 $rows[$rowNum]['civicrm_contact_sort_name'] = "";
580
581 if (array_key_exists('civicrm_email_email', $row)) {
582 $rows[$rowNum]['civicrm_email_email'] = "";
583 }
584 if (array_key_exists('civicrm_phone_phone', $row)) {
585 $rows[$rowNum]['civicrm_phone_phone'] = "";
586 }
587 }
588 else {
589 $url = CRM_Utils_System::url('civicrm/contact/view',
590 'reset=1&cid=' . $value,
591 $this->_absoluteUrl
592 );
593
594 $rows[$rowNum]['civicrm_contact_sort_name'] = "<a href='$url'>" . $row['civicrm_contact_sort_name'] .
595 '</a>';
596 }
597 $entryFound = TRUE;
598 }
599 }
600
601 if (array_key_exists('civicrm_activity_activity_type_id', $row)) {
602 if ($value = $row['civicrm_activity_activity_type_id']) {
603
604 $value = explode(',', $value);
605 foreach ($value as $key => $id) {
606 $value[$key] = $activityType[$id];
607 }
608
609 $rows[$rowNum]['civicrm_activity_activity_type_id'] = implode(' , ', $value);
610 $entryFound = TRUE;
611 }
612 }
613
614 if (array_key_exists('civicrm_activity_status_id', $row)) {
615 if ($value = $row['civicrm_activity_status_id']) {
616 $rows[$rowNum]['civicrm_activity_status_id'] = $activityStatus[$value];
617 $entryFound = TRUE;
618 }
619 }
620
621 if (!$entryFound) {
622 break;
623 }
624 }
625 }
626
627 }