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