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