Merge pull request #20713 from totten/5.39-setup-url
[civicrm-core.git] / CRM / Price / DAO / LineItem.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Price/LineItem.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:588f54f07db70f636888c88374b6b5b1)
10 */
11
12 /**
13 * Database access object for the LineItem entity.
14 */
15 class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.7';
18 const COMPONENT = 'CiviContribute';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_line_item';
26
27 /**
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 *
30 * @var bool
31 */
32 public static $_log = TRUE;
33
34 /**
35 * Line Item
36 *
37 * @var int
38 */
39 public $id;
40
41 /**
42 * May contain civicrm_contribution, civicrm_participant or civicrm_membership
43 *
44 * @var string
45 */
46 public $entity_table;
47
48 /**
49 * entry in table
50 *
51 * @var int
52 */
53 public $entity_id;
54
55 /**
56 * FK to civicrm_contribution
57 *
58 * @var int
59 */
60 public $contribution_id;
61
62 /**
63 * FK to civicrm_price_field
64 *
65 * @var int
66 */
67 public $price_field_id;
68
69 /**
70 * descriptive label for item - from price_field_value.label
71 *
72 * @var string
73 */
74 public $label;
75
76 /**
77 * How many items ordered
78 *
79 * @var float
80 */
81 public $qty;
82
83 /**
84 * price of each item
85 *
86 * @var float
87 */
88 public $unit_price;
89
90 /**
91 * qty * unit_price
92 *
93 * @var float
94 */
95 public $line_total;
96
97 /**
98 * Participant count for field
99 *
100 * @var int
101 */
102 public $participant_count;
103
104 /**
105 * FK to civicrm_price_field_value
106 *
107 * @var int
108 */
109 public $price_field_value_id;
110
111 /**
112 * FK to Financial Type.
113 *
114 * @var int
115 */
116 public $financial_type_id;
117
118 /**
119 * Portion of total amount which is NOT tax deductible.
120 *
121 * @var float
122 */
123 public $non_deductible_amount;
124
125 /**
126 * tax of each item
127 *
128 * @var float
129 */
130 public $tax_amount;
131
132 /**
133 * Class constructor.
134 */
135 public function __construct() {
136 $this->__table = 'civicrm_line_item';
137 parent::__construct();
138 }
139
140 /**
141 * Returns localized title of this entity.
142 *
143 * @param bool $plural
144 * Whether to return the plural version of the title.
145 */
146 public static function getEntityTitle($plural = FALSE) {
147 return $plural ? ts('Line Items') : ts('Line Item');
148 }
149
150 /**
151 * Returns foreign keys and entity references.
152 *
153 * @return array
154 * [CRM_Core_Reference_Interface]
155 */
156 public static function getReferenceColumns() {
157 if (!isset(Civi::$statics[__CLASS__]['links'])) {
158 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
159 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id');
160 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_field_id', 'civicrm_price_field', 'id');
161 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_field_value_id', 'civicrm_price_field_value', 'id');
162 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
163 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
164 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
165 }
166 return Civi::$statics[__CLASS__]['links'];
167 }
168
169 /**
170 * Returns all the column names of this table
171 *
172 * @return array
173 */
174 public static function &fields() {
175 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
176 Civi::$statics[__CLASS__]['fields'] = [
177 'id' => [
178 'name' => 'id',
179 'type' => CRM_Utils_Type::T_INT,
180 'title' => ts('Line Item ID'),
181 'description' => ts('Line Item'),
182 'required' => TRUE,
183 'where' => 'civicrm_line_item.id',
184 'table_name' => 'civicrm_line_item',
185 'entity' => 'LineItem',
186 'bao' => 'CRM_Price_BAO_LineItem',
187 'localizable' => 0,
188 'html' => [
189 'type' => 'Number',
190 ],
191 'readonly' => TRUE,
192 'add' => '1.7',
193 ],
194 'entity_table' => [
195 'name' => 'entity_table',
196 'type' => CRM_Utils_Type::T_STRING,
197 'title' => ts('Line Item Entity Type'),
198 'description' => ts('May contain civicrm_contribution, civicrm_participant or civicrm_membership'),
199 'required' => TRUE,
200 'maxlength' => 64,
201 'size' => CRM_Utils_Type::BIG,
202 'where' => 'civicrm_line_item.entity_table',
203 'table_name' => 'civicrm_line_item',
204 'entity' => 'LineItem',
205 'bao' => 'CRM_Price_BAO_LineItem',
206 'localizable' => 0,
207 'pseudoconstant' => [
208 'callback' => 'CRM_Price_BAO_LineItem::entityTables',
209 ],
210 'add' => '1.7',
211 ],
212 'entity_id' => [
213 'name' => 'entity_id',
214 'type' => CRM_Utils_Type::T_INT,
215 'title' => ts('Line Item Entity'),
216 'description' => ts('entry in table'),
217 'required' => TRUE,
218 'where' => 'civicrm_line_item.entity_id',
219 'table_name' => 'civicrm_line_item',
220 'entity' => 'LineItem',
221 'bao' => 'CRM_Price_BAO_LineItem',
222 'localizable' => 0,
223 'add' => '1.7',
224 ],
225 'contribution_id' => [
226 'name' => 'contribution_id',
227 'type' => CRM_Utils_Type::T_INT,
228 'title' => ts('Contribution ID'),
229 'description' => ts('FK to civicrm_contribution'),
230 'where' => 'civicrm_line_item.contribution_id',
231 'table_name' => 'civicrm_line_item',
232 'entity' => 'LineItem',
233 'bao' => 'CRM_Price_BAO_LineItem',
234 'localizable' => 0,
235 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
236 'html' => [
237 'label' => ts("Contribution"),
238 ],
239 'add' => '4.5',
240 ],
241 'price_field_id' => [
242 'name' => 'price_field_id',
243 'type' => CRM_Utils_Type::T_INT,
244 'title' => ts('Price Field ID'),
245 'description' => ts('FK to civicrm_price_field'),
246 'where' => 'civicrm_line_item.price_field_id',
247 'table_name' => 'civicrm_line_item',
248 'entity' => 'LineItem',
249 'bao' => 'CRM_Price_BAO_LineItem',
250 'localizable' => 0,
251 'FKClassName' => 'CRM_Price_DAO_PriceField',
252 'html' => [
253 'label' => ts("Price Field"),
254 ],
255 'pseudoconstant' => [
256 'table' => 'civicrm_price_field',
257 'keyColumn' => 'id',
258 'labelColumn' => 'label',
259 'nameColumn' => 'name',
260 ],
261 'add' => '1.7',
262 ],
263 'label' => [
264 'name' => 'label',
265 'type' => CRM_Utils_Type::T_STRING,
266 'title' => ts('Line Item Label'),
267 'description' => ts('descriptive label for item - from price_field_value.label'),
268 'maxlength' => 255,
269 'size' => CRM_Utils_Type::HUGE,
270 'where' => 'civicrm_line_item.label',
271 'default' => 'NULL',
272 'table_name' => 'civicrm_line_item',
273 'entity' => 'LineItem',
274 'bao' => 'CRM_Price_BAO_LineItem',
275 'localizable' => 0,
276 'html' => [
277 'type' => 'Text',
278 ],
279 'add' => '1.7',
280 ],
281 'qty' => [
282 'name' => 'qty',
283 'type' => CRM_Utils_Type::T_MONEY,
284 'title' => ts('Line Item Quantity'),
285 'description' => ts('How many items ordered'),
286 'required' => TRUE,
287 'precision' => [
288 20,
289 2,
290 ],
291 'where' => 'civicrm_line_item.qty',
292 'table_name' => 'civicrm_line_item',
293 'entity' => 'LineItem',
294 'bao' => 'CRM_Price_BAO_LineItem',
295 'localizable' => 0,
296 'html' => [
297 'type' => 'Text',
298 ],
299 'add' => '1.7',
300 ],
301 'unit_price' => [
302 'name' => 'unit_price',
303 'type' => CRM_Utils_Type::T_MONEY,
304 'title' => ts('Unit Price'),
305 'description' => ts('price of each item'),
306 'required' => TRUE,
307 'precision' => [
308 20,
309 2,
310 ],
311 'where' => 'civicrm_line_item.unit_price',
312 'table_name' => 'civicrm_line_item',
313 'entity' => 'LineItem',
314 'bao' => 'CRM_Price_BAO_LineItem',
315 'localizable' => 0,
316 'html' => [
317 'type' => 'Text',
318 'label' => ts("Unit Price"),
319 ],
320 'add' => '1.7',
321 ],
322 'line_total' => [
323 'name' => 'line_total',
324 'type' => CRM_Utils_Type::T_MONEY,
325 'title' => ts('Line Item Total'),
326 'description' => ts('qty * unit_price'),
327 'required' => TRUE,
328 'precision' => [
329 20,
330 2,
331 ],
332 'where' => 'civicrm_line_item.line_total',
333 'table_name' => 'civicrm_line_item',
334 'entity' => 'LineItem',
335 'bao' => 'CRM_Price_BAO_LineItem',
336 'localizable' => 0,
337 'add' => '1.7',
338 ],
339 'participant_count' => [
340 'name' => 'participant_count',
341 'type' => CRM_Utils_Type::T_INT,
342 'title' => ts('Line Item Participant Count'),
343 'description' => ts('Participant count for field'),
344 'where' => 'civicrm_line_item.participant_count',
345 'default' => 'NULL',
346 'table_name' => 'civicrm_line_item',
347 'entity' => 'LineItem',
348 'bao' => 'CRM_Price_BAO_LineItem',
349 'localizable' => 0,
350 'html' => [
351 'type' => 'Text',
352 ],
353 'add' => '3.2',
354 ],
355 'price_field_value_id' => [
356 'name' => 'price_field_value_id',
357 'type' => CRM_Utils_Type::T_INT,
358 'title' => ts('Option ID'),
359 'description' => ts('FK to civicrm_price_field_value'),
360 'where' => 'civicrm_line_item.price_field_value_id',
361 'default' => 'NULL',
362 'table_name' => 'civicrm_line_item',
363 'entity' => 'LineItem',
364 'bao' => 'CRM_Price_BAO_LineItem',
365 'localizable' => 0,
366 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue',
367 'html' => [
368 'label' => ts("Option"),
369 ],
370 'pseudoconstant' => [
371 'table' => 'civicrm_price_field_value',
372 'keyColumn' => 'id',
373 'labelColumn' => 'label',
374 'nameColumn' => 'name',
375 ],
376 'add' => '3.3',
377 ],
378 'financial_type_id' => [
379 'name' => 'financial_type_id',
380 'type' => CRM_Utils_Type::T_INT,
381 'title' => ts('Financial Type ID'),
382 'description' => ts('FK to Financial Type.'),
383 'where' => 'civicrm_line_item.financial_type_id',
384 'default' => 'NULL',
385 'table_name' => 'civicrm_line_item',
386 'entity' => 'LineItem',
387 'bao' => 'CRM_Price_BAO_LineItem',
388 'localizable' => 0,
389 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
390 'html' => [
391 'type' => 'Select',
392 'label' => ts("Financial Type"),
393 ],
394 'pseudoconstant' => [
395 'table' => 'civicrm_financial_type',
396 'keyColumn' => 'id',
397 'labelColumn' => 'name',
398 ],
399 'add' => '4.3',
400 ],
401 'non_deductible_amount' => [
402 'name' => 'non_deductible_amount',
403 'type' => CRM_Utils_Type::T_MONEY,
404 'title' => ts('Non-deductible Amount'),
405 'description' => ts('Portion of total amount which is NOT tax deductible.'),
406 'required' => TRUE,
407 'precision' => [
408 20,
409 2,
410 ],
411 'where' => 'civicrm_line_item.non_deductible_amount',
412 'headerPattern' => '/non?.?deduct/i',
413 'dataPattern' => '/^\d+(\.\d{2})?$/',
414 'default' => '0.0',
415 'table_name' => 'civicrm_line_item',
416 'entity' => 'LineItem',
417 'bao' => 'CRM_Price_BAO_LineItem',
418 'localizable' => 0,
419 'html' => [
420 'type' => 'Text',
421 ],
422 'add' => '4.7',
423 ],
424 'tax_amount' => [
425 'name' => 'tax_amount',
426 'type' => CRM_Utils_Type::T_MONEY,
427 'title' => ts('Tax Amount'),
428 'description' => ts('tax of each item'),
429 'precision' => [
430 20,
431 2,
432 ],
433 'import' => TRUE,
434 'where' => 'civicrm_line_item.tax_amount',
435 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
436 'dataPattern' => '/^\d+(\.\d{2})?$/',
437 'export' => TRUE,
438 'table_name' => 'civicrm_line_item',
439 'entity' => 'LineItem',
440 'bao' => 'CRM_Price_BAO_LineItem',
441 'localizable' => 0,
442 'html' => [
443 'type' => 'Text',
444 ],
445 'add' => '4.6',
446 ],
447 ];
448 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
449 }
450 return Civi::$statics[__CLASS__]['fields'];
451 }
452
453 /**
454 * Return a mapping from field-name to the corresponding key (as used in fields()).
455 *
456 * @return array
457 * Array(string $name => string $uniqueName).
458 */
459 public static function &fieldKeys() {
460 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
461 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
462 }
463 return Civi::$statics[__CLASS__]['fieldKeys'];
464 }
465
466 /**
467 * Returns the names of this table
468 *
469 * @return string
470 */
471 public static function getTableName() {
472 return self::$_tableName;
473 }
474
475 /**
476 * Returns if this table needs to be logged
477 *
478 * @return bool
479 */
480 public function getLog() {
481 return self::$_log;
482 }
483
484 /**
485 * Returns the list of fields that can be imported
486 *
487 * @param bool $prefix
488 *
489 * @return array
490 */
491 public static function &import($prefix = FALSE) {
492 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'line_item', $prefix, []);
493 return $r;
494 }
495
496 /**
497 * Returns the list of fields that can be exported
498 *
499 * @param bool $prefix
500 *
501 * @return array
502 */
503 public static function &export($prefix = FALSE) {
504 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'line_item', $prefix, []);
505 return $r;
506 }
507
508 /**
509 * Returns the list of indices
510 *
511 * @param bool $localize
512 *
513 * @return array
514 */
515 public static function indices($localize = TRUE) {
516 $indices = [
517 'UI_line_item_value' => [
518 'name' => 'UI_line_item_value',
519 'field' => [
520 0 => 'entity_id',
521 1 => 'entity_table',
522 2 => 'contribution_id',
523 3 => 'price_field_value_id',
524 4 => 'price_field_id',
525 ],
526 'localizable' => FALSE,
527 'unique' => TRUE,
528 'sig' => 'civicrm_line_item::1::entity_id::entity_table::contribution_id::price_field_value_id::price_field_id',
529 ],
530 ];
531 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
532 }
533
534 }