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:dea1c7db61776456a70f752fe9f93f06)
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';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_product';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = TRUE;
39 * Required product/premium name
46 * Optional description of the product/premium.
53 * Optional product sku or code.
60 * Store comma-delimited list of color, size, etc. options for the product.
67 * Full or relative URL to uploaded image - fullsize.
74 * Full or relative URL to image thumbnail.
81 * Sell price or market value for premiums. For tax-deductible contributions, this will be stored as non_deductible_amount in the contribution record.
88 * 3 character string, value from config setting or input via user.
95 * FK to Financial Type.
99 public $financial_type_id;
102 * Minimum contribution required to be eligible to select this premium.
106 public $min_contribution;
109 * Actual cost of this product. Useful to determine net return from sale or using this as an incentive.
116 * Disabling premium removes it from the premiums_premium join table below.
123 * Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
124 * (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006)
131 * Month and day (MMDD) that fixed period type subscription or membership starts.
135 public $fixed_period_start_day;
140 public $duration_unit;
143 * Number of units for total duration of subscription, service, membership (e.g. 12 Months).
147 public $duration_interval;
150 * Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.
154 public $frequency_unit;
157 * Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).
161 public $frequency_interval;
166 public function __construct() {
167 $this->__table
= 'civicrm_product';
168 parent
::__construct();
172 * Returns localized title of this entity.
174 public static function getEntityTitle() {
175 return ts('Products');
179 * Returns foreign keys and entity references.
182 * [CRM_Core_Reference_Interface]
184 public static function getReferenceColumns() {
185 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
186 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
187 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
188 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
190 return Civi
::$statics[__CLASS__
]['links'];
194 * Returns all the column names of this table
198 public static function &fields() {
199 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
200 Civi
::$statics[__CLASS__
]['fields'] = [
203 'type' => CRM_Utils_Type
::T_INT
,
204 'title' => ts('Product ID'),
206 'where' => 'civicrm_product.id',
207 'table_name' => 'civicrm_product',
208 'entity' => 'Product',
209 'bao' => 'CRM_Contribute_BAO_Product',
215 'type' => CRM_Utils_Type
::T_STRING
,
216 'title' => ts('Product Name'),
217 'description' => ts('Required product/premium name'),
220 'size' => CRM_Utils_Type
::HUGE
,
221 'where' => 'civicrm_product.name',
223 'table_name' => 'civicrm_product',
224 'entity' => 'Product',
225 'bao' => 'CRM_Contribute_BAO_Product',
230 'name' => 'description',
231 'type' => CRM_Utils_Type
::T_TEXT
,
232 'title' => ts('Description'),
233 'description' => ts('Optional description of the product/premium.'),
234 'where' => 'civicrm_product.description',
235 'table_name' => 'civicrm_product',
236 'entity' => 'Product',
237 'bao' => 'CRM_Contribute_BAO_Product',
243 'type' => CRM_Utils_Type
::T_STRING
,
244 'title' => ts('SKU'),
245 'description' => ts('Optional product sku or code.'),
247 'size' => CRM_Utils_Type
::BIG
,
248 'where' => 'civicrm_product.sku',
250 'table_name' => 'civicrm_product',
251 'entity' => 'Product',
252 'bao' => 'CRM_Contribute_BAO_Product',
258 'type' => CRM_Utils_Type
::T_TEXT
,
259 'title' => ts('Options'),
260 'description' => ts('Store comma-delimited list of color, size, etc. options for the product.'),
261 'where' => 'civicrm_product.options',
262 'table_name' => 'civicrm_product',
263 'entity' => 'Product',
264 'bao' => 'CRM_Contribute_BAO_Product',
270 'type' => CRM_Utils_Type
::T_STRING
,
271 'title' => ts('Image'),
272 'description' => ts('Full or relative URL to uploaded image - fullsize.'),
274 'size' => CRM_Utils_Type
::HUGE
,
275 'where' => 'civicrm_product.image',
276 'table_name' => 'civicrm_product',
277 'entity' => 'Product',
278 'bao' => 'CRM_Contribute_BAO_Product',
283 'name' => 'thumbnail',
284 'type' => CRM_Utils_Type
::T_STRING
,
285 'title' => ts('Thumbnail'),
286 'description' => ts('Full or relative URL to image thumbnail.'),
288 'size' => CRM_Utils_Type
::HUGE
,
289 'where' => 'civicrm_product.thumbnail',
290 'table_name' => 'civicrm_product',
291 'entity' => 'Product',
292 'bao' => 'CRM_Contribute_BAO_Product',
298 'type' => CRM_Utils_Type
::T_MONEY
,
299 'title' => ts('Price'),
300 '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.'),
305 'where' => 'civicrm_product.price',
306 'table_name' => 'civicrm_product',
307 'entity' => 'Product',
308 'bao' => 'CRM_Contribute_BAO_Product',
313 'name' => 'currency',
314 'type' => CRM_Utils_Type
::T_STRING
,
315 'title' => ts('Currency'),
316 'description' => ts('3 character string, value from config setting or input via user.'),
318 'size' => CRM_Utils_Type
::FOUR
,
319 'where' => 'civicrm_product.currency',
321 'table_name' => 'civicrm_product',
322 'entity' => 'Product',
323 'bao' => 'CRM_Contribute_BAO_Product',
328 'pseudoconstant' => [
329 'table' => 'civicrm_currency',
330 'keyColumn' => 'name',
331 'labelColumn' => 'full_name',
332 'nameColumn' => 'name',
333 'abbrColumn' => 'symbol',
337 'financial_type_id' => [
338 'name' => 'financial_type_id',
339 'type' => CRM_Utils_Type
::T_INT
,
340 'title' => ts('Financial Type'),
341 'description' => ts('FK to Financial Type.'),
342 'where' => 'civicrm_product.financial_type_id',
344 'table_name' => 'civicrm_product',
345 'entity' => 'Product',
346 'bao' => 'CRM_Contribute_BAO_Product',
348 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
349 'pseudoconstant' => [
350 'table' => 'civicrm_financial_type',
352 'labelColumn' => 'name',
356 'min_contribution' => [
357 'name' => 'min_contribution',
358 'type' => CRM_Utils_Type
::T_MONEY
,
359 'title' => ts('Minimum Contribution'),
360 'description' => ts('Minimum contribution required to be eligible to select this premium.'),
365 'where' => 'civicrm_product.min_contribution',
366 'table_name' => 'civicrm_product',
367 'entity' => 'Product',
368 'bao' => 'CRM_Contribute_BAO_Product',
374 'type' => CRM_Utils_Type
::T_MONEY
,
375 'title' => ts('Cost'),
376 'description' => ts('Actual cost of this product. Useful to determine net return from sale or using this as an incentive.'),
381 'where' => 'civicrm_product.cost',
382 'table_name' => 'civicrm_product',
383 'entity' => 'Product',
384 'bao' => 'CRM_Contribute_BAO_Product',
389 'name' => 'is_active',
390 'type' => CRM_Utils_Type
::T_BOOLEAN
,
391 'title' => ts('Is Active'),
392 'description' => ts('Disabling premium removes it from the premiums_premium join table below.'),
394 'where' => 'civicrm_product.is_active',
395 'table_name' => 'civicrm_product',
396 'entity' => 'Product',
397 'bao' => 'CRM_Contribute_BAO_Product',
402 'name' => 'period_type',
403 'type' => CRM_Utils_Type
::T_STRING
,
404 'title' => ts('Period Type'),
405 'description' => ts('Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
406 (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) '),
408 'size' => CRM_Utils_Type
::EIGHT
,
409 'where' => 'civicrm_product.period_type',
410 'default' => 'rolling',
411 'table_name' => 'civicrm_product',
412 'entity' => 'Product',
413 'bao' => 'CRM_Contribute_BAO_Product',
418 'pseudoconstant' => [
419 'callback' => 'CRM_Core_SelectValues::periodType',
423 'fixed_period_start_day' => [
424 'name' => 'fixed_period_start_day',
425 'type' => CRM_Utils_Type
::T_INT
,
426 'title' => ts('Fixed Period Start Day'),
427 'description' => ts('Month and day (MMDD) that fixed period type subscription or membership starts.'),
428 'where' => 'civicrm_product.fixed_period_start_day',
430 'table_name' => 'civicrm_product',
431 'entity' => 'Product',
432 'bao' => 'CRM_Contribute_BAO_Product',
437 'name' => 'duration_unit',
438 'type' => CRM_Utils_Type
::T_STRING
,
439 'title' => ts('Duration Unit'),
441 'size' => CRM_Utils_Type
::EIGHT
,
442 'where' => 'civicrm_product.duration_unit',
444 'table_name' => 'civicrm_product',
445 'entity' => 'Product',
446 'bao' => 'CRM_Contribute_BAO_Product',
451 'pseudoconstant' => [
452 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
456 'duration_interval' => [
457 'name' => 'duration_interval',
458 'type' => CRM_Utils_Type
::T_INT
,
459 'title' => ts('Duration Interval'),
460 'description' => ts('Number of units for total duration of subscription, service, membership (e.g. 12 Months).'),
461 'where' => 'civicrm_product.duration_interval',
462 'table_name' => 'civicrm_product',
463 'entity' => 'Product',
464 'bao' => 'CRM_Contribute_BAO_Product',
468 'frequency_unit' => [
469 'name' => 'frequency_unit',
470 'type' => CRM_Utils_Type
::T_STRING
,
471 'title' => ts('Frequency Unit'),
472 'description' => ts('Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.'),
474 'size' => CRM_Utils_Type
::EIGHT
,
475 'where' => 'civicrm_product.frequency_unit',
476 'default' => 'month',
477 'table_name' => 'civicrm_product',
478 'entity' => 'Product',
479 'bao' => 'CRM_Contribute_BAO_Product',
484 'pseudoconstant' => [
485 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
489 'frequency_interval' => [
490 'name' => 'frequency_interval',
491 'type' => CRM_Utils_Type
::T_INT
,
492 'title' => ts('Frequency Interval'),
493 'description' => ts('Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).'),
494 'where' => 'civicrm_product.frequency_interval',
495 'table_name' => 'civicrm_product',
496 'entity' => 'Product',
497 'bao' => 'CRM_Contribute_BAO_Product',
502 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
504 return Civi
::$statics[__CLASS__
]['fields'];
508 * Return a mapping from field-name to the corresponding key (as used in fields()).
511 * Array(string $name => string $uniqueName).
513 public static function &fieldKeys() {
514 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
515 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
517 return Civi
::$statics[__CLASS__
]['fieldKeys'];
521 * Returns the names of this table
525 public static function getTableName() {
526 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
530 * Returns if this table needs to be logged
534 public function getLog() {
539 * Returns the list of fields that can be imported
541 * @param bool $prefix
545 public static function &import($prefix = FALSE) {
546 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'product', $prefix, []);
551 * Returns the list of fields that can be exported
553 * @param bool $prefix
557 public static function &export($prefix = FALSE) {
558 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'product', $prefix, []);
563 * Returns the list of indices
565 * @param bool $localize
569 public static function indices($localize = TRUE) {
571 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;