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