Merge pull request #22482 from eileenmcnaughton/token
[civicrm-core.git] / CRM / Event / DAO / Participant.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Event/Participant.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:4ca199ee96c9079ad7ce673c7a06d5f6)
10 */
11
12 /**
13 * Database access object for the Participant entity.
14 */
15 class CRM_Event_DAO_Participant extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.7';
18 const COMPONENT = 'CiviEvent';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_participant';
26
27 /**
28 * Icon associated with this entity.
29 *
30 * @var string
31 */
32 public static $_icon = 'fa-ticket';
33
34 /**
35 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 *
37 * @var bool
38 */
39 public static $_log = TRUE;
40
41 /**
42 * Participant ID
43 *
44 * @var int
45 */
46 public $id;
47
48 /**
49 * FK to Contact ID
50 *
51 * @var int
52 */
53 public $contact_id;
54
55 /**
56 * FK to Event ID
57 *
58 * @var int
59 */
60 public $event_id;
61
62 /**
63 * Participant status ID. FK to civicrm_participant_status_type. Default of 1 should map to status = Registered.
64 *
65 * @var int
66 */
67 public $status_id;
68
69 /**
70 * Participant role ID. Implicit FK to civicrm_option_value where option_group = participant_role.
71 *
72 * @var string
73 */
74 public $role_id;
75
76 /**
77 * When did contact register for event?
78 *
79 * @var datetime
80 */
81 public $register_date;
82
83 /**
84 * Source of this event registration.
85 *
86 * @var string
87 */
88 public $source;
89
90 /**
91 * Populate with the label (text) associated with a fee level for paid events with multiple levels. Note that
92 * we store the label value and not the key
93 *
94 * @var text
95 */
96 public $fee_level;
97
98 /**
99 * @var bool
100 */
101 public $is_test;
102
103 /**
104 * @var bool
105 */
106 public $is_pay_later;
107
108 /**
109 * actual processor fee if known - may be 0.
110 *
111 * @var float
112 */
113 public $fee_amount;
114
115 /**
116 * FK to Participant ID
117 *
118 * @var int
119 */
120 public $registered_by_id;
121
122 /**
123 * FK to Discount ID
124 *
125 * @var int
126 */
127 public $discount_id;
128
129 /**
130 * 3 character string, value derived from config setting.
131 *
132 * @var string
133 */
134 public $fee_currency;
135
136 /**
137 * The campaign for which this participant has been registered.
138 *
139 * @var int
140 */
141 public $campaign_id;
142
143 /**
144 * Discount Amount
145 *
146 * @var int
147 */
148 public $discount_amount;
149
150 /**
151 * FK to civicrm_event_carts
152 *
153 * @var int
154 */
155 public $cart_id;
156
157 /**
158 * On Waiting List
159 *
160 * @var int
161 */
162 public $must_wait;
163
164 /**
165 * FK to Contact ID
166 *
167 * @var int
168 */
169 public $transferred_to_contact_id;
170
171 /**
172 * Class constructor.
173 */
174 public function __construct() {
175 $this->__table = 'civicrm_participant';
176 parent::__construct();
177 }
178
179 /**
180 * Returns localized title of this entity.
181 *
182 * @param bool $plural
183 * Whether to return the plural version of the title.
184 */
185 public static function getEntityTitle($plural = FALSE) {
186 return $plural ? ts('Participants') : ts('Participant');
187 }
188
189 /**
190 * Returns user-friendly description of this entity.
191 *
192 * @return string
193 */
194 public static function getEntityDescription() {
195 return ts('Records of contacts\' attendance and roles in events.');
196 }
197
198 /**
199 * Returns foreign keys and entity references.
200 *
201 * @return array
202 * [CRM_Core_Reference_Interface]
203 */
204 public static function getReferenceColumns() {
205 if (!isset(Civi::$statics[__CLASS__]['links'])) {
206 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
207 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
208 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'event_id', 'civicrm_event', 'id');
209 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'status_id', 'civicrm_participant_status_type', 'id');
210 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'registered_by_id', 'civicrm_participant', 'id');
211 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'discount_id', 'civicrm_discount', 'id');
212 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
213 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'cart_id', 'civicrm_event_carts', 'id');
214 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'transferred_to_contact_id', 'civicrm_contact', 'id');
215 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
216 }
217 return Civi::$statics[__CLASS__]['links'];
218 }
219
220 /**
221 * Returns all the column names of this table
222 *
223 * @return array
224 */
225 public static function &fields() {
226 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
227 Civi::$statics[__CLASS__]['fields'] = [
228 'participant_id' => [
229 'name' => 'id',
230 'type' => CRM_Utils_Type::T_INT,
231 'title' => ts('Participant ID'),
232 'description' => ts('Participant ID'),
233 'required' => TRUE,
234 'import' => TRUE,
235 'where' => 'civicrm_participant.id',
236 'headerPattern' => '/(^(participant(.)?)?id$)/i',
237 'export' => TRUE,
238 'table_name' => 'civicrm_participant',
239 'entity' => 'Participant',
240 'bao' => 'CRM_Event_BAO_Participant',
241 'localizable' => 0,
242 'html' => [
243 'type' => 'Number',
244 ],
245 'readonly' => TRUE,
246 'add' => '1.7',
247 ],
248 'participant_contact_id' => [
249 'name' => 'contact_id',
250 'type' => CRM_Utils_Type::T_INT,
251 'title' => ts('Contact ID'),
252 'description' => ts('FK to Contact ID'),
253 'required' => TRUE,
254 'import' => TRUE,
255 'where' => 'civicrm_participant.contact_id',
256 'headerPattern' => '/contact(.?id)?/i',
257 'export' => TRUE,
258 'table_name' => 'civicrm_participant',
259 'entity' => 'Participant',
260 'bao' => 'CRM_Event_BAO_Participant',
261 'localizable' => 0,
262 'FKClassName' => 'CRM_Contact_DAO_Contact',
263 'html' => [
264 'label' => ts("Contact"),
265 ],
266 'add' => '1.7',
267 ],
268 'event_id' => [
269 'name' => 'event_id',
270 'type' => CRM_Utils_Type::T_INT,
271 'title' => ts('Event ID'),
272 'description' => ts('FK to Event ID'),
273 'required' => TRUE,
274 'import' => TRUE,
275 'where' => 'civicrm_participant.event_id',
276 'headerPattern' => '/event id$/i',
277 'export' => TRUE,
278 'table_name' => 'civicrm_participant',
279 'entity' => 'Participant',
280 'bao' => 'CRM_Event_BAO_Participant',
281 'localizable' => 0,
282 'FKClassName' => 'CRM_Event_DAO_Event',
283 'html' => [
284 'label' => ts("Event"),
285 ],
286 'add' => '1.7',
287 ],
288 'participant_status_id' => [
289 'name' => 'status_id',
290 'type' => CRM_Utils_Type::T_INT,
291 'title' => ts('Status ID'),
292 'description' => ts('Participant status ID. FK to civicrm_participant_status_type. Default of 1 should map to status = Registered.'),
293 'required' => TRUE,
294 'import' => TRUE,
295 'where' => 'civicrm_participant.status_id',
296 'headerPattern' => '/(participant.)?(status)$/i',
297 'export' => TRUE,
298 'default' => '1',
299 'table_name' => 'civicrm_participant',
300 'entity' => 'Participant',
301 'bao' => 'CRM_Event_BAO_Participant',
302 'localizable' => 0,
303 'FKClassName' => 'CRM_Event_DAO_ParticipantStatusType',
304 'html' => [
305 'type' => 'Select',
306 'label' => ts("Status"),
307 ],
308 'pseudoconstant' => [
309 'table' => 'civicrm_participant_status_type',
310 'keyColumn' => 'id',
311 'labelColumn' => 'label',
312 ],
313 'add' => '1.7',
314 ],
315 'participant_role_id' => [
316 'name' => 'role_id',
317 'type' => CRM_Utils_Type::T_STRING,
318 'title' => ts('Participant Role ID'),
319 'description' => ts('Participant role ID. Implicit FK to civicrm_option_value where option_group = participant_role.'),
320 'maxlength' => 128,
321 'size' => CRM_Utils_Type::HUGE,
322 'import' => TRUE,
323 'where' => 'civicrm_participant.role_id',
324 'headerPattern' => '/(participant.)?(role)$/i',
325 'export' => TRUE,
326 'default' => NULL,
327 'table_name' => 'civicrm_participant',
328 'entity' => 'Participant',
329 'bao' => 'CRM_Event_BAO_Participant',
330 'localizable' => 0,
331 'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
332 'html' => [
333 'type' => 'Select',
334 'label' => ts("Participant Role"),
335 ],
336 'pseudoconstant' => [
337 'optionGroupName' => 'participant_role',
338 'optionEditPath' => 'civicrm/admin/options/participant_role',
339 ],
340 'add' => '1.7',
341 ],
342 'participant_register_date' => [
343 'name' => 'register_date',
344 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
345 'title' => ts('Register date'),
346 'description' => ts('When did contact register for event?'),
347 'import' => TRUE,
348 'where' => 'civicrm_participant.register_date',
349 'headerPattern' => '/^(r(egister\s)?date)$/i',
350 'export' => TRUE,
351 'table_name' => 'civicrm_participant',
352 'entity' => 'Participant',
353 'bao' => 'CRM_Event_BAO_Participant',
354 'localizable' => 0,
355 'html' => [
356 'type' => 'Select Date',
357 'formatType' => 'activityDateTime',
358 ],
359 'add' => '1.7',
360 ],
361 'participant_source' => [
362 'name' => 'source',
363 'type' => CRM_Utils_Type::T_STRING,
364 'title' => ts('Participant Source'),
365 'description' => ts('Source of this event registration.'),
366 'maxlength' => 128,
367 'size' => CRM_Utils_Type::HUGE,
368 'import' => TRUE,
369 'where' => 'civicrm_participant.source',
370 'headerPattern' => '/(participant.)?(source)$/i',
371 'export' => TRUE,
372 'table_name' => 'civicrm_participant',
373 'entity' => 'Participant',
374 'bao' => 'CRM_Event_BAO_Participant',
375 'localizable' => 0,
376 'html' => [
377 'type' => 'Text',
378 ],
379 'add' => '1.7',
380 ],
381 'participant_fee_level' => [
382 'name' => 'fee_level',
383 'type' => CRM_Utils_Type::T_TEXT,
384 'title' => ts('Fee level'),
385 'description' => ts('Populate with the label (text) associated with a fee level for paid events with multiple levels. Note that
386 we store the label value and not the key'),
387 'import' => TRUE,
388 'where' => 'civicrm_participant.fee_level',
389 'headerPattern' => '/^(f(ee\s)?level)$/i',
390 'export' => TRUE,
391 'table_name' => 'civicrm_participant',
392 'entity' => 'Participant',
393 'bao' => 'CRM_Event_BAO_Participant',
394 'localizable' => 0,
395 'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
396 'add' => '1.7',
397 ],
398 'participant_is_test' => [
399 'name' => 'is_test',
400 'type' => CRM_Utils_Type::T_BOOLEAN,
401 'title' => ts('Test'),
402 'import' => TRUE,
403 'where' => 'civicrm_participant.is_test',
404 'export' => TRUE,
405 'default' => '0',
406 'table_name' => 'civicrm_participant',
407 'entity' => 'Participant',
408 'bao' => 'CRM_Event_BAO_Participant',
409 'localizable' => 0,
410 'add' => '1.7',
411 ],
412 'participant_is_pay_later' => [
413 'name' => 'is_pay_later',
414 'type' => CRM_Utils_Type::T_BOOLEAN,
415 'title' => ts('Is Pay Later'),
416 'import' => TRUE,
417 'where' => 'civicrm_participant.is_pay_later',
418 'headerPattern' => '/(is.)?(pay(.)?later)$/i',
419 'export' => TRUE,
420 'default' => '0',
421 'table_name' => 'civicrm_participant',
422 'entity' => 'Participant',
423 'bao' => 'CRM_Event_BAO_Participant',
424 'localizable' => 0,
425 'add' => '2.1',
426 ],
427 'participant_fee_amount' => [
428 'name' => 'fee_amount',
429 'type' => CRM_Utils_Type::T_MONEY,
430 'title' => ts('Fee Amount'),
431 'description' => ts('actual processor fee if known - may be 0.'),
432 'precision' => [
433 20,
434 2,
435 ],
436 'import' => TRUE,
437 'where' => 'civicrm_participant.fee_amount',
438 'headerPattern' => '/fee(.?am(ou)?nt)?/i',
439 'dataPattern' => '/^\d+(\.\d{2})?$/',
440 'export' => TRUE,
441 'table_name' => 'civicrm_participant',
442 'entity' => 'Participant',
443 'bao' => 'CRM_Event_BAO_Participant',
444 'localizable' => 0,
445 'add' => '2.1',
446 ],
447 'participant_registered_by_id' => [
448 'name' => 'registered_by_id',
449 'type' => CRM_Utils_Type::T_INT,
450 'title' => ts('Registered By Participant ID'),
451 'description' => ts('FK to Participant ID'),
452 'import' => TRUE,
453 'where' => 'civicrm_participant.registered_by_id',
454 'export' => TRUE,
455 'default' => NULL,
456 'table_name' => 'civicrm_participant',
457 'entity' => 'Participant',
458 'bao' => 'CRM_Event_BAO_Participant',
459 'localizable' => 0,
460 'FKClassName' => 'CRM_Event_DAO_Participant',
461 'html' => [
462 'label' => ts("Registered By"),
463 ],
464 'add' => '2.1',
465 ],
466 'participant_discount_id' => [
467 'name' => 'discount_id',
468 'type' => CRM_Utils_Type::T_INT,
469 'title' => ts('Discount ID'),
470 'description' => ts('FK to Discount ID'),
471 'where' => 'civicrm_participant.discount_id',
472 'default' => NULL,
473 'table_name' => 'civicrm_participant',
474 'entity' => 'Participant',
475 'bao' => 'CRM_Event_BAO_Participant',
476 'localizable' => 0,
477 'FKClassName' => 'CRM_Core_DAO_Discount',
478 'html' => [
479 'label' => ts("Discount"),
480 ],
481 'add' => '2.1',
482 ],
483 'participant_fee_currency' => [
484 'name' => 'fee_currency',
485 'type' => CRM_Utils_Type::T_STRING,
486 'title' => ts('Fee Currency'),
487 'description' => ts('3 character string, value derived from config setting.'),
488 'maxlength' => 3,
489 'size' => CRM_Utils_Type::FOUR,
490 'import' => TRUE,
491 'where' => 'civicrm_participant.fee_currency',
492 'headerPattern' => '/(fee)?.?cur(rency)?/i',
493 'dataPattern' => '/^[A-Z]{3}$/i',
494 'export' => TRUE,
495 'default' => NULL,
496 'table_name' => 'civicrm_participant',
497 'entity' => 'Participant',
498 'bao' => 'CRM_Event_BAO_Participant',
499 'localizable' => 0,
500 'html' => [
501 'type' => 'Select',
502 ],
503 'pseudoconstant' => [
504 'table' => 'civicrm_currency',
505 'keyColumn' => 'name',
506 'labelColumn' => 'full_name',
507 'nameColumn' => 'name',
508 'abbrColumn' => 'symbol',
509 ],
510 'add' => '3.0',
511 ],
512 'participant_campaign_id' => [
513 'name' => 'campaign_id',
514 'type' => CRM_Utils_Type::T_INT,
515 'title' => ts('Campaign ID'),
516 'description' => ts('The campaign for which this participant has been registered.'),
517 'import' => TRUE,
518 'where' => 'civicrm_participant.campaign_id',
519 'export' => TRUE,
520 'table_name' => 'civicrm_participant',
521 'entity' => 'Participant',
522 'bao' => 'CRM_Event_BAO_Participant',
523 'localizable' => 0,
524 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
525 'component' => 'CiviCampaign',
526 'html' => [
527 'type' => 'EntityRef',
528 'label' => ts("Campaign"),
529 ],
530 'pseudoconstant' => [
531 'table' => 'civicrm_campaign',
532 'keyColumn' => 'id',
533 'labelColumn' => 'title',
534 'prefetch' => 'FALSE',
535 ],
536 'add' => '3.4',
537 ],
538 'discount_amount' => [
539 'name' => 'discount_amount',
540 'type' => CRM_Utils_Type::T_INT,
541 'title' => ts('Discount Amount'),
542 'description' => ts('Discount Amount'),
543 'where' => 'civicrm_participant.discount_amount',
544 'table_name' => 'civicrm_participant',
545 'entity' => 'Participant',
546 'bao' => 'CRM_Event_BAO_Participant',
547 'localizable' => 0,
548 'add' => '4.1',
549 ],
550 'cart_id' => [
551 'name' => 'cart_id',
552 'type' => CRM_Utils_Type::T_INT,
553 'title' => ts('Event Cart ID'),
554 'description' => ts('FK to civicrm_event_carts'),
555 'where' => 'civicrm_participant.cart_id',
556 'table_name' => 'civicrm_participant',
557 'entity' => 'Participant',
558 'bao' => 'CRM_Event_BAO_Participant',
559 'localizable' => 0,
560 'FKClassName' => 'CRM_Event_Cart_DAO_Cart',
561 'html' => [
562 'label' => ts("Event Cart"),
563 ],
564 'add' => '4.1',
565 ],
566 'must_wait' => [
567 'name' => 'must_wait',
568 'type' => CRM_Utils_Type::T_INT,
569 'title' => ts('Must Wait on List'),
570 'description' => ts('On Waiting List'),
571 'where' => 'civicrm_participant.must_wait',
572 'table_name' => 'civicrm_participant',
573 'entity' => 'Participant',
574 'bao' => 'CRM_Event_BAO_Participant',
575 'localizable' => 0,
576 'add' => '4.1',
577 ],
578 'transferred_to_contact_id' => [
579 'name' => 'transferred_to_contact_id',
580 'type' => CRM_Utils_Type::T_INT,
581 'title' => ts('Transferred to Contact ID'),
582 'description' => ts('FK to Contact ID'),
583 'import' => TRUE,
584 'where' => 'civicrm_participant.transferred_to_contact_id',
585 'headerPattern' => '/transfer(.?id)?/i',
586 'export' => TRUE,
587 'default' => NULL,
588 'table_name' => 'civicrm_participant',
589 'entity' => 'Participant',
590 'bao' => 'CRM_Event_BAO_Participant',
591 'localizable' => 0,
592 'FKClassName' => 'CRM_Contact_DAO_Contact',
593 'html' => [
594 'label' => ts("Transferred to"),
595 ],
596 'add' => '4.7',
597 ],
598 ];
599 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
600 }
601 return Civi::$statics[__CLASS__]['fields'];
602 }
603
604 /**
605 * Return a mapping from field-name to the corresponding key (as used in fields()).
606 *
607 * @return array
608 * Array(string $name => string $uniqueName).
609 */
610 public static function &fieldKeys() {
611 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
612 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
613 }
614 return Civi::$statics[__CLASS__]['fieldKeys'];
615 }
616
617 /**
618 * Returns the names of this table
619 *
620 * @return string
621 */
622 public static function getTableName() {
623 return self::$_tableName;
624 }
625
626 /**
627 * Returns if this table needs to be logged
628 *
629 * @return bool
630 */
631 public function getLog() {
632 return self::$_log;
633 }
634
635 /**
636 * Returns the list of fields that can be imported
637 *
638 * @param bool $prefix
639 *
640 * @return array
641 */
642 public static function &import($prefix = FALSE) {
643 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'participant', $prefix, []);
644 return $r;
645 }
646
647 /**
648 * Returns the list of fields that can be exported
649 *
650 * @param bool $prefix
651 *
652 * @return array
653 */
654 public static function &export($prefix = FALSE) {
655 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'participant', $prefix, []);
656 return $r;
657 }
658
659 /**
660 * Returns the list of indices
661 *
662 * @param bool $localize
663 *
664 * @return array
665 */
666 public static function indices($localize = TRUE) {
667 $indices = [
668 'index_status_id' => [
669 'name' => 'index_status_id',
670 'field' => [
671 0 => 'status_id',
672 ],
673 'localizable' => FALSE,
674 'sig' => 'civicrm_participant::0::status_id',
675 ],
676 'index_role_id' => [
677 'name' => 'index_role_id',
678 'field' => [
679 0 => 'role_id',
680 ],
681 'localizable' => FALSE,
682 'sig' => 'civicrm_participant::0::role_id',
683 ],
684 ];
685 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
686 }
687
688 }