Regenerate DAO files
[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
2cbbebe8 9 * (GenCodeChecksum:da319316754e17cc5f9447c9e2b095ad)
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',
a0a2c91d 180 ],
a9d0587b 181 'add' => '1.8',
c3fc2621
CW
182 ],
183 'domain_id' => [
e501603b
TO
184 'name' => 'domain_id',
185 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 186 'title' => ts('Domain ID'),
215b423e 187 'description' => ts('Which Domain is this price-set for'),
a36434b9 188 'where' => 'civicrm_price_set.domain_id',
522a26c9 189 'table_name' => 'civicrm_price_set',
190 'entity' => 'PriceSet',
191 'bao' => 'CRM_Price_BAO_PriceSet',
6a7e5e5d 192 'localizable' => 0,
e501603b 193 'FKClassName' => 'CRM_Core_DAO_Domain',
c3fc2621 194 'html' => [
e501603b 195 'type' => 'Text',
2cbbebe8 196 'label' => ts("Domain"),
c3fc2621
CW
197 ],
198 'pseudoconstant' => [
e501603b
TO
199 'table' => 'civicrm_domain',
200 'keyColumn' => 'id',
201 'labelColumn' => 'name',
e6ca0a57 202 ],
a9d0587b 203 'add' => '3.1',
c3fc2621
CW
204 ],
205 'name' => [
e501603b
TO
206 'name' => 'name',
207 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 208 'title' => ts('Name'),
215b423e 209 'description' => ts('Variable name/programmatic handle for this set of price fields.'),
c3fc2621 210 'required' => TRUE,
e501603b
TO
211 'maxlength' => 255,
212 'size' => CRM_Utils_Type::HUGE,
a36434b9 213 'where' => 'civicrm_price_set.name',
522a26c9 214 'table_name' => 'civicrm_price_set',
215 'entity' => 'PriceSet',
216 'bao' => 'CRM_Price_BAO_PriceSet',
6a7e5e5d 217 'localizable' => 0,
c3fc2621 218 'html' => [
e501603b 219 'type' => 'Text',
c3fc2621 220 ],
a9d0587b 221 'add' => '1.8',
c3fc2621
CW
222 ],
223 'title' => [
e501603b
TO
224 'name' => 'title',
225 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 226 'title' => ts('Price Set Title'),
215b423e 227 'description' => ts('Displayed title for the Price Set.'),
c3fc2621 228 'required' => TRUE,
e501603b
TO
229 'maxlength' => 255,
230 'size' => CRM_Utils_Type::HUGE,
a36434b9 231 'where' => 'civicrm_price_set.title',
522a26c9 232 'table_name' => 'civicrm_price_set',
233 'entity' => 'PriceSet',
234 'bao' => 'CRM_Price_BAO_PriceSet',
6a7e5e5d 235 'localizable' => 1,
c3fc2621 236 'html' => [
e501603b 237 'type' => 'Text',
c3fc2621 238 ],
a9d0587b 239 'add' => '1.8',
c3fc2621
CW
240 ],
241 'is_active' => [
e501603b
TO
242 'name' => 'is_active',
243 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 244 'title' => ts('Price Set Is Active?'),
215b423e 245 'description' => ts('Is this price set active'),
a36434b9 246 'where' => 'civicrm_price_set.is_active',
e501603b 247 'default' => '1',
522a26c9 248 'table_name' => 'civicrm_price_set',
249 'entity' => 'PriceSet',
250 'bao' => 'CRM_Price_BAO_PriceSet',
6a7e5e5d 251 'localizable' => 0,
c3fc2621 252 'html' => [
e501603b 253 'type' => 'CheckBox',
c3fc2621 254 ],
a9d0587b 255 'add' => '1.8',
c3fc2621
CW
256 ],
257 'help_pre' => [
e501603b
TO
258 'name' => 'help_pre',
259 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 260 'title' => ts('Price Set Pre Help'),
215b423e 261 'description' => ts('Description and/or help text to display before fields in form.'),
e501603b
TO
262 'rows' => 4,
263 'cols' => 80,
a36434b9 264 'where' => 'civicrm_price_set.help_pre',
522a26c9 265 'table_name' => 'civicrm_price_set',
266 'entity' => 'PriceSet',
267 'bao' => 'CRM_Price_BAO_PriceSet',
6a7e5e5d 268 'localizable' => 1,
c3fc2621 269 'html' => [
e501603b 270 'type' => 'TextArea',
c3fc2621 271 ],
a9d0587b 272 'add' => '1.8',
c3fc2621
CW
273 ],
274 'help_post' => [
e501603b
TO
275 'name' => 'help_post',
276 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 277 'title' => ts('Price Set Post Help'),
215b423e 278 'description' => ts('Description and/or help text to display after fields in form.'),
e501603b
TO
279 'rows' => 4,
280 'cols' => 80,
a36434b9 281 'where' => 'civicrm_price_set.help_post',
522a26c9 282 'table_name' => 'civicrm_price_set',
283 'entity' => 'PriceSet',
284 'bao' => 'CRM_Price_BAO_PriceSet',
6a7e5e5d 285 'localizable' => 1,
c3fc2621 286 'html' => [
e501603b 287 'type' => 'TextArea',
c3fc2621 288 ],
a9d0587b 289 'add' => '1.8',
c3fc2621
CW
290 ],
291 'javascript' => [
e501603b
TO
292 'name' => 'javascript',
293 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 294 'title' => ts('Price Set Javascript'),
215b423e 295 'description' => ts('Optional Javascript script function(s) included on the form with this price_set. Can be used for conditional'),
e501603b
TO
296 'maxlength' => 64,
297 'size' => CRM_Utils_Type::BIG,
a36434b9 298 'where' => 'civicrm_price_set.javascript',
522a26c9 299 'table_name' => 'civicrm_price_set',
300 'entity' => 'PriceSet',
301 'bao' => 'CRM_Price_BAO_PriceSet',
6a7e5e5d 302 'localizable' => 0,
c3fc2621 303 'html' => [
e501603b 304 'type' => 'Text',
c3fc2621 305 ],
a9d0587b 306 'add' => '1.8',
c3fc2621
CW
307 ],
308 'extends' => [
e501603b
TO
309 'name' => 'extends',
310 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 311 'title' => ts('Price Set Extends'),
215b423e 312 'description' => ts('What components are using this price set?'),
c3fc2621 313 'required' => TRUE,
e501603b
TO
314 'maxlength' => 255,
315 'size' => CRM_Utils_Type::HUGE,
a36434b9 316 'where' => 'civicrm_price_set.extends',
522a26c9 317 'table_name' => 'civicrm_price_set',
318 'entity' => 'PriceSet',
319 'bao' => 'CRM_Price_BAO_PriceSet',
6a7e5e5d 320 'localizable' => 0,
c3fc2621 321 'html' => [
e501603b 322 'type' => 'Text',
c3fc2621
CW
323 ],
324 'pseudoconstant' => [
e501603b
TO
325 'table' => 'civicrm_component',
326 'keyColumn' => 'id',
327 'labelColumn' => 'name',
e6ca0a57 328 ],
a9d0587b 329 'add' => '3.1',
c3fc2621
CW
330 ],
331 'financial_type_id' => [
e501603b
TO
332 'name' => 'financial_type_id',
333 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 334 'title' => ts('Financial Type ID'),
215b423e 335 'description' => ts('FK to Financial Type(for membership price sets only).'),
a36434b9 336 'where' => 'civicrm_price_set.financial_type_id',
e501603b 337 'default' => 'NULL',
522a26c9 338 'table_name' => 'civicrm_price_set',
339 'entity' => 'PriceSet',
340 'bao' => 'CRM_Price_BAO_PriceSet',
6a7e5e5d 341 'localizable' => 0,
e501603b 342 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
c3fc2621 343 'html' => [
e501603b 344 'type' => 'Select',
2cbbebe8 345 'label' => ts("Financial Type"),
c3fc2621
CW
346 ],
347 'pseudoconstant' => [
e501603b
TO
348 'table' => 'civicrm_financial_type',
349 'keyColumn' => 'id',
350 'labelColumn' => 'name',
e6ca0a57 351 ],
a9d0587b 352 'add' => '4.3',
c3fc2621
CW
353 ],
354 'is_quick_config' => [
e501603b
TO
355 'name' => 'is_quick_config',
356 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 357 'title' => ts('Is Price Set Quick Config?'),
215b423e 358 'description' => ts('Is set if edited on Contribution or Event Page rather than through Manage Price Sets'),
a36434b9 359 'where' => 'civicrm_price_set.is_quick_config',
45a83e42 360 'default' => '0',
522a26c9 361 'table_name' => 'civicrm_price_set',
362 'entity' => 'PriceSet',
363 'bao' => 'CRM_Price_BAO_PriceSet',
6a7e5e5d 364 'localizable' => 0,
c3fc2621 365 'html' => [
e501603b 366 'type' => 'CheckBox',
c3fc2621 367 ],
a9d0587b 368 'add' => '4.1',
c3fc2621
CW
369 ],
370 'is_reserved' => [
e501603b
TO
371 'name' => 'is_reserved',
372 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 373 'title' => ts('Price Set Is Reserved'),
215b423e 374 'description' => ts('Is this a predefined system price set (i.e. it can not be deleted, edited)?'),
a36434b9 375 'where' => 'civicrm_price_set.is_reserved',
45a83e42 376 'default' => '0',
522a26c9 377 'table_name' => 'civicrm_price_set',
378 'entity' => 'PriceSet',
379 'bao' => 'CRM_Price_BAO_PriceSet',
6a7e5e5d 380 'localizable' => 0,
c3fc2621 381 'html' => [
e501603b 382 'type' => 'CheckBox',
c3fc2621 383 ],
a9d0587b 384 'add' => '4.2',
c3fc2621
CW
385 ],
386 'min_amount' => [
601c7a24 387 'name' => 'min_amount',
f5e61d50 388 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 389 'title' => ts('Minimum Amount'),
215b423e 390 'description' => ts('Minimum Amount required for this set.'),
f5e61d50
PN
391 'precision' => [
392 20,
393 2,
394 ],
a36434b9 395 'where' => 'civicrm_price_set.min_amount',
f5e61d50 396 'default' => '0.0',
522a26c9 397 'table_name' => 'civicrm_price_set',
398 'entity' => 'PriceSet',
399 'bao' => 'CRM_Price_BAO_PriceSet',
6a7e5e5d 400 'localizable' => 0,
c3fc2621 401 'html' => [
601c7a24 402 'type' => 'Text',
c3fc2621 403 ],
a9d0587b 404 'add' => '4.7',
c3fc2621
CW
405 ],
406 ];
346aaaba 407 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 408 }
346aaaba 409 return Civi::$statics[__CLASS__]['fields'];
e501603b 410 }
c3fc2621 411
e501603b 412 /**
bd8e0b14 413 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
414 *
415 * @return array
bd8e0b14 416 * Array(string $name => string $uniqueName).
e501603b 417 */
c3fc2621 418 public static function &fieldKeys() {
bd8e0b14
TO
419 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
420 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 421 }
bd8e0b14 422 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 423 }
c3fc2621 424
e501603b
TO
425 /**
426 * Returns the names of this table
427 *
428 * @return string
429 */
c3fc2621 430 public static function getTableName() {
e501603b
TO
431 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
432 }
c3fc2621 433
e501603b
TO
434 /**
435 * Returns if this table needs to be logged
436 *
c3fc2621 437 * @return bool
e501603b 438 */
c3fc2621 439 public function getLog() {
e501603b
TO
440 return self::$_log;
441 }
c3fc2621 442
e501603b
TO
443 /**
444 * Returns the list of fields that can be imported
445 *
446 * @param bool $prefix
447 *
448 * @return array
449 */
c3fc2621
CW
450 public static function &import($prefix = FALSE) {
451 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'price_set', $prefix, []);
60808919 452 return $r;
e501603b 453 }
c3fc2621 454
e501603b
TO
455 /**
456 * Returns the list of fields that can be exported
457 *
458 * @param bool $prefix
459 *
460 * @return array
461 */
c3fc2621
CW
462 public static function &export($prefix = FALSE) {
463 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'price_set', $prefix, []);
60808919 464 return $r;
e501603b 465 }
c3fc2621 466
e7a6b91a
AS
467 /**
468 * Returns the list of indices
c3fc2621
CW
469 *
470 * @param bool $localize
471 *
472 * @return array
e7a6b91a
AS
473 */
474 public static function indices($localize = TRUE) {
c3fc2621
CW
475 $indices = [
476 'UI_name' => [
e7a6b91a 477 'name' => 'UI_name',
c3fc2621 478 'field' => [
e7a6b91a 479 0 => 'name',
c3fc2621
CW
480 ],
481 'localizable' => FALSE,
482 'unique' => TRUE,
e7a6b91a 483 'sig' => 'civicrm_price_set::1::name',
c3fc2621
CW
484 ],
485 ];
e7a6b91a
AS
486 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
487 }
c3fc2621 488
e501603b 489}