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 static $_tableName = 'civicrm_product';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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 'table_name' => 'civicrm_product',
198 'entity' => 'Product',
199 'bao' => 'CRM_Contribute_BAO_Product',
204 'type' => CRM_Utils_Type
::T_STRING
,
205 'title' => ts('Product Name'),
206 'description' => ts('Required product/premium name'),
209 'size' => CRM_Utils_Type
::HUGE
,
211 'where' => 'civicrm_product.name',
212 'headerPattern' => '',
214 'table_name' => 'civicrm_product',
215 'entity' => 'Product',
216 'bao' => 'CRM_Contribute_BAO_Product',
220 'name' => 'description',
221 'type' => CRM_Utils_Type
::T_TEXT
,
222 'title' => ts('Description'),
223 'description' => ts('Optional description of the product/premium.'),
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
,
237 'where' => 'civicrm_product.sku',
238 'headerPattern' => '',
240 'table_name' => 'civicrm_product',
241 'entity' => 'Product',
242 'bao' => 'CRM_Contribute_BAO_Product',
247 'type' => CRM_Utils_Type
::T_TEXT
,
248 'title' => ts('Options'),
249 'description' => ts('Store comma-delimited list of color, size, etc. options for the product.'),
250 'table_name' => 'civicrm_product',
251 'entity' => 'Product',
252 'bao' => 'CRM_Contribute_BAO_Product',
257 'type' => CRM_Utils_Type
::T_STRING
,
258 'title' => ts('Image'),
259 'description' => ts('Full or relative URL to uploaded image - fullsize.'),
261 'size' => CRM_Utils_Type
::HUGE
,
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 'table_name' => 'civicrm_product',
275 'entity' => 'Product',
276 'bao' => 'CRM_Contribute_BAO_Product',
281 'type' => CRM_Utils_Type
::T_MONEY
,
282 'title' => ts('Price'),
283 '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.'),
288 'table_name' => 'civicrm_product',
289 'entity' => 'Product',
290 'bao' => 'CRM_Contribute_BAO_Product',
294 'name' => 'currency',
295 'type' => CRM_Utils_Type
::T_STRING
,
296 'title' => ts('Currency'),
297 'description' => ts('3 character string, value from config setting or input via user.'),
299 'size' => CRM_Utils_Type
::FOUR
,
301 'table_name' => 'civicrm_product',
302 'entity' => 'Product',
303 'bao' => 'CRM_Contribute_BAO_Product',
308 'pseudoconstant' => [
309 'table' => 'civicrm_currency',
310 'keyColumn' => 'name',
311 'labelColumn' => 'full_name',
312 'nameColumn' => 'name',
315 'financial_type_id' => [
316 'name' => 'financial_type_id',
317 'type' => CRM_Utils_Type
::T_INT
,
318 'title' => ts('Financial Type'),
319 'description' => ts('FK to Financial Type.'),
321 'table_name' => 'civicrm_product',
322 'entity' => 'Product',
323 'bao' => 'CRM_Contribute_BAO_Product',
325 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
326 'pseudoconstant' => [
327 'table' => 'civicrm_financial_type',
329 'labelColumn' => 'name',
332 'min_contribution' => [
333 'name' => 'min_contribution',
334 'type' => CRM_Utils_Type
::T_MONEY
,
335 'title' => ts('Minimum Contribution'),
336 'description' => ts('Minimum contribution required to be eligible to select this premium.'),
341 'table_name' => 'civicrm_product',
342 'entity' => 'Product',
343 'bao' => 'CRM_Contribute_BAO_Product',
348 'type' => CRM_Utils_Type
::T_MONEY
,
349 'title' => ts('Cost'),
350 'description' => ts('Actual cost of this product. Useful to determine net return from sale or using this as an incentive.'),
355 'table_name' => 'civicrm_product',
356 'entity' => 'Product',
357 'bao' => 'CRM_Contribute_BAO_Product',
361 'name' => 'is_active',
362 'type' => CRM_Utils_Type
::T_BOOLEAN
,
363 'title' => ts('Is Active'),
364 'description' => ts('Disabling premium removes it from the premiums_premium join table below.'),
366 'table_name' => 'civicrm_product',
367 'entity' => 'Product',
368 'bao' => 'CRM_Contribute_BAO_Product',
372 'name' => 'period_type',
373 'type' => CRM_Utils_Type
::T_STRING
,
374 'title' => ts('Period Type'),
375 'description' => ts('Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
376 (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) '),
378 'size' => CRM_Utils_Type
::EIGHT
,
379 'default' => 'rolling',
380 'table_name' => 'civicrm_product',
381 'entity' => 'Product',
382 'bao' => 'CRM_Contribute_BAO_Product',
387 'pseudoconstant' => [
388 'callback' => 'CRM_Core_SelectValues::periodType',
391 'fixed_period_start_day' => [
392 'name' => 'fixed_period_start_day',
393 'type' => CRM_Utils_Type
::T_INT
,
394 'title' => ts('Fixed Period Start Day'),
395 'description' => ts('Month and day (MMDD) that fixed period type subscription or membership starts.'),
397 'table_name' => 'civicrm_product',
398 'entity' => 'Product',
399 'bao' => 'CRM_Contribute_BAO_Product',
403 'name' => 'duration_unit',
404 'type' => CRM_Utils_Type
::T_STRING
,
405 'title' => ts('Duration Unit'),
407 'size' => CRM_Utils_Type
::EIGHT
,
409 'table_name' => 'civicrm_product',
410 'entity' => 'Product',
411 'bao' => 'CRM_Contribute_BAO_Product',
416 'pseudoconstant' => [
417 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
420 'duration_interval' => [
421 'name' => 'duration_interval',
422 'type' => CRM_Utils_Type
::T_INT
,
423 'title' => ts('Duration Interval'),
424 'description' => ts('Number of units for total duration of subscription, service, membership (e.g. 12 Months).'),
425 'table_name' => 'civicrm_product',
426 'entity' => 'Product',
427 'bao' => 'CRM_Contribute_BAO_Product',
430 'frequency_unit' => [
431 'name' => 'frequency_unit',
432 'type' => CRM_Utils_Type
::T_STRING
,
433 'title' => ts('Frequency Unit'),
434 'description' => ts('Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.'),
436 'size' => CRM_Utils_Type
::EIGHT
,
437 'default' => 'month',
438 'table_name' => 'civicrm_product',
439 'entity' => 'Product',
440 'bao' => 'CRM_Contribute_BAO_Product',
445 'pseudoconstant' => [
446 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
449 'frequency_interval' => [
450 'name' => 'frequency_interval',
451 'type' => CRM_Utils_Type
::T_INT
,
452 'title' => ts('Frequency Interval'),
453 'description' => ts('Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).'),
454 'table_name' => 'civicrm_product',
455 'entity' => 'Product',
456 'bao' => 'CRM_Contribute_BAO_Product',
460 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
462 return Civi
::$statics[__CLASS__
]['fields'];
466 * Return a mapping from field-name to the corresponding key (as used in fields()).
469 * Array(string $name => string $uniqueName).
471 public static function &fieldKeys() {
472 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
473 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
475 return Civi
::$statics[__CLASS__
]['fieldKeys'];
479 * Returns the names of this table
483 public static function getTableName() {
484 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
488 * Returns if this table needs to be logged
492 public function getLog() {
497 * Returns the list of fields that can be imported
499 * @param bool $prefix
503 public static function &import($prefix = FALSE) {
504 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'product', $prefix, []);
509 * Returns the list of fields that can be exported
511 * @param bool $prefix
515 public static function &export($prefix = FALSE) {
516 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'product', $prefix, []);
521 * Returns the list of indices
523 * @param bool $localize
527 public static function indices($localize = TRUE) {
529 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;