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:45a3c80396259fbc6da8cbecc0ba652d)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
32 public static $_log = TRUE;
40 * Required product/premium name
47 * Optional description of the product/premium.
54 * Optional product sku or code.
61 * Store comma-delimited list of color, size, etc. options for the product.
68 * Full or relative URL to uploaded image - fullsize.
75 * Full or relative URL to image thumbnail.
82 * Sell price or market value for premiums. For tax-deductible contributions, this will be stored as non_deductible_amount in the contribution record.
89 * 3 character string, value from config setting or input via user.
96 * FK to Financial Type.
100 public $financial_type_id;
103 * Minimum contribution required to be eligible to select this premium.
107 public $min_contribution;
110 * Actual cost of this product. Useful to determine net return from sale or using this as an incentive.
117 * Disabling premium removes it from the premiums_premium join table below.
124 * Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
125 * (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006)
132 * Month and day (MMDD) that fixed period type subscription or membership starts.
136 public $fixed_period_start_day;
141 public $duration_unit;
144 * Number of units for total duration of subscription, service, membership (e.g. 12 Months).
148 public $duration_interval;
151 * Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.
155 public $frequency_unit;
158 * Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).
162 public $frequency_interval;
167 public function __construct() {
168 $this->__table
= 'civicrm_product';
169 parent
::__construct();
173 * Returns localized title of this entity.
175 * @param bool $plural
176 * Whether to return the plural version of the title.
178 public static function getEntityTitle($plural = FALSE) {
179 return $plural ?
ts('Products') : ts('Product');
183 * Returns foreign keys and entity references.
186 * [CRM_Core_Reference_Interface]
188 public static function getReferenceColumns() {
189 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
190 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
191 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
192 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
194 return Civi
::$statics[__CLASS__
]['links'];
198 * Returns all the column names of this table
202 public static function &fields() {
203 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
204 Civi
::$statics[__CLASS__
]['fields'] = [
207 'type' => CRM_Utils_Type
::T_INT
,
208 'title' => ts('Product ID'),
210 'where' => 'civicrm_product.id',
211 'table_name' => 'civicrm_product',
212 'entity' => 'Product',
213 'bao' => 'CRM_Contribute_BAO_Product',
219 'type' => CRM_Utils_Type
::T_STRING
,
220 'title' => ts('Product Name'),
221 'description' => ts('Required product/premium name'),
224 'size' => CRM_Utils_Type
::HUGE
,
225 'where' => 'civicrm_product.name',
227 'table_name' => 'civicrm_product',
228 'entity' => 'Product',
229 'bao' => 'CRM_Contribute_BAO_Product',
234 'name' => 'description',
235 'type' => CRM_Utils_Type
::T_TEXT
,
236 'title' => ts('Description'),
237 'description' => ts('Optional description of the product/premium.'),
238 'where' => 'civicrm_product.description',
239 'table_name' => 'civicrm_product',
240 'entity' => 'Product',
241 'bao' => 'CRM_Contribute_BAO_Product',
247 'type' => CRM_Utils_Type
::T_STRING
,
248 'title' => ts('SKU'),
249 'description' => ts('Optional product sku or code.'),
251 'size' => CRM_Utils_Type
::BIG
,
252 'where' => 'civicrm_product.sku',
254 'table_name' => 'civicrm_product',
255 'entity' => 'Product',
256 'bao' => 'CRM_Contribute_BAO_Product',
262 'type' => CRM_Utils_Type
::T_TEXT
,
263 'title' => ts('Options'),
264 'description' => ts('Store comma-delimited list of color, size, etc. options for the product.'),
265 'where' => 'civicrm_product.options',
266 'table_name' => 'civicrm_product',
267 'entity' => 'Product',
268 'bao' => 'CRM_Contribute_BAO_Product',
274 'type' => CRM_Utils_Type
::T_STRING
,
275 'title' => ts('Image'),
276 'description' => ts('Full or relative URL to uploaded image - fullsize.'),
278 'size' => CRM_Utils_Type
::HUGE
,
279 'where' => 'civicrm_product.image',
280 'table_name' => 'civicrm_product',
281 'entity' => 'Product',
282 'bao' => 'CRM_Contribute_BAO_Product',
287 'name' => 'thumbnail',
288 'type' => CRM_Utils_Type
::T_STRING
,
289 'title' => ts('Thumbnail'),
290 'description' => ts('Full or relative URL to image thumbnail.'),
292 'size' => CRM_Utils_Type
::HUGE
,
293 'where' => 'civicrm_product.thumbnail',
294 'table_name' => 'civicrm_product',
295 'entity' => 'Product',
296 'bao' => 'CRM_Contribute_BAO_Product',
302 'type' => CRM_Utils_Type
::T_MONEY
,
303 'title' => ts('Price'),
304 '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.'),
309 'where' => 'civicrm_product.price',
310 'table_name' => 'civicrm_product',
311 'entity' => 'Product',
312 'bao' => 'CRM_Contribute_BAO_Product',
317 'name' => 'currency',
318 'type' => CRM_Utils_Type
::T_STRING
,
319 'title' => ts('Currency'),
320 'description' => ts('3 character string, value from config setting or input via user.'),
322 'size' => CRM_Utils_Type
::FOUR
,
323 'where' => 'civicrm_product.currency',
325 'table_name' => 'civicrm_product',
326 'entity' => 'Product',
327 'bao' => 'CRM_Contribute_BAO_Product',
332 'pseudoconstant' => [
333 'table' => 'civicrm_currency',
334 'keyColumn' => 'name',
335 'labelColumn' => 'full_name',
336 'nameColumn' => 'name',
337 'abbrColumn' => 'symbol',
341 'financial_type_id' => [
342 'name' => 'financial_type_id',
343 'type' => CRM_Utils_Type
::T_INT
,
344 'title' => ts('Financial Type'),
345 'description' => ts('FK to Financial Type.'),
346 'where' => 'civicrm_product.financial_type_id',
348 'table_name' => 'civicrm_product',
349 'entity' => 'Product',
350 'bao' => 'CRM_Contribute_BAO_Product',
352 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
353 'pseudoconstant' => [
354 'table' => 'civicrm_financial_type',
356 'labelColumn' => 'name',
360 'min_contribution' => [
361 'name' => 'min_contribution',
362 'type' => CRM_Utils_Type
::T_MONEY
,
363 'title' => ts('Minimum Contribution'),
364 'description' => ts('Minimum contribution required to be eligible to select this premium.'),
369 'where' => 'civicrm_product.min_contribution',
370 'table_name' => 'civicrm_product',
371 'entity' => 'Product',
372 'bao' => 'CRM_Contribute_BAO_Product',
378 'type' => CRM_Utils_Type
::T_MONEY
,
379 'title' => ts('Cost'),
380 'description' => ts('Actual cost of this product. Useful to determine net return from sale or using this as an incentive.'),
385 'where' => 'civicrm_product.cost',
386 'table_name' => 'civicrm_product',
387 'entity' => 'Product',
388 'bao' => 'CRM_Contribute_BAO_Product',
393 'name' => 'is_active',
394 'type' => CRM_Utils_Type
::T_BOOLEAN
,
395 'title' => ts('Is Active'),
396 'description' => ts('Disabling premium removes it from the premiums_premium join table below.'),
398 'where' => 'civicrm_product.is_active',
399 'table_name' => 'civicrm_product',
400 'entity' => 'Product',
401 'bao' => 'CRM_Contribute_BAO_Product',
406 'name' => 'period_type',
407 'type' => CRM_Utils_Type
::T_STRING
,
408 'title' => ts('Period Type'),
409 'description' => ts('Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
410 (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) '),
412 'size' => CRM_Utils_Type
::EIGHT
,
413 'where' => 'civicrm_product.period_type',
414 'default' => 'rolling',
415 'table_name' => 'civicrm_product',
416 'entity' => 'Product',
417 'bao' => 'CRM_Contribute_BAO_Product',
422 'pseudoconstant' => [
423 'callback' => 'CRM_Core_SelectValues::periodType',
427 'fixed_period_start_day' => [
428 'name' => 'fixed_period_start_day',
429 'type' => CRM_Utils_Type
::T_INT
,
430 'title' => ts('Fixed Period Start Day'),
431 'description' => ts('Month and day (MMDD) that fixed period type subscription or membership starts.'),
432 'where' => 'civicrm_product.fixed_period_start_day',
434 'table_name' => 'civicrm_product',
435 'entity' => 'Product',
436 'bao' => 'CRM_Contribute_BAO_Product',
441 'name' => 'duration_unit',
442 'type' => CRM_Utils_Type
::T_STRING
,
443 'title' => ts('Duration Unit'),
445 'size' => CRM_Utils_Type
::EIGHT
,
446 'where' => 'civicrm_product.duration_unit',
448 'table_name' => 'civicrm_product',
449 'entity' => 'Product',
450 'bao' => 'CRM_Contribute_BAO_Product',
455 'pseudoconstant' => [
456 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
460 'duration_interval' => [
461 'name' => 'duration_interval',
462 'type' => CRM_Utils_Type
::T_INT
,
463 'title' => ts('Duration Interval'),
464 'description' => ts('Number of units for total duration of subscription, service, membership (e.g. 12 Months).'),
465 'where' => 'civicrm_product.duration_interval',
466 'table_name' => 'civicrm_product',
467 'entity' => 'Product',
468 'bao' => 'CRM_Contribute_BAO_Product',
472 'frequency_unit' => [
473 'name' => 'frequency_unit',
474 'type' => CRM_Utils_Type
::T_STRING
,
475 'title' => ts('Frequency Unit'),
476 'description' => ts('Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.'),
478 'size' => CRM_Utils_Type
::EIGHT
,
479 'where' => 'civicrm_product.frequency_unit',
480 'default' => 'month',
481 'table_name' => 'civicrm_product',
482 'entity' => 'Product',
483 'bao' => 'CRM_Contribute_BAO_Product',
488 'pseudoconstant' => [
489 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
493 'frequency_interval' => [
494 'name' => 'frequency_interval',
495 'type' => CRM_Utils_Type
::T_INT
,
496 'title' => ts('Frequency Interval'),
497 'description' => ts('Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).'),
498 'where' => 'civicrm_product.frequency_interval',
499 'table_name' => 'civicrm_product',
500 'entity' => 'Product',
501 'bao' => 'CRM_Contribute_BAO_Product',
506 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
508 return Civi
::$statics[__CLASS__
]['fields'];
512 * Return a mapping from field-name to the corresponding key (as used in fields()).
515 * Array(string $name => string $uniqueName).
517 public static function &fieldKeys() {
518 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
519 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
521 return Civi
::$statics[__CLASS__
]['fieldKeys'];
525 * Returns the names of this table
529 public static function getTableName() {
530 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
534 * Returns if this table needs to be logged
538 public function getLog() {
543 * Returns the list of fields that can be imported
545 * @param bool $prefix
549 public static function &import($prefix = FALSE) {
550 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'product', $prefix, []);
555 * Returns the list of fields that can be exported
557 * @param bool $prefix
561 public static function &export($prefix = FALSE) {
562 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'product', $prefix, []);
567 * Returns the list of indices
569 * @param bool $localize
573 public static function indices($localize = TRUE) {
575 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;