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