commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / CRM / Price / DAO / LineItem.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/Price/LineItem.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_Price_DAO_LineItem extends CRM_Core_DAO {
37 /**
38 * static instance to hold the table name
39 *
40 * @var string
41 */
42 static $_tableName = 'civicrm_line_item';
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 * Line Item
84 *
85 * @var int unsigned
86 */
87 public $id;
88 /**
89 * table which has the transaction
90 *
91 * @var string
92 */
93 public $entity_table;
94 /**
95 * entry in table
96 *
97 * @var int unsigned
98 */
99 public $entity_id;
100 /**
101 * FK to civicrm_contribution
102 *
103 * @var int unsigned
104 */
105 public $contribution_id;
106 /**
107 * FK to civicrm_price_field
108 *
109 * @var int unsigned
110 */
111 public $price_field_id;
112 /**
113 * descriptive label for item - from price_field_value.label
114 *
115 * @var string
116 */
117 public $label;
118 /**
119 * How many items ordered
120 *
121 * @var float
122 */
123 public $qty;
124 /**
125 * price of each item
126 *
127 * @var float
128 */
129 public $unit_price;
130 /**
131 * qty * unit_price
132 *
133 * @var float
134 */
135 public $line_total;
136 /**
137 * Participant count for field
138 *
139 * @var int unsigned
140 */
141 public $participant_count;
142 /**
143 * FK to civicrm_price_field_value
144 *
145 * @var int unsigned
146 */
147 public $price_field_value_id;
148 /**
149 * FK to Financial Type.
150 *
151 * @var int unsigned
152 */
153 public $financial_type_id;
154 /**
155 * Tax-deductible portion of the amount
156 *
157 * @var float
158 */
159 public $deductible_amount;
160 /**
161 * tax of each item
162 *
163 * @var float
164 */
165 public $tax_amount;
166 /**
167 * class constructor
168 *
169 * @return civicrm_line_item
170 */
171 function __construct() {
172 $this->__table = 'civicrm_line_item';
173 parent::__construct();
174 }
175 /**
176 * Returns foreign keys and entity references
177 *
178 * @return array
179 * [CRM_Core_Reference_Interface]
180 */
181 static function getReferenceColumns() {
182 if (!self::$_links) {
183 self::$_links = static ::createReferenceColumns(__CLASS__);
184 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'contribution_id', 'civicrm_contribution', 'id');
185 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'price_field_id', 'civicrm_price_field', 'id');
186 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'price_field_value_id', 'civicrm_price_field_value', 'id');
187 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_type_id', 'civicrm_financial_type', 'id');
188 self::$_links[] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table');
189 }
190 return self::$_links;
191 }
192 /**
193 * Returns all the column names of this table
194 *
195 * @return array
196 */
197 static function &fields() {
198 if (!(self::$_fields)) {
199 self::$_fields = array(
200 'id' => array(
201 'name' => 'id',
202 'type' => CRM_Utils_Type::T_INT,
203 'title' => ts('Line Item ID') ,
204 'description' => 'Line Item',
205 'required' => true,
206 ) ,
207 'entity_table' => array(
208 'name' => 'entity_table',
209 'type' => CRM_Utils_Type::T_STRING,
210 'title' => ts('Line Item Entity Type') ,
211 'description' => 'table which has the transaction',
212 'required' => true,
213 'maxlength' => 64,
214 'size' => CRM_Utils_Type::BIG,
215 ) ,
216 'entity_id' => array(
217 'name' => 'entity_id',
218 'type' => CRM_Utils_Type::T_INT,
219 'title' => ts('Line Item Entity') ,
220 'description' => 'entry in table',
221 'required' => true,
222 ) ,
223 'contribution_id' => array(
224 'name' => 'contribution_id',
225 'type' => CRM_Utils_Type::T_INT,
226 'title' => ts('Line Item Contribution') ,
227 'description' => 'FK to civicrm_contribution',
228 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
229 ) ,
230 'price_field_id' => array(
231 'name' => 'price_field_id',
232 'type' => CRM_Utils_Type::T_INT,
233 'title' => ts('Line Item Price Field') ,
234 'description' => 'FK to civicrm_price_field',
235 'FKClassName' => 'CRM_Price_DAO_PriceField',
236 ) ,
237 'label' => array(
238 'name' => 'label',
239 'type' => CRM_Utils_Type::T_STRING,
240 'title' => ts('Line Item Label') ,
241 'description' => 'descriptive label for item - from price_field_value.label',
242 'maxlength' => 255,
243 'size' => CRM_Utils_Type::HUGE,
244 'default' => 'NULL',
245 'html' => array(
246 'type' => 'Text',
247 ) ,
248 ) ,
249 'qty' => array(
250 'name' => 'qty',
251 'type' => CRM_Utils_Type::T_MONEY,
252 'title' => ts('Line Item Quantity') ,
253 'description' => 'How many items ordered',
254 'required' => true,
255 'precision' => array(
256 20,
257 2
258 ) ,
259 'html' => array(
260 'type' => 'Text',
261 ) ,
262 ) ,
263 'unit_price' => array(
264 'name' => 'unit_price',
265 'type' => CRM_Utils_Type::T_MONEY,
266 'title' => ts('Unit Price') ,
267 'description' => 'price of each item',
268 'required' => true,
269 'precision' => array(
270 20,
271 2
272 ) ,
273 'html' => array(
274 'type' => 'Text',
275 ) ,
276 ) ,
277 'line_total' => array(
278 'name' => 'line_total',
279 'type' => CRM_Utils_Type::T_MONEY,
280 'title' => ts('Line Item Total') ,
281 'description' => 'qty * unit_price',
282 'required' => true,
283 'precision' => array(
284 20,
285 2
286 ) ,
287 ) ,
288 'participant_count' => array(
289 'name' => 'participant_count',
290 'type' => CRM_Utils_Type::T_INT,
291 'title' => ts('Line Item Participant Count') ,
292 'description' => 'Participant count for field',
293 'default' => 'NULL',
294 'html' => array(
295 'type' => 'Text',
296 ) ,
297 ) ,
298 'price_field_value_id' => array(
299 'name' => 'price_field_value_id',
300 'type' => CRM_Utils_Type::T_INT,
301 'title' => ts('Line Item Option') ,
302 'description' => 'FK to civicrm_price_field_value',
303 'default' => 'NULL',
304 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue',
305 ) ,
306 'financial_type_id' => array(
307 'name' => 'financial_type_id',
308 'type' => CRM_Utils_Type::T_INT,
309 'title' => ts('Financial Type') ,
310 'description' => 'FK to Financial Type.',
311 'default' => 'NULL',
312 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
313 'html' => array(
314 'type' => 'Select',
315 ) ,
316 'pseudoconstant' => array(
317 'table' => 'civicrm_financial_type',
318 'keyColumn' => 'id',
319 'labelColumn' => 'name',
320 )
321 ) ,
322 'deductible_amount' => array(
323 'name' => 'deductible_amount',
324 'type' => CRM_Utils_Type::T_MONEY,
325 'title' => ts('Deductible Amount') ,
326 'description' => 'Tax-deductible portion of the amount',
327 'required' => true,
328 'precision' => array(
329 20,
330 2
331 ) ,
332 'default' => '0.0',
333 'html' => array(
334 'type' => 'Text',
335 ) ,
336 ) ,
337 'tax_amount' => array(
338 'name' => 'tax_amount',
339 'type' => CRM_Utils_Type::T_MONEY,
340 'title' => ts('Tax Amount') ,
341 'description' => 'tax of each item',
342 'precision' => array(
343 20,
344 2
345 ) ,
346 'import' => true,
347 'where' => 'civicrm_line_item.tax_amount',
348 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
349 'dataPattern' => '/^\d+(\.\d{2})?$/',
350 'export' => true,
351 'html' => array(
352 'type' => 'Text',
353 ) ,
354 ) ,
355 );
356 }
357 return self::$_fields;
358 }
359 /**
360 * Returns an array containing, for each field, the arary key used for that
361 * field in self::$_fields.
362 *
363 * @return array
364 */
365 static function &fieldKeys() {
366 if (!(self::$_fieldKeys)) {
367 self::$_fieldKeys = array(
368 'id' => 'id',
369 'entity_table' => 'entity_table',
370 'entity_id' => 'entity_id',
371 'contribution_id' => 'contribution_id',
372 'price_field_id' => 'price_field_id',
373 'label' => 'label',
374 'qty' => 'qty',
375 'unit_price' => 'unit_price',
376 'line_total' => 'line_total',
377 'participant_count' => 'participant_count',
378 'price_field_value_id' => 'price_field_value_id',
379 'financial_type_id' => 'financial_type_id',
380 'deductible_amount' => 'deductible_amount',
381 'tax_amount' => 'tax_amount',
382 );
383 }
384 return self::$_fieldKeys;
385 }
386 /**
387 * Returns the names of this table
388 *
389 * @return string
390 */
391 static function getTableName() {
392 return self::$_tableName;
393 }
394 /**
395 * Returns if this table needs to be logged
396 *
397 * @return boolean
398 */
399 function getLog() {
400 return self::$_log;
401 }
402 /**
403 * Returns the list of fields that can be imported
404 *
405 * @param bool $prefix
406 *
407 * @return array
408 */
409 static function &import($prefix = false) {
410 if (!(self::$_import)) {
411 self::$_import = array();
412 $fields = self::fields();
413 foreach($fields as $name => $field) {
414 if (CRM_Utils_Array::value('import', $field)) {
415 if ($prefix) {
416 self::$_import['line_item'] = & $fields[$name];
417 } else {
418 self::$_import[$name] = & $fields[$name];
419 }
420 }
421 }
422 }
423 return self::$_import;
424 }
425 /**
426 * Returns the list of fields that can be exported
427 *
428 * @param bool $prefix
429 *
430 * @return array
431 */
432 static function &export($prefix = false) {
433 if (!(self::$_export)) {
434 self::$_export = array();
435 $fields = self::fields();
436 foreach($fields as $name => $field) {
437 if (CRM_Utils_Array::value('export', $field)) {
438 if ($prefix) {
439 self::$_export['line_item'] = & $fields[$name];
440 } else {
441 self::$_export[$name] = & $fields[$name];
442 }
443 }
444 }
445 }
446 return self::$_export;
447 }
448 }