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:6e0a8b319985de1fe01120f4d91003a8)
13 * Database access object for the Product entity.
15 class CRM_Contribute_DAO_Product
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_product';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
37 * Required product/premium name
44 * Optional description of the product/premium.
51 * Optional product sku or code.
58 * Store comma-delimited list of color, size, etc. options for the product.
65 * Full or relative URL to uploaded image - fullsize.
72 * Full or relative URL to image thumbnail.
79 * Sell price or market value for premiums. For tax-deductible contributions, this will be stored as non_deductible_amount in the contribution record.
86 * 3 character string, value from config setting or input via user.
93 * FK to Financial Type.
97 public $financial_type_id;
100 * Minimum contribution required to be eligible to select this premium.
104 public $min_contribution;
107 * Actual cost of this product. Useful to determine net return from sale or using this as an incentive.
114 * Disabling premium removes it from the premiums_premium join table below.
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)
129 * Month and day (MMDD) that fixed period type subscription or membership starts.
133 public $fixed_period_start_day;
138 public $duration_unit;
141 * Number of units for total duration of subscription, service, membership (e.g. 12 Months).
145 public $duration_interval;
148 * Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.
152 public $frequency_unit;
155 * Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).
159 public $frequency_interval;
164 public function __construct() {
165 $this->__table
= 'civicrm_product';
166 parent
::__construct();
170 * Returns localized title of this entity.
172 public static function getEntityTitle() {
173 return ts('Products');
177 * Returns foreign keys and entity references.
180 * [CRM_Core_Reference_Interface]
182 public static function getReferenceColumns() {
183 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
184 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
185 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
186 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
188 return Civi
::$statics[__CLASS__
]['links'];
192 * Returns all the column names of this table
196 public static function &fields() {
197 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
198 Civi
::$statics[__CLASS__
]['fields'] = [
201 'type' => CRM_Utils_Type
::T_INT
,
202 'title' => ts('Product ID'),
204 'where' => 'civicrm_product.id',
205 'table_name' => 'civicrm_product',
206 'entity' => 'Product',
207 'bao' => 'CRM_Contribute_BAO_Product',
213 'type' => CRM_Utils_Type
::T_STRING
,
214 'title' => ts('Product Name'),
215 'description' => ts('Required product/premium name'),
218 'size' => CRM_Utils_Type
::HUGE
,
219 'where' => 'civicrm_product.name',
221 'table_name' => 'civicrm_product',
222 'entity' => 'Product',
223 'bao' => 'CRM_Contribute_BAO_Product',
228 'name' => 'description',
229 'type' => CRM_Utils_Type
::T_TEXT
,
230 'title' => ts('Description'),
231 'description' => ts('Optional description of the product/premium.'),
232 'where' => 'civicrm_product.description',
233 'table_name' => 'civicrm_product',
234 'entity' => 'Product',
235 'bao' => 'CRM_Contribute_BAO_Product',
241 'type' => CRM_Utils_Type
::T_STRING
,
242 'title' => ts('SKU'),
243 'description' => ts('Optional product sku or code.'),
245 'size' => CRM_Utils_Type
::BIG
,
246 'where' => 'civicrm_product.sku',
248 'table_name' => 'civicrm_product',
249 'entity' => 'Product',
250 'bao' => 'CRM_Contribute_BAO_Product',
256 'type' => CRM_Utils_Type
::T_TEXT
,
257 'title' => ts('Options'),
258 'description' => ts('Store comma-delimited list of color, size, etc. options for the product.'),
259 'where' => 'civicrm_product.options',
260 'table_name' => 'civicrm_product',
261 'entity' => 'Product',
262 'bao' => 'CRM_Contribute_BAO_Product',
268 'type' => CRM_Utils_Type
::T_STRING
,
269 'title' => ts('Image'),
270 'description' => ts('Full or relative URL to uploaded image - fullsize.'),
272 'size' => CRM_Utils_Type
::HUGE
,
273 'where' => 'civicrm_product.image',
274 'table_name' => 'civicrm_product',
275 'entity' => 'Product',
276 'bao' => 'CRM_Contribute_BAO_Product',
281 'name' => 'thumbnail',
282 'type' => CRM_Utils_Type
::T_STRING
,
283 'title' => ts('Thumbnail'),
284 'description' => ts('Full or relative URL to image thumbnail.'),
286 'size' => CRM_Utils_Type
::HUGE
,
287 'where' => 'civicrm_product.thumbnail',
288 'table_name' => 'civicrm_product',
289 'entity' => 'Product',
290 'bao' => 'CRM_Contribute_BAO_Product',
296 'type' => CRM_Utils_Type
::T_MONEY
,
297 'title' => ts('Price'),
298 '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.'),
303 'where' => 'civicrm_product.price',
304 'table_name' => 'civicrm_product',
305 'entity' => 'Product',
306 'bao' => 'CRM_Contribute_BAO_Product',
311 'name' => 'currency',
312 'type' => CRM_Utils_Type
::T_STRING
,
313 'title' => ts('Currency'),
314 'description' => ts('3 character string, value from config setting or input via user.'),
316 'size' => CRM_Utils_Type
::FOUR
,
317 'where' => 'civicrm_product.currency',
319 'table_name' => 'civicrm_product',
320 'entity' => 'Product',
321 'bao' => 'CRM_Contribute_BAO_Product',
326 'pseudoconstant' => [
327 'table' => 'civicrm_currency',
328 'keyColumn' => 'name',
329 'labelColumn' => 'full_name',
330 'nameColumn' => 'name',
331 'abbrColumn' => 'symbol',
335 'financial_type_id' => [
336 'name' => 'financial_type_id',
337 'type' => CRM_Utils_Type
::T_INT
,
338 'title' => ts('Financial Type'),
339 'description' => ts('FK to Financial Type.'),
340 'where' => 'civicrm_product.financial_type_id',
342 'table_name' => 'civicrm_product',
343 'entity' => 'Product',
344 'bao' => 'CRM_Contribute_BAO_Product',
346 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
347 'pseudoconstant' => [
348 'table' => 'civicrm_financial_type',
350 'labelColumn' => 'name',
354 'min_contribution' => [
355 'name' => 'min_contribution',
356 'type' => CRM_Utils_Type
::T_MONEY
,
357 'title' => ts('Minimum Contribution'),
358 'description' => ts('Minimum contribution required to be eligible to select this premium.'),
363 'where' => 'civicrm_product.min_contribution',
364 'table_name' => 'civicrm_product',
365 'entity' => 'Product',
366 'bao' => 'CRM_Contribute_BAO_Product',
372 'type' => CRM_Utils_Type
::T_MONEY
,
373 'title' => ts('Cost'),
374 'description' => ts('Actual cost of this product. Useful to determine net return from sale or using this as an incentive.'),
379 'where' => 'civicrm_product.cost',
380 'table_name' => 'civicrm_product',
381 'entity' => 'Product',
382 'bao' => 'CRM_Contribute_BAO_Product',
387 'name' => 'is_active',
388 'type' => CRM_Utils_Type
::T_BOOLEAN
,
389 'title' => ts('Is Active'),
390 'description' => ts('Disabling premium removes it from the premiums_premium join table below.'),
392 'where' => 'civicrm_product.is_active',
393 'table_name' => 'civicrm_product',
394 'entity' => 'Product',
395 'bao' => 'CRM_Contribute_BAO_Product',
400 'name' => 'period_type',
401 'type' => CRM_Utils_Type
::T_STRING
,
402 'title' => ts('Period Type'),
403 'description' => ts('Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
404 (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) '),
406 'size' => CRM_Utils_Type
::EIGHT
,
407 'where' => 'civicrm_product.period_type',
408 'default' => 'rolling',
409 'table_name' => 'civicrm_product',
410 'entity' => 'Product',
411 'bao' => 'CRM_Contribute_BAO_Product',
416 'pseudoconstant' => [
417 'callback' => 'CRM_Core_SelectValues::periodType',
421 'fixed_period_start_day' => [
422 'name' => 'fixed_period_start_day',
423 'type' => CRM_Utils_Type
::T_INT
,
424 'title' => ts('Fixed Period Start Day'),
425 'description' => ts('Month and day (MMDD) that fixed period type subscription or membership starts.'),
426 'where' => 'civicrm_product.fixed_period_start_day',
428 'table_name' => 'civicrm_product',
429 'entity' => 'Product',
430 'bao' => 'CRM_Contribute_BAO_Product',
435 'name' => 'duration_unit',
436 'type' => CRM_Utils_Type
::T_STRING
,
437 'title' => ts('Duration Unit'),
439 'size' => CRM_Utils_Type
::EIGHT
,
440 'where' => 'civicrm_product.duration_unit',
442 'table_name' => 'civicrm_product',
443 'entity' => 'Product',
444 'bao' => 'CRM_Contribute_BAO_Product',
449 'pseudoconstant' => [
450 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
454 'duration_interval' => [
455 'name' => 'duration_interval',
456 'type' => CRM_Utils_Type
::T_INT
,
457 'title' => ts('Duration Interval'),
458 'description' => ts('Number of units for total duration of subscription, service, membership (e.g. 12 Months).'),
459 'where' => 'civicrm_product.duration_interval',
460 'table_name' => 'civicrm_product',
461 'entity' => 'Product',
462 'bao' => 'CRM_Contribute_BAO_Product',
466 'frequency_unit' => [
467 'name' => 'frequency_unit',
468 'type' => CRM_Utils_Type
::T_STRING
,
469 'title' => ts('Frequency Unit'),
470 'description' => ts('Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.'),
472 'size' => CRM_Utils_Type
::EIGHT
,
473 'where' => 'civicrm_product.frequency_unit',
474 'default' => 'month',
475 'table_name' => 'civicrm_product',
476 'entity' => 'Product',
477 'bao' => 'CRM_Contribute_BAO_Product',
482 'pseudoconstant' => [
483 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
487 'frequency_interval' => [
488 'name' => 'frequency_interval',
489 'type' => CRM_Utils_Type
::T_INT
,
490 'title' => ts('Frequency Interval'),
491 'description' => ts('Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).'),
492 'where' => 'civicrm_product.frequency_interval',
493 'table_name' => 'civicrm_product',
494 'entity' => 'Product',
495 'bao' => 'CRM_Contribute_BAO_Product',
500 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
502 return Civi
::$statics[__CLASS__
]['fields'];
506 * Return a mapping from field-name to the corresponding key (as used in fields()).
509 * Array(string $name => string $uniqueName).
511 public static function &fieldKeys() {
512 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
513 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
515 return Civi
::$statics[__CLASS__
]['fieldKeys'];
519 * Returns the names of this table
523 public static function getTableName() {
524 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
528 * Returns if this table needs to be logged
532 public function getLog() {
537 * Returns the list of fields that can be imported
539 * @param bool $prefix
543 public static function &import($prefix = FALSE) {
544 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'product', $prefix, []);
549 * Returns the list of fields that can be exported
551 * @param bool $prefix
555 public static function &export($prefix = FALSE) {
556 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'product', $prefix, []);
561 * Returns the list of indices
563 * @param bool $localize
567 public static function indices($localize = TRUE) {
569 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;