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