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