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