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