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