Commit | Line | Data |
---|---|---|
e501603b TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.7 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2016 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | /** | |
28 | * @package CRM | |
29 | * @copyright CiviCRM LLC (c) 2004-2016 | |
30 | * | |
31 | * Generated from xml/schema/CRM/Contribute/Product.xml | |
32 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
33 | * (GenCodeChecksum:9907599518b86a4ff232db541df43d85) | |
34 | */ | |
35 | require_once 'CRM/Core/DAO.php'; | |
36 | require_once 'CRM/Utils/Type.php'; | |
37 | class CRM_Contribute_DAO_Product extends CRM_Core_DAO { | |
38 | /** | |
39 | * static instance to hold the table name | |
40 | * | |
41 | * @var string | |
42 | */ | |
43 | static $_tableName = 'civicrm_product'; | |
44 | /** | |
45 | * static instance to hold the field values | |
46 | * | |
47 | * @var array | |
48 | */ | |
49 | static $_fields = null; | |
50 | /** | |
51 | * static instance to hold the keys used in $_fields for each field. | |
52 | * | |
53 | * @var array | |
54 | */ | |
55 | static $_fieldKeys = null; | |
56 | /** | |
57 | * static instance to hold the FK relationships | |
58 | * | |
59 | * @var string | |
60 | */ | |
61 | static $_links = null; | |
62 | /** | |
63 | * static instance to hold the values that can | |
64 | * be imported | |
65 | * | |
66 | * @var array | |
67 | */ | |
68 | static $_import = null; | |
69 | /** | |
70 | * static instance to hold the values that can | |
71 | * be exported | |
72 | * | |
73 | * @var array | |
74 | */ | |
75 | static $_export = null; | |
76 | /** | |
77 | * static value to see if we should log any modifications to | |
78 | * this table in the civicrm_log table | |
79 | * | |
80 | * @var boolean | |
81 | */ | |
82 | static $_log = true; | |
83 | /** | |
84 | * | |
85 | * @var int unsigned | |
86 | */ | |
87 | public $id; | |
88 | /** | |
89 | * Required product/premium name | |
90 | * | |
91 | * @var string | |
92 | */ | |
93 | public $name; | |
94 | /** | |
95 | * Optional description of the product/premium. | |
96 | * | |
97 | * @var text | |
98 | */ | |
99 | public $description; | |
100 | /** | |
101 | * Optional product sku or code. | |
102 | * | |
103 | * @var string | |
104 | */ | |
105 | public $sku; | |
106 | /** | |
107 | * Store comma-delimited list of color, size, etc. options for the product. | |
108 | * | |
109 | * @var text | |
110 | */ | |
111 | public $options; | |
112 | /** | |
113 | * Full or relative URL to uploaded image - fullsize. | |
114 | * | |
115 | * @var string | |
116 | */ | |
117 | public $image; | |
118 | /** | |
119 | * Full or relative URL to image thumbnail. | |
120 | * | |
121 | * @var string | |
122 | */ | |
123 | public $thumbnail; | |
124 | /** | |
125 | * Sell price or market value for premiums. For tax-deductible contributions, this will be stored as non_deductible_amount in the contribution record. | |
126 | * | |
127 | * @var float | |
128 | */ | |
129 | public $price; | |
130 | /** | |
131 | * 3 character string, value from config setting or input via user. | |
132 | * | |
133 | * @var string | |
134 | */ | |
135 | public $currency; | |
136 | /** | |
137 | * FK to Financial Type. | |
138 | * | |
139 | * @var int unsigned | |
140 | */ | |
141 | public $financial_type_id; | |
142 | /** | |
143 | * Minimum contribution required to be eligible to select this premium. | |
144 | * | |
145 | * @var float | |
146 | */ | |
147 | public $min_contribution; | |
148 | /** | |
149 | * Actual cost of this product. Useful to determine net return from sale or using this as an incentive. | |
150 | * | |
151 | * @var float | |
152 | */ | |
153 | public $cost; | |
154 | /** | |
155 | * Disabling premium removes it from the premiums_premium join table below. | |
156 | * | |
157 | * @var boolean | |
158 | */ | |
159 | public $is_active; | |
160 | /** | |
161 | * Rolling means we set start/end based on current day, fixed means we set start/end for current year or month | |
162 | (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) | |
163 | * | |
164 | * @var string | |
165 | */ | |
166 | public $period_type; | |
167 | /** | |
168 | * Month and day (MMDD) that fixed period type subscription or membership starts. | |
169 | * | |
170 | * @var int | |
171 | */ | |
172 | public $fixed_period_start_day; | |
173 | /** | |
174 | * | |
175 | * @var string | |
176 | */ | |
177 | public $duration_unit; | |
178 | /** | |
179 | * Number of units for total duration of subscription, service, membership (e.g. 12 Months). | |
180 | * | |
181 | * @var int | |
182 | */ | |
183 | public $duration_interval; | |
184 | /** | |
185 | * Frequency unit and interval allow option to store actual delivery frequency for a subscription or service. | |
186 | * | |
187 | * @var string | |
188 | */ | |
189 | public $frequency_unit; | |
190 | /** | |
191 | * Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months). | |
192 | * | |
193 | * @var int | |
194 | */ | |
195 | public $frequency_interval; | |
196 | /** | |
197 | * class constructor | |
198 | * | |
199 | * @return civicrm_product | |
200 | */ | |
201 | function __construct() { | |
202 | $this->__table = 'civicrm_product'; | |
203 | parent::__construct(); | |
204 | } | |
205 | /** | |
206 | * Returns foreign keys and entity references | |
207 | * | |
208 | * @return array | |
209 | * [CRM_Core_Reference_Interface] | |
210 | */ | |
211 | static function getReferenceColumns() { | |
212 | if (!self::$_links) { | |
213 | self::$_links = static ::createReferenceColumns(__CLASS__); | |
214 | self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_type_id', 'civicrm_financial_type', 'id'); | |
215 | } | |
216 | return self::$_links; | |
217 | } | |
218 | /** | |
219 | * Returns all the column names of this table | |
220 | * | |
221 | * @return array | |
222 | */ | |
223 | static function &fields() { | |
224 | if (!(self::$_fields)) { | |
225 | self::$_fields = array( | |
226 | 'id' => array( | |
227 | 'name' => 'id', | |
228 | 'type' => CRM_Utils_Type::T_INT, | |
229 | 'title' => ts('Product ID') , | |
230 | 'required' => true, | |
231 | ) , | |
232 | 'product_name' => array( | |
233 | 'name' => 'name', | |
234 | 'type' => CRM_Utils_Type::T_STRING, | |
235 | 'title' => ts('Product Name') , | |
236 | 'description' => 'Required product/premium name', | |
237 | 'required' => true, | |
238 | 'maxlength' => 255, | |
239 | 'size' => CRM_Utils_Type::HUGE, | |
240 | 'export' => true, | |
241 | 'where' => 'civicrm_product.name', | |
242 | 'headerPattern' => '', | |
243 | 'dataPattern' => '', | |
244 | ) , | |
245 | 'description' => array( | |
246 | 'name' => 'description', | |
247 | 'type' => CRM_Utils_Type::T_TEXT, | |
248 | 'title' => ts('Description') , | |
249 | 'description' => 'Optional description of the product/premium.', | |
250 | ) , | |
251 | 'sku' => array( | |
252 | 'name' => 'sku', | |
253 | 'type' => CRM_Utils_Type::T_STRING, | |
254 | 'title' => ts('SKU') , | |
255 | 'description' => 'Optional product sku or code.', | |
256 | 'maxlength' => 50, | |
257 | 'size' => CRM_Utils_Type::BIG, | |
258 | 'export' => true, | |
259 | 'where' => 'civicrm_product.sku', | |
260 | 'headerPattern' => '', | |
261 | 'dataPattern' => '', | |
262 | ) , | |
263 | 'options' => array( | |
264 | 'name' => 'options', | |
265 | 'type' => CRM_Utils_Type::T_TEXT, | |
266 | 'title' => ts('Options') , | |
267 | 'description' => 'Store comma-delimited list of color, size, etc. options for the product.', | |
268 | ) , | |
269 | 'image' => array( | |
270 | 'name' => 'image', | |
271 | 'type' => CRM_Utils_Type::T_STRING, | |
272 | 'title' => ts('Image') , | |
273 | 'description' => 'Full or relative URL to uploaded image - fullsize.', | |
274 | 'maxlength' => 255, | |
275 | 'size' => CRM_Utils_Type::HUGE, | |
276 | ) , | |
277 | 'thumbnail' => array( | |
278 | 'name' => 'thumbnail', | |
279 | 'type' => CRM_Utils_Type::T_STRING, | |
280 | 'title' => ts('Thumbnail') , | |
281 | 'description' => 'Full or relative URL to image thumbnail.', | |
282 | 'maxlength' => 255, | |
283 | 'size' => CRM_Utils_Type::HUGE, | |
284 | ) , | |
285 | 'price' => array( | |
286 | 'name' => 'price', | |
287 | 'type' => CRM_Utils_Type::T_MONEY, | |
288 | 'title' => ts('Price') , | |
289 | 'description' => 'Sell price or market value for premiums. For tax-deductible contributions, this will be stored as non_deductible_amount in the contribution record.', | |
290 | 'precision' => array( | |
291 | 20, | |
292 | 2 | |
293 | ) , | |
294 | ) , | |
295 | 'currency' => array( | |
296 | 'name' => 'currency', | |
297 | 'type' => CRM_Utils_Type::T_STRING, | |
298 | 'title' => ts('Currency') , | |
299 | 'description' => '3 character string, value from config setting or input via user.', | |
300 | 'maxlength' => 3, | |
301 | 'size' => CRM_Utils_Type::FOUR, | |
302 | 'default' => 'NULL', | |
303 | 'html' => array( | |
304 | 'type' => 'Select', | |
305 | ) , | |
306 | 'pseudoconstant' => array( | |
307 | 'table' => 'civicrm_currency', | |
308 | 'keyColumn' => 'name', | |
309 | 'labelColumn' => 'full_name', | |
310 | 'nameColumn' => 'name', | |
311 | ) | |
312 | ) , | |
313 | 'financial_type_id' => array( | |
314 | 'name' => 'financial_type_id', | |
315 | 'type' => CRM_Utils_Type::T_INT, | |
316 | 'title' => ts('Financial Type') , | |
317 | 'description' => 'FK to Financial Type.', | |
318 | 'default' => 'NULL', | |
319 | 'FKClassName' => 'CRM_Financial_DAO_FinancialType', | |
320 | 'pseudoconstant' => array( | |
321 | 'table' => 'civicrm_financial_type', | |
322 | 'keyColumn' => 'id', | |
323 | 'labelColumn' => 'name', | |
324 | ) | |
325 | ) , | |
326 | 'min_contribution' => array( | |
327 | 'name' => 'min_contribution', | |
328 | 'type' => CRM_Utils_Type::T_MONEY, | |
329 | 'title' => ts('Minimum Contribution') , | |
330 | 'description' => 'Minimum contribution required to be eligible to select this premium.', | |
331 | 'precision' => array( | |
332 | 20, | |
333 | 2 | |
334 | ) , | |
335 | ) , | |
336 | 'cost' => array( | |
337 | 'name' => 'cost', | |
338 | 'type' => CRM_Utils_Type::T_MONEY, | |
339 | 'title' => ts('Cost') , | |
340 | 'description' => 'Actual cost of this product. Useful to determine net return from sale or using this as an incentive.', | |
341 | 'precision' => array( | |
342 | 20, | |
343 | 2 | |
344 | ) , | |
345 | ) , | |
346 | 'is_active' => array( | |
347 | 'name' => 'is_active', | |
348 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
349 | 'title' => ts('Is Active') , | |
350 | 'description' => 'Disabling premium removes it from the premiums_premium join table below.', | |
351 | 'required' => true, | |
352 | ) , | |
353 | 'period_type' => array( | |
354 | 'name' => 'period_type', | |
355 | 'type' => CRM_Utils_Type::T_STRING, | |
356 | 'title' => ts('Period Type') , | |
357 | 'description' => 'Rolling means we set start/end based on current day, fixed means we set start/end for current year or month | |
358 | (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) ', | |
359 | 'maxlength' => 8, | |
360 | 'size' => CRM_Utils_Type::EIGHT, | |
361 | 'default' => 'rolling', | |
362 | 'html' => array( | |
363 | 'type' => 'Select', | |
364 | ) , | |
365 | 'pseudoconstant' => array( | |
366 | 'callback' => 'CRM_Core_SelectValues::periodType', | |
367 | ) | |
368 | ) , | |
369 | 'fixed_period_start_day' => array( | |
370 | 'name' => 'fixed_period_start_day', | |
371 | 'type' => CRM_Utils_Type::T_INT, | |
372 | 'title' => ts('Fixed Period Start Day') , | |
373 | 'description' => 'Month and day (MMDD) that fixed period type subscription or membership starts.', | |
374 | 'default' => '0101', | |
375 | ) , | |
376 | 'duration_unit' => array( | |
377 | 'name' => 'duration_unit', | |
378 | 'type' => CRM_Utils_Type::T_STRING, | |
379 | 'title' => ts('Duration Unit') , | |
380 | 'maxlength' => 8, | |
381 | 'size' => CRM_Utils_Type::EIGHT, | |
382 | 'default' => 'year', | |
383 | 'html' => array( | |
384 | 'type' => 'Select', | |
385 | ) , | |
386 | 'pseudoconstant' => array( | |
387 | 'callback' => 'CRM_Core_SelectValues::getPremiumUnits', | |
388 | ) | |
389 | ) , | |
390 | 'duration_interval' => array( | |
391 | 'name' => 'duration_interval', | |
392 | 'type' => CRM_Utils_Type::T_INT, | |
393 | 'title' => ts('Duration Interval') , | |
394 | 'description' => 'Number of units for total duration of subscription, service, membership (e.g. 12 Months).', | |
395 | ) , | |
396 | 'frequency_unit' => array( | |
397 | 'name' => 'frequency_unit', | |
398 | 'type' => CRM_Utils_Type::T_STRING, | |
399 | 'title' => ts('Frequency Unit') , | |
400 | 'description' => 'Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.', | |
401 | 'maxlength' => 8, | |
402 | 'size' => CRM_Utils_Type::EIGHT, | |
403 | 'default' => 'month', | |
404 | 'html' => array( | |
405 | 'type' => 'Select', | |
406 | ) , | |
407 | 'pseudoconstant' => array( | |
408 | 'callback' => 'CRM_Core_SelectValues::getPremiumUnits', | |
409 | ) | |
410 | ) , | |
411 | 'frequency_interval' => array( | |
412 | 'name' => 'frequency_interval', | |
413 | 'type' => CRM_Utils_Type::T_INT, | |
414 | 'title' => ts('Frequency Interval') , | |
415 | 'description' => 'Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).', | |
416 | ) , | |
417 | ); | |
418 | } | |
419 | return self::$_fields; | |
420 | } | |
421 | /** | |
422 | * Returns an array containing, for each field, the arary key used for that | |
423 | * field in self::$_fields. | |
424 | * | |
425 | * @return array | |
426 | */ | |
427 | static function &fieldKeys() { | |
428 | if (!(self::$_fieldKeys)) { | |
429 | self::$_fieldKeys = array( | |
430 | 'id' => 'id', | |
431 | 'name' => 'product_name', | |
432 | 'description' => 'description', | |
433 | 'sku' => 'sku', | |
434 | 'options' => 'options', | |
435 | 'image' => 'image', | |
436 | 'thumbnail' => 'thumbnail', | |
437 | 'price' => 'price', | |
438 | 'currency' => 'currency', | |
439 | 'financial_type_id' => 'financial_type_id', | |
440 | 'min_contribution' => 'min_contribution', | |
441 | 'cost' => 'cost', | |
442 | 'is_active' => 'is_active', | |
443 | 'period_type' => 'period_type', | |
444 | 'fixed_period_start_day' => 'fixed_period_start_day', | |
445 | 'duration_unit' => 'duration_unit', | |
446 | 'duration_interval' => 'duration_interval', | |
447 | 'frequency_unit' => 'frequency_unit', | |
448 | 'frequency_interval' => 'frequency_interval', | |
449 | ); | |
450 | } | |
451 | return self::$_fieldKeys; | |
452 | } | |
453 | /** | |
454 | * Returns the names of this table | |
455 | * | |
456 | * @return string | |
457 | */ | |
458 | static function getTableName() { | |
459 | return CRM_Core_DAO::getLocaleTableName(self::$_tableName); | |
460 | } | |
461 | /** | |
462 | * Returns if this table needs to be logged | |
463 | * | |
464 | * @return boolean | |
465 | */ | |
466 | function getLog() { | |
467 | return self::$_log; | |
468 | } | |
469 | /** | |
470 | * Returns the list of fields that can be imported | |
471 | * | |
472 | * @param bool $prefix | |
473 | * | |
474 | * @return array | |
475 | */ | |
476 | static function &import($prefix = false) { | |
477 | if (!(self::$_import)) { | |
478 | self::$_import = array(); | |
479 | $fields = self::fields(); | |
480 | foreach($fields as $name => $field) { | |
481 | if (CRM_Utils_Array::value('import', $field)) { | |
482 | if ($prefix) { | |
483 | self::$_import['product'] = & $fields[$name]; | |
484 | } else { | |
485 | self::$_import[$name] = & $fields[$name]; | |
486 | } | |
487 | } | |
488 | } | |
489 | } | |
490 | return self::$_import; | |
491 | } | |
492 | /** | |
493 | * Returns the list of fields that can be exported | |
494 | * | |
495 | * @param bool $prefix | |
496 | * | |
497 | * @return array | |
498 | */ | |
499 | static function &export($prefix = false) { | |
500 | if (!(self::$_export)) { | |
501 | self::$_export = array(); | |
502 | $fields = self::fields(); | |
503 | foreach($fields as $name => $field) { | |
504 | if (CRM_Utils_Array::value('export', $field)) { | |
505 | if ($prefix) { | |
506 | self::$_export['product'] = & $fields[$name]; | |
507 | } else { | |
508 | self::$_export[$name] = & $fields[$name]; | |
509 | } | |
510 | } | |
511 | } | |
512 | } | |
513 | return self::$_export; | |
514 | } | |
515 | } |