Update copyright date for 2020
[civicrm-core.git] / CRM / Report / Form / Event / ParticipantListCount.php
CommitLineData
6a488035 1<?php
6a488035
TO
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
f299f7db 6 | Copyright CiviCRM LLC (c) 2004-2020 |
6a488035 7 +--------------------------------------------------------------------+
e7112fa7
CW
8 | This file is a part of CiviCRM. |
9 | |
6a488035 10 | CiviCRM is free software; you can copy, modify, and distribute it |
e7112fa7
CW
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 |
6a488035 25 +--------------------------------------------------------------------+
e70a7fc0 26 */
6a488035
TO
27
28/**
29 *
30 * @package CRM
f299f7db 31 * @copyright CiviCRM LLC (c) 2004-2020
6a488035 32 */
70d00fce 33class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form {
6a488035
TO
34
35 protected $_summary = NULL;
26dcc739
E
36 protected $_groupFilter = TRUE;
37 protected $_tagFilter = TRUE;
be2fb01f 38 protected $_customGroupExtends = [
0f18adb9
E
39 'Participant',
40 'Event',
be2fb01f 41 ];
1728e9a0 42 /**
43 * This report has not been optimised for group filtering.
44 *
45 * The functionality for group filtering has been improved but not
46 * all reports have been adjusted to take care of it. This report has not
47 * and will run an inefficient query until fixed.
48 *
49 * CRM-19170
50 *
51 * @var bool
52 */
53 protected $groupFilterNotOptimised = TRUE;
6a488035 54
be2fb01f 55 public $_drilldownReport = ['event/income' => 'Link to Detail Report'];
74cf4551 56
74cf4551 57 /**
73b448bf 58 * Class constructor.
74cf4551 59 */
00be9182 60 public function __construct() {
be2fb01f
CW
61 $this->_columns = [
62 'civicrm_contact' => [
6a488035 63 'dao' => 'CRM_Contact_DAO_Contact',
be2fb01f
CW
64 'fields' => [
65 'sort_name' => [
9d72cede 66 'title' => ts('Name'),
6a488035
TO
67 'default' => TRUE,
68 'no_repeat' => TRUE,
69 'required' => TRUE,
be2fb01f
CW
70 ],
71 'first_name' => [
70bea8e2 72 'title' => ts('First Name'),
be2fb01f
CW
73 ],
74 'middle_name' => [
70bea8e2 75 'title' => ts('Middle Name'),
be2fb01f
CW
76 ],
77 'last_name' => [
70bea8e2 78 'title' => ts('Last Name'),
be2fb01f
CW
79 ],
80 'id' => [
6a488035
TO
81 'no_display' => TRUE,
82 'required' => TRUE,
be2fb01f
CW
83 ],
84 'gender_id' => [
70bea8e2 85 'title' => ts('Gender'),
be2fb01f
CW
86 ],
87 'birth_date' => [
70bea8e2 88 'title' => ts('Birth Date'),
be2fb01f
CW
89 ],
90 'age' => [
70bea8e2 91 'title' => ts('Age'),
92 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())',
be2fb01f
CW
93 ],
94 'contact_type' => [
70bea8e2 95 'title' => ts('Contact Type'),
be2fb01f
CW
96 ],
97 'contact_sub_type' => [
70bea8e2 98 'title' => ts('Contact Subtype'),
be2fb01f
CW
99 ],
100 ],
101 'filters' => [
102 'sort_name' => [
9d72cede 103 'title' => ts('Participant Name'),
6a488035 104 'operator' => 'like',
be2fb01f
CW
105 ],
106 'id' => [
70bea8e2 107 'title' => ts('Contact ID'),
108 'no_display' => TRUE,
be2fb01f
CW
109 ],
110 'gender_id' => [
70bea8e2 111 'title' => ts('Gender'),
112 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
113 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'),
be2fb01f
CW
114 ],
115 'birth_date' => [
70bea8e2 116 'title' => ts('Birth Date'),
117 'operatorType' => CRM_Report_Form::OP_DATE,
be2fb01f
CW
118 ],
119 'contact_type' => [
70bea8e2 120 'title' => ts('Contact Type'),
be2fb01f
CW
121 ],
122 'contact_sub_type' => [
70bea8e2 123 'title' => ts('Contact Subtype'),
be2fb01f
CW
124 ],
125 ],
70bea8e2 126 'grouping' => 'contact-fields',
be2fb01f
CW
127 'order_bys' => [
128 'sort_name' => [
47d66b4c 129 'title' => ts('Last Name, First Name'),
130 'default' => '1',
131 'default_weight' => '0',
132 'default_order' => 'ASC',
be2fb01f
CW
133 ],
134 'first_name' => [
70bea8e2 135 'name' => 'first_name',
136 'title' => ts('First Name'),
be2fb01f
CW
137 ],
138 'gender_id' => [
70bea8e2 139 'name' => 'gender_id',
140 'title' => ts('Gender'),
be2fb01f
CW
141 ],
142 'birth_date' => [
70bea8e2 143 'name' => 'birth_date',
144 'title' => ts('Birth Date'),
be2fb01f
CW
145 ],
146 'contact_type' => [
70bea8e2 147 'title' => ts('Contact Type'),
be2fb01f
CW
148 ],
149 'contact_sub_type' => [
70bea8e2 150 'title' => ts('Contact Subtype'),
be2fb01f
CW
151 ],
152 ],
153 ],
154 'civicrm_employer' => [
9d72cede
EM
155 'dao' => 'CRM_Contact_DAO_Contact',
156 'grouping' => 'contact-fields',
be2fb01f
CW
157 'fields' => [
158 'id' => [
9d72cede
EM
159 'no_display' => TRUE,
160 'required' => TRUE,
be2fb01f
CW
161 ],
162 'organization_name' => [
ccc29f8e 163 'title' => ts('Employer'),
9d72cede
EM
164 'default' => TRUE,
165 'no_repeat' => TRUE,
be2fb01f
CW
166 ],
167 ],
168 ],
169 'civicrm_email' => [
6a488035 170 'dao' => 'CRM_Core_DAO_Email',
be2fb01f
CW
171 'fields' => [
172 'email' => [
9d72cede 173 'title' => ts('Email'),
6a488035 174 'no_repeat' => TRUE,
be2fb01f
CW
175 ],
176 ],
6a488035 177 'grouping' => 'contact-fields',
be2fb01f
CW
178 'filters' => [
179 'email' => [
9d72cede 180 'title' => ts('Participant E-mail'),
6a488035 181 'operator' => 'like',
be2fb01f
CW
182 ],
183 ],
184 ],
185 'civicrm_phone' => [
9d72cede
EM
186 'dao' => 'CRM_Core_DAO_Phone',
187 'grouping' => 'contact-fields',
be2fb01f
CW
188 'fields' => [
189 'phone' => [
9d72cede
EM
190 'title' => ts('Phone No'),
191 'default' => TRUE,
be2fb01f
CW
192 ],
193 ],
194 ],
195 'civicrm_address' => [
6a488035 196 'dao' => 'CRM_Core_DAO_Address',
be2fb01f 197 'fields' => [
6a488035 198 'street_address' => NULL,
9cd28c89
DL
199 'city' => NULL,
200 'postal_code' => NULL,
be2fb01f 201 'state_province_id' => [
9d72cede 202 'title' => ts('State/Province'),
be2fb01f
CW
203 ],
204 'country_id' => [
9d72cede 205 'title' => ts('Country'),
be2fb01f
CW
206 ],
207 ],
6a488035 208 'grouping' => 'contact-fields',
be2fb01f
CW
209 ],
210 'civicrm_participant' => [
6a488035 211 'dao' => 'CRM_Event_DAO_Participant',
be2fb01f
CW
212 'fields' => [
213 'participant_id' => [
9d72cede 214 'title' => ts('Participant ID'),
6a488035 215 'default' => TRUE,
be2fb01f
CW
216 ],
217 'event_id' => [
9d72cede 218 'title' => ts('Event'),
6a488035 219 'type' => CRM_Utils_Type::T_STRING,
be2fb01f
CW
220 ],
221 'role_id' => [
9d72cede 222 'title' => ts('Role'),
6a488035 223 'default' => TRUE,
be2fb01f
CW
224 ],
225 'status_id' => [
9d72cede 226 'title' => ts('Status'),
6a488035 227 'default' => TRUE,
be2fb01f
CW
228 ],
229 'participant_register_date' => [
9d72cede 230 'title' => ts('Registration Date'),
be2fb01f
CW
231 ],
232 ],
6a488035 233 'grouping' => 'event-fields',
be2fb01f
CW
234 'filters' => [
235 'event_id' => [
6a488035
TO
236 'name' => 'event_id',
237 'title' => ts('Event'),
2107cde9
CW
238 'operatorType' => CRM_Report_Form::OP_ENTITYREF,
239 'type' => CRM_Utils_Type::T_INT,
be2fb01f 240 'attributes' => [
af00ced5 241 'entity' => 'Event',
be2fb01f
CW
242 'select' => ['minimumInputLength' => 0],
243 ],
244 ],
245 'sid' => [
6a488035
TO
246 'name' => 'status_id',
247 'title' => ts('Participant Status'),
525ae77a 248 'type' => CRM_Utils_Type::T_INT,
6a488035
TO
249 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
250 'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'),
be2fb01f
CW
251 ],
252 'rid' => [
6a488035
TO
253 'name' => 'role_id',
254 'title' => ts('Participant Role'),
2039ce87 255 'operatorType' => CRM_Report_Form::OP_MULTISELECT_SEPARATOR,
1c193324 256 'type' => CRM_Utils_Type::T_INT,
6a488035 257 'options' => CRM_Event_PseudoConstant::participantRole(),
be2fb01f
CW
258 ],
259 'participant_register_date' => [
9d72cede 260 'title' => ts('Registration Date'),
6a488035 261 'operatorType' => CRM_Report_Form::OP_DATE,
be2fb01f
CW
262 ],
263 ],
264 'group_bys' => [
265 'event_id' => [
9d72cede 266 'title' => ts('Event'),
be2fb01f
CW
267 ],
268 ],
269 ],
270 'civicrm_event' => [
6a488035 271 'dao' => 'CRM_Event_DAO_Event',
be2fb01f
CW
272 'fields' => [
273 'event_type_id' => [
9d72cede 274 'title' => ts('Event Type'),
be2fb01f
CW
275 ],
276 'start_date' => [
9d72cede 277 'title' => ts('Event Start Date'),
be2fb01f
CW
278 ],
279 'end_date' => [
9d72cede 280 'title' => ts('Event End Date'),
be2fb01f
CW
281 ],
282 ],
6a488035 283 'grouping' => 'event-fields',
be2fb01f
CW
284 'filters' => [
285 'eid' => [
6a488035
TO
286 'name' => 'event_type_id',
287 'title' => ts('Event Type'),
525ae77a 288 'type' => CRM_Utils_Type::T_INT,
6a488035
TO
289 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
290 'options' => CRM_Core_OptionGroup::values('event_type'),
be2fb01f
CW
291 ],
292 'event_start_date' => [
c4c31bc4 293 'name' => 'event_start_date',
6a488035
TO
294 'title' => ts('Event Start Date'),
295 'operatorType' => CRM_Report_Form::OP_DATE,
be2fb01f
CW
296 ],
297 'event_end_date' => [
c4c31bc4 298 'name' => 'event_end_date',
6a488035
TO
299 'title' => ts('Event End Date'),
300 'operatorType' => CRM_Report_Form::OP_DATE,
be2fb01f
CW
301 ],
302 ],
303 'group_bys' => [
304 'event_type_id' => [
9d72cede 305 'title' => ts('Event Type '),
be2fb01f
CW
306 ],
307 ],
308 ],
309 'civicrm_line_item' => [
6a488035 310 'dao' => 'CRM_Price_DAO_LineItem',
be2fb01f
CW
311 'fields' => [
312 'line_total' => [
9d72cede 313 'title' => ts('Income'),
6a488035 314 'default' => TRUE,
be2fb01f 315 'statistics' => [
9d72cede 316 'sum' => ts('Amount'),
6a488035 317 'avg' => ts('Average'),
be2fb01f
CW
318 ],
319 ],
320 'participant_count' => [
9d72cede 321 'title' => ts('Count'),
6a488035 322 'default' => TRUE,
be2fb01f 323 'statistics' => [
9d72cede 324 'sum' => ts('Count'),
be2fb01f
CW
325 ],
326 ],
327 ],
328 ],
329 ];
330
331 $this->_options = [
332 'blank_column_begin' => [
9d72cede 333 'title' => ts('Blank column at the Begining'),
6a488035 334 'type' => 'checkbox',
be2fb01f
CW
335 ],
336 'blank_column_end' => [
9d72cede 337 'title' => ts('Blank column at the End'),
6a488035 338 'type' => 'select',
be2fb01f 339 'options' => [
6a488035
TO
340 '' => '-select-',
341 1 => ts('One'),
342 2 => ts('Two'),
343 3 => ts('Three'),
be2fb01f
CW
344 ],
345 ],
346 ];
6a488035
TO
347 parent::__construct();
348 }
349
00be9182 350 public function preProcess() {
6a488035
TO
351 parent::preProcess();
352 }
353
74cf4551 354 /**
fe482240 355 * Add The statistics.
74cf4551
EM
356 * @param $rows
357 *
358 * @return array
359 */
00be9182 360 public function statistics(&$rows) {
6a488035
TO
361
362 $statistics = parent::statistics($rows);
9d72cede
EM
363 $avg = NULL;
364 $select = " SELECT SUM( {$this->_aliases['civicrm_line_item']}.participant_count ) as count,
2f4c2f5d 365 SUM( {$this->_aliases['civicrm_line_item']}.line_total ) as amount
366 ";
6a488035
TO
367 $sql = "{$select} {$this->_from} {$this->_where}";
368 $dao = CRM_Core_DAO::executeQuery($sql);
369 if ($dao->fetch()) {
370
371 if ($dao->count && $dao->amount) {
372 $avg = $dao->amount / $dao->count;
373 }
be2fb01f 374 $statistics['counts']['count'] = [
6a488035 375 'value' => $dao->count,
ccc29f8e 376 'title' => ts('Total Participants'),
6a488035 377 'type' => CRM_Utils_Type::T_INT,
be2fb01f
CW
378 ];
379 $statistics['counts']['amount'] = [
6a488035 380 'value' => $dao->amount,
ccc29f8e 381 'title' => ts('Total Income'),
6a488035 382 'type' => CRM_Utils_Type::T_MONEY,
be2fb01f
CW
383 ];
384 $statistics['counts']['avg'] = [
6a488035 385 'value' => $avg,
ccc29f8e 386 'title' => ts('Average'),
6a488035 387 'type' => CRM_Utils_Type::T_MONEY,
be2fb01f 388 ];
6a488035
TO
389 }
390
391 return $statistics;
392 }
393
00be9182 394 public function select() {
be2fb01f
CW
395 $select = [];
396 $this->_columnHeaders = [];
6a488035
TO
397
398 //add blank column at the Start
9d72cede
EM
399 if (array_key_exists('options', $this->_params) &&
400 !empty($this->_params['options']['blank_column_begin'])
401 ) {
6a488035
TO
402 $select[] = " '' as blankColumnBegin";
403 $this->_columnHeaders['blankColumnBegin']['title'] = '_ _ _ _';
404 }
405 foreach ($this->_columns as $tableName => $table) {
406 if (array_key_exists('fields', $table)) {
407 foreach ($table['fields'] as $fieldName => $field) {
9d72cede
EM
408 if (!empty($field['required']) ||
409 !empty($this->_params['fields'][$fieldName])
410 ) {
a7488080 411 if (!empty($field['statistics'])) {
6a488035
TO
412 foreach ($field['statistics'] as $stat => $label) {
413 switch (strtolower($stat)) {
414 case 'sum':
415 $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}";
416 $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['type'] = CRM_Utils_Type::T_INT;
417 $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
418 $this->_statFields[] = "{$tableName}_{$fieldName}_{$stat}";
419 break;
420 }
421 }
422 }
423 else {
424 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
425 $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field);
426 $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'];
427 }
428 }
429 }
430 }
431 }
432 //add blank column at the end
433 if ($blankcols = CRM_Utils_Array::value('blank_column_end', $this->_params)) {
434 for ($i = 1; $i <= $blankcols; $i++) {
435 $select[] = " '' as blankColumnEnd_{$i}";
436 $this->_columnHeaders["blank_{$i}"]['title'] = "_ _ _ _";
437 }
438 }
d1641c51 439 $this->_selectClauses = $select;
6a488035
TO
440 $this->_select = "SELECT " . implode(', ', $select) . " ";
441 }
442
74cf4551
EM
443 /**
444 * @param $fields
445 * @param $files
446 * @param $self
447 *
448 * @return array
449 */
00be9182 450 public static function formRule($fields, $files, $self) {
be2fb01f 451 $errors = $grouping = [];
6a488035
TO
452 return $errors;
453 }
454
00be9182 455 public function from() {
6a488035 456 $this->_from = "
f813f78e 457 FROM civicrm_participant {$this->_aliases['civicrm_participant']}
458 LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']}
99f13d8d 459 ON ({$this->_aliases['civicrm_event']}.id = {$this->_aliases['civicrm_participant']}.event_id ) AND {$this->_aliases['civicrm_event']}.is_template = 0
f813f78e 460 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
461 ON ({$this->_aliases['civicrm_participant']}.contact_id = {$this->_aliases['civicrm_contact']}.id )
462 {$this->_aclFrom}
463 LEFT JOIN civicrm_contact {$this->_aliases['civicrm_employer']}
464 ON ({$this->_aliases['civicrm_employer']}.id = {$this->_aliases['civicrm_contact']}.employer_id )
2f4c2f5d 465 LEFT JOIN civicrm_line_item {$this->_aliases['civicrm_line_item']}
5fa8e57d 466 ON {$this->_aliases['civicrm_line_item']}.entity_table = 'civicrm_participant' AND {$this->_aliases['civicrm_participant']}.id ={$this->_aliases['civicrm_line_item']}.entity_id";
185c566a 467
468 $this->joinAddressFromContact();
469 $this->joinPhoneFromContact();
470 $this->joinEmailFromContact();
6a488035
TO
471 }
472
00be9182 473 public function storeWhereHavingClauseArray() {
e8b2628d
DS
474 parent::storeWhereHavingClauseArray();
475 $this->_whereClauses[] = "{$this->_aliases['civicrm_participant']}.is_test = 0";
6a488035
TO
476 }
477
00be9182 478 public function groupBy() {
0179fdce 479 // We override this function because we use GROUP functions in the
480 // SELECT clause, therefore we have to group by *something*. If the
481 // user doesn't select a column to group by, we should group by participant id.
a49d6344 482 parent::groupBy();
0179fdce 483 if (empty($this->_groupBy)) {
b708c08d 484 $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, "{$this->_aliases['civicrm_participant']}.id");
6a488035 485 }
6a488035
TO
486 }
487
00be9182 488 public function postProcess() {
6a488035
TO
489
490 // get ready with post process params
491 $this->beginPostProcess();
492
493 // get the acl clauses built before we assemble the query
494 $this->buildACLClause($this->_aliases['civicrm_contact']);
495 // build query
496 $sql = $this->buildQuery(TRUE);
497
498 // build array of result based on column headers. This method also allows
499 // modifying column headers before using it to build result set i.e $rows.
500 $this->buildRows($sql, $rows);
501
502 // format result set.
503 $this->formatDisplay($rows);
504
505 // assign variables to templates
506 $this->doTemplateAssignment($rows);
507
508 // do print / pdf / instance stuff if needed
509 $this->endPostProcess($rows);
510 }
511
74cf4551 512 /**
ced9bfed
EM
513 * Alter display of rows.
514 *
515 * Iterate through the rows retrieved via SQL and make changes for display purposes,
516 * such as rendering contacts as links.
517 *
518 * @param array $rows
519 * Rows generated by SQL, with an array for each row.
74cf4551 520 */
00be9182 521 public function alterDisplay(&$rows) {
6a488035
TO
522 $entryFound = FALSE;
523 $eventType = CRM_Core_OptionGroup::values('event_type');
524
525 foreach ($rows as $rowNum => $row) {
526
527 // convert sort name to links
528 if (array_key_exists('civicrm_contact_sort_name', $row) &&
529 array_key_exists('civicrm_contact_id', $row)
530 ) {
531 if ($value = $row['civicrm_contact_sort_name']) {
532 $url = CRM_Utils_System::url("civicrm/contact/view",
533 'reset=1&cid=' . $row['civicrm_contact_id'],
534 $this->_absoluteUrl
535 );
536 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
537 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contact Summary for this Contact.");
538 }
539 $entryFound = TRUE;
540 }
541
542 // convert participant ID to links
543 if (array_key_exists('civicrm_participant_participant_id', $row) &&
544 array_key_exists('civicrm_contact_id', $row)
545 ) {
546 if ($value = $row['civicrm_participant_participant_id']) {
547 $url = CRM_Utils_System::url("civicrm/contact/view/participant",
9d72cede
EM
548 'reset=1&id=' . $row['civicrm_participant_participant_id'] .
549 '&cid=' . $row['civicrm_contact_id'] .
550 '&action=view&context=participant',
6a488035
TO
551 $this->_absoluteUrl
552 );
553 $rows[$rowNum]['civicrm_participant_participant_id_link'] = $url;
554 $rows[$rowNum]['civicrm_participant_participant_id_hover'] = ts("View Participant Record for this Contact.");
555 }
556 $entryFound = TRUE;
557 }
558
559 // convert event name to links
560 if (array_key_exists('civicrm_participant_event_id', $row)) {
561 if ($value = $row['civicrm_participant_event_id']) {
562 $rows[$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($value, FALSE);
563 $url = CRM_Report_Utils_Report::getNextUrl('event/Income',
564 'reset=1&force=1&event_id_op=eq&event_id_value=' . $value,
565 $this->_absoluteUrl, $this->_id, $this->_drilldownReport
566 );
567 $rows[$rowNum]['civicrm_participant_event_id_link'] = $url;
568 $rows[$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income Details for this Event");
569 }
570 $entryFound = TRUE;
571 }
572
573 // handle event type id
574 if (array_key_exists('civicrm_event_event_type_id', $row)) {
575 if ($value = $row['civicrm_event_event_type_id']) {
576 $rows[$rowNum]['civicrm_event_event_type_id'] = $eventType[$value];
577 }
578 $entryFound = TRUE;
579 }
580
581 // handle participant status id
582 if (array_key_exists('civicrm_participant_status_id', $row)) {
583 if ($value = $row['civicrm_participant_status_id']) {
584 $rows[$rowNum]['civicrm_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($value, FALSE);
585 }
586 $entryFound = TRUE;
587 }
588
589 // handle participant role id
590 if (array_key_exists('civicrm_participant_role_id', $row)) {
591 if ($value = $row['civicrm_participant_role_id']) {
592 $roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
be2fb01f 593 $value = [];
6a488035
TO
594 foreach ($roles as $role) {
595 $value[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE);
596 }
597 $rows[$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
598 }
599 $entryFound = TRUE;
600 }
601
3da34b73 602 $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, NULL, NULL) ? TRUE : $entryFound;
70bea8e2 603
6a488035
TO
604 // skip looking further in rows, if first row itself doesn't
605 // have the column we need
606 if (!$entryFound) {
607 break;
608 }
609 }
610 }
96025800 611
6a488035 612}