Merge pull request #22326 from totten/master-sqlpara
[civicrm-core.git] / CRM / Price / DAO / PriceSet.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Price/PriceSet.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:5c5630b1371dd1c8894a25b58ffbb5d9)
10 */
11
12 /**
13 * Database access object for the PriceSet entity.
14 */
15 class CRM_Price_DAO_PriceSet 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_set';
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 Set
36 *
37 * @var int
38 */
39 public $id;
40
41 /**
42 * Which Domain is this price-set for
43 *
44 * @var int
45 */
46 public $domain_id;
47
48 /**
49 * Variable name/programmatic handle for this set of price fields.
50 *
51 * @var string
52 */
53 public $name;
54
55 /**
56 * Displayed title for the Price Set.
57 *
58 * @var string
59 */
60 public $title;
61
62 /**
63 * Is this price set active
64 *
65 * @var bool
66 */
67 public $is_active;
68
69 /**
70 * Description and/or help text to display before fields in form.
71 *
72 * @var text
73 */
74 public $help_pre;
75
76 /**
77 * Description and/or help text to display after fields in form.
78 *
79 * @var text
80 */
81 public $help_post;
82
83 /**
84 * Optional Javascript script function(s) included on the form with this price_set. Can be used for conditional
85 *
86 * @var string
87 */
88 public $javascript;
89
90 /**
91 * What components are using this price set?
92 *
93 * @var string
94 */
95 public $extends;
96
97 /**
98 * FK to Financial Type(for membership price sets only).
99 *
100 * @var int
101 */
102 public $financial_type_id;
103
104 /**
105 * Is set if edited on Contribution or Event Page rather than through Manage Price Sets
106 *
107 * @var bool
108 */
109 public $is_quick_config;
110
111 /**
112 * Is this a predefined system price set (i.e. it can not be deleted, edited)?
113 *
114 * @var bool
115 */
116 public $is_reserved;
117
118 /**
119 * Minimum Amount required for this set.
120 *
121 * @var float
122 */
123 public $min_amount;
124
125 /**
126 * Class constructor.
127 */
128 public function __construct() {
129 $this->__table = 'civicrm_price_set';
130 parent::__construct();
131 }
132
133 /**
134 * Returns localized title of this entity.
135 *
136 * @param bool $plural
137 * Whether to return the plural version of the title.
138 */
139 public static function getEntityTitle($plural = FALSE) {
140 return $plural ? ts('Price Sets') : ts('Price Set');
141 }
142
143 /**
144 * Returns foreign keys and entity references.
145 *
146 * @return array
147 * [CRM_Core_Reference_Interface]
148 */
149 public static function getReferenceColumns() {
150 if (!isset(Civi::$statics[__CLASS__]['links'])) {
151 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
152 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id');
153 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
154 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
155 }
156 return Civi::$statics[__CLASS__]['links'];
157 }
158
159 /**
160 * Returns all the column names of this table
161 *
162 * @return array
163 */
164 public static function &fields() {
165 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
166 Civi::$statics[__CLASS__]['fields'] = [
167 'id' => [
168 'name' => 'id',
169 'type' => CRM_Utils_Type::T_INT,
170 'title' => ts('Price Set'),
171 'description' => ts('Price Set'),
172 'required' => TRUE,
173 'where' => 'civicrm_price_set.id',
174 'table_name' => 'civicrm_price_set',
175 'entity' => 'PriceSet',
176 'bao' => 'CRM_Price_BAO_PriceSet',
177 'localizable' => 0,
178 'html' => [
179 'type' => 'Number',
180 'label' => ts("ID"),
181 ],
182 'readonly' => TRUE,
183 'add' => '1.8',
184 ],
185 'domain_id' => [
186 'name' => 'domain_id',
187 'type' => CRM_Utils_Type::T_INT,
188 'title' => ts('Domain ID'),
189 'description' => ts('Which Domain is this price-set for'),
190 'where' => 'civicrm_price_set.domain_id',
191 'table_name' => 'civicrm_price_set',
192 'entity' => 'PriceSet',
193 'bao' => 'CRM_Price_BAO_PriceSet',
194 'localizable' => 0,
195 'FKClassName' => 'CRM_Core_DAO_Domain',
196 'html' => [
197 'type' => 'Text',
198 'label' => ts("Domain"),
199 ],
200 'pseudoconstant' => [
201 'table' => 'civicrm_domain',
202 'keyColumn' => 'id',
203 'labelColumn' => 'name',
204 ],
205 'add' => '3.1',
206 ],
207 'name' => [
208 'name' => 'name',
209 'type' => CRM_Utils_Type::T_STRING,
210 'title' => ts('Name'),
211 'description' => ts('Variable name/programmatic handle for this set of price fields.'),
212 'required' => TRUE,
213 'maxlength' => 255,
214 'size' => CRM_Utils_Type::HUGE,
215 'where' => 'civicrm_price_set.name',
216 'table_name' => 'civicrm_price_set',
217 'entity' => 'PriceSet',
218 'bao' => 'CRM_Price_BAO_PriceSet',
219 'localizable' => 0,
220 'html' => [
221 'type' => 'Text',
222 'label' => ts("Name"),
223 ],
224 'add' => '1.8',
225 ],
226 'title' => [
227 'name' => 'title',
228 'type' => CRM_Utils_Type::T_STRING,
229 'title' => ts('Price Set Title'),
230 'description' => ts('Displayed title for the Price Set.'),
231 'required' => TRUE,
232 'maxlength' => 255,
233 'size' => CRM_Utils_Type::HUGE,
234 'where' => 'civicrm_price_set.title',
235 'table_name' => 'civicrm_price_set',
236 'entity' => 'PriceSet',
237 'bao' => 'CRM_Price_BAO_PriceSet',
238 'localizable' => 1,
239 'html' => [
240 'type' => 'Text',
241 ],
242 'add' => '1.8',
243 ],
244 'is_active' => [
245 'name' => 'is_active',
246 'type' => CRM_Utils_Type::T_BOOLEAN,
247 'title' => ts('Price Set Is Active?'),
248 'description' => ts('Is this price set active'),
249 'where' => 'civicrm_price_set.is_active',
250 'default' => '1',
251 'table_name' => 'civicrm_price_set',
252 'entity' => 'PriceSet',
253 'bao' => 'CRM_Price_BAO_PriceSet',
254 'localizable' => 0,
255 'html' => [
256 'type' => 'CheckBox',
257 ],
258 'add' => '1.8',
259 ],
260 'help_pre' => [
261 'name' => 'help_pre',
262 'type' => CRM_Utils_Type::T_TEXT,
263 'title' => ts('Price Set Pre Help'),
264 'description' => ts('Description and/or help text to display before fields in form.'),
265 'rows' => 4,
266 'cols' => 80,
267 'where' => 'civicrm_price_set.help_pre',
268 'table_name' => 'civicrm_price_set',
269 'entity' => 'PriceSet',
270 'bao' => 'CRM_Price_BAO_PriceSet',
271 'localizable' => 1,
272 'html' => [
273 'type' => 'TextArea',
274 ],
275 'add' => '1.8',
276 ],
277 'help_post' => [
278 'name' => 'help_post',
279 'type' => CRM_Utils_Type::T_TEXT,
280 'title' => ts('Price Set Post Help'),
281 'description' => ts('Description and/or help text to display after fields in form.'),
282 'rows' => 4,
283 'cols' => 80,
284 'where' => 'civicrm_price_set.help_post',
285 'table_name' => 'civicrm_price_set',
286 'entity' => 'PriceSet',
287 'bao' => 'CRM_Price_BAO_PriceSet',
288 'localizable' => 1,
289 'html' => [
290 'type' => 'TextArea',
291 ],
292 'add' => '1.8',
293 ],
294 'javascript' => [
295 'name' => 'javascript',
296 'type' => CRM_Utils_Type::T_STRING,
297 'title' => ts('Price Set Javascript'),
298 'description' => ts('Optional Javascript script function(s) included on the form with this price_set. Can be used for conditional'),
299 'maxlength' => 64,
300 'size' => CRM_Utils_Type::BIG,
301 'where' => 'civicrm_price_set.javascript',
302 'table_name' => 'civicrm_price_set',
303 'entity' => 'PriceSet',
304 'bao' => 'CRM_Price_BAO_PriceSet',
305 'localizable' => 0,
306 'html' => [
307 'type' => 'Text',
308 ],
309 'add' => '1.8',
310 ],
311 'extends' => [
312 'name' => 'extends',
313 'type' => CRM_Utils_Type::T_STRING,
314 'title' => ts('Price Set Extends'),
315 'description' => ts('What components are using this price set?'),
316 'required' => TRUE,
317 'maxlength' => 255,
318 'size' => CRM_Utils_Type::HUGE,
319 'where' => 'civicrm_price_set.extends',
320 'table_name' => 'civicrm_price_set',
321 'entity' => 'PriceSet',
322 'bao' => 'CRM_Price_BAO_PriceSet',
323 'localizable' => 0,
324 'html' => [
325 'type' => 'Text',
326 ],
327 'pseudoconstant' => [
328 'table' => 'civicrm_component',
329 'keyColumn' => 'id',
330 'labelColumn' => 'name',
331 ],
332 'add' => '3.1',
333 ],
334 'financial_type_id' => [
335 'name' => 'financial_type_id',
336 'type' => CRM_Utils_Type::T_INT,
337 'title' => ts('Financial Type ID'),
338 'description' => ts('FK to Financial Type(for membership price sets only).'),
339 'where' => 'civicrm_price_set.financial_type_id',
340 'default' => NULL,
341 'table_name' => 'civicrm_price_set',
342 'entity' => 'PriceSet',
343 'bao' => 'CRM_Price_BAO_PriceSet',
344 'localizable' => 0,
345 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
346 'html' => [
347 'type' => 'Select',
348 'label' => ts("Financial Type"),
349 ],
350 'pseudoconstant' => [
351 'table' => 'civicrm_financial_type',
352 'keyColumn' => 'id',
353 'labelColumn' => 'name',
354 ],
355 'add' => '4.3',
356 ],
357 'is_quick_config' => [
358 'name' => 'is_quick_config',
359 'type' => CRM_Utils_Type::T_BOOLEAN,
360 'title' => ts('Is Price Set Quick Config?'),
361 'description' => ts('Is set if edited on Contribution or Event Page rather than through Manage Price Sets'),
362 'where' => 'civicrm_price_set.is_quick_config',
363 'default' => '0',
364 'table_name' => 'civicrm_price_set',
365 'entity' => 'PriceSet',
366 'bao' => 'CRM_Price_BAO_PriceSet',
367 'localizable' => 0,
368 'html' => [
369 'type' => 'CheckBox',
370 ],
371 'add' => '4.1',
372 ],
373 'is_reserved' => [
374 'name' => 'is_reserved',
375 'type' => CRM_Utils_Type::T_BOOLEAN,
376 'title' => ts('Price Set Is Reserved'),
377 'description' => ts('Is this a predefined system price set (i.e. it can not be deleted, edited)?'),
378 'where' => 'civicrm_price_set.is_reserved',
379 'default' => '0',
380 'table_name' => 'civicrm_price_set',
381 'entity' => 'PriceSet',
382 'bao' => 'CRM_Price_BAO_PriceSet',
383 'localizable' => 0,
384 'html' => [
385 'type' => 'CheckBox',
386 ],
387 'add' => '4.2',
388 ],
389 'min_amount' => [
390 'name' => 'min_amount',
391 'type' => CRM_Utils_Type::T_MONEY,
392 'title' => ts('Minimum Amount'),
393 'description' => ts('Minimum Amount required for this set.'),
394 'precision' => [
395 20,
396 2,
397 ],
398 'where' => 'civicrm_price_set.min_amount',
399 'default' => '0.0',
400 'table_name' => 'civicrm_price_set',
401 'entity' => 'PriceSet',
402 'bao' => 'CRM_Price_BAO_PriceSet',
403 'localizable' => 0,
404 'html' => [
405 'type' => 'Text',
406 ],
407 'add' => '4.7',
408 ],
409 ];
410 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
411 }
412 return Civi::$statics[__CLASS__]['fields'];
413 }
414
415 /**
416 * Return a mapping from field-name to the corresponding key (as used in fields()).
417 *
418 * @return array
419 * Array(string $name => string $uniqueName).
420 */
421 public static function &fieldKeys() {
422 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
423 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
424 }
425 return Civi::$statics[__CLASS__]['fieldKeys'];
426 }
427
428 /**
429 * Returns the names of this table
430 *
431 * @return string
432 */
433 public static function getTableName() {
434 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
435 }
436
437 /**
438 * Returns if this table needs to be logged
439 *
440 * @return bool
441 */
442 public function getLog() {
443 return self::$_log;
444 }
445
446 /**
447 * Returns the list of fields that can be imported
448 *
449 * @param bool $prefix
450 *
451 * @return array
452 */
453 public static function &import($prefix = FALSE) {
454 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'price_set', $prefix, []);
455 return $r;
456 }
457
458 /**
459 * Returns the list of fields that can be exported
460 *
461 * @param bool $prefix
462 *
463 * @return array
464 */
465 public static function &export($prefix = FALSE) {
466 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'price_set', $prefix, []);
467 return $r;
468 }
469
470 /**
471 * Returns the list of indices
472 *
473 * @param bool $localize
474 *
475 * @return array
476 */
477 public static function indices($localize = TRUE) {
478 $indices = [
479 'UI_name' => [
480 'name' => 'UI_name',
481 'field' => [
482 0 => 'name',
483 ],
484 'localizable' => FALSE,
485 'unique' => TRUE,
486 'sig' => 'civicrm_price_set::1::name',
487 ],
488 ];
489 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
490 }
491
492 }