5 * @copyright CiviCRM LLC (c) 2004-2019
7 * Generated from xml/schema/CRM/Contribute/Product.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:7db77c58d48112d25da791aba4586080)
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',
318 'financial_type_id' => [
319 'name' => 'financial_type_id',
320 'type' => CRM_Utils_Type
::T_INT
,
321 'title' => ts('Financial Type'),
322 'description' => ts('FK to Financial Type.'),
323 'where' => 'civicrm_product.financial_type_id',
325 'table_name' => 'civicrm_product',
326 'entity' => 'Product',
327 'bao' => 'CRM_Contribute_BAO_Product',
329 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
330 'pseudoconstant' => [
331 'table' => 'civicrm_financial_type',
333 'labelColumn' => 'name',
336 'min_contribution' => [
337 'name' => 'min_contribution',
338 'type' => CRM_Utils_Type
::T_MONEY
,
339 'title' => ts('Minimum Contribution'),
340 'description' => ts('Minimum contribution required to be eligible to select this premium.'),
345 'where' => 'civicrm_product.min_contribution',
346 'table_name' => 'civicrm_product',
347 'entity' => 'Product',
348 'bao' => 'CRM_Contribute_BAO_Product',
353 'type' => CRM_Utils_Type
::T_MONEY
,
354 'title' => ts('Cost'),
355 'description' => ts('Actual cost of this product. Useful to determine net return from sale or using this as an incentive.'),
360 'where' => 'civicrm_product.cost',
361 'table_name' => 'civicrm_product',
362 'entity' => 'Product',
363 'bao' => 'CRM_Contribute_BAO_Product',
367 'name' => 'is_active',
368 'type' => CRM_Utils_Type
::T_BOOLEAN
,
369 'title' => ts('Is Active'),
370 'description' => ts('Disabling premium removes it from the premiums_premium join table below.'),
372 'where' => 'civicrm_product.is_active',
373 'table_name' => 'civicrm_product',
374 'entity' => 'Product',
375 'bao' => 'CRM_Contribute_BAO_Product',
379 'name' => 'period_type',
380 'type' => CRM_Utils_Type
::T_STRING
,
381 'title' => ts('Period Type'),
382 'description' => ts('Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
383 (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) '),
385 'size' => CRM_Utils_Type
::EIGHT
,
386 'where' => 'civicrm_product.period_type',
387 'default' => 'rolling',
388 'table_name' => 'civicrm_product',
389 'entity' => 'Product',
390 'bao' => 'CRM_Contribute_BAO_Product',
395 'pseudoconstant' => [
396 'callback' => 'CRM_Core_SelectValues::periodType',
399 'fixed_period_start_day' => [
400 'name' => 'fixed_period_start_day',
401 'type' => CRM_Utils_Type
::T_INT
,
402 'title' => ts('Fixed Period Start Day'),
403 'description' => ts('Month and day (MMDD) that fixed period type subscription or membership starts.'),
404 'where' => 'civicrm_product.fixed_period_start_day',
406 'table_name' => 'civicrm_product',
407 'entity' => 'Product',
408 'bao' => 'CRM_Contribute_BAO_Product',
412 'name' => 'duration_unit',
413 'type' => CRM_Utils_Type
::T_STRING
,
414 'title' => ts('Duration Unit'),
416 'size' => CRM_Utils_Type
::EIGHT
,
417 'where' => 'civicrm_product.duration_unit',
419 'table_name' => 'civicrm_product',
420 'entity' => 'Product',
421 'bao' => 'CRM_Contribute_BAO_Product',
426 'pseudoconstant' => [
427 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
430 'duration_interval' => [
431 'name' => 'duration_interval',
432 'type' => CRM_Utils_Type
::T_INT
,
433 'title' => ts('Duration Interval'),
434 'description' => ts('Number of units for total duration of subscription, service, membership (e.g. 12 Months).'),
435 'where' => 'civicrm_product.duration_interval',
436 'table_name' => 'civicrm_product',
437 'entity' => 'Product',
438 'bao' => 'CRM_Contribute_BAO_Product',
441 'frequency_unit' => [
442 'name' => 'frequency_unit',
443 'type' => CRM_Utils_Type
::T_STRING
,
444 'title' => ts('Frequency Unit'),
445 'description' => ts('Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.'),
447 'size' => CRM_Utils_Type
::EIGHT
,
448 'where' => 'civicrm_product.frequency_unit',
449 'default' => 'month',
450 'table_name' => 'civicrm_product',
451 'entity' => 'Product',
452 'bao' => 'CRM_Contribute_BAO_Product',
457 'pseudoconstant' => [
458 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
461 'frequency_interval' => [
462 'name' => 'frequency_interval',
463 'type' => CRM_Utils_Type
::T_INT
,
464 'title' => ts('Frequency Interval'),
465 'description' => ts('Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).'),
466 'where' => 'civicrm_product.frequency_interval',
467 'table_name' => 'civicrm_product',
468 'entity' => 'Product',
469 'bao' => 'CRM_Contribute_BAO_Product',
473 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
475 return Civi
::$statics[__CLASS__
]['fields'];
479 * Return a mapping from field-name to the corresponding key (as used in fields()).
482 * Array(string $name => string $uniqueName).
484 public static function &fieldKeys() {
485 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
486 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
488 return Civi
::$statics[__CLASS__
]['fieldKeys'];
492 * Returns the names of this table
496 public static function getTableName() {
497 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
501 * Returns if this table needs to be logged
505 public function getLog() {
510 * Returns the list of fields that can be imported
512 * @param bool $prefix
516 public static function &import($prefix = FALSE) {
517 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'product', $prefix, []);
522 * Returns the list of fields that can be exported
524 * @param bool $prefix
528 public static function &export($prefix = FALSE) {
529 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'product', $prefix, []);
534 * Returns the list of indices
536 * @param bool $localize
540 public static function indices($localize = TRUE) {
542 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;