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