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