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