Add "labelField" metadata to entities
[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
8ab43c93 9 * (GenCodeChecksum:80c222a0dfea9ae97009c96e010fce90)
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,
a9d0587b 203 'add' => '1.8',
c3fc2621
CW
204 ],
205 'price_set_id' => [
e501603b
TO
206 'name' => 'price_set_id',
207 'type' => CRM_Utils_Type::T_INT,
c3fc2621 208 'title' => ts('Price Set'),
215b423e 209 'description' => ts('FK to civicrm_price_set'),
c3fc2621 210 'required' => TRUE,
a36434b9 211 'where' => 'civicrm_price_field.price_set_id',
522a26c9 212 'table_name' => 'civicrm_price_field',
213 'entity' => 'PriceField',
214 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 215 'localizable' => 0,
e501603b 216 'FKClassName' => 'CRM_Price_DAO_PriceSet',
56616a73
PN
217 'pseudoconstant' => [
218 'table' => 'civicrm_price_set',
219 'keyColumn' => 'id',
220 'labelColumn' => 'title',
4f238b49 221 'nameColumn' => 'name',
56616a73 222 ],
a9d0587b 223 'add' => '1.8',
c3fc2621
CW
224 ],
225 'name' => [
e501603b
TO
226 'name' => 'name',
227 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 228 'title' => ts('Name'),
215b423e 229 'description' => ts('Variable name/programmatic handle for this field.'),
c3fc2621 230 'required' => TRUE,
e501603b
TO
231 'maxlength' => 255,
232 'size' => CRM_Utils_Type::HUGE,
a36434b9 233 'where' => 'civicrm_price_field.name',
522a26c9 234 'table_name' => 'civicrm_price_field',
235 'entity' => 'PriceField',
236 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 237 'localizable' => 0,
c3fc2621 238 'html' => [
e501603b 239 'type' => 'Text',
c3fc2621 240 ],
a9d0587b 241 'add' => '1.8',
c3fc2621
CW
242 ],
243 'label' => [
e501603b
TO
244 'name' => 'label',
245 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 246 'title' => ts('Label'),
215b423e 247 'description' => ts('Text for form field label (also friendly name for administering this field).'),
c3fc2621 248 'required' => TRUE,
e501603b
TO
249 'maxlength' => 255,
250 'size' => CRM_Utils_Type::HUGE,
a36434b9 251 'where' => 'civicrm_price_field.label',
522a26c9 252 'table_name' => 'civicrm_price_field',
253 'entity' => 'PriceField',
254 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 255 'localizable' => 1,
c3fc2621 256 'html' => [
e501603b 257 'type' => 'Text',
c3fc2621 258 ],
a9d0587b 259 'add' => '1.8',
c3fc2621
CW
260 ],
261 'html_type' => [
e501603b
TO
262 'name' => 'html_type',
263 'type' => CRM_Utils_Type::T_STRING,
c3fc2621
CW
264 'title' => ts('Html Type'),
265 'required' => TRUE,
e501603b
TO
266 'maxlength' => 12,
267 'size' => CRM_Utils_Type::TWELVE,
a36434b9 268 'where' => 'civicrm_price_field.html_type',
522a26c9 269 'table_name' => 'civicrm_price_field',
270 'entity' => 'PriceField',
271 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 272 'localizable' => 0,
c3fc2621 273 'html' => [
e501603b 274 'type' => 'Select',
c3fc2621
CW
275 ],
276 'pseudoconstant' => [
e501603b 277 'callback' => 'CRM_Price_BAO_PriceField::htmlTypes',
e6ca0a57 278 ],
a9d0587b 279 'add' => '1.8',
c3fc2621
CW
280 ],
281 'is_enter_qty' => [
e501603b
TO
282 'name' => 'is_enter_qty',
283 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 284 'title' => ts('Price Field Quantity Required?'),
215b423e 285 'description' => ts('Enter a quantity for this field?'),
a36434b9 286 'where' => 'civicrm_price_field.is_enter_qty',
45a83e42 287 'default' => '0',
522a26c9 288 'table_name' => 'civicrm_price_field',
289 'entity' => 'PriceField',
290 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 291 'localizable' => 0,
c3fc2621 292 'html' => [
e501603b 293 'type' => 'CheckBox',
c3fc2621 294 ],
a9d0587b 295 'add' => '1.8',
c3fc2621
CW
296 ],
297 'help_pre' => [
e501603b
TO
298 'name' => 'help_pre',
299 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 300 'title' => ts('Price Field Pre Text'),
215b423e 301 'description' => ts('Description and/or help text to display before this field.'),
e501603b
TO
302 'rows' => 4,
303 'cols' => 80,
a36434b9 304 'where' => 'civicrm_price_field.help_pre',
522a26c9 305 'table_name' => 'civicrm_price_field',
306 'entity' => 'PriceField',
307 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 308 'localizable' => 1,
c3fc2621 309 'html' => [
e501603b 310 'type' => 'TextArea',
c3fc2621 311 ],
a9d0587b 312 'add' => '1.8',
c3fc2621
CW
313 ],
314 'help_post' => [
e501603b
TO
315 'name' => 'help_post',
316 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 317 'title' => ts('Price Field Post Text'),
215b423e 318 'description' => ts('Description and/or help text to display after this field.'),
e501603b
TO
319 'rows' => 4,
320 'cols' => 80,
a36434b9 321 'where' => 'civicrm_price_field.help_post',
522a26c9 322 'table_name' => 'civicrm_price_field',
323 'entity' => 'PriceField',
324 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 325 'localizable' => 1,
c3fc2621 326 'html' => [
e501603b 327 'type' => 'TextArea',
c3fc2621 328 ],
a9d0587b 329 'add' => '1.8',
c3fc2621
CW
330 ],
331 'weight' => [
e501603b
TO
332 'name' => 'weight',
333 'type' => CRM_Utils_Type::T_INT,
c3fc2621 334 'title' => ts('Order'),
215b423e 335 'description' => ts('Order in which the fields should appear'),
a36434b9 336 'where' => 'civicrm_price_field.weight',
e501603b 337 'default' => '1',
522a26c9 338 'table_name' => 'civicrm_price_field',
339 'entity' => 'PriceField',
340 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 341 'localizable' => 0,
c3fc2621 342 'html' => [
e501603b 343 'type' => 'Select',
c3fc2621 344 ],
a9d0587b 345 'add' => '1.8',
c3fc2621
CW
346 ],
347 'is_display_amounts' => [
e501603b
TO
348 'name' => 'is_display_amounts',
349 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 350 'title' => ts('Price Field Show Amounts?'),
215b423e 351 'description' => ts('Should the price be displayed next to the label for each option?'),
a36434b9 352 'where' => 'civicrm_price_field.is_display_amounts',
e501603b 353 'default' => '1',
522a26c9 354 'table_name' => 'civicrm_price_field',
355 'entity' => 'PriceField',
356 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 357 'localizable' => 0,
c3fc2621 358 'html' => [
e501603b 359 'type' => 'CheckBox',
c3fc2621 360 ],
a9d0587b 361 'add' => NULL,
c3fc2621
CW
362 ],
363 'options_per_line' => [
e501603b
TO
364 'name' => 'options_per_line',
365 'type' => CRM_Utils_Type::T_INT,
c3fc2621 366 'title' => ts('Price Field Options per Row'),
215b423e 367 'description' => ts('number of options per line for checkbox and radio'),
a36434b9 368 'where' => 'civicrm_price_field.options_per_line',
e501603b 369 'default' => '1',
522a26c9 370 'table_name' => 'civicrm_price_field',
371 'entity' => 'PriceField',
372 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 373 'localizable' => 0,
c3fc2621 374 'html' => [
e501603b 375 'type' => 'Text',
c3fc2621 376 ],
a9d0587b 377 'add' => '1.8',
c3fc2621
CW
378 ],
379 'is_active' => [
e501603b
TO
380 'name' => 'is_active',
381 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 382 'title' => ts('Price Field Is Active?'),
215b423e 383 'description' => ts('Is this price field active'),
a36434b9 384 'where' => 'civicrm_price_field.is_active',
e501603b 385 'default' => '1',
522a26c9 386 'table_name' => 'civicrm_price_field',
387 'entity' => 'PriceField',
388 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 389 'localizable' => 0,
c3fc2621 390 'html' => [
e501603b 391 'type' => 'CheckBox',
c3fc2621 392 ],
a9d0587b 393 'add' => '1.8',
c3fc2621
CW
394 ],
395 'is_required' => [
e501603b
TO
396 'name' => 'is_required',
397 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 398 'title' => ts('Price Field is Required?'),
215b423e 399 'description' => ts('Is this price field required (value must be > 1)'),
a36434b9 400 'where' => 'civicrm_price_field.is_required',
e501603b 401 'default' => '1',
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' => 'CheckBox',
c3fc2621 408 ],
a9d0587b 409 'add' => '1.8',
c3fc2621
CW
410 ],
411 'active_on' => [
e501603b
TO
412 'name' => 'active_on',
413 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 414 'title' => ts('Price Field Start Date'),
215b423e 415 'description' => ts('If non-zero, do not show this field before the date specified'),
a36434b9 416 'where' => 'civicrm_price_field.active_on',
e501603b 417 'default' => 'NULL',
522a26c9 418 'table_name' => 'civicrm_price_field',
419 'entity' => 'PriceField',
420 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 421 'localizable' => 0,
c3fc2621 422 'html' => [
70a44aee
SL
423 'type' => 'Select Date',
424 'formatType' => 'activityDateTime',
c3fc2621 425 ],
a9d0587b 426 'add' => '1.8',
c3fc2621
CW
427 ],
428 'expire_on' => [
e501603b
TO
429 'name' => 'expire_on',
430 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 431 'title' => ts('Price Field End Date'),
215b423e 432 'description' => ts('If non-zero, do not show this field after the date specified'),
a36434b9 433 'where' => 'civicrm_price_field.expire_on',
e501603b 434 'default' => 'NULL',
522a26c9 435 'table_name' => 'civicrm_price_field',
436 'entity' => 'PriceField',
437 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 438 'localizable' => 0,
c3fc2621 439 'html' => [
e501603b 440 'type' => 'Select Date',
70a44aee 441 'formatType' => 'activityDateTime',
c3fc2621 442 ],
a9d0587b 443 'add' => '1.8',
c3fc2621
CW
444 ],
445 'javascript' => [
e501603b
TO
446 'name' => 'javascript',
447 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 448 'title' => ts('Price Field Javascript'),
215b423e 449 'description' => ts('Optional scripting attributes for field'),
e501603b
TO
450 'maxlength' => 255,
451 'size' => CRM_Utils_Type::HUGE,
a36434b9 452 'where' => 'civicrm_price_field.javascript',
522a26c9 453 'table_name' => 'civicrm_price_field',
454 'entity' => 'PriceField',
455 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 456 'localizable' => 0,
c3fc2621 457 'html' => [
e501603b 458 'type' => 'Text',
c3fc2621 459 ],
a9d0587b 460 'add' => '1.8',
c3fc2621
CW
461 ],
462 'visibility_id' => [
e501603b
TO
463 'name' => 'visibility_id',
464 'type' => CRM_Utils_Type::T_INT,
c3fc2621 465 'title' => ts('Price Field Visibility'),
215b423e 466 'description' => ts('Implicit FK to civicrm_option_group with name = \'visibility\''),
a36434b9 467 'where' => 'civicrm_price_field.visibility_id',
e501603b 468 'default' => '1',
522a26c9 469 'table_name' => 'civicrm_price_field',
470 'entity' => 'PriceField',
471 'bao' => 'CRM_Price_BAO_PriceField',
6a7e5e5d 472 'localizable' => 0,
c3fc2621 473 'html' => [
e501603b 474 'type' => 'Select',
c3fc2621
CW
475 ],
476 'pseudoconstant' => [
e501603b
TO
477 'optionGroupName' => 'visibility',
478 'optionEditPath' => 'civicrm/admin/options/visibility',
e6ca0a57 479 ],
a9d0587b 480 'add' => '3.2',
c3fc2621
CW
481 ],
482 ];
346aaaba 483 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 484 }
346aaaba 485 return Civi::$statics[__CLASS__]['fields'];
e501603b 486 }
c3fc2621 487
e501603b 488 /**
bd8e0b14 489 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
490 *
491 * @return array
bd8e0b14 492 * Array(string $name => string $uniqueName).
e501603b 493 */
c3fc2621 494 public static function &fieldKeys() {
bd8e0b14
TO
495 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
496 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 497 }
bd8e0b14 498 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 499 }
c3fc2621 500
e501603b
TO
501 /**
502 * Returns the names of this table
503 *
504 * @return string
505 */
c3fc2621 506 public static function getTableName() {
e501603b
TO
507 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
508 }
c3fc2621 509
e501603b
TO
510 /**
511 * Returns if this table needs to be logged
512 *
c3fc2621 513 * @return bool
e501603b 514 */
c3fc2621 515 public function getLog() {
e501603b
TO
516 return self::$_log;
517 }
c3fc2621 518
e501603b
TO
519 /**
520 * Returns the list of fields that can be imported
521 *
522 * @param bool $prefix
523 *
524 * @return array
525 */
c3fc2621
CW
526 public static function &import($prefix = FALSE) {
527 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'price_field', $prefix, []);
60808919 528 return $r;
e501603b 529 }
c3fc2621 530
e501603b
TO
531 /**
532 * Returns the list of fields that can be exported
533 *
534 * @param bool $prefix
535 *
536 * @return array
537 */
c3fc2621
CW
538 public static function &export($prefix = FALSE) {
539 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'price_field', $prefix, []);
60808919 540 return $r;
e501603b 541 }
c3fc2621 542
e7a6b91a
AS
543 /**
544 * Returns the list of indices
c3fc2621
CW
545 *
546 * @param bool $localize
547 *
548 * @return array
e7a6b91a
AS
549 */
550 public static function indices($localize = TRUE) {
c3fc2621
CW
551 $indices = [
552 'index_name' => [
e7a6b91a 553 'name' => 'index_name',
c3fc2621 554 'field' => [
e7a6b91a 555 0 => 'name',
c3fc2621
CW
556 ],
557 'localizable' => FALSE,
e7a6b91a 558 'sig' => 'civicrm_price_field::0::name',
c3fc2621
CW
559 ],
560 ];
e7a6b91a
AS
561 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
562 }
c3fc2621 563
e501603b 564}