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