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