Merge pull request #4337 from colemanw/explorerEntityRef
[civicrm-core.git] / CRM / Report / Form / Case / Detail.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.5 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
27 */
28
29 /**
30 *
31 * @package CRM
32 * @copyright CiviCRM LLC (c) 2004-2014
33 * $Id$
34 *
35 */
36 class CRM_Report_Form_Case_Detail extends CRM_Report_Form {
37
38 protected $_relField = FALSE;
39
40 protected $_addressField = FALSE;
41
42 protected $_emailField = FALSE;
43
44 protected $_phoneField = FALSE;
45
46 protected $_worldRegionField = FALSE;
47
48 protected $_activityLast = FALSE;
49
50 protected $_activityLastCompleted = FALSE;
51
52 protected $_includeCaseDetailExtra = FALSE;
53
54 protected $_caseDetailExtra = array(
55 );
56
57 /**
58 *
59 */
60 /**
61 *
62 */
63 function __construct() {
64 $this->case_statuses = CRM_Core_OptionGroup::values('case_status');
65 $this->case_types = CRM_Case_PseudoConstant::caseType();
66 $rels = CRM_Core_PseudoConstant::relationshipType();
67 foreach ($rels as $relid => $v) {
68 $this->rel_types[$relid] = $v['label_b_a'];
69 }
70
71 $this->deleted_labels = array('' => ts('- select -'), 0 => ts('No'), 1 => ts('Yes'));
72
73 $this->caseActivityTypes = array();
74 foreach (CRM_Case_PseudoConstant::caseActivityType() as $typeDetail) {
75 $this->caseActivityTypes[$typeDetail['id']] = $typeDetail['label'];
76 }
77
78 $this->_columns = array(
79 'civicrm_case' =>
80 array(
81 'dao' => 'CRM_Case_DAO_Case',
82 'fields' =>
83 array(
84 'id' => array('title' => ts('Case ID'),
85 'no_display' => TRUE,
86 'required' => TRUE,
87 ),
88 'subject' => array('title' => ts('Subject'),
89 'required' => TRUE,
90 ),
91 'start_date' => array('title' => ts('Start Date'),
92 'type' => CRM_Utils_Type::T_DATE,
93 ),
94 'end_date' => array('title' => ts('End Date'),
95 'type' => CRM_Utils_Type::T_DATE,
96 ),
97 'status_id' => array('title' => ts('Case Status')),
98 'case_type_id' => array('title' => ts('Case Type')),
99 'is_deleted' => array('title' => ts('Deleted?'),
100 'default' => FALSE,
101 'type' => CRM_Utils_Type::T_INT,
102 ),
103 ),
104 'filters' =>
105 array(
106 'start_date' => array('title' => ts('Start Date'),
107 'operatorType' => CRM_Report_Form::OP_DATE,
108 'type' => CRM_Utils_Type::T_DATE,
109 ),
110 'end_date' => array('title' => ts('End Date'),
111 'operatorType' => CRM_Report_Form::OP_DATE,
112 'type' => CRM_Utils_Type::T_DATE,
113 ),
114 'status_id' => array('title' => ts('Case Status'),
115 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
116 'options' => $this->case_statuses,
117 ),
118 'case_type_id' => array('title' => ts('Case Type'),
119 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
120 'options' => $this->case_types,
121 ),
122 'is_deleted' => array('title' => ts('Deleted?'),
123 'type' => CRM_Utils_Type::T_INT,
124 'operatorType' => CRM_Report_Form::OP_SELECT,
125 'options' => $this->deleted_labels,
126 'default' => 0,
127 ),
128 ),
129 ),
130 'civicrm_contact' =>
131 array(
132 'dao' => 'CRM_Contact_DAO_Contact',
133 'fields' =>
134 array(
135 'client_sort_name' => array(
136 'name' => 'sort_name',
137 'title' => ts('Client Name'),
138 'required' => TRUE,
139 ),
140 'id' => array(
141 'no_display' => TRUE,
142 'required' => TRUE,
143 ),
144 ),
145 'filters' =>
146 array(
147 'sort_name' => array('title' => ts('Client Name')),
148 ),
149 ),
150 'civicrm_relationship' =>
151 array(
152 'dao' => 'CRM_Contact_DAO_Relationship',
153 'fields' =>
154 array(
155 'case_role' => array('name' => 'relationship_type_id',
156 'title' => ts('Case Role(s)'),
157 ),
158 ),
159 'filters' =>
160 array(
161 'case_role' =>
162 array(
163 'name' => 'relationship_type_id',
164 'title' => ts('Case Role(s)'),
165 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
166 'options' => $this->rel_types,
167 ),
168 ),
169 ),
170 'civicrm_email' =>
171 array(
172 'dao' => 'CRM_Core_DAO_Email',
173 'fields' =>
174 array('email' => array('title' => ts('Email'),
175 'no_repeat' => TRUE,
176 ),
177 ),
178 'grouping' => 'contact-fields',
179 ),
180 'civicrm_phone' =>
181 array(
182 'dao' => 'CRM_Core_DAO_Phone',
183 'fields' =>
184 array(
185 'phone' =>
186 array('title' => ts('Phone'),
187 'no_repeat' => TRUE,
188 ),
189 ),
190 'grouping' => 'contact-fields',
191 ),
192 'civicrm_address' =>
193 array(
194 'dao' => 'CRM_Core_DAO_Address',
195 'fields' =>
196 array(
197 'street_address' => NULL,
198 'state_province_id' => array('title' => ts('State/Province'),
199 ),
200 'country_id' => array('title' => ts('Country')),
201 ),
202 'grouping' => 'contact-fields',
203 'filters' =>
204 array(
205 'country_id' =>
206 array('title' => ts('Country'),
207 'type' => CRM_Utils_Type::T_INT,
208 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
209 'options' => CRM_Core_PseudoConstant::country(),
210 ),
211 'state_province_id' =>
212 array('title' => ts('State/Province'),
213 'type' => CRM_Utils_Type::T_INT,
214 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
215 'options' => CRM_Core_PseudoConstant::stateProvince(),
216 ),
217 ),
218 ),
219 'civicrm_worldregion' =>
220 array(
221 'dao' => 'CRM_Core_DAO_Worldregion',
222 'filters' =>
223 array(
224 'worldregion_id' => array(
225 'name' => 'id',
226 'title' => ts('WorldRegion'),
227 'type' => CRM_Utils_Type::T_INT,
228 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
229 'options' => CRM_Core_PseudoConstant::worldRegion(),
230 ),
231 ),
232 ),
233 'civicrm_country' =>
234 array(
235 'dao' => 'CRM_Core_DAO_Country',
236 ),
237 'civicrm_activity_last' =>
238 array(
239 'dao' => 'CRM_Activity_DAO_Activity',
240 'filters' =>
241 array(
242 'last_activity_date_time' =>
243 array(
244 'name' => 'activity_date_time',
245 'title' => ts('Last Action Date'),
246 'operatorType' => CRM_Report_Form::OP_DATE,
247 ),
248 ),
249 'alias' => 'civireport_activity_last',
250 ),
251 'civicrm_activity_last_completed' =>
252 array(
253 'dao' => 'CRM_Activity_DAO_Activity',
254 'fields' =>
255 array(
256 'last_completed_activity_subject' =>
257 array(
258 'name' => 'subject',
259 'title' => ts('Subject of the last completed activity in the case'),
260 ),
261 'last_completed_activity_type' =>
262 array(
263 'name' => 'activity_type_id',
264 'title' => ts('Activity type of the last completed activity'),
265 ),
266 ),
267 ),
268 );
269
270 $this->_options = array(
271 'my_cases' =>
272 array('title' => ts('My Cases'),
273 'type' => 'checkbox',
274 ),
275 );
276 parent::__construct();
277 }
278
279 function preProcess() {
280 parent::preProcess();
281 }
282
283 function buildQuickForm() {
284 parent::buildQuickForm();
285 $this->caseDetailSpecialColumnsAdd();
286 }
287
288 function caseDetailSpecialColumnsAdd() {
289 $elements = array();
290 $elements[] = &$this->createElement('select', 'case_activity_all_dates', NULL,
291 array(
292 '' => ts('-- select --')) + $this->caseActivityTypes
293 );
294 $this->addGroup($elements, 'case_detail_extra');
295
296 $this->_caseDetailExtra = array('case_activity_all_dates' => array('title' => ts('List of all dates of activities of Type'),
297 'name' => 'activity_date_time',
298 ),
299 );
300
301 $this->assign('caseDetailExtra', $this->_caseDetailExtra);
302 }
303
304 function select() {
305 $select = array();
306 $this->_columnHeaders = array();
307 foreach ($this->_columns as $tableName => $table) {
308 if (array_key_exists('fields', $table)) {
309 foreach ($table['fields'] as $fieldName => $field) {
310 if ($tableName == 'civicrm_address') {
311 $this->_addressField = TRUE;
312 }
313 if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) {
314 if ($tableName == 'civicrm_email') {
315 $this->_emailField = TRUE;
316 }
317 elseif ($tableName == 'civicrm_phone') {
318 $this->_phoneField = TRUE;
319 }
320 elseif ($tableName == 'civicrm_relationship') {
321 $this->_relField = TRUE;
322 }
323 if ($fieldName == 'sort_name') {
324 $select[] = "GROUP_CONCAT({$field['dbAlias']} ORDER BY {$field['dbAlias']} )
325 as {$tableName}_{$fieldName}";
326 }
327 if ($tableName == 'civicrm_activity_last_completed') {
328 $this->_activityLastCompleted = TRUE;
329 }
330
331 if ($fieldName == 'case_role') {
332 $select[] = "GROUP_CONCAT(DISTINCT({$field['dbAlias']}) ORDER BY {$field['dbAlias']}) as {$tableName}_{$fieldName}";
333 }
334 else {
335 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
336 }
337
338 $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field);
339 $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'];
340 }
341 }
342 }
343 }
344
345 $this->_select = 'SELECT ' . implode(', ', $select) . ' ';
346 }
347
348 function from() {
349
350 $case = $this->_aliases['civicrm_case'];
351 $conact = $this->_aliases['civicrm_contact'];
352
353 $this->_from = "
354 FROM civicrm_case $case
355 LEFT JOIN civicrm_case_contact civireport_case_contact on civireport_case_contact.case_id = {$case}.id
356 LEFT JOIN civicrm_contact $conact ON {$conact}.id = civireport_case_contact.contact_id
357 ";
358 if ($this->_relField) {
359 $this->_from .= "
360 LEFT JOIN civicrm_relationship {$this->_aliases['civicrm_relationship']} ON {$this->_aliases['civicrm_relationship']}.case_id = {$case}.id
361 ";
362 }
363
364 if ($this->_addressField) {
365 $this->_from .= "
366 LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
367 ON {$conact}.id = {$this->_aliases['civicrm_address']}.contact_id AND
368 {$this->_aliases['civicrm_address']}.is_primary = 1 ";
369 }
370 if ($this->_emailField) {
371 $this->_from .= "
372 LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
373 ON {$conact}.id = {$this->_aliases['civicrm_email']}.contact_id AND
374 {$this->_aliases['civicrm_email']}.is_primary = 1 ";
375 }
376 if ($this->_phoneField) {
377 $this->_from .= "
378 LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
379 ON ( {$conact}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
380 {$this->_aliases['civicrm_phone']}.is_primary = 1) ";
381 }
382 if ($this->_worldRegionField) {
383 $this->_from .= "
384 LEFT JOIN civicrm_country {$this->_aliases['civicrm_country']}
385 ON {$this->_aliases['civicrm_country']}.id ={$this->_aliases['civicrm_address']}.country_id
386 LEFT JOIN civicrm_worldregion {$this->_aliases['civicrm_worldregion']}
387 ON {$this->_aliases['civicrm_country']}.region_id = {$this->_aliases['civicrm_worldregion']}.id ";
388 }
389
390 // Include clause for last activity of the case
391 if ($this->_activityLast) {
392 $this->_from .= " LEFT JOIN civicrm_activity {$this->_aliases['civicrm_activity_last']} ON ( {$this->_aliases['civicrm_activity_last']}.id = ( SELECT max(activity_id) FROM civicrm_case_activity WHERE case_id = {$case}.id) )";
393 }
394
395 // Include clause for last completed activity of the case
396 if ($this->_activityLastCompleted) {
397 $this->_from .= " LEFT JOIN civicrm_activity {$this->_aliases['civicrm_activity_last_completed']} ON ( {$this->_aliases['civicrm_activity_last_completed']}.id = ( SELECT max(activity_id) FROM civicrm_case_activity cca, civicrm_activity ca WHERE ca.id = cca.activity_id AND cca.case_id = {$case}.id AND ca.status_id = 2 ) )";
398 }
399 }
400
401 function where() {
402 $clauses = array();
403 $this->_having = '';
404 foreach ($this->_columns as $tableName => $table) {
405 if (array_key_exists('filters', $table)) {
406 foreach ($table['filters'] as $fieldName => $field) {
407 $clause = NULL;
408
409 if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
410 $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
411 $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
412 $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
413
414 $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type']);
415 }
416 else {
417
418 $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
419 if ($fieldName == 'case_type_id' && !empty($this->_params['case_type_id_value'])) {
420 foreach ($this->_params['case_type_id_value'] as $key => $value) {
421 if (strpos($value, CRM_Core_DAO::VALUE_SEPARATOR) === FALSE) {
422 $value = CRM_Core_DAO::VALUE_SEPARATOR . $value . CRM_Core_DAO::VALUE_SEPARATOR;
423
424 $this->_params['case_type_id_value'][$key] = "'{$value}'";
425 }
426 else {
427 $this->_params['case_type_id_value'][$key] = $value;
428 }
429 }
430 }
431
432 if ($op) {
433 $clause = $this->whereClause($field,
434 $op,
435 CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
436 CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
437 CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
438 );
439 }
440 }
441
442 if (!empty($clause)) {
443 $clauses[] = $clause;
444 }
445 }
446 }
447 }
448
449 if (isset($this->_params['options']['my_cases'])) {
450 $session = CRM_Core_Session::singleton();
451 $userID = $session->get('userID');
452 $clauses[] = "{$this->_aliases['civicrm_contact']}.id = {$userID}";
453 }
454
455 if (empty($clauses)) {
456 $this->_where = 'WHERE ( 1 ) ';
457 }
458 else {
459 $this->_where = 'WHERE ' . implode(' AND ', $clauses);
460 }
461 }
462
463 function groupBy() {
464 $this->_groupBy = " GROUP BY {$this->_aliases['civicrm_case']}.id";
465 }
466
467 /**
468 * @param $rows
469 *
470 * @return array
471 */
472 function statistics(&$rows) {
473 $statistics = parent::statistics($rows);
474
475 $select = "select COUNT( DISTINCT( {$this->_aliases['civicrm_address']}.country_id))";
476 $sql = "{$select} {$this->_from} {$this->_where}";
477 $countryCount = CRM_Core_DAO::singleValueQuery($sql);
478
479 //CaseType statistics
480 if (array_key_exists('filters', $statistics)) {
481 foreach ($statistics['filters'] as $id => $value) {
482 if ($value['title'] == 'Case Type') {
483 $statistics['filters'][$id]['value'] = 'Is ' . $this->case_types[substr($statistics['filters'][$id]
484 ['value'], -3, -2
485 )];
486 }
487 }
488 }
489 $statistics['counts']['case'] = array(
490 'title' => ts('Total Number of Cases '),
491 'value' => isset($statistics['counts']['rowsFound']) ? $statistics['counts']['rowsFound']['value'] : count($rows),
492 );
493 $statistics['counts']['country'] = array(
494 'title' => ts('Total Number of Countries '),
495 'value' => $countryCount,
496 );
497
498 return $statistics;
499 }
500
501 function orderBy() {
502 $this->_orderBy = " ORDER BY {$this->_aliases['civicrm_case']}.start_date DESC ";
503 }
504
505 function caseDetailSpecialColumnProcess() {
506 if (!$this->_includeCaseDetailExtra) {
507 return;
508 }
509
510 $from = $select = array();
511 $case = $this->_aliases['civicrm_case'];
512
513 if ($activityType = CRM_Utils_Array::value('case_activity_all_dates', $this->_params['case_detail_extra'])) {
514 $select[] = "GROUP_CONCAT(DISTINCT(civireport_activity_all_{$activityType}.{$this->_caseDetailExtra['case_activity_all_dates']['name']}) ORDER BY civireport_activity_all_{$activityType}.{$this->_caseDetailExtra['case_activity_all_dates']['name']}) as case_activity_all_dates";
515
516 $from[] = " LEFT JOIN civicrm_case_activity civireport_case_activity_all_{$activityType} ON ( civireport_case_activity_all_{$activityType}.case_id = {$case}.id)
517 LEFT JOIN civicrm_activity civireport_activity_all_{$activityType} ON ( civireport_activity_all_{$activityType}.id = civireport_case_activity_all_{$activityType}.activity_id AND civireport_activity_all_{$activityType}.activity_type_id = {$activityType})";
518
519 $this->_columnHeaders['case_activity_all_dates'] = array(
520 'title' => $this->_caseDetailExtra['case_activity_all_dates']['title'] . ": {$this->caseActivityTypes[$activityType]}",
521 'type' => CRM_Utils_Array::value('type', $this->_caseDetailExtra['case_activity_all_dates']),
522 );
523 }
524
525 $this->_select .= ', ' . implode(', ', $select) . ' ';
526 $this->_from .= ' ' . implode(' ', $from) . ' ';
527 }
528
529 function postProcess() {
530
531 $this->beginPostProcess();
532
533 $this->checkEnabledFields();
534
535 $this->buildQuery(TRUE);
536
537 $this->caseDetailSpecialColumnProcess();
538
539 $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
540
541 $rows = $graphRows = array();
542 $this->buildRows($sql, $rows);
543
544 $this->formatDisplay($rows);
545
546 $this->doTemplateAssignment($rows);
547 $this->endPostProcess($rows);
548 }
549
550 function checkEnabledFields() {
551 if (isset($this->_params['worldregion_id_value']) && !empty($this->_params['worldregion_id_value'])) {
552 $this->_addressField = TRUE;
553 $this->_worldRegionField = TRUE;
554 }
555
556 if (isset($this->_params['case_role_value'])
557 && !empty($this->_params['case_role_value'])
558 ) {
559 $this->_relField = TRUE;
560 }
561
562 if (!empty($this->_params['activity_date_time_relative']) || !empty($this->_params['activity_date_time_from']) ||
563 CRM_Utils_Array::value('activity_date_time_to', $this->_params)
564 ) {
565 $this->_activityLast = TRUE;
566 }
567
568 foreach (array_keys($this->_caseDetailExtra) as $field) {
569 if (!empty($this->_params['case_detail_extra'][$field])) {
570 $this->_includeCaseDetailExtra = TRUE;
571 break;
572 }
573 }
574 }
575
576 /**
577 * @param $rows
578 */
579 function alterDisplay(&$rows) {
580 $entryFound = FALSE;
581 $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
582
583 foreach ($rows as $rowNum => $row) {
584 if (array_key_exists('civicrm_case_status_id', $row)) {
585 if ($value = $row['civicrm_case_status_id']) {
586 $rows[$rowNum]['civicrm_case_status_id'] = $this->case_statuses[$value];
587
588 $entryFound = TRUE;
589 }
590 }
591 if (array_key_exists('civicrm_case_case_type_id', $row)) {
592 if ($value = str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $row['civicrm_case_case_type_id'])) {
593 $rows[$rowNum]['civicrm_case_case_type_id'] = $this->case_types[$value];
594
595 $entryFound = TRUE;
596 }
597 }
598 if (array_key_exists('civicrm_case_subject', $row)) {
599 if ($value = $row['civicrm_case_subject']) {
600 $caseId = $row['civicrm_case_id'];
601 $contactId = $row['civicrm_contact_id'];
602 $rows[$rowNum]['civicrm_case_subject'] = "<a href= 'javascript:viewCase( $caseId,$contactId );'>$value</a>";
603 $rows[$rowNum]['civicrm_case_subject_hover'] = ts('View Details of Case.');
604
605 $entryFound = TRUE;
606 }
607 }
608 if (array_key_exists('civicrm_relationship_case_role', $row)) {
609 if ($value = $row['civicrm_relationship_case_role']) {
610 $caseRoles = explode(',', $value);
611 foreach ($caseRoles as $num => $caseRole) {
612 $caseRoles[$num] = $this->rel_types[$caseRole];
613 }
614 $rows[$rowNum]['civicrm_relationship_case_role'] = implode('; ', $caseRoles);
615 }
616 $entryFound = TRUE;
617 }
618 if (array_key_exists('civicrm_address_country_id', $row)) {
619 if ($value = $row['civicrm_address_country_id']) {
620 $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($value, FALSE);
621 }
622 $entryFound = TRUE;
623 }
624 if (array_key_exists('civicrm_address_state_province_id', $row)) {
625 if ($value = $row['civicrm_address_state_province_id']) {
626 $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, FALSE);
627 }
628 $entryFound = TRUE;
629 }
630 if (array_key_exists('civicrm_activity_last_completed_last_completed_activity_subject', $row) && empty($row['civicrm_activity_last_completed_last_completed_activity_subject'])) {
631 $rows[$rowNum]['civicrm_activity_last_completed_last_completed_activity_subject'] = ts('(no subject)');
632 $entryFound = TRUE;
633 }
634 if (array_key_exists('civicrm_contact_client_sort_name', $row) &&
635 array_key_exists('civicrm_contact_id', $row)
636 ) {
637 $url = CRM_Utils_System::url("civicrm/contact/view",
638 'reset=1&cid=' . $row['civicrm_contact_id'],
639 $this->_absoluteUrl
640 );
641 $rows[$rowNum]['civicrm_contact_client_sort_name_link'] = $url;
642 $rows[$rowNum]['civicrm_contact_client_sort_name_hover'] = ts("View Contact Summary for this Contact");
643 $entryFound = TRUE;
644 }
645 if (array_key_exists('civicrm_activity_last_completed_last_completed_activity_type', $row)) {
646 if ($value = $row['civicrm_activity_last_completed_last_completed_activity_type']) {
647 $rows[$rowNum]['civicrm_activity_last_completed_last_completed_activity_type'] = $activityTypes[$value];
648 }
649 $entryFound = TRUE;
650 }
651
652 if (array_key_exists('case_activity_all_dates', $row)) {
653 if ($value = $row['case_activity_all_dates']) {
654 $activityDates = explode(',', $value);
655 foreach ($activityDates as $num => $activityDate) {
656 $activityDates[$num] = CRM_Utils_Date::customFormat($activityDate);
657 }
658 $rows[$rowNum]['case_activity_all_dates'] = implode('; ', $activityDates);
659 }
660 $entryFound = TRUE;
661 }
662
663 if (array_key_exists('civicrm_case_is_deleted', $row)) {
664 $value = $row['civicrm_case_is_deleted'];
665 $rows[$rowNum]['civicrm_case_is_deleted'] = $this->deleted_labels[$value];
666 $entryFound = TRUE;
667 }
668
669 if (!$entryFound) {
670 break;
671 }
672 }
673 }
674 }
675