Merge pull request #14862 from mlutfy/event9
[civicrm-core.git] / CRM / Price / DAO / PriceField.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
6b83d5bd 5 * @copyright CiviCRM LLC (c) 2004-2019
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Price/PriceField.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
74db51d3 9 * (GenCodeChecksum:f96f9517fa4009fff3275da63195efd3)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the PriceField entity.
f41f0342 14 */
e501603b 15class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
c3fc2621 16
e501603b 17 /**
f41f0342 18 * Static instance to hold the table name.
e501603b
TO
19 *
20 * @var string
21 */
fa45b5b9 22 public static $_tableName = 'civicrm_price_field';
c3fc2621 23
e501603b 24 /**
f41f0342 25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 26 *
c3fc2621 27 * @var bool
e501603b 28 */
fa45b5b9 29 public static $_log = TRUE;
c3fc2621 30
e501603b
TO
31 /**
32 * Price Field
33 *
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * FK to civicrm_price_set
40 *
e6ca0a57 41 * @var int
e501603b
TO
42 */
43 public $price_set_id;
c3fc2621 44
e501603b
TO
45 /**
46 * Variable name/programmatic handle for this field.
47 *
48 * @var string
49 */
50 public $name;
c3fc2621 51
e501603b
TO
52 /**
53 * Text for form field label (also friendly name for administering this field).
54 *
55 * @var string
56 */
57 public $label;
c3fc2621 58
e501603b 59 /**
e501603b
TO
60 * @var string
61 */
62 public $html_type;
c3fc2621 63
e501603b
TO
64 /**
65 * Enter a quantity for this field?
66 *
e6ca0a57 67 * @var bool
e501603b
TO
68 */
69 public $is_enter_qty;
c3fc2621 70
e501603b
TO
71 /**
72 * Description and/or help text to display before this field.
73 *
74 * @var text
75 */
76 public $help_pre;
c3fc2621 77
e501603b
TO
78 /**
79 * Description and/or help text to display after this field.
80 *
81 * @var text
82 */
83 public $help_post;
c3fc2621 84
e501603b
TO
85 /**
86 * Order in which the fields should appear
87 *
88 * @var int
89 */
90 public $weight;
c3fc2621 91
e501603b
TO
92 /**
93 * Should the price be displayed next to the label for each option?
94 *
e6ca0a57 95 * @var bool
e501603b
TO
96 */
97 public $is_display_amounts;
c3fc2621 98
e501603b
TO
99 /**
100 * number of options per line for checkbox and radio
101 *
e6ca0a57 102 * @var int
e501603b
TO
103 */
104 public $options_per_line;
c3fc2621 105
e501603b
TO
106 /**
107 * Is this price field active
108 *
e6ca0a57 109 * @var bool
e501603b
TO
110 */
111 public $is_active;
c3fc2621 112
e501603b
TO
113 /**
114 * Is this price field required (value must be > 1)
115 *
e6ca0a57 116 * @var bool
e501603b
TO
117 */
118 public $is_required;
c3fc2621 119
e501603b
TO
120 /**
121 * If non-zero, do not show this field before the date specified
122 *
123 * @var datetime
124 */
125 public $active_on;
c3fc2621 126
e501603b
TO
127 /**
128 * If non-zero, do not show this field after the date specified
129 *
130 * @var datetime
131 */
132 public $expire_on;
c3fc2621 133
e501603b
TO
134 /**
135 * Optional scripting attributes for field
136 *
137 * @var string
138 */
139 public $javascript;
c3fc2621 140
e501603b
TO
141 /**
142 * Implicit FK to civicrm_option_group with name = 'visibility'
143 *
e6ca0a57 144 * @var int
e501603b
TO
145 */
146 public $visibility_id;
c3fc2621 147
e501603b 148 /**
f41f0342 149 * Class constructor.
e501603b 150 */
c3fc2621 151 public function __construct() {
e501603b
TO
152 $this->__table = 'civicrm_price_field';
153 parent::__construct();
154 }
c3fc2621 155
e501603b 156 /**
f41f0342 157 * Returns foreign keys and entity references.
e501603b
TO
158 *
159 * @return array
160 * [CRM_Core_Reference_Interface]
161 */
c3fc2621 162 public static function getReferenceColumns() {
346aaaba 163 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 164 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 165 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_set_id', 'civicrm_price_set', 'id');
346aaaba 166 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 167 }
346aaaba 168 return Civi::$statics[__CLASS__]['links'];
e501603b 169 }
c3fc2621 170
e501603b
TO
171 /**
172 * Returns all the column names of this table
173 *
174 * @return array
175 */
c3fc2621 176 public static function &fields() {
346aaaba 177 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
178 Civi::$statics[__CLASS__]['fields'] = [
179 'id' => [
e501603b
TO
180 'name' => 'id',
181 'type' => CRM_Utils_Type::T_INT,
c3fc2621 182 'title' => ts('Price Field ID'),
215b423e 183 'description' => ts('Price Field'),
c3fc2621 184 'required' => TRUE,
a36434b9 185 'where' => 'civicrm_price_field.id',
522a26c9 186 'table_name' => 'civicrm_price_field',
187 'entity' => 'PriceField',
188 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 189 'localizable' => 0,
c3fc2621
CW
190 ],
191 'price_set_id' => [
e501603b
TO
192 'name' => 'price_set_id',
193 'type' => CRM_Utils_Type::T_INT,
c3fc2621 194 'title' => ts('Price Set'),
215b423e 195 'description' => ts('FK to civicrm_price_set'),
c3fc2621 196 'required' => TRUE,
a36434b9 197 'where' => 'civicrm_price_field.price_set_id',
522a26c9 198 'table_name' => 'civicrm_price_field',
199 'entity' => 'PriceField',
200 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 201 'localizable' => 0,
e501603b 202 'FKClassName' => 'CRM_Price_DAO_PriceSet',
c3fc2621
CW
203 ],
204 'name' => [
e501603b
TO
205 'name' => 'name',
206 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 207 'title' => ts('Name'),
215b423e 208 'description' => ts('Variable name/programmatic handle for this field.'),
c3fc2621 209 'required' => TRUE,
e501603b
TO
210 'maxlength' => 255,
211 'size' => CRM_Utils_Type::HUGE,
a36434b9 212 'where' => 'civicrm_price_field.name',
522a26c9 213 'table_name' => 'civicrm_price_field',
214 'entity' => 'PriceField',
215 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 216 'localizable' => 0,
c3fc2621 217 'html' => [
e501603b 218 'type' => 'Text',
c3fc2621
CW
219 ],
220 ],
221 'label' => [
e501603b
TO
222 'name' => 'label',
223 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 224 'title' => ts('Label'),
215b423e 225 'description' => ts('Text for form field label (also friendly name for administering this field).'),
c3fc2621 226 'required' => TRUE,
e501603b
TO
227 'maxlength' => 255,
228 'size' => CRM_Utils_Type::HUGE,
a36434b9 229 'where' => 'civicrm_price_field.label',
522a26c9 230 'table_name' => 'civicrm_price_field',
231 'entity' => 'PriceField',
232 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 233 'localizable' => 1,
c3fc2621 234 'html' => [
e501603b 235 'type' => 'Text',
c3fc2621
CW
236 ],
237 ],
238 'html_type' => [
e501603b
TO
239 'name' => 'html_type',
240 'type' => CRM_Utils_Type::T_STRING,
c3fc2621
CW
241 'title' => ts('Html Type'),
242 'required' => TRUE,
e501603b
TO
243 'maxlength' => 12,
244 'size' => CRM_Utils_Type::TWELVE,
a36434b9 245 'where' => 'civicrm_price_field.html_type',
522a26c9 246 'table_name' => 'civicrm_price_field',
247 'entity' => 'PriceField',
248 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 249 'localizable' => 0,
c3fc2621 250 'html' => [
e501603b 251 'type' => 'Select',
c3fc2621
CW
252 ],
253 'pseudoconstant' => [
e501603b 254 'callback' => 'CRM_Price_BAO_PriceField::htmlTypes',
e6ca0a57 255 ],
c3fc2621
CW
256 ],
257 'is_enter_qty' => [
e501603b
TO
258 'name' => 'is_enter_qty',
259 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 260 'title' => ts('Price Field Quantity Required?'),
215b423e 261 'description' => ts('Enter a quantity for this field?'),
a36434b9 262 'where' => 'civicrm_price_field.is_enter_qty',
45a83e42 263 'default' => '0',
522a26c9 264 'table_name' => 'civicrm_price_field',
265 'entity' => 'PriceField',
266 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 267 'localizable' => 0,
c3fc2621 268 'html' => [
e501603b 269 'type' => 'CheckBox',
c3fc2621
CW
270 ],
271 ],
272 'help_pre' => [
e501603b
TO
273 'name' => 'help_pre',
274 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 275 'title' => ts('Price Field Pre Text'),
215b423e 276 'description' => ts('Description and/or help text to display before this field.'),
e501603b
TO
277 'rows' => 4,
278 'cols' => 80,
a36434b9 279 'where' => 'civicrm_price_field.help_pre',
522a26c9 280 'table_name' => 'civicrm_price_field',
281 'entity' => 'PriceField',
282 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 283 'localizable' => 1,
c3fc2621 284 'html' => [
e501603b 285 'type' => 'TextArea',
c3fc2621
CW
286 ],
287 ],
288 'help_post' => [
e501603b
TO
289 'name' => 'help_post',
290 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 291 'title' => ts('Price Field Post Text'),
215b423e 292 'description' => ts('Description and/or help text to display after this field.'),
e501603b
TO
293 'rows' => 4,
294 'cols' => 80,
a36434b9 295 'where' => 'civicrm_price_field.help_post',
522a26c9 296 'table_name' => 'civicrm_price_field',
297 'entity' => 'PriceField',
298 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 299 'localizable' => 1,
c3fc2621 300 'html' => [
e501603b 301 'type' => 'TextArea',
c3fc2621
CW
302 ],
303 ],
304 'weight' => [
e501603b
TO
305 'name' => 'weight',
306 'type' => CRM_Utils_Type::T_INT,
c3fc2621 307 'title' => ts('Order'),
215b423e 308 'description' => ts('Order in which the fields should appear'),
a36434b9 309 'where' => 'civicrm_price_field.weight',
e501603b 310 'default' => '1',
522a26c9 311 'table_name' => 'civicrm_price_field',
312 'entity' => 'PriceField',
313 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 314 'localizable' => 0,
c3fc2621 315 'html' => [
e501603b 316 'type' => 'Select',
c3fc2621
CW
317 ],
318 ],
319 'is_display_amounts' => [
e501603b
TO
320 'name' => 'is_display_amounts',
321 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 322 'title' => ts('Price Field Show Amounts?'),
215b423e 323 'description' => ts('Should the price be displayed next to the label for each option?'),
a36434b9 324 'where' => 'civicrm_price_field.is_display_amounts',
e501603b 325 'default' => '1',
522a26c9 326 'table_name' => 'civicrm_price_field',
327 'entity' => 'PriceField',
328 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 329 'localizable' => 0,
c3fc2621 330 'html' => [
e501603b 331 'type' => 'CheckBox',
c3fc2621
CW
332 ],
333 ],
334 'options_per_line' => [
e501603b
TO
335 'name' => 'options_per_line',
336 'type' => CRM_Utils_Type::T_INT,
c3fc2621 337 'title' => ts('Price Field Options per Row'),
215b423e 338 'description' => ts('number of options per line for checkbox and radio'),
a36434b9 339 'where' => 'civicrm_price_field.options_per_line',
e501603b 340 'default' => '1',
522a26c9 341 'table_name' => 'civicrm_price_field',
342 'entity' => 'PriceField',
343 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 344 'localizable' => 0,
c3fc2621 345 'html' => [
e501603b 346 'type' => 'Text',
c3fc2621
CW
347 ],
348 ],
349 'is_active' => [
e501603b
TO
350 'name' => 'is_active',
351 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 352 'title' => ts('Price Field Is Active?'),
215b423e 353 'description' => ts('Is this price field active'),
a36434b9 354 'where' => 'civicrm_price_field.is_active',
e501603b 355 'default' => '1',
522a26c9 356 'table_name' => 'civicrm_price_field',
357 'entity' => 'PriceField',
358 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 359 'localizable' => 0,
c3fc2621 360 'html' => [
e501603b 361 'type' => 'CheckBox',
c3fc2621
CW
362 ],
363 ],
364 'is_required' => [
e501603b
TO
365 'name' => 'is_required',
366 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 367 'title' => ts('Price Field is Required?'),
215b423e 368 'description' => ts('Is this price field required (value must be > 1)'),
a36434b9 369 'where' => 'civicrm_price_field.is_required',
e501603b 370 'default' => '1',
522a26c9 371 'table_name' => 'civicrm_price_field',
372 'entity' => 'PriceField',
373 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 374 'localizable' => 0,
c3fc2621 375 'html' => [
e501603b 376 'type' => 'CheckBox',
c3fc2621
CW
377 ],
378 ],
379 'active_on' => [
e501603b
TO
380 'name' => 'active_on',
381 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 382 'title' => ts('Price Field Start Date'),
215b423e 383 'description' => ts('If non-zero, do not show this field before the date specified'),
a36434b9 384 'where' => 'civicrm_price_field.active_on',
e501603b 385 'default' => 'NULL',
522a26c9 386 'table_name' => 'civicrm_price_field',
387 'entity' => 'PriceField',
388 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 389 'localizable' => 0,
c3fc2621 390 'html' => [
70a44aee
SL
391 'type' => 'Select Date',
392 'formatType' => 'activityDateTime',
c3fc2621
CW
393 ],
394 ],
395 'expire_on' => [
e501603b
TO
396 'name' => 'expire_on',
397 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 398 'title' => ts('Price Field End Date'),
215b423e 399 'description' => ts('If non-zero, do not show this field after the date specified'),
a36434b9 400 'where' => 'civicrm_price_field.expire_on',
e501603b 401 'default' => 'NULL',
522a26c9 402 'table_name' => 'civicrm_price_field',
403 'entity' => 'PriceField',
404 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 405 'localizable' => 0,
c3fc2621 406 'html' => [
e501603b 407 'type' => 'Select Date',
70a44aee 408 'formatType' => 'activityDateTime',
c3fc2621
CW
409 ],
410 ],
411 'javascript' => [
e501603b
TO
412 'name' => 'javascript',
413 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 414 'title' => ts('Price Field Javascript'),
215b423e 415 'description' => ts('Optional scripting attributes for field'),
e501603b
TO
416 'maxlength' => 255,
417 'size' => CRM_Utils_Type::HUGE,
a36434b9 418 'where' => 'civicrm_price_field.javascript',
522a26c9 419 'table_name' => 'civicrm_price_field',
420 'entity' => 'PriceField',
421 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 422 'localizable' => 0,
c3fc2621 423 'html' => [
e501603b 424 'type' => 'Text',
c3fc2621
CW
425 ],
426 ],
427 'visibility_id' => [
e501603b
TO
428 'name' => 'visibility_id',
429 'type' => CRM_Utils_Type::T_INT,
c3fc2621 430 'title' => ts('Price Field Visibility'),
215b423e 431 'description' => ts('Implicit FK to civicrm_option_group with name = \'visibility\''),
a36434b9 432 'where' => 'civicrm_price_field.visibility_id',
e501603b 433 'default' => '1',
522a26c9 434 'table_name' => 'civicrm_price_field',
435 'entity' => 'PriceField',
436 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 437 'localizable' => 0,
c3fc2621 438 'html' => [
e501603b 439 'type' => 'Select',
c3fc2621
CW
440 ],
441 'pseudoconstant' => [
e501603b
TO
442 'optionGroupName' => 'visibility',
443 'optionEditPath' => 'civicrm/admin/options/visibility',
e6ca0a57 444 ],
c3fc2621
CW
445 ],
446 ];
346aaaba 447 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 448 }
346aaaba 449 return Civi::$statics[__CLASS__]['fields'];
e501603b 450 }
c3fc2621 451
e501603b 452 /**
bd8e0b14 453 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
454 *
455 * @return array
bd8e0b14 456 * Array(string $name => string $uniqueName).
e501603b 457 */
c3fc2621 458 public static function &fieldKeys() {
bd8e0b14
TO
459 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
460 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 461 }
bd8e0b14 462 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 463 }
c3fc2621 464
e501603b
TO
465 /**
466 * Returns the names of this table
467 *
468 * @return string
469 */
c3fc2621 470 public static function getTableName() {
e501603b
TO
471 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
472 }
c3fc2621 473
e501603b
TO
474 /**
475 * Returns if this table needs to be logged
476 *
c3fc2621 477 * @return bool
e501603b 478 */
c3fc2621 479 public function getLog() {
e501603b
TO
480 return self::$_log;
481 }
c3fc2621 482
e501603b
TO
483 /**
484 * Returns the list of fields that can be imported
485 *
486 * @param bool $prefix
487 *
488 * @return array
489 */
c3fc2621
CW
490 public static function &import($prefix = FALSE) {
491 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'price_field', $prefix, []);
60808919 492 return $r;
e501603b 493 }
c3fc2621 494
e501603b
TO
495 /**
496 * Returns the list of fields that can be exported
497 *
498 * @param bool $prefix
499 *
500 * @return array
501 */
c3fc2621
CW
502 public static function &export($prefix = FALSE) {
503 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'price_field', $prefix, []);
60808919 504 return $r;
e501603b 505 }
c3fc2621 506
e7a6b91a
AS
507 /**
508 * Returns the list of indices
c3fc2621
CW
509 *
510 * @param bool $localize
511 *
512 * @return array
e7a6b91a
AS
513 */
514 public static function indices($localize = TRUE) {
c3fc2621
CW
515 $indices = [
516 'index_name' => [
e7a6b91a 517 'name' => 'index_name',
c3fc2621 518 'field' => [
e7a6b91a 519 0 => 'name',
c3fc2621
CW
520 ],
521 'localizable' => FALSE,
e7a6b91a 522 'sig' => 'civicrm_price_field::0::name',
c3fc2621
CW
523 ],
524 ];
e7a6b91a
AS
525 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
526 }
c3fc2621 527
e501603b 528}