Merge pull request #11062 from mattwire/CRM-21203_joomla_cli_3_8_0
[civicrm-core.git] / CRM / Price / DAO / LineItem.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/Price/LineItem.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
e7a6b91a 33 * (GenCodeChecksum:db7c7e55df64ed93a7152b5297d13d25)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
f41f0342 37/**
38 * CRM_Price_DAO_LineItem constructor.
39 */
e501603b
TO
40class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
41 /**
f41f0342 42 * Static instance to hold the table name.
e501603b
TO
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_line_item';
e501603b 47 /**
f41f0342 48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b
TO
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 * Line Item
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * table which has the transaction
61 *
62 * @var string
63 */
64 public $entity_table;
65 /**
66 * entry in table
67 *
68 * @var int unsigned
69 */
70 public $entity_id;
71 /**
72 * FK to civicrm_contribution
73 *
74 * @var int unsigned
75 */
76 public $contribution_id;
77 /**
78 * FK to civicrm_price_field
79 *
80 * @var int unsigned
81 */
82 public $price_field_id;
83 /**
84 * descriptive label for item - from price_field_value.label
85 *
86 * @var string
87 */
88 public $label;
89 /**
90 * How many items ordered
91 *
92 * @var float
93 */
94 public $qty;
95 /**
96 * price of each item
97 *
98 * @var float
99 */
100 public $unit_price;
101 /**
102 * qty * unit_price
103 *
104 * @var float
105 */
106 public $line_total;
107 /**
108 * Participant count for field
109 *
110 * @var int unsigned
111 */
112 public $participant_count;
113 /**
114 * FK to civicrm_price_field_value
115 *
116 * @var int unsigned
117 */
118 public $price_field_value_id;
119 /**
120 * FK to Financial Type.
121 *
122 * @var int unsigned
123 */
124 public $financial_type_id;
125 /**
5afce5ad 126 * Portion of total amount which is NOT tax deductible.
e501603b
TO
127 *
128 * @var float
129 */
5afce5ad 130 public $non_deductible_amount;
e501603b
TO
131 /**
132 * tax of each item
133 *
134 * @var float
135 */
136 public $tax_amount;
137 /**
f41f0342 138 * Class constructor.
e501603b
TO
139 */
140 function __construct() {
141 $this->__table = 'civicrm_line_item';
142 parent::__construct();
143 }
144 /**
f41f0342 145 * Returns foreign keys and entity references.
e501603b
TO
146 *
147 * @return array
148 * [CRM_Core_Reference_Interface]
149 */
150 static function getReferenceColumns() {
346aaaba
TO
151 if (!isset(Civi::$statics[__CLASS__]['links'])) {
152 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
153 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contribution_id', 'civicrm_contribution', 'id');
154 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'price_field_id', 'civicrm_price_field', 'id');
155 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'price_field_value_id', 'civicrm_price_field_value', 'id');
156 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_type_id', 'civicrm_financial_type', 'id');
157 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table');
158 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 159 }
346aaaba 160 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
161 }
162 /**
163 * Returns all the column names of this table
164 *
165 * @return array
166 */
167 static function &fields() {
346aaaba
TO
168 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
169 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
170 'id' => array(
171 'name' => 'id',
172 'type' => CRM_Utils_Type::T_INT,
173 'title' => ts('Line Item ID') ,
174 'description' => 'Line Item',
175 'required' => true,
522a26c9 176 'table_name' => 'civicrm_line_item',
177 'entity' => 'LineItem',
178 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 179 'localizable' => 0,
e501603b
TO
180 ) ,
181 'entity_table' => array(
182 'name' => 'entity_table',
183 'type' => CRM_Utils_Type::T_STRING,
184 'title' => ts('Line Item Entity Type') ,
185 'description' => 'table which has the transaction',
186 'required' => true,
187 'maxlength' => 64,
188 'size' => CRM_Utils_Type::BIG,
522a26c9 189 'table_name' => 'civicrm_line_item',
190 'entity' => 'LineItem',
191 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 192 'localizable' => 0,
e501603b
TO
193 ) ,
194 'entity_id' => array(
195 'name' => 'entity_id',
196 'type' => CRM_Utils_Type::T_INT,
197 'title' => ts('Line Item Entity') ,
198 'description' => 'entry in table',
199 'required' => true,
522a26c9 200 'table_name' => 'civicrm_line_item',
201 'entity' => 'LineItem',
202 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 203 'localizable' => 0,
e501603b
TO
204 ) ,
205 'contribution_id' => array(
206 'name' => 'contribution_id',
207 'type' => CRM_Utils_Type::T_INT,
208 'title' => ts('Line Item Contribution') ,
209 'description' => 'FK to civicrm_contribution',
522a26c9 210 'table_name' => 'civicrm_line_item',
211 'entity' => 'LineItem',
212 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 213 'localizable' => 0,
e501603b
TO
214 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
215 ) ,
216 'price_field_id' => array(
217 'name' => 'price_field_id',
218 'type' => CRM_Utils_Type::T_INT,
219 'title' => ts('Line Item Price Field') ,
220 'description' => 'FK to civicrm_price_field',
522a26c9 221 'table_name' => 'civicrm_line_item',
222 'entity' => 'LineItem',
223 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 224 'localizable' => 0,
e501603b
TO
225 'FKClassName' => 'CRM_Price_DAO_PriceField',
226 ) ,
227 'label' => array(
228 'name' => 'label',
229 'type' => CRM_Utils_Type::T_STRING,
230 'title' => ts('Line Item Label') ,
231 'description' => 'descriptive label for item - from price_field_value.label',
232 'maxlength' => 255,
233 'size' => CRM_Utils_Type::HUGE,
234 'default' => 'NULL',
522a26c9 235 'table_name' => 'civicrm_line_item',
236 'entity' => 'LineItem',
237 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 238 'localizable' => 0,
e501603b
TO
239 'html' => array(
240 'type' => 'Text',
241 ) ,
242 ) ,
243 'qty' => array(
244 'name' => 'qty',
245 'type' => CRM_Utils_Type::T_MONEY,
246 'title' => ts('Line Item Quantity') ,
247 'description' => 'How many items ordered',
248 'required' => true,
249 'precision' => array(
250 20,
251 2
252 ) ,
522a26c9 253 'table_name' => 'civicrm_line_item',
254 'entity' => 'LineItem',
255 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 256 'localizable' => 0,
e501603b
TO
257 'html' => array(
258 'type' => 'Text',
259 ) ,
260 ) ,
261 'unit_price' => array(
262 'name' => 'unit_price',
263 'type' => CRM_Utils_Type::T_MONEY,
264 'title' => ts('Unit Price') ,
265 'description' => 'price of each item',
266 'required' => true,
267 'precision' => array(
268 20,
269 2
270 ) ,
522a26c9 271 'table_name' => 'civicrm_line_item',
272 'entity' => 'LineItem',
273 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 274 'localizable' => 0,
e501603b
TO
275 'html' => array(
276 'type' => 'Text',
277 ) ,
278 ) ,
279 'line_total' => array(
280 'name' => 'line_total',
281 'type' => CRM_Utils_Type::T_MONEY,
282 'title' => ts('Line Item Total') ,
283 'description' => 'qty * unit_price',
284 'required' => true,
285 'precision' => array(
286 20,
287 2
288 ) ,
522a26c9 289 'table_name' => 'civicrm_line_item',
290 'entity' => 'LineItem',
291 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 292 'localizable' => 0,
e501603b
TO
293 ) ,
294 'participant_count' => array(
295 'name' => 'participant_count',
296 'type' => CRM_Utils_Type::T_INT,
297 'title' => ts('Line Item Participant Count') ,
298 'description' => 'Participant count for field',
299 'default' => 'NULL',
522a26c9 300 'table_name' => 'civicrm_line_item',
301 'entity' => 'LineItem',
302 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 303 'localizable' => 0,
e501603b
TO
304 'html' => array(
305 'type' => 'Text',
306 ) ,
307 ) ,
308 'price_field_value_id' => array(
309 'name' => 'price_field_value_id',
310 'type' => CRM_Utils_Type::T_INT,
311 'title' => ts('Line Item Option') ,
312 'description' => 'FK to civicrm_price_field_value',
313 'default' => 'NULL',
522a26c9 314 'table_name' => 'civicrm_line_item',
315 'entity' => 'LineItem',
316 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 317 'localizable' => 0,
e501603b
TO
318 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue',
319 ) ,
320 'financial_type_id' => array(
321 'name' => 'financial_type_id',
322 'type' => CRM_Utils_Type::T_INT,
323 'title' => ts('Financial Type') ,
324 'description' => 'FK to Financial Type.',
325 'default' => 'NULL',
522a26c9 326 'table_name' => 'civicrm_line_item',
327 'entity' => 'LineItem',
328 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 329 'localizable' => 0,
e501603b
TO
330 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
331 'html' => array(
332 'type' => 'Select',
333 ) ,
334 'pseudoconstant' => array(
335 'table' => 'civicrm_financial_type',
336 'keyColumn' => 'id',
337 'labelColumn' => 'name',
338 )
339 ) ,
5afce5ad 340 'non_deductible_amount' => array(
341 'name' => 'non_deductible_amount',
e501603b 342 'type' => CRM_Utils_Type::T_MONEY,
5afce5ad 343 'title' => ts('Non-deductible Amount') ,
344 'description' => 'Portion of total amount which is NOT tax deductible.',
e501603b
TO
345 'required' => true,
346 'precision' => array(
347 20,
348 2
349 ) ,
350 'default' => '0.0',
522a26c9 351 'table_name' => 'civicrm_line_item',
352 'entity' => 'LineItem',
353 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 354 'localizable' => 0,
e501603b
TO
355 'html' => array(
356 'type' => 'Text',
357 ) ,
358 ) ,
359 'tax_amount' => array(
360 'name' => 'tax_amount',
361 'type' => CRM_Utils_Type::T_MONEY,
362 'title' => ts('Tax Amount') ,
363 'description' => 'tax of each item',
364 'precision' => array(
365 20,
366 2
367 ) ,
368 'import' => true,
369 'where' => 'civicrm_line_item.tax_amount',
370 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
371 'dataPattern' => '/^\d+(\.\d{2})?$/',
372 'export' => true,
522a26c9 373 'table_name' => 'civicrm_line_item',
374 'entity' => 'LineItem',
375 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 376 'localizable' => 0,
e501603b
TO
377 'html' => array(
378 'type' => 'Text',
379 ) ,
380 ) ,
381 );
346aaaba 382 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 383 }
346aaaba 384 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
385 }
386 /**
bd8e0b14 387 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
388 *
389 * @return array
bd8e0b14 390 * Array(string $name => string $uniqueName).
e501603b
TO
391 */
392 static function &fieldKeys() {
bd8e0b14
TO
393 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
394 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 395 }
bd8e0b14 396 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
397 }
398 /**
399 * Returns the names of this table
400 *
401 * @return string
402 */
403 static function getTableName() {
404 return self::$_tableName;
405 }
406 /**
407 * Returns if this table needs to be logged
408 *
409 * @return boolean
410 */
411 function getLog() {
412 return self::$_log;
413 }
414 /**
415 * Returns the list of fields that can be imported
416 *
417 * @param bool $prefix
418 *
419 * @return array
420 */
421 static function &import($prefix = false) {
60808919
TO
422 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'line_item', $prefix, array());
423 return $r;
e501603b
TO
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) {
60808919
TO
433 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'line_item', $prefix, array());
434 return $r;
e501603b 435 }
e7a6b91a
AS
436 /**
437 * Returns the list of indices
438 */
439 public static function indices($localize = TRUE) {
440 $indices = array(
441 'index_entity' => array(
442 'name' => 'index_entity',
443 'field' => array(
444 0 => 'entity_table',
445 1 => 'entity_id',
446 ) ,
447 'localizable' => false,
448 'sig' => 'civicrm_line_item::0::entity_table::entity_id',
449 ) ,
450 'UI_line_item_value' => array(
451 'name' => 'UI_line_item_value',
452 'field' => array(
453 0 => 'entity_table',
454 1 => 'entity_id',
455 2 => 'contribution_id',
456 3 => 'price_field_value_id',
457 4 => 'price_field_id',
458 ) ,
459 'localizable' => false,
460 'unique' => true,
461 'sig' => 'civicrm_line_item::1::entity_table::entity_id::contribution_id::price_field_value_id::price_field_id',
462 ) ,
463 );
464 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
465 }
e501603b 466}