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