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