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