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