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