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