Schema - Fix boolean fields in various tables
[civicrm-core.git] / CRM / Price / DAO / PriceFieldValue.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Price/PriceFieldValue.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:d39a35fbdcaed47315fdc0ecce662c7f)
10 */
11
12 /**
13 * Database access object for the PriceFieldValue entity.
14 */
15 class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '3.3';
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_value';
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 = FALSE;
33
34 /**
35 * Price Field Value
36 *
37 * @var int|string|null
38 * (SQL type: int unsigned)
39 * Note that values will be retrieved from the database as a string.
40 */
41 public $id;
42
43 /**
44 * FK to civicrm_price_field
45 *
46 * @var int|string
47 * (SQL type: int unsigned)
48 * Note that values will be retrieved from the database as a string.
49 */
50 public $price_field_id;
51
52 /**
53 * Price field option name
54 *
55 * @var string|null
56 * (SQL type: varchar(255))
57 * Note that values will be retrieved from the database as a string.
58 */
59 public $name;
60
61 /**
62 * Price field option label
63 *
64 * @var string|null
65 * (SQL type: varchar(255))
66 * Note that values will be retrieved from the database as a string.
67 */
68 public $label;
69
70 /**
71 * Price field option description.
72 *
73 * @var string|null
74 * (SQL type: text)
75 * Note that values will be retrieved from the database as a string.
76 */
77 public $description;
78
79 /**
80 * Price field option pre help text.
81 *
82 * @var string|null
83 * (SQL type: text)
84 * Note that values will be retrieved from the database as a string.
85 */
86 public $help_pre;
87
88 /**
89 * Price field option post field help.
90 *
91 * @var string|null
92 * (SQL type: text)
93 * Note that values will be retrieved from the database as a string.
94 */
95 public $help_post;
96
97 /**
98 * Price field option amount
99 *
100 * @var float|string
101 * (SQL type: decimal(18,9))
102 * Note that values will be retrieved from the database as a string.
103 */
104 public $amount;
105
106 /**
107 * Number of participants per field option
108 *
109 * @var int|string|null
110 * (SQL type: int unsigned)
111 * Note that values will be retrieved from the database as a string.
112 */
113 public $count;
114
115 /**
116 * Max number of participants per field options
117 *
118 * @var int|string|null
119 * (SQL type: int unsigned)
120 * Note that values will be retrieved from the database as a string.
121 */
122 public $max_value;
123
124 /**
125 * Order in which the field options should appear
126 *
127 * @var int|string|null
128 * (SQL type: int)
129 * Note that values will be retrieved from the database as a string.
130 */
131 public $weight;
132
133 /**
134 * FK to Membership Type
135 *
136 * @var int|string|null
137 * (SQL type: int unsigned)
138 * Note that values will be retrieved from the database as a string.
139 */
140 public $membership_type_id;
141
142 /**
143 * Number of terms for this membership
144 *
145 * @var int|string|null
146 * (SQL type: int unsigned)
147 * Note that values will be retrieved from the database as a string.
148 */
149 public $membership_num_terms;
150
151 /**
152 * Is this default price field option
153 *
154 * @var bool|string
155 * (SQL type: tinyint)
156 * Note that values will be retrieved from the database as a string.
157 */
158 public $is_default;
159
160 /**
161 * Is this price field value active
162 *
163 * @var bool|string
164 * (SQL type: tinyint)
165 * Note that values will be retrieved from the database as a string.
166 */
167 public $is_active;
168
169 /**
170 * FK to Financial Type.
171 *
172 * @var int|string|null
173 * (SQL type: int unsigned)
174 * Note that values will be retrieved from the database as a string.
175 */
176 public $financial_type_id;
177
178 /**
179 * Portion of total amount which is NOT tax deductible.
180 *
181 * @var float|string
182 * (SQL type: decimal(20,2))
183 * Note that values will be retrieved from the database as a string.
184 */
185 public $non_deductible_amount;
186
187 /**
188 * Implicit FK to civicrm_option_group with name = 'visibility'
189 *
190 * @var int|string|null
191 * (SQL type: int unsigned)
192 * Note that values will be retrieved from the database as a string.
193 */
194 public $visibility_id;
195
196 /**
197 * Class constructor.
198 */
199 public function __construct() {
200 $this->__table = 'civicrm_price_field_value';
201 parent::__construct();
202 }
203
204 /**
205 * Returns localized title of this entity.
206 *
207 * @param bool $plural
208 * Whether to return the plural version of the title.
209 */
210 public static function getEntityTitle($plural = FALSE) {
211 return $plural ? ts('Price Field Values') : ts('Price Field Value');
212 }
213
214 /**
215 * Returns foreign keys and entity references.
216 *
217 * @return array
218 * [CRM_Core_Reference_Interface]
219 */
220 public static function getReferenceColumns() {
221 if (!isset(Civi::$statics[__CLASS__]['links'])) {
222 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
223 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_field_id', 'civicrm_price_field', 'id');
224 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'membership_type_id', 'civicrm_membership_type', 'id');
225 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
226 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
227 }
228 return Civi::$statics[__CLASS__]['links'];
229 }
230
231 /**
232 * Returns all the column names of this table
233 *
234 * @return array
235 */
236 public static function &fields() {
237 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
238 Civi::$statics[__CLASS__]['fields'] = [
239 'id' => [
240 'name' => 'id',
241 'type' => CRM_Utils_Type::T_INT,
242 'title' => ts('Price Field Value ID'),
243 'description' => ts('Price Field Value'),
244 'required' => TRUE,
245 'where' => 'civicrm_price_field_value.id',
246 'table_name' => 'civicrm_price_field_value',
247 'entity' => 'PriceFieldValue',
248 'bao' => 'CRM_Price_BAO_PriceFieldValue',
249 'localizable' => 0,
250 'html' => [
251 'type' => 'Number',
252 ],
253 'readonly' => TRUE,
254 'add' => '3.3',
255 ],
256 'price_field_id' => [
257 'name' => 'price_field_id',
258 'type' => CRM_Utils_Type::T_INT,
259 'title' => ts('Price Field ID'),
260 'description' => ts('FK to civicrm_price_field'),
261 'required' => TRUE,
262 'where' => 'civicrm_price_field_value.price_field_id',
263 'table_name' => 'civicrm_price_field_value',
264 'entity' => 'PriceFieldValue',
265 'bao' => 'CRM_Price_BAO_PriceFieldValue',
266 'localizable' => 0,
267 'FKClassName' => 'CRM_Price_DAO_PriceField',
268 'html' => [
269 'label' => ts("Price Field"),
270 ],
271 'add' => '3.3',
272 ],
273 'name' => [
274 'name' => 'name',
275 'type' => CRM_Utils_Type::T_STRING,
276 'title' => ts('Name'),
277 'description' => ts('Price field option name'),
278 'maxlength' => 255,
279 'size' => CRM_Utils_Type::HUGE,
280 'where' => 'civicrm_price_field_value.name',
281 'default' => NULL,
282 'table_name' => 'civicrm_price_field_value',
283 'entity' => 'PriceFieldValue',
284 'bao' => 'CRM_Price_BAO_PriceFieldValue',
285 'localizable' => 0,
286 'html' => [
287 'type' => 'Text',
288 ],
289 'add' => '3.3',
290 ],
291 'label' => [
292 'name' => 'label',
293 'type' => CRM_Utils_Type::T_STRING,
294 'title' => ts('Label'),
295 'description' => ts('Price field option label'),
296 'maxlength' => 255,
297 'size' => CRM_Utils_Type::HUGE,
298 'where' => 'civicrm_price_field_value.label',
299 'default' => NULL,
300 'table_name' => 'civicrm_price_field_value',
301 'entity' => 'PriceFieldValue',
302 'bao' => 'CRM_Price_BAO_PriceFieldValue',
303 'localizable' => 1,
304 'html' => [
305 'type' => 'Text',
306 ],
307 'add' => '3.3',
308 ],
309 'description' => [
310 'name' => 'description',
311 'type' => CRM_Utils_Type::T_TEXT,
312 'title' => ts('Description'),
313 'description' => ts('Price field option description.'),
314 'rows' => 2,
315 'cols' => 60,
316 'where' => 'civicrm_price_field_value.description',
317 'default' => NULL,
318 'table_name' => 'civicrm_price_field_value',
319 'entity' => 'PriceFieldValue',
320 'bao' => 'CRM_Price_BAO_PriceFieldValue',
321 'localizable' => 1,
322 'html' => [
323 'type' => 'TextArea',
324 'label' => ts("Description"),
325 ],
326 'add' => '3.3',
327 ],
328 'help_pre' => [
329 'name' => 'help_pre',
330 'type' => CRM_Utils_Type::T_TEXT,
331 'title' => ts('Help Pre'),
332 'description' => ts('Price field option pre help text.'),
333 'rows' => 2,
334 'cols' => 60,
335 'where' => 'civicrm_price_field_value.help_pre',
336 'default' => NULL,
337 'table_name' => 'civicrm_price_field_value',
338 'entity' => 'PriceFieldValue',
339 'bao' => 'CRM_Price_BAO_PriceFieldValue',
340 'localizable' => 1,
341 'html' => [
342 'type' => 'TextArea',
343 'label' => ts("Pre Help"),
344 ],
345 'add' => '4.7',
346 ],
347 'help_post' => [
348 'name' => 'help_post',
349 'type' => CRM_Utils_Type::T_TEXT,
350 'title' => ts('Help Post'),
351 'description' => ts('Price field option post field help.'),
352 'rows' => 2,
353 'cols' => 60,
354 'where' => 'civicrm_price_field_value.help_post',
355 'default' => NULL,
356 'table_name' => 'civicrm_price_field_value',
357 'entity' => 'PriceFieldValue',
358 'bao' => 'CRM_Price_BAO_PriceFieldValue',
359 'localizable' => 1,
360 'html' => [
361 'type' => 'TextArea',
362 'label' => ts("Post Help"),
363 ],
364 'add' => '4.7',
365 ],
366 'amount' => [
367 'name' => 'amount',
368 'type' => CRM_Utils_Type::T_MONEY,
369 'title' => ts('Amount'),
370 'description' => ts('Price field option amount'),
371 'required' => TRUE,
372 'precision' => [
373 18,
374 9,
375 ],
376 'where' => 'civicrm_price_field_value.amount',
377 'table_name' => 'civicrm_price_field_value',
378 'entity' => 'PriceFieldValue',
379 'bao' => 'CRM_Price_BAO_PriceFieldValue',
380 'localizable' => 0,
381 'html' => [
382 'type' => 'Text',
383 ],
384 'add' => '3.3',
385 ],
386 'count' => [
387 'name' => 'count',
388 'type' => CRM_Utils_Type::T_INT,
389 'title' => ts('Count'),
390 'description' => ts('Number of participants per field option'),
391 'where' => 'civicrm_price_field_value.count',
392 'default' => NULL,
393 'table_name' => 'civicrm_price_field_value',
394 'entity' => 'PriceFieldValue',
395 'bao' => 'CRM_Price_BAO_PriceFieldValue',
396 'localizable' => 0,
397 'html' => [
398 'type' => 'Text',
399 'label' => ts("Count"),
400 ],
401 'add' => '3.3',
402 ],
403 'max_value' => [
404 'name' => 'max_value',
405 'type' => CRM_Utils_Type::T_INT,
406 'title' => ts('Max Value'),
407 'description' => ts('Max number of participants per field options'),
408 'where' => 'civicrm_price_field_value.max_value',
409 'default' => NULL,
410 'table_name' => 'civicrm_price_field_value',
411 'entity' => 'PriceFieldValue',
412 'bao' => 'CRM_Price_BAO_PriceFieldValue',
413 'localizable' => 0,
414 'html' => [
415 'type' => 'Text',
416 'label' => ts("Max Value"),
417 ],
418 'add' => '3.3',
419 ],
420 'weight' => [
421 'name' => 'weight',
422 'type' => CRM_Utils_Type::T_INT,
423 'title' => ts('Order'),
424 'description' => ts('Order in which the field options should appear'),
425 'where' => 'civicrm_price_field_value.weight',
426 'default' => '1',
427 'table_name' => 'civicrm_price_field_value',
428 'entity' => 'PriceFieldValue',
429 'bao' => 'CRM_Price_BAO_PriceFieldValue',
430 'localizable' => 0,
431 'html' => [
432 'type' => 'Text',
433 ],
434 'add' => '3.3',
435 ],
436 'membership_type_id' => [
437 'name' => 'membership_type_id',
438 'type' => CRM_Utils_Type::T_INT,
439 'title' => ts('Membership Type ID'),
440 'description' => ts('FK to Membership Type'),
441 'where' => 'civicrm_price_field_value.membership_type_id',
442 'default' => NULL,
443 'table_name' => 'civicrm_price_field_value',
444 'entity' => 'PriceFieldValue',
445 'bao' => 'CRM_Price_BAO_PriceFieldValue',
446 'localizable' => 0,
447 'FKClassName' => 'CRM_Member_DAO_MembershipType',
448 'html' => [
449 'type' => 'Select',
450 'label' => ts("Membership Type"),
451 ],
452 'add' => '3.4',
453 ],
454 'membership_num_terms' => [
455 'name' => 'membership_num_terms',
456 'type' => CRM_Utils_Type::T_INT,
457 'title' => ts('Membership Num Terms'),
458 'description' => ts('Number of terms for this membership'),
459 'where' => 'civicrm_price_field_value.membership_num_terms',
460 'default' => NULL,
461 'table_name' => 'civicrm_price_field_value',
462 'entity' => 'PriceFieldValue',
463 'bao' => 'CRM_Price_BAO_PriceFieldValue',
464 'localizable' => 0,
465 'html' => [
466 'type' => 'Text',
467 'label' => ts("Number of terms"),
468 ],
469 'add' => '4.3',
470 ],
471 'is_default' => [
472 'name' => 'is_default',
473 'type' => CRM_Utils_Type::T_BOOLEAN,
474 'title' => ts('Is Default Price Field Option?'),
475 'description' => ts('Is this default price field option'),
476 'required' => TRUE,
477 'where' => 'civicrm_price_field_value.is_default',
478 'default' => '0',
479 'table_name' => 'civicrm_price_field_value',
480 'entity' => 'PriceFieldValue',
481 'bao' => 'CRM_Price_BAO_PriceFieldValue',
482 'localizable' => 0,
483 'html' => [
484 'type' => 'CheckBox',
485 ],
486 'add' => '3.3',
487 ],
488 'is_active' => [
489 'name' => 'is_active',
490 'type' => CRM_Utils_Type::T_BOOLEAN,
491 'title' => ts('Price Field Value is Active'),
492 'description' => ts('Is this price field value active'),
493 'required' => TRUE,
494 'where' => 'civicrm_price_field_value.is_active',
495 'default' => '1',
496 'table_name' => 'civicrm_price_field_value',
497 'entity' => 'PriceFieldValue',
498 'bao' => 'CRM_Price_BAO_PriceFieldValue',
499 'localizable' => 0,
500 'add' => '3.3',
501 ],
502 'financial_type_id' => [
503 'name' => 'financial_type_id',
504 'type' => CRM_Utils_Type::T_INT,
505 'title' => ts('Financial Type ID'),
506 'description' => ts('FK to Financial Type.'),
507 'where' => 'civicrm_price_field_value.financial_type_id',
508 'default' => NULL,
509 'table_name' => 'civicrm_price_field_value',
510 'entity' => 'PriceFieldValue',
511 'bao' => 'CRM_Price_BAO_PriceFieldValue',
512 'localizable' => 0,
513 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
514 'html' => [
515 'type' => 'Select',
516 'label' => ts("Financial Type"),
517 ],
518 'pseudoconstant' => [
519 'table' => 'civicrm_financial_type',
520 'keyColumn' => 'id',
521 'labelColumn' => 'name',
522 ],
523 'add' => '4.3',
524 ],
525 'non_deductible_amount' => [
526 'name' => 'non_deductible_amount',
527 'type' => CRM_Utils_Type::T_MONEY,
528 'title' => ts('Non-deductible Amount'),
529 'description' => ts('Portion of total amount which is NOT tax deductible.'),
530 'required' => TRUE,
531 'precision' => [
532 20,
533 2,
534 ],
535 'where' => 'civicrm_price_field_value.non_deductible_amount',
536 'headerPattern' => '/non?.?deduct/i',
537 'dataPattern' => '/^\d+(\.\d{2})?$/',
538 'default' => '0.0',
539 'table_name' => 'civicrm_price_field_value',
540 'entity' => 'PriceFieldValue',
541 'bao' => 'CRM_Price_BAO_PriceFieldValue',
542 'localizable' => 0,
543 'html' => [
544 'type' => 'Text',
545 ],
546 'add' => '4.7',
547 ],
548 'visibility_id' => [
549 'name' => 'visibility_id',
550 'type' => CRM_Utils_Type::T_INT,
551 'title' => ts('Price Field Option Visibility'),
552 'description' => ts('Implicit FK to civicrm_option_group with name = \'visibility\''),
553 'where' => 'civicrm_price_field_value.visibility_id',
554 'default' => '1',
555 'table_name' => 'civicrm_price_field_value',
556 'entity' => 'PriceFieldValue',
557 'bao' => 'CRM_Price_BAO_PriceFieldValue',
558 'localizable' => 0,
559 'html' => [
560 'type' => 'Select',
561 ],
562 'pseudoconstant' => [
563 'optionGroupName' => 'visibility',
564 'optionEditPath' => 'civicrm/admin/options/visibility',
565 ],
566 'add' => '4.7',
567 ],
568 ];
569 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
570 }
571 return Civi::$statics[__CLASS__]['fields'];
572 }
573
574 /**
575 * Return a mapping from field-name to the corresponding key (as used in fields()).
576 *
577 * @return array
578 * Array(string $name => string $uniqueName).
579 */
580 public static function &fieldKeys() {
581 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
582 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
583 }
584 return Civi::$statics[__CLASS__]['fieldKeys'];
585 }
586
587 /**
588 * Returns the names of this table
589 *
590 * @return string
591 */
592 public static function getTableName() {
593 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
594 }
595
596 /**
597 * Returns if this table needs to be logged
598 *
599 * @return bool
600 */
601 public function getLog() {
602 return self::$_log;
603 }
604
605 /**
606 * Returns the list of fields that can be imported
607 *
608 * @param bool $prefix
609 *
610 * @return array
611 */
612 public static function &import($prefix = FALSE) {
613 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'price_field_value', $prefix, []);
614 return $r;
615 }
616
617 /**
618 * Returns the list of fields that can be exported
619 *
620 * @param bool $prefix
621 *
622 * @return array
623 */
624 public static function &export($prefix = FALSE) {
625 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'price_field_value', $prefix, []);
626 return $r;
627 }
628
629 /**
630 * Returns the list of indices
631 *
632 * @param bool $localize
633 *
634 * @return array
635 */
636 public static function indices($localize = TRUE) {
637 $indices = [];
638 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
639 }
640
641 }