Merge pull request #16610 from mattwire/settingstrait_datepicker
[civicrm-core.git] / CRM / Contribute / DAO / Product.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contribute/Product.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ba0100c0ce50f67d39a4e131474de7e1)
10 */
11
12 /**
13 * Database access object for the Product entity.
14 */
15 class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_product';
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 * @var int
33 */
34 public $id;
35
36 /**
37 * Required product/premium name
38 *
39 * @var string
40 */
41 public $name;
42
43 /**
44 * Optional description of the product/premium.
45 *
46 * @var text
47 */
48 public $description;
49
50 /**
51 * Optional product sku or code.
52 *
53 * @var string
54 */
55 public $sku;
56
57 /**
58 * Store comma-delimited list of color, size, etc. options for the product.
59 *
60 * @var text
61 */
62 public $options;
63
64 /**
65 * Full or relative URL to uploaded image - fullsize.
66 *
67 * @var string
68 */
69 public $image;
70
71 /**
72 * Full or relative URL to image thumbnail.
73 *
74 * @var string
75 */
76 public $thumbnail;
77
78 /**
79 * Sell price or market value for premiums. For tax-deductible contributions, this will be stored as non_deductible_amount in the contribution record.
80 *
81 * @var float
82 */
83 public $price;
84
85 /**
86 * 3 character string, value from config setting or input via user.
87 *
88 * @var string
89 */
90 public $currency;
91
92 /**
93 * FK to Financial Type.
94 *
95 * @var int
96 */
97 public $financial_type_id;
98
99 /**
100 * Minimum contribution required to be eligible to select this premium.
101 *
102 * @var float
103 */
104 public $min_contribution;
105
106 /**
107 * Actual cost of this product. Useful to determine net return from sale or using this as an incentive.
108 *
109 * @var float
110 */
111 public $cost;
112
113 /**
114 * Disabling premium removes it from the premiums_premium join table below.
115 *
116 * @var bool
117 */
118 public $is_active;
119
120 /**
121 * Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
122 * (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006)
123 *
124 * @var string
125 */
126 public $period_type;
127
128 /**
129 * Month and day (MMDD) that fixed period type subscription or membership starts.
130 *
131 * @var int
132 */
133 public $fixed_period_start_day;
134
135 /**
136 * @var string
137 */
138 public $duration_unit;
139
140 /**
141 * Number of units for total duration of subscription, service, membership (e.g. 12 Months).
142 *
143 * @var int
144 */
145 public $duration_interval;
146
147 /**
148 * Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.
149 *
150 * @var string
151 */
152 public $frequency_unit;
153
154 /**
155 * Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).
156 *
157 * @var int
158 */
159 public $frequency_interval;
160
161 /**
162 * Class constructor.
163 */
164 public function __construct() {
165 $this->__table = 'civicrm_product';
166 parent::__construct();
167 }
168
169 /**
170 * Returns localized title of this entity.
171 */
172 public static function getEntityTitle() {
173 return ts('Products');
174 }
175
176 /**
177 * Returns foreign keys and entity references.
178 *
179 * @return array
180 * [CRM_Core_Reference_Interface]
181 */
182 public static function getReferenceColumns() {
183 if (!isset(Civi::$statics[__CLASS__]['links'])) {
184 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
185 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
186 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
187 }
188 return Civi::$statics[__CLASS__]['links'];
189 }
190
191 /**
192 * Returns all the column names of this table
193 *
194 * @return array
195 */
196 public static function &fields() {
197 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
198 Civi::$statics[__CLASS__]['fields'] = [
199 'id' => [
200 'name' => 'id',
201 'type' => CRM_Utils_Type::T_INT,
202 'title' => ts('Product ID'),
203 'required' => TRUE,
204 'where' => 'civicrm_product.id',
205 'table_name' => 'civicrm_product',
206 'entity' => 'Product',
207 'bao' => 'CRM_Contribute_BAO_Product',
208 'localizable' => 0,
209 ],
210 'product_name' => [
211 'name' => 'name',
212 'type' => CRM_Utils_Type::T_STRING,
213 'title' => ts('Product Name'),
214 'description' => ts('Required product/premium name'),
215 'required' => TRUE,
216 'maxlength' => 255,
217 'size' => CRM_Utils_Type::HUGE,
218 'where' => 'civicrm_product.name',
219 'export' => TRUE,
220 'table_name' => 'civicrm_product',
221 'entity' => 'Product',
222 'bao' => 'CRM_Contribute_BAO_Product',
223 'localizable' => 1,
224 ],
225 'description' => [
226 'name' => 'description',
227 'type' => CRM_Utils_Type::T_TEXT,
228 'title' => ts('Description'),
229 'description' => ts('Optional description of the product/premium.'),
230 'where' => 'civicrm_product.description',
231 'table_name' => 'civicrm_product',
232 'entity' => 'Product',
233 'bao' => 'CRM_Contribute_BAO_Product',
234 'localizable' => 1,
235 ],
236 'sku' => [
237 'name' => 'sku',
238 'type' => CRM_Utils_Type::T_STRING,
239 'title' => ts('SKU'),
240 'description' => ts('Optional product sku or code.'),
241 'maxlength' => 50,
242 'size' => CRM_Utils_Type::BIG,
243 'where' => 'civicrm_product.sku',
244 'export' => TRUE,
245 'table_name' => 'civicrm_product',
246 'entity' => 'Product',
247 'bao' => 'CRM_Contribute_BAO_Product',
248 'localizable' => 0,
249 ],
250 'options' => [
251 'name' => 'options',
252 'type' => CRM_Utils_Type::T_TEXT,
253 'title' => ts('Options'),
254 'description' => ts('Store comma-delimited list of color, size, etc. options for the product.'),
255 'where' => 'civicrm_product.options',
256 'table_name' => 'civicrm_product',
257 'entity' => 'Product',
258 'bao' => 'CRM_Contribute_BAO_Product',
259 'localizable' => 1,
260 ],
261 'image' => [
262 'name' => 'image',
263 'type' => CRM_Utils_Type::T_STRING,
264 'title' => ts('Image'),
265 'description' => ts('Full or relative URL to uploaded image - fullsize.'),
266 'maxlength' => 255,
267 'size' => CRM_Utils_Type::HUGE,
268 'where' => 'civicrm_product.image',
269 'table_name' => 'civicrm_product',
270 'entity' => 'Product',
271 'bao' => 'CRM_Contribute_BAO_Product',
272 'localizable' => 0,
273 ],
274 'thumbnail' => [
275 'name' => 'thumbnail',
276 'type' => CRM_Utils_Type::T_STRING,
277 'title' => ts('Thumbnail'),
278 'description' => ts('Full or relative URL to image thumbnail.'),
279 'maxlength' => 255,
280 'size' => CRM_Utils_Type::HUGE,
281 'where' => 'civicrm_product.thumbnail',
282 'table_name' => 'civicrm_product',
283 'entity' => 'Product',
284 'bao' => 'CRM_Contribute_BAO_Product',
285 'localizable' => 0,
286 ],
287 'price' => [
288 'name' => 'price',
289 'type' => CRM_Utils_Type::T_MONEY,
290 'title' => ts('Price'),
291 'description' => ts('Sell price or market value for premiums. For tax-deductible contributions, this will be stored as non_deductible_amount in the contribution record.'),
292 'precision' => [
293 20,
294 2,
295 ],
296 'where' => 'civicrm_product.price',
297 'table_name' => 'civicrm_product',
298 'entity' => 'Product',
299 'bao' => 'CRM_Contribute_BAO_Product',
300 'localizable' => 0,
301 ],
302 'currency' => [
303 'name' => 'currency',
304 'type' => CRM_Utils_Type::T_STRING,
305 'title' => ts('Currency'),
306 'description' => ts('3 character string, value from config setting or input via user.'),
307 'maxlength' => 3,
308 'size' => CRM_Utils_Type::FOUR,
309 'where' => 'civicrm_product.currency',
310 'default' => 'NULL',
311 'table_name' => 'civicrm_product',
312 'entity' => 'Product',
313 'bao' => 'CRM_Contribute_BAO_Product',
314 'localizable' => 0,
315 'html' => [
316 'type' => 'Select',
317 ],
318 'pseudoconstant' => [
319 'table' => 'civicrm_currency',
320 'keyColumn' => 'name',
321 'labelColumn' => 'full_name',
322 'nameColumn' => 'name',
323 'abbrColumn' => 'symbol',
324 ],
325 ],
326 'financial_type_id' => [
327 'name' => 'financial_type_id',
328 'type' => CRM_Utils_Type::T_INT,
329 'title' => ts('Financial Type'),
330 'description' => ts('FK to Financial Type.'),
331 'where' => 'civicrm_product.financial_type_id',
332 'default' => 'NULL',
333 'table_name' => 'civicrm_product',
334 'entity' => 'Product',
335 'bao' => 'CRM_Contribute_BAO_Product',
336 'localizable' => 0,
337 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
338 'pseudoconstant' => [
339 'table' => 'civicrm_financial_type',
340 'keyColumn' => 'id',
341 'labelColumn' => 'name',
342 ],
343 ],
344 'min_contribution' => [
345 'name' => 'min_contribution',
346 'type' => CRM_Utils_Type::T_MONEY,
347 'title' => ts('Minimum Contribution'),
348 'description' => ts('Minimum contribution required to be eligible to select this premium.'),
349 'precision' => [
350 20,
351 2,
352 ],
353 'where' => 'civicrm_product.min_contribution',
354 'table_name' => 'civicrm_product',
355 'entity' => 'Product',
356 'bao' => 'CRM_Contribute_BAO_Product',
357 'localizable' => 0,
358 ],
359 'cost' => [
360 'name' => 'cost',
361 'type' => CRM_Utils_Type::T_MONEY,
362 'title' => ts('Cost'),
363 'description' => ts('Actual cost of this product. Useful to determine net return from sale or using this as an incentive.'),
364 'precision' => [
365 20,
366 2,
367 ],
368 'where' => 'civicrm_product.cost',
369 'table_name' => 'civicrm_product',
370 'entity' => 'Product',
371 'bao' => 'CRM_Contribute_BAO_Product',
372 'localizable' => 0,
373 ],
374 'is_active' => [
375 'name' => 'is_active',
376 'type' => CRM_Utils_Type::T_BOOLEAN,
377 'title' => ts('Is Active'),
378 'description' => ts('Disabling premium removes it from the premiums_premium join table below.'),
379 'required' => TRUE,
380 'where' => 'civicrm_product.is_active',
381 'table_name' => 'civicrm_product',
382 'entity' => 'Product',
383 'bao' => 'CRM_Contribute_BAO_Product',
384 'localizable' => 0,
385 ],
386 'period_type' => [
387 'name' => 'period_type',
388 'type' => CRM_Utils_Type::T_STRING,
389 'title' => ts('Period Type'),
390 'description' => ts('Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
391 (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) '),
392 'maxlength' => 8,
393 'size' => CRM_Utils_Type::EIGHT,
394 'where' => 'civicrm_product.period_type',
395 'default' => 'rolling',
396 'table_name' => 'civicrm_product',
397 'entity' => 'Product',
398 'bao' => 'CRM_Contribute_BAO_Product',
399 'localizable' => 0,
400 'html' => [
401 'type' => 'Select',
402 ],
403 'pseudoconstant' => [
404 'callback' => 'CRM_Core_SelectValues::periodType',
405 ],
406 ],
407 'fixed_period_start_day' => [
408 'name' => 'fixed_period_start_day',
409 'type' => CRM_Utils_Type::T_INT,
410 'title' => ts('Fixed Period Start Day'),
411 'description' => ts('Month and day (MMDD) that fixed period type subscription or membership starts.'),
412 'where' => 'civicrm_product.fixed_period_start_day',
413 'default' => '0101',
414 'table_name' => 'civicrm_product',
415 'entity' => 'Product',
416 'bao' => 'CRM_Contribute_BAO_Product',
417 'localizable' => 0,
418 ],
419 'duration_unit' => [
420 'name' => 'duration_unit',
421 'type' => CRM_Utils_Type::T_STRING,
422 'title' => ts('Duration Unit'),
423 'maxlength' => 8,
424 'size' => CRM_Utils_Type::EIGHT,
425 'where' => 'civicrm_product.duration_unit',
426 'default' => 'year',
427 'table_name' => 'civicrm_product',
428 'entity' => 'Product',
429 'bao' => 'CRM_Contribute_BAO_Product',
430 'localizable' => 0,
431 'html' => [
432 'type' => 'Select',
433 ],
434 'pseudoconstant' => [
435 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
436 ],
437 ],
438 'duration_interval' => [
439 'name' => 'duration_interval',
440 'type' => CRM_Utils_Type::T_INT,
441 'title' => ts('Duration Interval'),
442 'description' => ts('Number of units for total duration of subscription, service, membership (e.g. 12 Months).'),
443 'where' => 'civicrm_product.duration_interval',
444 'table_name' => 'civicrm_product',
445 'entity' => 'Product',
446 'bao' => 'CRM_Contribute_BAO_Product',
447 'localizable' => 0,
448 ],
449 'frequency_unit' => [
450 'name' => 'frequency_unit',
451 'type' => CRM_Utils_Type::T_STRING,
452 'title' => ts('Frequency Unit'),
453 'description' => ts('Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.'),
454 'maxlength' => 8,
455 'size' => CRM_Utils_Type::EIGHT,
456 'where' => 'civicrm_product.frequency_unit',
457 'default' => 'month',
458 'table_name' => 'civicrm_product',
459 'entity' => 'Product',
460 'bao' => 'CRM_Contribute_BAO_Product',
461 'localizable' => 0,
462 'html' => [
463 'type' => 'Select',
464 ],
465 'pseudoconstant' => [
466 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
467 ],
468 ],
469 'frequency_interval' => [
470 'name' => 'frequency_interval',
471 'type' => CRM_Utils_Type::T_INT,
472 'title' => ts('Frequency Interval'),
473 'description' => ts('Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).'),
474 'where' => 'civicrm_product.frequency_interval',
475 'table_name' => 'civicrm_product',
476 'entity' => 'Product',
477 'bao' => 'CRM_Contribute_BAO_Product',
478 'localizable' => 0,
479 ],
480 ];
481 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
482 }
483 return Civi::$statics[__CLASS__]['fields'];
484 }
485
486 /**
487 * Return a mapping from field-name to the corresponding key (as used in fields()).
488 *
489 * @return array
490 * Array(string $name => string $uniqueName).
491 */
492 public static function &fieldKeys() {
493 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
494 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
495 }
496 return Civi::$statics[__CLASS__]['fieldKeys'];
497 }
498
499 /**
500 * Returns the names of this table
501 *
502 * @return string
503 */
504 public static function getTableName() {
505 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
506 }
507
508 /**
509 * Returns if this table needs to be logged
510 *
511 * @return bool
512 */
513 public function getLog() {
514 return self::$_log;
515 }
516
517 /**
518 * Returns the list of fields that can be imported
519 *
520 * @param bool $prefix
521 *
522 * @return array
523 */
524 public static function &import($prefix = FALSE) {
525 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'product', $prefix, []);
526 return $r;
527 }
528
529 /**
530 * Returns the list of fields that can be exported
531 *
532 * @param bool $prefix
533 *
534 * @return array
535 */
536 public static function &export($prefix = FALSE) {
537 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'product', $prefix, []);
538 return $r;
539 }
540
541 /**
542 * Returns the list of indices
543 *
544 * @param bool $localize
545 *
546 * @return array
547 */
548 public static function indices($localize = TRUE) {
549 $indices = [];
550 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
551 }
552
553 }