5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contribute/Product.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:b70d9c858ea4a663872931e6028b0ead)
13 * Database access object for the Product entity.
15 class CRM_Contribute_DAO_Product
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.4';
18 const COMPONENT
= 'CiviContribute';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_product';
28 * Field to show when displaying a record.
32 public static $_labelField = 'name';
35 * Should CiviCRM log any modifications to this table in the civicrm_log table.
39 public static $_log = TRUE;
47 * Required product/premium name
54 * Optional description of the product/premium.
61 * Optional product sku or code.
68 * Store comma-delimited list of color, size, etc. options for the product.
75 * Full or relative URL to uploaded image - fullsize.
82 * Full or relative URL to image thumbnail.
89 * Sell price or market value for premiums. For tax-deductible contributions, this will be stored as non_deductible_amount in the contribution record.
96 * 3 character string, value from config setting or input via user.
103 * FK to Financial Type.
107 public $financial_type_id;
110 * Minimum contribution required to be eligible to select this premium.
114 public $min_contribution;
117 * Actual cost of this product. Useful to determine net return from sale or using this as an incentive.
124 * Disabling premium removes it from the premiums_premium join table below.
131 * Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
132 * (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006)
139 * Month and day (MMDD) that fixed period type subscription or membership starts.
143 public $fixed_period_start_day;
148 public $duration_unit;
151 * Number of units for total duration of subscription, service, membership (e.g. 12 Months).
155 public $duration_interval;
158 * Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.
162 public $frequency_unit;
165 * Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).
169 public $frequency_interval;
174 public function __construct() {
175 $this->__table
= 'civicrm_product';
176 parent
::__construct();
180 * Returns localized title of this entity.
182 * @param bool $plural
183 * Whether to return the plural version of the title.
185 public static function getEntityTitle($plural = FALSE) {
186 return $plural ?
ts('Products') : ts('Product');
190 * Returns foreign keys and entity references.
193 * [CRM_Core_Reference_Interface]
195 public static function getReferenceColumns() {
196 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
197 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
198 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
199 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
201 return Civi
::$statics[__CLASS__
]['links'];
205 * Returns all the column names of this table
209 public static function &fields() {
210 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
211 Civi
::$statics[__CLASS__
]['fields'] = [
214 'type' => CRM_Utils_Type
::T_INT
,
215 'title' => ts('Product ID'),
217 'where' => 'civicrm_product.id',
218 'table_name' => 'civicrm_product',
219 'entity' => 'Product',
220 'bao' => 'CRM_Contribute_BAO_Product',
230 'type' => CRM_Utils_Type
::T_STRING
,
231 'title' => ts('Product Name'),
232 'description' => ts('Required product/premium name'),
235 'size' => CRM_Utils_Type
::HUGE
,
236 'where' => 'civicrm_product.name',
238 'table_name' => 'civicrm_product',
239 'entity' => 'Product',
240 'bao' => 'CRM_Contribute_BAO_Product',
245 'name' => 'description',
246 'type' => CRM_Utils_Type
::T_TEXT
,
247 'title' => ts('Description'),
248 'description' => ts('Optional description of the product/premium.'),
249 'where' => 'civicrm_product.description',
250 'table_name' => 'civicrm_product',
251 'entity' => 'Product',
252 'bao' => 'CRM_Contribute_BAO_Product',
258 'type' => CRM_Utils_Type
::T_STRING
,
259 'title' => ts('SKU'),
260 'description' => ts('Optional product sku or code.'),
262 'size' => CRM_Utils_Type
::BIG
,
263 'where' => 'civicrm_product.sku',
265 'table_name' => 'civicrm_product',
266 'entity' => 'Product',
267 'bao' => 'CRM_Contribute_BAO_Product',
273 'type' => CRM_Utils_Type
::T_TEXT
,
274 'title' => ts('Options'),
275 'description' => ts('Store comma-delimited list of color, size, etc. options for the product.'),
276 'where' => 'civicrm_product.options',
277 'table_name' => 'civicrm_product',
278 'entity' => 'Product',
279 'bao' => 'CRM_Contribute_BAO_Product',
285 'type' => CRM_Utils_Type
::T_STRING
,
286 'title' => ts('Image'),
287 'description' => ts('Full or relative URL to uploaded image - fullsize.'),
289 'size' => CRM_Utils_Type
::HUGE
,
290 'where' => 'civicrm_product.image',
291 'table_name' => 'civicrm_product',
292 'entity' => 'Product',
293 'bao' => 'CRM_Contribute_BAO_Product',
298 'name' => 'thumbnail',
299 'type' => CRM_Utils_Type
::T_STRING
,
300 'title' => ts('Thumbnail'),
301 'description' => ts('Full or relative URL to image thumbnail.'),
303 'size' => CRM_Utils_Type
::HUGE
,
304 'where' => 'civicrm_product.thumbnail',
305 'table_name' => 'civicrm_product',
306 'entity' => 'Product',
307 'bao' => 'CRM_Contribute_BAO_Product',
313 'type' => CRM_Utils_Type
::T_MONEY
,
314 'title' => ts('Price'),
315 '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.'),
320 'where' => 'civicrm_product.price',
321 'table_name' => 'civicrm_product',
322 'entity' => 'Product',
323 'bao' => 'CRM_Contribute_BAO_Product',
328 'name' => 'currency',
329 'type' => CRM_Utils_Type
::T_STRING
,
330 'title' => ts('Currency'),
331 'description' => ts('3 character string, value from config setting or input via user.'),
333 'size' => CRM_Utils_Type
::FOUR
,
334 'where' => 'civicrm_product.currency',
336 'table_name' => 'civicrm_product',
337 'entity' => 'Product',
338 'bao' => 'CRM_Contribute_BAO_Product',
342 'label' => ts("Currency"),
344 'pseudoconstant' => [
345 'table' => 'civicrm_currency',
346 'keyColumn' => 'name',
347 'labelColumn' => 'full_name',
348 'nameColumn' => 'name',
349 'abbrColumn' => 'symbol',
353 'financial_type_id' => [
354 'name' => 'financial_type_id',
355 'type' => CRM_Utils_Type
::T_INT
,
356 'title' => ts('Financial Type ID'),
357 'description' => ts('FK to Financial Type.'),
358 'where' => 'civicrm_product.financial_type_id',
360 'table_name' => 'civicrm_product',
361 'entity' => 'Product',
362 'bao' => 'CRM_Contribute_BAO_Product',
364 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
366 'label' => ts("Financial Type"),
368 'pseudoconstant' => [
369 'table' => 'civicrm_financial_type',
371 'labelColumn' => 'name',
375 'min_contribution' => [
376 'name' => 'min_contribution',
377 'type' => CRM_Utils_Type
::T_MONEY
,
378 'title' => ts('Minimum Contribution'),
379 'description' => ts('Minimum contribution required to be eligible to select this premium.'),
384 'where' => 'civicrm_product.min_contribution',
385 'table_name' => 'civicrm_product',
386 'entity' => 'Product',
387 'bao' => 'CRM_Contribute_BAO_Product',
393 'type' => CRM_Utils_Type
::T_MONEY
,
394 'title' => ts('Cost'),
395 'description' => ts('Actual cost of this product. Useful to determine net return from sale or using this as an incentive.'),
400 'where' => 'civicrm_product.cost',
401 'table_name' => 'civicrm_product',
402 'entity' => 'Product',
403 'bao' => 'CRM_Contribute_BAO_Product',
408 'name' => 'is_active',
409 'type' => CRM_Utils_Type
::T_BOOLEAN
,
410 'title' => ts('Is Active'),
411 'description' => ts('Disabling premium removes it from the premiums_premium join table below.'),
413 'where' => 'civicrm_product.is_active',
414 'table_name' => 'civicrm_product',
415 'entity' => 'Product',
416 'bao' => 'CRM_Contribute_BAO_Product',
421 'name' => 'period_type',
422 'type' => CRM_Utils_Type
::T_STRING
,
423 'title' => ts('Period Type'),
424 'description' => ts('Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
425 (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) '),
427 'size' => CRM_Utils_Type
::EIGHT
,
428 'where' => 'civicrm_product.period_type',
429 'default' => 'rolling',
430 'table_name' => 'civicrm_product',
431 'entity' => 'Product',
432 'bao' => 'CRM_Contribute_BAO_Product',
437 'pseudoconstant' => [
438 'callback' => 'CRM_Core_SelectValues::periodType',
442 'fixed_period_start_day' => [
443 'name' => 'fixed_period_start_day',
444 'type' => CRM_Utils_Type
::T_INT
,
445 'title' => ts('Fixed Period Start Day'),
446 'description' => ts('Month and day (MMDD) that fixed period type subscription or membership starts.'),
447 'where' => 'civicrm_product.fixed_period_start_day',
449 'table_name' => 'civicrm_product',
450 'entity' => 'Product',
451 'bao' => 'CRM_Contribute_BAO_Product',
456 'name' => 'duration_unit',
457 'type' => CRM_Utils_Type
::T_STRING
,
458 'title' => ts('Duration Unit'),
460 'size' => CRM_Utils_Type
::EIGHT
,
461 'where' => 'civicrm_product.duration_unit',
463 'table_name' => 'civicrm_product',
464 'entity' => 'Product',
465 'bao' => 'CRM_Contribute_BAO_Product',
470 'pseudoconstant' => [
471 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
475 'duration_interval' => [
476 'name' => 'duration_interval',
477 'type' => CRM_Utils_Type
::T_INT
,
478 'title' => ts('Duration Interval'),
479 'description' => ts('Number of units for total duration of subscription, service, membership (e.g. 12 Months).'),
480 'where' => 'civicrm_product.duration_interval',
481 'table_name' => 'civicrm_product',
482 'entity' => 'Product',
483 'bao' => 'CRM_Contribute_BAO_Product',
487 'frequency_unit' => [
488 'name' => 'frequency_unit',
489 'type' => CRM_Utils_Type
::T_STRING
,
490 'title' => ts('Frequency Unit'),
491 'description' => ts('Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.'),
493 'size' => CRM_Utils_Type
::EIGHT
,
494 'where' => 'civicrm_product.frequency_unit',
495 'default' => 'month',
496 'table_name' => 'civicrm_product',
497 'entity' => 'Product',
498 'bao' => 'CRM_Contribute_BAO_Product',
503 'pseudoconstant' => [
504 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
508 'frequency_interval' => [
509 'name' => 'frequency_interval',
510 'type' => CRM_Utils_Type
::T_INT
,
511 'title' => ts('Frequency Interval'),
512 'description' => ts('Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).'),
513 'where' => 'civicrm_product.frequency_interval',
514 'table_name' => 'civicrm_product',
515 'entity' => 'Product',
516 'bao' => 'CRM_Contribute_BAO_Product',
521 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
523 return Civi
::$statics[__CLASS__
]['fields'];
527 * Return a mapping from field-name to the corresponding key (as used in fields()).
530 * Array(string $name => string $uniqueName).
532 public static function &fieldKeys() {
533 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
534 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
536 return Civi
::$statics[__CLASS__
]['fieldKeys'];
540 * Returns the names of this table
544 public static function getTableName() {
545 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
549 * Returns if this table needs to be logged
553 public function getLog() {
558 * Returns the list of fields that can be imported
560 * @param bool $prefix
564 public static function &import($prefix = FALSE) {
565 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'product', $prefix, []);
570 * Returns the list of fields that can be exported
572 * @param bool $prefix
576 public static function &export($prefix = FALSE) {
577 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'product', $prefix, []);
582 * Returns the list of indices
584 * @param bool $localize
588 public static function indices($localize = TRUE) {
590 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;