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