Merge pull request #9560 from aydun/CRM-19754
[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:5c9653302e7cc416c68b794981f9f9b8)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 class CRM_Event_DAO_Participant extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_participant';
44 /**
45 * static value to see if we should log any modifications to
46 * this table in the civicrm_log table
47 *
48 * @var boolean
49 */
50 static $_log = true;
51 /**
52 * Participant Id
53 *
54 * @var int unsigned
55 */
56 public $id;
57 /**
58 * FK to Contact ID
59 *
60 * @var int unsigned
61 */
62 public $contact_id;
63 /**
64 * FK to Event ID
65 *
66 * @var int unsigned
67 */
68 public $event_id;
69 /**
70 * Participant status ID. FK to civicrm_participant_status_type. Default of 1 should map to status = Registered.
71 *
72 * @var int unsigned
73 */
74 public $status_id;
75 /**
76 * Participant role ID. Implicit FK to civicrm_option_value where option_group = participant_role.
77 *
78 * @var string
79 */
80 public $role_id;
81 /**
82 * When did contact register for event?
83 *
84 * @var datetime
85 */
86 public $register_date;
87 /**
88 * Source of this event registration.
89 *
90 * @var string
91 */
92 public $source;
93 /**
94 * Populate with the label (text) associated with a fee level for paid events with multiple levels. Note that
95 we store the label value and not the key
96 *
97 * @var text
98 */
99 public $fee_level;
100 /**
101 *
102 * @var boolean
103 */
104 public $is_test;
105 /**
106 *
107 * @var boolean
108 */
109 public $is_pay_later;
110 /**
111 * actual processor fee if known - may be 0.
112 *
113 * @var float
114 */
115 public $fee_amount;
116 /**
117 * FK to Participant ID
118 *
119 * @var int unsigned
120 */
121 public $registered_by_id;
122 /**
123 * FK to Discount ID
124 *
125 * @var int unsigned
126 */
127 public $discount_id;
128 /**
129 * 3 character string, value derived from config setting.
130 *
131 * @var string
132 */
133 public $fee_currency;
134 /**
135 * The campaign for which this participant has been registered.
136 *
137 * @var int unsigned
138 */
139 public $campaign_id;
140 /**
141 * Discount Amount
142 *
143 * @var int unsigned
144 */
145 public $discount_amount;
146 /**
147 * FK to civicrm_event_carts
148 *
149 * @var int unsigned
150 */
151 public $cart_id;
152 /**
153 * On Waiting List
154 *
155 * @var int
156 */
157 public $must_wait;
158 /**
159 * FK to Contact ID
160 *
161 * @var int unsigned
162 */
163 public $transferred_to_contact_id;
164 /**
165 * class constructor
166 *
167 * @return civicrm_participant
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 ) ,
214 'participant_contact_id' => array(
215 'name' => 'contact_id',
216 'type' => CRM_Utils_Type::T_INT,
217 'title' => ts('Contact ID') ,
218 'description' => 'FK to Contact ID',
219 'required' => true,
220 'import' => true,
221 'where' => 'civicrm_participant.contact_id',
222 'headerPattern' => '/contact(.?id)?/i',
223 'dataPattern' => '',
224 'export' => true,
225 'FKClassName' => 'CRM_Contact_DAO_Contact',
226 ) ,
227 'event_id' => array(
228 'name' => 'event_id',
229 'type' => CRM_Utils_Type::T_INT,
230 'title' => ts('Event') ,
231 'description' => 'FK to Event ID',
232 'required' => true,
233 'import' => true,
234 'where' => 'civicrm_participant.event_id',
235 'headerPattern' => '/event id$/i',
236 'dataPattern' => '',
237 'export' => true,
238 'FKClassName' => 'CRM_Event_DAO_Event',
239 ) ,
240 'participant_status_id' => array(
241 'name' => 'status_id',
242 'type' => CRM_Utils_Type::T_INT,
243 'title' => ts('Participant Status') ,
244 'description' => 'Participant status ID. FK to civicrm_participant_status_type. Default of 1 should map to status = Registered.',
245 'required' => true,
246 'import' => true,
247 'where' => 'civicrm_participant.status_id',
248 'headerPattern' => '/(participant.)?(status)$/i',
249 'dataPattern' => '',
250 'export' => true,
251 'default' => '1',
252 'FKClassName' => 'CRM_Event_DAO_ParticipantStatusType',
253 'html' => array(
254 'type' => 'Select',
255 ) ,
256 'pseudoconstant' => array(
257 'table' => 'civicrm_participant_status_type',
258 'keyColumn' => 'id',
259 'labelColumn' => 'label',
260 )
261 ) ,
262 'participant_role_id' => array(
263 'name' => 'role_id',
264 'type' => CRM_Utils_Type::T_STRING,
265 'title' => ts('Participant Role') ,
266 'description' => 'Participant role ID. Implicit FK to civicrm_option_value where option_group = participant_role.',
267 'maxlength' => 128,
268 'size' => CRM_Utils_Type::HUGE,
269 'import' => true,
270 'where' => 'civicrm_participant.role_id',
271 'headerPattern' => '/(participant.)?(role)$/i',
272 'dataPattern' => '',
273 'export' => true,
274 'default' => 'NULL',
275 'html' => array(
276 'type' => 'Select',
277 ) ,
278 'pseudoconstant' => array(
279 'optionGroupName' => 'participant_role',
280 'optionEditPath' => 'civicrm/admin/options/participant_role',
281 )
282 ) ,
283 'participant_register_date' => array(
284 'name' => 'register_date',
285 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
286 'title' => ts('Register date') ,
287 'description' => 'When did contact register for event?',
288 'import' => true,
289 'where' => 'civicrm_participant.register_date',
290 'headerPattern' => '/^(r(egister\s)?date)$/i',
291 'dataPattern' => '',
292 'export' => true,
293 ) ,
294 'participant_source' => array(
295 'name' => 'source',
296 'type' => CRM_Utils_Type::T_STRING,
297 'title' => ts('Participant Source') ,
298 'description' => 'Source of this event registration.',
299 'maxlength' => 128,
300 'size' => CRM_Utils_Type::HUGE,
301 'import' => true,
302 'where' => 'civicrm_participant.source',
303 'headerPattern' => '/(participant.)?(source)$/i',
304 'dataPattern' => '',
305 'export' => true,
306 ) ,
307 'participant_fee_level' => array(
308 'name' => 'fee_level',
309 'type' => CRM_Utils_Type::T_TEXT,
310 'title' => ts('Fee level') ,
311 'description' => 'Populate with the label (text) associated with a fee level for paid events with multiple levels. Note that
312 we store the label value and not the key
313 ',
314 'import' => true,
315 'where' => 'civicrm_participant.fee_level',
316 'headerPattern' => '/^(f(ee\s)?level)$/i',
317 'dataPattern' => '',
318 'export' => true,
319 ) ,
320 'participant_is_test' => array(
321 'name' => 'is_test',
322 'type' => CRM_Utils_Type::T_BOOLEAN,
323 'title' => ts('Test') ,
324 'import' => true,
325 'where' => 'civicrm_participant.is_test',
326 'headerPattern' => '',
327 'dataPattern' => '',
328 'export' => true,
329 ) ,
330 'participant_is_pay_later' => array(
331 'name' => 'is_pay_later',
332 'type' => CRM_Utils_Type::T_BOOLEAN,
333 'title' => ts('Is Pay Later') ,
334 'import' => true,
335 'where' => 'civicrm_participant.is_pay_later',
336 'headerPattern' => '/(is.)?(pay(.)?later)$/i',
337 'dataPattern' => '',
338 'export' => true,
339 ) ,
340 'participant_fee_amount' => array(
341 'name' => 'fee_amount',
342 'type' => CRM_Utils_Type::T_MONEY,
343 'title' => ts('Fee Amount') ,
344 'description' => 'actual processor fee if known - may be 0.',
345 'precision' => array(
346 20,
347 2
348 ) ,
349 'import' => true,
350 'where' => 'civicrm_participant.fee_amount',
351 'headerPattern' => '/fee(.?am(ou)?nt)?/i',
352 'dataPattern' => '/^\d+(\.\d{2})?$/',
353 'export' => true,
354 ) ,
355 'participant_registered_by_id' => array(
356 'name' => 'registered_by_id',
357 'type' => CRM_Utils_Type::T_INT,
358 'title' => ts('Registered By ID') ,
359 'description' => 'FK to Participant ID',
360 'import' => true,
361 'where' => 'civicrm_participant.registered_by_id',
362 'headerPattern' => '',
363 'dataPattern' => '',
364 'export' => true,
365 'default' => 'NULL',
366 'FKClassName' => 'CRM_Event_DAO_Participant',
367 ) ,
368 'participant_discount_id' => array(
369 'name' => 'discount_id',
370 'type' => CRM_Utils_Type::T_INT,
371 'title' => ts('Discount ID') ,
372 'description' => 'FK to Discount ID',
373 'default' => 'NULL',
374 'FKClassName' => 'CRM_Core_DAO_Discount',
375 ) ,
376 'participant_fee_currency' => array(
377 'name' => 'fee_currency',
378 'type' => CRM_Utils_Type::T_STRING,
379 'title' => ts('Fee Currency') ,
380 'description' => '3 character string, value derived from config setting.',
381 'maxlength' => 3,
382 'size' => CRM_Utils_Type::FOUR,
383 'import' => true,
384 'where' => 'civicrm_participant.fee_currency',
385 'headerPattern' => '/(fee)?.?cur(rency)?/i',
386 'dataPattern' => '/^[A-Z]{3}$/i',
387 'export' => true,
388 'default' => 'NULL',
389 'html' => array(
390 'type' => 'Select',
391 ) ,
392 'pseudoconstant' => array(
393 'table' => 'civicrm_currency',
394 'keyColumn' => 'name',
395 'labelColumn' => 'full_name',
396 'nameColumn' => 'name',
397 )
398 ) ,
399 'participant_campaign_id' => array(
400 'name' => 'campaign_id',
401 'type' => CRM_Utils_Type::T_INT,
402 'title' => ts('Campaign') ,
403 'description' => 'The campaign for which this participant has been registered.',
404 'import' => true,
405 'where' => 'civicrm_participant.campaign_id',
406 'headerPattern' => '',
407 'dataPattern' => '',
408 'export' => true,
409 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
410 'pseudoconstant' => array(
411 'table' => 'civicrm_campaign',
412 'keyColumn' => 'id',
413 'labelColumn' => 'title',
414 )
415 ) ,
416 'discount_amount' => array(
417 'name' => 'discount_amount',
418 'type' => CRM_Utils_Type::T_INT,
419 'title' => ts('Discount Amount') ,
420 'description' => 'Discount Amount',
421 ) ,
422 'cart_id' => array(
423 'name' => 'cart_id',
424 'type' => CRM_Utils_Type::T_INT,
425 'title' => ts('Event Cart ID') ,
426 'description' => 'FK to civicrm_event_carts',
427 'FKClassName' => 'CRM_Event_Cart_DAO_Cart',
428 ) ,
429 'must_wait' => array(
430 'name' => 'must_wait',
431 'type' => CRM_Utils_Type::T_INT,
432 'title' => ts('Must Wait on List') ,
433 'description' => 'On Waiting List',
434 ) ,
435 'transferred_to_contact_id' => array(
436 'name' => 'transferred_to_contact_id',
437 'type' => CRM_Utils_Type::T_INT,
438 'title' => ts('Transferred to Contact ID') ,
439 'description' => 'FK to Contact ID',
440 'import' => true,
441 'where' => 'civicrm_participant.transferred_to_contact_id',
442 'headerPattern' => '/transfer(.?id)?/i',
443 'dataPattern' => '',
444 'export' => true,
445 'default' => 'NULL',
446 'FKClassName' => 'CRM_Contact_DAO_Contact',
447 ) ,
448 );
449 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
450 }
451 return Civi::$statics[__CLASS__]['fields'];
452 }
453 /**
454 * Return a mapping from field-name to the corresponding key (as used in fields()).
455 *
456 * @return array
457 * Array(string $name => string $uniqueName).
458 */
459 static function &fieldKeys() {
460 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
461 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
462 }
463 return Civi::$statics[__CLASS__]['fieldKeys'];
464 }
465 /**
466 * Returns the names of this table
467 *
468 * @return string
469 */
470 static function getTableName() {
471 return self::$_tableName;
472 }
473 /**
474 * Returns if this table needs to be logged
475 *
476 * @return boolean
477 */
478 function getLog() {
479 return self::$_log;
480 }
481 /**
482 * Returns the list of fields that can be imported
483 *
484 * @param bool $prefix
485 *
486 * @return array
487 */
488 static function &import($prefix = false) {
489 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'participant', $prefix, array());
490 return $r;
491 }
492 /**
493 * Returns the list of fields that can be exported
494 *
495 * @param bool $prefix
496 *
497 * @return array
498 */
499 static function &export($prefix = false) {
500 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'participant', $prefix, array());
501 return $r;
502 }
503 }