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