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:ba0100c0ce50f67d39a4e131474de7e1)
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',
212 'type' => CRM_Utils_Type
::T_STRING
,
213 'title' => ts('Product Name'),
214 'description' => ts('Required product/premium name'),
217 'size' => CRM_Utils_Type
::HUGE
,
218 'where' => 'civicrm_product.name',
220 'table_name' => 'civicrm_product',
221 'entity' => 'Product',
222 'bao' => 'CRM_Contribute_BAO_Product',
226 'name' => 'description',
227 'type' => CRM_Utils_Type
::T_TEXT
,
228 'title' => ts('Description'),
229 'description' => ts('Optional description of the product/premium.'),
230 'where' => 'civicrm_product.description',
231 'table_name' => 'civicrm_product',
232 'entity' => 'Product',
233 'bao' => 'CRM_Contribute_BAO_Product',
238 'type' => CRM_Utils_Type
::T_STRING
,
239 'title' => ts('SKU'),
240 'description' => ts('Optional product sku or code.'),
242 'size' => CRM_Utils_Type
::BIG
,
243 'where' => 'civicrm_product.sku',
245 'table_name' => 'civicrm_product',
246 'entity' => 'Product',
247 'bao' => 'CRM_Contribute_BAO_Product',
252 'type' => CRM_Utils_Type
::T_TEXT
,
253 'title' => ts('Options'),
254 'description' => ts('Store comma-delimited list of color, size, etc. options for the product.'),
255 'where' => 'civicrm_product.options',
256 'table_name' => 'civicrm_product',
257 'entity' => 'Product',
258 'bao' => 'CRM_Contribute_BAO_Product',
263 'type' => CRM_Utils_Type
::T_STRING
,
264 'title' => ts('Image'),
265 'description' => ts('Full or relative URL to uploaded image - fullsize.'),
267 'size' => CRM_Utils_Type
::HUGE
,
268 'where' => 'civicrm_product.image',
269 'table_name' => 'civicrm_product',
270 'entity' => 'Product',
271 'bao' => 'CRM_Contribute_BAO_Product',
275 'name' => 'thumbnail',
276 'type' => CRM_Utils_Type
::T_STRING
,
277 'title' => ts('Thumbnail'),
278 'description' => ts('Full or relative URL to image thumbnail.'),
280 'size' => CRM_Utils_Type
::HUGE
,
281 'where' => 'civicrm_product.thumbnail',
282 'table_name' => 'civicrm_product',
283 'entity' => 'Product',
284 'bao' => 'CRM_Contribute_BAO_Product',
289 'type' => CRM_Utils_Type
::T_MONEY
,
290 'title' => ts('Price'),
291 '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.'),
296 'where' => 'civicrm_product.price',
297 'table_name' => 'civicrm_product',
298 'entity' => 'Product',
299 'bao' => 'CRM_Contribute_BAO_Product',
303 'name' => 'currency',
304 'type' => CRM_Utils_Type
::T_STRING
,
305 'title' => ts('Currency'),
306 'description' => ts('3 character string, value from config setting or input via user.'),
308 'size' => CRM_Utils_Type
::FOUR
,
309 'where' => 'civicrm_product.currency',
311 'table_name' => 'civicrm_product',
312 'entity' => 'Product',
313 'bao' => 'CRM_Contribute_BAO_Product',
318 'pseudoconstant' => [
319 'table' => 'civicrm_currency',
320 'keyColumn' => 'name',
321 'labelColumn' => 'full_name',
322 'nameColumn' => 'name',
323 'abbrColumn' => 'symbol',
326 'financial_type_id' => [
327 'name' => 'financial_type_id',
328 'type' => CRM_Utils_Type
::T_INT
,
329 'title' => ts('Financial Type'),
330 'description' => ts('FK to Financial Type.'),
331 'where' => 'civicrm_product.financial_type_id',
333 'table_name' => 'civicrm_product',
334 'entity' => 'Product',
335 'bao' => 'CRM_Contribute_BAO_Product',
337 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
338 'pseudoconstant' => [
339 'table' => 'civicrm_financial_type',
341 'labelColumn' => 'name',
344 'min_contribution' => [
345 'name' => 'min_contribution',
346 'type' => CRM_Utils_Type
::T_MONEY
,
347 'title' => ts('Minimum Contribution'),
348 'description' => ts('Minimum contribution required to be eligible to select this premium.'),
353 'where' => 'civicrm_product.min_contribution',
354 'table_name' => 'civicrm_product',
355 'entity' => 'Product',
356 'bao' => 'CRM_Contribute_BAO_Product',
361 'type' => CRM_Utils_Type
::T_MONEY
,
362 'title' => ts('Cost'),
363 'description' => ts('Actual cost of this product. Useful to determine net return from sale or using this as an incentive.'),
368 'where' => 'civicrm_product.cost',
369 'table_name' => 'civicrm_product',
370 'entity' => 'Product',
371 'bao' => 'CRM_Contribute_BAO_Product',
375 'name' => 'is_active',
376 'type' => CRM_Utils_Type
::T_BOOLEAN
,
377 'title' => ts('Is Active'),
378 'description' => ts('Disabling premium removes it from the premiums_premium join table below.'),
380 'where' => 'civicrm_product.is_active',
381 'table_name' => 'civicrm_product',
382 'entity' => 'Product',
383 'bao' => 'CRM_Contribute_BAO_Product',
387 'name' => 'period_type',
388 'type' => CRM_Utils_Type
::T_STRING
,
389 'title' => ts('Period Type'),
390 'description' => ts('Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
391 (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) '),
393 'size' => CRM_Utils_Type
::EIGHT
,
394 'where' => 'civicrm_product.period_type',
395 'default' => 'rolling',
396 'table_name' => 'civicrm_product',
397 'entity' => 'Product',
398 'bao' => 'CRM_Contribute_BAO_Product',
403 'pseudoconstant' => [
404 'callback' => 'CRM_Core_SelectValues::periodType',
407 'fixed_period_start_day' => [
408 'name' => 'fixed_period_start_day',
409 'type' => CRM_Utils_Type
::T_INT
,
410 'title' => ts('Fixed Period Start Day'),
411 'description' => ts('Month and day (MMDD) that fixed period type subscription or membership starts.'),
412 'where' => 'civicrm_product.fixed_period_start_day',
414 'table_name' => 'civicrm_product',
415 'entity' => 'Product',
416 'bao' => 'CRM_Contribute_BAO_Product',
420 'name' => 'duration_unit',
421 'type' => CRM_Utils_Type
::T_STRING
,
422 'title' => ts('Duration Unit'),
424 'size' => CRM_Utils_Type
::EIGHT
,
425 'where' => 'civicrm_product.duration_unit',
427 'table_name' => 'civicrm_product',
428 'entity' => 'Product',
429 'bao' => 'CRM_Contribute_BAO_Product',
434 'pseudoconstant' => [
435 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
438 'duration_interval' => [
439 'name' => 'duration_interval',
440 'type' => CRM_Utils_Type
::T_INT
,
441 'title' => ts('Duration Interval'),
442 'description' => ts('Number of units for total duration of subscription, service, membership (e.g. 12 Months).'),
443 'where' => 'civicrm_product.duration_interval',
444 'table_name' => 'civicrm_product',
445 'entity' => 'Product',
446 'bao' => 'CRM_Contribute_BAO_Product',
449 'frequency_unit' => [
450 'name' => 'frequency_unit',
451 'type' => CRM_Utils_Type
::T_STRING
,
452 'title' => ts('Frequency Unit'),
453 'description' => ts('Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.'),
455 'size' => CRM_Utils_Type
::EIGHT
,
456 'where' => 'civicrm_product.frequency_unit',
457 'default' => 'month',
458 'table_name' => 'civicrm_product',
459 'entity' => 'Product',
460 'bao' => 'CRM_Contribute_BAO_Product',
465 'pseudoconstant' => [
466 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
469 'frequency_interval' => [
470 'name' => 'frequency_interval',
471 'type' => CRM_Utils_Type
::T_INT
,
472 'title' => ts('Frequency Interval'),
473 'description' => ts('Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).'),
474 'where' => 'civicrm_product.frequency_interval',
475 'table_name' => 'civicrm_product',
476 'entity' => 'Product',
477 'bao' => 'CRM_Contribute_BAO_Product',
481 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
483 return Civi
::$statics[__CLASS__
]['fields'];
487 * Return a mapping from field-name to the corresponding key (as used in fields()).
490 * Array(string $name => string $uniqueName).
492 public static function &fieldKeys() {
493 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
494 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
496 return Civi
::$statics[__CLASS__
]['fieldKeys'];
500 * Returns the names of this table
504 public static function getTableName() {
505 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
509 * Returns if this table needs to be logged
513 public function getLog() {
518 * Returns the list of fields that can be imported
520 * @param bool $prefix
524 public static function &import($prefix = FALSE) {
525 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'product', $prefix, []);
530 * Returns the list of fields that can be exported
532 * @param bool $prefix
536 public static function &export($prefix = FALSE) {
537 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'product', $prefix, []);
542 * Returns the list of indices
544 * @param bool $localize
548 public static function indices($localize = TRUE) {
550 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;