financial#46 - clean money format at form layer
[civicrm-core.git] / CRM / Contribute / DAO / Product.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Contribute/Product.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:7db77c58d48112d25da791aba4586080)
10 */
11
12 /**
13 * Database access object for the Product entity.
14 */
15 class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 static $_tableName = 'civicrm_product';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 static $_log = TRUE;
30
31 /**
32 * @var int unsigned
33 */
34 public $id;
35
36 /**
37 * Required product/premium name
38 *
39 * @var string
40 */
41 public $name;
42
43 /**
44 * Optional description of the product/premium.
45 *
46 * @var text
47 */
48 public $description;
49
50 /**
51 * Optional product sku or code.
52 *
53 * @var string
54 */
55 public $sku;
56
57 /**
58 * Store comma-delimited list of color, size, etc. options for the product.
59 *
60 * @var text
61 */
62 public $options;
63
64 /**
65 * Full or relative URL to uploaded image - fullsize.
66 *
67 * @var string
68 */
69 public $image;
70
71 /**
72 * Full or relative URL to image thumbnail.
73 *
74 * @var string
75 */
76 public $thumbnail;
77
78 /**
79 * Sell price or market value for premiums. For tax-deductible contributions, this will be stored as non_deductible_amount in the contribution record.
80 *
81 * @var float
82 */
83 public $price;
84
85 /**
86 * 3 character string, value from config setting or input via user.
87 *
88 * @var string
89 */
90 public $currency;
91
92 /**
93 * FK to Financial Type.
94 *
95 * @var int unsigned
96 */
97 public $financial_type_id;
98
99 /**
100 * Minimum contribution required to be eligible to select this premium.
101 *
102 * @var float
103 */
104 public $min_contribution;
105
106 /**
107 * Actual cost of this product. Useful to determine net return from sale or using this as an incentive.
108 *
109 * @var float
110 */
111 public $cost;
112
113 /**
114 * Disabling premium removes it from the premiums_premium join table below.
115 *
116 * @var boolean
117 */
118 public $is_active;
119
120 /**
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)
123 *
124 * @var string
125 */
126 public $period_type;
127
128 /**
129 * Month and day (MMDD) that fixed period type subscription or membership starts.
130 *
131 * @var int
132 */
133 public $fixed_period_start_day;
134
135 /**
136 * @var string
137 */
138 public $duration_unit;
139
140 /**
141 * Number of units for total duration of subscription, service, membership (e.g. 12 Months).
142 *
143 * @var int
144 */
145 public $duration_interval;
146
147 /**
148 * Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.
149 *
150 * @var string
151 */
152 public $frequency_unit;
153
154 /**
155 * Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).
156 *
157 * @var int
158 */
159 public $frequency_interval;
160
161 /**
162 * Class constructor.
163 */
164 public function __construct() {
165 $this->__table = 'civicrm_product';
166 parent::__construct();
167 }
168
169 /**
170 * Returns foreign keys and entity references.
171 *
172 * @return array
173 * [CRM_Core_Reference_Interface]
174 */
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']);
180 }
181 return Civi::$statics[__CLASS__]['links'];
182 }
183
184 /**
185 * Returns all the column names of this table
186 *
187 * @return array
188 */
189 public static function &fields() {
190 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
191 Civi::$statics[__CLASS__]['fields'] = [
192 'id' => [
193 'name' => 'id',
194 'type' => CRM_Utils_Type::T_INT,
195 'title' => ts('Product ID'),
196 'required' => TRUE,
197 'table_name' => 'civicrm_product',
198 'entity' => 'Product',
199 'bao' => 'CRM_Contribute_BAO_Product',
200 'localizable' => 0,
201 ],
202 'product_name' => [
203 'name' => 'name',
204 'type' => CRM_Utils_Type::T_STRING,
205 'title' => ts('Product Name'),
206 'description' => ts('Required product/premium name'),
207 'required' => TRUE,
208 'maxlength' => 255,
209 'size' => CRM_Utils_Type::HUGE,
210 'export' => TRUE,
211 'where' => 'civicrm_product.name',
212 'headerPattern' => '',
213 'dataPattern' => '',
214 'table_name' => 'civicrm_product',
215 'entity' => 'Product',
216 'bao' => 'CRM_Contribute_BAO_Product',
217 'localizable' => 1,
218 ],
219 'description' => [
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',
227 'localizable' => 1,
228 ],
229 'sku' => [
230 'name' => 'sku',
231 'type' => CRM_Utils_Type::T_STRING,
232 'title' => ts('SKU'),
233 'description' => ts('Optional product sku or code.'),
234 'maxlength' => 50,
235 'size' => CRM_Utils_Type::BIG,
236 'export' => TRUE,
237 'where' => 'civicrm_product.sku',
238 'headerPattern' => '',
239 'dataPattern' => '',
240 'table_name' => 'civicrm_product',
241 'entity' => 'Product',
242 'bao' => 'CRM_Contribute_BAO_Product',
243 'localizable' => 0,
244 ],
245 'options' => [
246 'name' => 'options',
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',
253 'localizable' => 1,
254 ],
255 'image' => [
256 'name' => 'image',
257 'type' => CRM_Utils_Type::T_STRING,
258 'title' => ts('Image'),
259 'description' => ts('Full or relative URL to uploaded image - fullsize.'),
260 'maxlength' => 255,
261 'size' => CRM_Utils_Type::HUGE,
262 'table_name' => 'civicrm_product',
263 'entity' => 'Product',
264 'bao' => 'CRM_Contribute_BAO_Product',
265 'localizable' => 0,
266 ],
267 'thumbnail' => [
268 'name' => 'thumbnail',
269 'type' => CRM_Utils_Type::T_STRING,
270 'title' => ts('Thumbnail'),
271 'description' => ts('Full or relative URL to image thumbnail.'),
272 'maxlength' => 255,
273 'size' => CRM_Utils_Type::HUGE,
274 'table_name' => 'civicrm_product',
275 'entity' => 'Product',
276 'bao' => 'CRM_Contribute_BAO_Product',
277 'localizable' => 0,
278 ],
279 'price' => [
280 'name' => 'price',
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.'),
284 'precision' => [
285 20,
286 2
287 ],
288 'table_name' => 'civicrm_product',
289 'entity' => 'Product',
290 'bao' => 'CRM_Contribute_BAO_Product',
291 'localizable' => 0,
292 ],
293 'currency' => [
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.'),
298 'maxlength' => 3,
299 'size' => CRM_Utils_Type::FOUR,
300 'default' => 'NULL',
301 'table_name' => 'civicrm_product',
302 'entity' => 'Product',
303 'bao' => 'CRM_Contribute_BAO_Product',
304 'localizable' => 0,
305 'html' => [
306 'type' => 'Select',
307 ],
308 'pseudoconstant' => [
309 'table' => 'civicrm_currency',
310 'keyColumn' => 'name',
311 'labelColumn' => 'full_name',
312 'nameColumn' => 'name',
313 ]
314 ],
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.'),
320 'default' => 'NULL',
321 'table_name' => 'civicrm_product',
322 'entity' => 'Product',
323 'bao' => 'CRM_Contribute_BAO_Product',
324 'localizable' => 0,
325 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
326 'pseudoconstant' => [
327 'table' => 'civicrm_financial_type',
328 'keyColumn' => 'id',
329 'labelColumn' => 'name',
330 ]
331 ],
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.'),
337 'precision' => [
338 20,
339 2
340 ],
341 'table_name' => 'civicrm_product',
342 'entity' => 'Product',
343 'bao' => 'CRM_Contribute_BAO_Product',
344 'localizable' => 0,
345 ],
346 'cost' => [
347 'name' => 'cost',
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.'),
351 'precision' => [
352 20,
353 2
354 ],
355 'table_name' => 'civicrm_product',
356 'entity' => 'Product',
357 'bao' => 'CRM_Contribute_BAO_Product',
358 'localizable' => 0,
359 ],
360 'is_active' => [
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.'),
365 'required' => TRUE,
366 'table_name' => 'civicrm_product',
367 'entity' => 'Product',
368 'bao' => 'CRM_Contribute_BAO_Product',
369 'localizable' => 0,
370 ],
371 'period_type' => [
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) '),
377 'maxlength' => 8,
378 'size' => CRM_Utils_Type::EIGHT,
379 'default' => 'rolling',
380 'table_name' => 'civicrm_product',
381 'entity' => 'Product',
382 'bao' => 'CRM_Contribute_BAO_Product',
383 'localizable' => 0,
384 'html' => [
385 'type' => 'Select',
386 ],
387 'pseudoconstant' => [
388 'callback' => 'CRM_Core_SelectValues::periodType',
389 ]
390 ],
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.'),
396 'default' => '0101',
397 'table_name' => 'civicrm_product',
398 'entity' => 'Product',
399 'bao' => 'CRM_Contribute_BAO_Product',
400 'localizable' => 0,
401 ],
402 'duration_unit' => [
403 'name' => 'duration_unit',
404 'type' => CRM_Utils_Type::T_STRING,
405 'title' => ts('Duration Unit'),
406 'maxlength' => 8,
407 'size' => CRM_Utils_Type::EIGHT,
408 'default' => 'year',
409 'table_name' => 'civicrm_product',
410 'entity' => 'Product',
411 'bao' => 'CRM_Contribute_BAO_Product',
412 'localizable' => 0,
413 'html' => [
414 'type' => 'Select',
415 ],
416 'pseudoconstant' => [
417 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
418 ]
419 ],
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',
428 'localizable' => 0,
429 ],
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.'),
435 'maxlength' => 8,
436 'size' => CRM_Utils_Type::EIGHT,
437 'default' => 'month',
438 'table_name' => 'civicrm_product',
439 'entity' => 'Product',
440 'bao' => 'CRM_Contribute_BAO_Product',
441 'localizable' => 0,
442 'html' => [
443 'type' => 'Select',
444 ],
445 'pseudoconstant' => [
446 'callback' => 'CRM_Core_SelectValues::getPremiumUnits',
447 ]
448 ],
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',
457 'localizable' => 0,
458 ],
459 ];
460 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
461 }
462 return Civi::$statics[__CLASS__]['fields'];
463 }
464
465 /**
466 * Return a mapping from field-name to the corresponding key (as used in fields()).
467 *
468 * @return array
469 * Array(string $name => string $uniqueName).
470 */
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()));
474 }
475 return Civi::$statics[__CLASS__]['fieldKeys'];
476 }
477
478 /**
479 * Returns the names of this table
480 *
481 * @return string
482 */
483 public static function getTableName() {
484 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
485 }
486
487 /**
488 * Returns if this table needs to be logged
489 *
490 * @return bool
491 */
492 public function getLog() {
493 return self::$_log;
494 }
495
496 /**
497 * Returns the list of fields that can be imported
498 *
499 * @param bool $prefix
500 *
501 * @return array
502 */
503 public static function &import($prefix = FALSE) {
504 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'product', $prefix, []);
505 return $r;
506 }
507
508 /**
509 * Returns the list of fields that can be exported
510 *
511 * @param bool $prefix
512 *
513 * @return array
514 */
515 public static function &export($prefix = FALSE) {
516 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'product', $prefix, []);
517 return $r;
518 }
519
520 /**
521 * Returns the list of indices
522 *
523 * @param bool $localize
524 *
525 * @return array
526 */
527 public static function indices($localize = TRUE) {
528 $indices = [];
529 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
530 }
531
532 }