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