Merge pull request #10037 from JMAConsulting/CRM-20331
[civicrm-core.git] / CRM / Event / DAO / Participant.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
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
29 * @copyright CiviCRM LLC (c) 2004-2017
30 *
31 * Generated from xml/schema/CRM/Event/Participant.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:cb95d1337bbf4098362e0808dbbdeabf)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Event_DAO_Participant constructor.
39 */
40 class CRM_Event_DAO_Participant extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_participant';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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 *
99 * @var text
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 /**
167 * Class constructor.
168 */
169 function __construct() {
170 $this->__table = 'civicrm_participant';
171 parent::__construct();
172 }
173 /**
174 * Returns foreign keys and entity references.
175 *
176 * @return array
177 * [CRM_Core_Reference_Interface]
178 */
179 static function getReferenceColumns() {
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']);
191 }
192 return Civi::$statics[__CLASS__]['links'];
193 }
194 /**
195 * Returns all the column names of this table
196 *
197 * @return array
198 */
199 static function &fields() {
200 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
201 Civi::$statics[__CLASS__]['fields'] = array(
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,
213 'table_name' => 'civicrm_participant',
214 'entity' => 'Participant',
215 'bao' => 'CRM_Event_BAO_Participant',
216 ) ,
217 'participant_contact_id' => array(
218 'name' => 'contact_id',
219 'type' => CRM_Utils_Type::T_INT,
220 'title' => ts('Contact ID') ,
221 'description' => 'FK to Contact ID',
222 'required' => true,
223 'import' => true,
224 'where' => 'civicrm_participant.contact_id',
225 'headerPattern' => '/contact(.?id)?/i',
226 'dataPattern' => '',
227 'export' => true,
228 'table_name' => 'civicrm_participant',
229 'entity' => 'Participant',
230 'bao' => 'CRM_Event_BAO_Participant',
231 'FKClassName' => 'CRM_Contact_DAO_Contact',
232 ) ,
233 'event_id' => array(
234 'name' => 'event_id',
235 'type' => CRM_Utils_Type::T_INT,
236 'title' => ts('Event') ,
237 'description' => 'FK to Event ID',
238 'required' => true,
239 'import' => true,
240 'where' => 'civicrm_participant.event_id',
241 'headerPattern' => '/event id$/i',
242 'dataPattern' => '',
243 'export' => true,
244 'table_name' => 'civicrm_participant',
245 'entity' => 'Participant',
246 'bao' => 'CRM_Event_BAO_Participant',
247 'FKClassName' => 'CRM_Event_DAO_Event',
248 ) ,
249 'participant_status_id' => array(
250 'name' => 'status_id',
251 'type' => CRM_Utils_Type::T_INT,
252 'title' => ts('Participant Status') ,
253 'description' => 'Participant status ID. FK to civicrm_participant_status_type. Default of 1 should map to status = Registered.',
254 'required' => true,
255 'import' => true,
256 'where' => 'civicrm_participant.status_id',
257 'headerPattern' => '/(participant.)?(status)$/i',
258 'dataPattern' => '',
259 'export' => true,
260 'default' => '1',
261 'table_name' => 'civicrm_participant',
262 'entity' => 'Participant',
263 'bao' => 'CRM_Event_BAO_Participant',
264 'FKClassName' => 'CRM_Event_DAO_ParticipantStatusType',
265 'html' => array(
266 'type' => 'Select',
267 ) ,
268 'pseudoconstant' => array(
269 'table' => 'civicrm_participant_status_type',
270 'keyColumn' => 'id',
271 'labelColumn' => 'label',
272 )
273 ) ,
274 'participant_role_id' => array(
275 'name' => 'role_id',
276 'type' => CRM_Utils_Type::T_STRING,
277 'title' => ts('Participant Role') ,
278 'description' => 'Participant role ID. Implicit FK to civicrm_option_value where option_group = participant_role.',
279 'maxlength' => 128,
280 'size' => CRM_Utils_Type::HUGE,
281 'import' => true,
282 'where' => 'civicrm_participant.role_id',
283 'headerPattern' => '/(participant.)?(role)$/i',
284 'dataPattern' => '',
285 'export' => true,
286 'default' => 'NULL',
287 'table_name' => 'civicrm_participant',
288 'entity' => 'Participant',
289 'bao' => 'CRM_Event_BAO_Participant',
290 'html' => array(
291 'type' => 'Select',
292 ) ,
293 'pseudoconstant' => array(
294 'optionGroupName' => 'participant_role',
295 'optionEditPath' => 'civicrm/admin/options/participant_role',
296 )
297 ) ,
298 'participant_register_date' => array(
299 'name' => 'register_date',
300 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
301 'title' => ts('Register date') ,
302 'description' => 'When did contact register for event?',
303 'import' => true,
304 'where' => 'civicrm_participant.register_date',
305 'headerPattern' => '/^(r(egister\s)?date)$/i',
306 'dataPattern' => '',
307 'export' => true,
308 'table_name' => 'civicrm_participant',
309 'entity' => 'Participant',
310 'bao' => 'CRM_Event_BAO_Participant',
311 'html' => array(
312 'type' => 'Select Date',
313 'formatType' => 'activityDateTime',
314 ) ,
315 ) ,
316 'participant_source' => array(
317 'name' => 'source',
318 'type' => CRM_Utils_Type::T_STRING,
319 'title' => ts('Participant Source') ,
320 'description' => 'Source of this event registration.',
321 'maxlength' => 128,
322 'size' => CRM_Utils_Type::HUGE,
323 'import' => true,
324 'where' => 'civicrm_participant.source',
325 'headerPattern' => '/(participant.)?(source)$/i',
326 'dataPattern' => '',
327 'export' => true,
328 'table_name' => 'civicrm_participant',
329 'entity' => 'Participant',
330 'bao' => 'CRM_Event_BAO_Participant',
331 ) ,
332 'participant_fee_level' => array(
333 'name' => 'fee_level',
334 'type' => CRM_Utils_Type::T_TEXT,
335 'title' => ts('Fee level') ,
336 'description' => 'Populate with the label (text) associated with a fee level for paid events with multiple levels. Note that
337 we store the label value and not the key
338 ',
339 'import' => true,
340 'where' => 'civicrm_participant.fee_level',
341 'headerPattern' => '/^(f(ee\s)?level)$/i',
342 'dataPattern' => '',
343 'export' => true,
344 'table_name' => 'civicrm_participant',
345 'entity' => 'Participant',
346 'bao' => 'CRM_Event_BAO_Participant',
347 ) ,
348 'participant_is_test' => array(
349 'name' => 'is_test',
350 'type' => CRM_Utils_Type::T_BOOLEAN,
351 'title' => ts('Test') ,
352 'import' => true,
353 'where' => 'civicrm_participant.is_test',
354 'headerPattern' => '',
355 'dataPattern' => '',
356 'export' => true,
357 'table_name' => 'civicrm_participant',
358 'entity' => 'Participant',
359 'bao' => 'CRM_Event_BAO_Participant',
360 ) ,
361 'participant_is_pay_later' => array(
362 'name' => 'is_pay_later',
363 'type' => CRM_Utils_Type::T_BOOLEAN,
364 'title' => ts('Is Pay Later') ,
365 'import' => true,
366 'where' => 'civicrm_participant.is_pay_later',
367 'headerPattern' => '/(is.)?(pay(.)?later)$/i',
368 'dataPattern' => '',
369 'export' => true,
370 'table_name' => 'civicrm_participant',
371 'entity' => 'Participant',
372 'bao' => 'CRM_Event_BAO_Participant',
373 ) ,
374 'participant_fee_amount' => array(
375 'name' => 'fee_amount',
376 'type' => CRM_Utils_Type::T_MONEY,
377 'title' => ts('Fee Amount') ,
378 'description' => 'actual processor fee if known - may be 0.',
379 'precision' => array(
380 20,
381 2
382 ) ,
383 'import' => true,
384 'where' => 'civicrm_participant.fee_amount',
385 'headerPattern' => '/fee(.?am(ou)?nt)?/i',
386 'dataPattern' => '/^\d+(\.\d{2})?$/',
387 'export' => true,
388 'table_name' => 'civicrm_participant',
389 'entity' => 'Participant',
390 'bao' => 'CRM_Event_BAO_Participant',
391 ) ,
392 'participant_registered_by_id' => array(
393 'name' => 'registered_by_id',
394 'type' => CRM_Utils_Type::T_INT,
395 'title' => ts('Registered By ID') ,
396 'description' => 'FK to Participant ID',
397 'import' => true,
398 'where' => 'civicrm_participant.registered_by_id',
399 'headerPattern' => '',
400 'dataPattern' => '',
401 'export' => true,
402 'default' => 'NULL',
403 'table_name' => 'civicrm_participant',
404 'entity' => 'Participant',
405 'bao' => 'CRM_Event_BAO_Participant',
406 'FKClassName' => 'CRM_Event_DAO_Participant',
407 ) ,
408 'participant_discount_id' => array(
409 'name' => 'discount_id',
410 'type' => CRM_Utils_Type::T_INT,
411 'title' => ts('Discount ID') ,
412 'description' => 'FK to Discount ID',
413 'default' => 'NULL',
414 'table_name' => 'civicrm_participant',
415 'entity' => 'Participant',
416 'bao' => 'CRM_Event_BAO_Participant',
417 'FKClassName' => 'CRM_Core_DAO_Discount',
418 ) ,
419 'participant_fee_currency' => array(
420 'name' => 'fee_currency',
421 'type' => CRM_Utils_Type::T_STRING,
422 'title' => ts('Fee Currency') ,
423 'description' => '3 character string, value derived from config setting.',
424 'maxlength' => 3,
425 'size' => CRM_Utils_Type::FOUR,
426 'import' => true,
427 'where' => 'civicrm_participant.fee_currency',
428 'headerPattern' => '/(fee)?.?cur(rency)?/i',
429 'dataPattern' => '/^[A-Z]{3}$/i',
430 'export' => true,
431 'default' => 'NULL',
432 'table_name' => 'civicrm_participant',
433 'entity' => 'Participant',
434 'bao' => 'CRM_Event_BAO_Participant',
435 'html' => array(
436 'type' => 'Select',
437 ) ,
438 'pseudoconstant' => array(
439 'table' => 'civicrm_currency',
440 'keyColumn' => 'name',
441 'labelColumn' => 'full_name',
442 'nameColumn' => 'name',
443 )
444 ) ,
445 'participant_campaign_id' => array(
446 'name' => 'campaign_id',
447 'type' => CRM_Utils_Type::T_INT,
448 'title' => ts('Campaign') ,
449 'description' => 'The campaign for which this participant has been registered.',
450 'import' => true,
451 'where' => 'civicrm_participant.campaign_id',
452 'headerPattern' => '',
453 'dataPattern' => '',
454 'export' => true,
455 'table_name' => 'civicrm_participant',
456 'entity' => 'Participant',
457 'bao' => 'CRM_Event_BAO_Participant',
458 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
459 'pseudoconstant' => array(
460 'table' => 'civicrm_campaign',
461 'keyColumn' => 'id',
462 'labelColumn' => 'title',
463 )
464 ) ,
465 'discount_amount' => array(
466 'name' => 'discount_amount',
467 'type' => CRM_Utils_Type::T_INT,
468 'title' => ts('Discount Amount') ,
469 'description' => 'Discount Amount',
470 'table_name' => 'civicrm_participant',
471 'entity' => 'Participant',
472 'bao' => 'CRM_Event_BAO_Participant',
473 ) ,
474 'cart_id' => array(
475 'name' => 'cart_id',
476 'type' => CRM_Utils_Type::T_INT,
477 'title' => ts('Event Cart ID') ,
478 'description' => 'FK to civicrm_event_carts',
479 'table_name' => 'civicrm_participant',
480 'entity' => 'Participant',
481 'bao' => 'CRM_Event_BAO_Participant',
482 'FKClassName' => 'CRM_Event_Cart_DAO_Cart',
483 ) ,
484 'must_wait' => array(
485 'name' => 'must_wait',
486 'type' => CRM_Utils_Type::T_INT,
487 'title' => ts('Must Wait on List') ,
488 'description' => 'On Waiting List',
489 'table_name' => 'civicrm_participant',
490 'entity' => 'Participant',
491 'bao' => 'CRM_Event_BAO_Participant',
492 ) ,
493 'transferred_to_contact_id' => array(
494 'name' => 'transferred_to_contact_id',
495 'type' => CRM_Utils_Type::T_INT,
496 'title' => ts('Transferred to Contact ID') ,
497 'description' => 'FK to Contact ID',
498 'import' => true,
499 'where' => 'civicrm_participant.transferred_to_contact_id',
500 'headerPattern' => '/transfer(.?id)?/i',
501 'dataPattern' => '',
502 'export' => true,
503 'default' => 'NULL',
504 'table_name' => 'civicrm_participant',
505 'entity' => 'Participant',
506 'bao' => 'CRM_Event_BAO_Participant',
507 'FKClassName' => 'CRM_Contact_DAO_Contact',
508 ) ,
509 );
510 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
511 }
512 return Civi::$statics[__CLASS__]['fields'];
513 }
514 /**
515 * Return a mapping from field-name to the corresponding key (as used in fields()).
516 *
517 * @return array
518 * Array(string $name => string $uniqueName).
519 */
520 static function &fieldKeys() {
521 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
522 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
523 }
524 return Civi::$statics[__CLASS__]['fieldKeys'];
525 }
526 /**
527 * Returns the names of this table
528 *
529 * @return string
530 */
531 static function getTableName() {
532 return self::$_tableName;
533 }
534 /**
535 * Returns if this table needs to be logged
536 *
537 * @return boolean
538 */
539 function getLog() {
540 return self::$_log;
541 }
542 /**
543 * Returns the list of fields that can be imported
544 *
545 * @param bool $prefix
546 *
547 * @return array
548 */
549 static function &import($prefix = false) {
550 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'participant', $prefix, array());
551 return $r;
552 }
553 /**
554 * Returns the list of fields that can be exported
555 *
556 * @param bool $prefix
557 *
558 * @return array
559 */
560 static function &export($prefix = false) {
561 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'participant', $prefix, array());
562 return $r;
563 }
564 }