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:0af317e71745b39afb378570922fab90)
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 foreign keys and entity references.
173 * [CRM_Core_Reference_Interface]
175 public static function getReferenceColumns() {
176 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
177 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
178 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
179 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
181 return Civi
::$statics[__CLASS__
]['links'];
185 * Returns all the column names of this table
189 public static function &fields() {
190 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
191 Civi
::$statics[__CLASS__
]['fields'] = [
194 'type' => CRM_Utils_Type
::T_INT
,
195 'title' => ts('Product ID'),
197 'where' => 'civicrm_product.id',
198 'table_name' => 'civicrm_product',
199 'entity' => 'Product',
200 'bao' => 'CRM_Contribute_BAO_Product',
205 'type' => CRM_Utils_Type
::T_STRING
,
206 'title' => ts('Product Name'),
207 'description' => ts('Required product/premium name'),
210 'size' => CRM_Utils_Type
::HUGE
,
211 'where' => 'civicrm_product.name',
213 'table_name' => 'civicrm_product',
214 'entity' => 'Product',
215 'bao' => 'CRM_Contribute_BAO_Product',
219 'name' => 'description',
220 'type' => CRM_Utils_Type
::T_TEXT
,
221 'title' => ts('Description'),
222 'description' => ts('Optional description of the product/premium.'),
223 'where' => 'civicrm_product.description',
224 'table_name' => 'civicrm_product',
225 'entity' => 'Product',
226 'bao' => 'CRM_Contribute_BAO_Product',
231 'type' => CRM_Utils_Type
::T_STRING
,
232 'title' => ts('SKU'),
233 'description' => ts('Optional product sku or code.'),
235 'size' => CRM_Utils_Type
::BIG
,
236 'where' => 'civicrm_product.sku',
238 'table_name' => 'civicrm_product',
239 'entity' => 'Product',
240 'bao' => 'CRM_Contribute_BAO_Product',
245 'type' => CRM_Utils_Type
::T_TEXT
,
246 'title' => ts('Options'),
247 'description' => ts('Store comma-delimited list of color, size, etc. options for the product.'),
248 'where' => 'civicrm_product.options',
249 'table_name' => 'civicrm_product',
250 'entity' => 'Product',
251 'bao' => 'CRM_Contribute_BAO_Product',
256 'type' => CRM_Utils_Type
::T_STRING
,
257 'title' => ts('Image'),
258 'description' => ts('Full or relative URL to uploaded image - fullsize.'),
260 'size' => CRM_Utils_Type
::HUGE
,
261 'where' => 'civicrm_product.image',
262 'table_name' => 'civicrm_product',
263 'entity' => 'Product',
264 'bao' => 'CRM_Contribute_BAO_Product',
268 'name' => 'thumbnail',
269 'type' => CRM_Utils_Type
::T_STRING
,
270 'title' => ts('Thumbnail'),
271 'description' => ts('Full or relative URL to image thumbnail.'),
273 'size' => CRM_Utils_Type
::HUGE
,
274 'where' => 'civicrm_product.thumbnail',
275 'table_name' => 'civicrm_product',
276 'entity' => 'Product',
277 'bao' => 'CRM_Contribute_BAO_Product',
282 'type' => CRM_Utils_Type
::T_MONEY
,
283 'title' => ts('Price'),
284 '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.'),
289 'where' => 'civicrm_product.price',
290 'table_name' => 'civicrm_product',
291 'entity' => 'Product',
292 'bao' => 'CRM_Contribute_BAO_Product',
296 'name' => 'currency',
297 'type' => CRM_Utils_Type
::T_STRING
,
298 'title' => ts('Currency'),
299 'description' => ts('3 character string, value from config setting or input via user.'),
301 'size' => CRM_Utils_Type
::FOUR
,
302 'where' => 'civicrm_product.currency',
304 'table_name' => 'civicrm_product',
305 'entity' => 'Product',
306 'bao' => 'CRM_Contribute_BAO_Product',
311 'pseudoconstant' => [
312 'table' => 'civicrm_currency',
313 'keyColumn' => 'name',
314 'labelColumn' => 'full_name',
315 'nameColumn' => 'name',
316 'abbrColumn' => 'symbol',
319 'financial_type_id' => [
320 'name' => 'financial_type_id',
321 'type' => CRM_Utils_Type
::T_INT
,
322 'title' => ts('Financial Type'),
323 'description' => ts('FK to Financial Type.'),
324 'where' => 'civicrm_product.financial_type_id',
326 'table_name' => 'civicrm_product',
327 'entity' => 'Product',
328 'bao' => 'CRM_Contribute_BAO_Product',
330 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
331 'pseudoconstant' => [
332 'table' => 'civicrm_financial_type',
334 'labelColumn' => 'name',
337 'min_contribution' => [
338 'name' => 'min_contribution',
339 'type' => CRM_Utils_Type
::T_MONEY
,
340 'title' => ts('Minimum Contribution'),
341 'description' => ts('Minimum contribution required to be eligible to select this premium.'),
346 'where' => 'civicrm_product.min_contribution',
347 'table_name' => 'civicrm_product',
348 'entity' => 'Product',
349 'bao' => 'CRM_Contribute_BAO_Product',
354 'type' => CRM_Utils_Type
::T_MONEY
,
355 'title' => ts('Cost'),
356 'description' => ts('Actual cost of this product. Useful to determine net return from sale or using this as an incentive.'),
361 'where' => 'civicrm_product.cost',
362 'table_name' => 'civicrm_product',
363 'entity' => 'Product',
364 'bao' => 'CRM_Contribute_BAO_Product',
368 'name' => 'is_active',
369 'type' => CRM_Utils_Type
::T_BOOLEAN
,
370 'title' => ts('Is Active'),
371 'description' => ts('Disabling premium removes it from the premiums_premium join table below.'),
373 'where' => 'civicrm_product.is_active',
374 'table_name' => 'civicrm_product',
375 'entity' => 'Product',
376 'bao' => 'CRM_Contribute_BAO_Product',
380 'name' => 'period_type',
381 'type' => CRM_Utils_Type
::T_STRING
,
382 'title' => ts('Period Type'),
383 'description' => ts('Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
384 (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) '),
386 'size' => CRM_Utils_Type
::EIGHT
,
387 'where' => 'civicrm_product.period_type',
388 'default' => 'rolling',
389 'table_name' => 'civicrm_product',
390 'entity' => 'Product',
391 'bao' => 'CRM_Contribute_BAO_Product',
396 'pseudoconstant' => [
397 'callback' => 'CRM_Core_SelectValues::periodType',
400 'fixed_period_start_day' => [
401 'name' => 'fixed_period_start_day',
402 'type' => CRM_Utils_Type
::T_INT
,
403 'title' => ts('Fixed Period Start Day'),
404 'description' => ts('Month and day (MMDD) that fixed period type subscription or membership starts.'),
405 'where' => 'civicrm_product.fixed_period_start_day',
407 'table_name' => 'civicrm_product',
408 'entity' => 'Product',
409 'bao' => 'CRM_Contribute_BAO_Product',
413 'name' => 'duration_unit',
414 'type' => CRM_Utils_Type
::T_STRING
,
415 'title' => ts('Duration Unit'),
417 'size' => CRM_Utils_Type
::EIGHT
,
418 'where' => 'civicrm_product.duration_unit',
420 'table_name' => 'civicrm_product',
421 'entity' => 'Product',
422 'bao' => 'CRM_Contribute_BAO_Product',
427 'pseudoconstant' => [
428 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
431 'duration_interval' => [
432 'name' => 'duration_interval',
433 'type' => CRM_Utils_Type
::T_INT
,
434 'title' => ts('Duration Interval'),
435 'description' => ts('Number of units for total duration of subscription, service, membership (e.g. 12 Months).'),
436 'where' => 'civicrm_product.duration_interval',
437 'table_name' => 'civicrm_product',
438 'entity' => 'Product',
439 'bao' => 'CRM_Contribute_BAO_Product',
442 'frequency_unit' => [
443 'name' => 'frequency_unit',
444 'type' => CRM_Utils_Type
::T_STRING
,
445 'title' => ts('Frequency Unit'),
446 'description' => ts('Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.'),
448 'size' => CRM_Utils_Type
::EIGHT
,
449 'where' => 'civicrm_product.frequency_unit',
450 'default' => 'month',
451 'table_name' => 'civicrm_product',
452 'entity' => 'Product',
453 'bao' => 'CRM_Contribute_BAO_Product',
458 'pseudoconstant' => [
459 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
462 'frequency_interval' => [
463 'name' => 'frequency_interval',
464 'type' => CRM_Utils_Type
::T_INT
,
465 'title' => ts('Frequency Interval'),
466 'description' => ts('Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).'),
467 'where' => 'civicrm_product.frequency_interval',
468 'table_name' => 'civicrm_product',
469 'entity' => 'Product',
470 'bao' => 'CRM_Contribute_BAO_Product',
474 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
476 return Civi
::$statics[__CLASS__
]['fields'];
480 * Return a mapping from field-name to the corresponding key (as used in fields()).
483 * Array(string $name => string $uniqueName).
485 public static function &fieldKeys() {
486 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
487 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
489 return Civi
::$statics[__CLASS__
]['fieldKeys'];
493 * Returns the names of this table
497 public static function getTableName() {
498 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
502 * Returns if this table needs to be logged
506 public function getLog() {
511 * Returns the list of fields that can be imported
513 * @param bool $prefix
517 public static function &import($prefix = FALSE) {
518 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'product', $prefix, []);
523 * Returns the list of fields that can be exported
525 * @param bool $prefix
529 public static function &export($prefix = FALSE) {
530 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'product', $prefix, []);
535 * Returns the list of indices
537 * @param bool $localize
541 public static function indices($localize = TRUE) {
543 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;