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