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