Regenerate DAOs with readonly attribute for id fields
[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:bb4e1d1cd260bfde06a046bc596ac691)
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 * table which has the transaction
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('table which has the transaction'),
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 'add' => '1.7',
208 ],
209 'entity_id' => [
210 'name' => 'entity_id',
211 'type' => CRM_Utils_Type::T_INT,
212 'title' => ts('Line Item Entity'),
213 'description' => ts('entry in table'),
214 'required' => TRUE,
215 'where' => 'civicrm_line_item.entity_id',
216 'table_name' => 'civicrm_line_item',
217 'entity' => 'LineItem',
218 'bao' => 'CRM_Price_BAO_LineItem',
219 'localizable' => 0,
220 'add' => '1.7',
221 ],
222 'contribution_id' => [
223 'name' => 'contribution_id',
224 'type' => CRM_Utils_Type::T_INT,
225 'title' => ts('Contribution ID'),
226 'description' => ts('FK to civicrm_contribution'),
227 'where' => 'civicrm_line_item.contribution_id',
228 'table_name' => 'civicrm_line_item',
229 'entity' => 'LineItem',
230 'bao' => 'CRM_Price_BAO_LineItem',
231 'localizable' => 0,
232 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
233 'html' => [
234 'label' => ts("Contribution"),
235 ],
236 'add' => '4.5',
237 ],
238 'price_field_id' => [
239 'name' => 'price_field_id',
240 'type' => CRM_Utils_Type::T_INT,
241 'title' => ts('Price Field ID'),
242 'description' => ts('FK to civicrm_price_field'),
243 'where' => 'civicrm_line_item.price_field_id',
244 'table_name' => 'civicrm_line_item',
245 'entity' => 'LineItem',
246 'bao' => 'CRM_Price_BAO_LineItem',
247 'localizable' => 0,
248 'FKClassName' => 'CRM_Price_DAO_PriceField',
249 'html' => [
250 'label' => ts("Price Field"),
251 ],
252 'pseudoconstant' => [
253 'table' => 'civicrm_price_field',
254 'keyColumn' => 'id',
255 'labelColumn' => 'label',
256 'nameColumn' => 'name',
257 ],
258 'add' => '1.7',
259 ],
260 'label' => [
261 'name' => 'label',
262 'type' => CRM_Utils_Type::T_STRING,
263 'title' => ts('Line Item Label'),
264 'description' => ts('descriptive label for item - from price_field_value.label'),
265 'maxlength' => 255,
266 'size' => CRM_Utils_Type::HUGE,
267 'where' => 'civicrm_line_item.label',
268 'default' => 'NULL',
269 'table_name' => 'civicrm_line_item',
270 'entity' => 'LineItem',
271 'bao' => 'CRM_Price_BAO_LineItem',
272 'localizable' => 0,
273 'html' => [
274 'type' => 'Text',
275 ],
276 'add' => '1.7',
277 ],
278 'qty' => [
279 'name' => 'qty',
280 'type' => CRM_Utils_Type::T_MONEY,
281 'title' => ts('Line Item Quantity'),
282 'description' => ts('How many items ordered'),
283 'required' => TRUE,
284 'precision' => [
285 20,
286 2,
287 ],
288 'where' => 'civicrm_line_item.qty',
289 'table_name' => 'civicrm_line_item',
290 'entity' => 'LineItem',
291 'bao' => 'CRM_Price_BAO_LineItem',
292 'localizable' => 0,
293 'html' => [
294 'type' => 'Text',
295 ],
296 'add' => '1.7',
297 ],
298 'unit_price' => [
299 'name' => 'unit_price',
300 'type' => CRM_Utils_Type::T_MONEY,
301 'title' => ts('Unit Price'),
302 'description' => ts('price of each item'),
303 'required' => TRUE,
304 'precision' => [
305 20,
306 2,
307 ],
308 'where' => 'civicrm_line_item.unit_price',
309 'table_name' => 'civicrm_line_item',
310 'entity' => 'LineItem',
311 'bao' => 'CRM_Price_BAO_LineItem',
312 'localizable' => 0,
313 'html' => [
314 'type' => 'Text',
315 'label' => ts("Unit Price"),
316 ],
317 'add' => '1.7',
318 ],
319 'line_total' => [
320 'name' => 'line_total',
321 'type' => CRM_Utils_Type::T_MONEY,
322 'title' => ts('Line Item Total'),
323 'description' => ts('qty * unit_price'),
324 'required' => TRUE,
325 'precision' => [
326 20,
327 2,
328 ],
329 'where' => 'civicrm_line_item.line_total',
330 'table_name' => 'civicrm_line_item',
331 'entity' => 'LineItem',
332 'bao' => 'CRM_Price_BAO_LineItem',
333 'localizable' => 0,
334 'add' => '1.7',
335 ],
336 'participant_count' => [
337 'name' => 'participant_count',
338 'type' => CRM_Utils_Type::T_INT,
339 'title' => ts('Line Item Participant Count'),
340 'description' => ts('Participant count for field'),
341 'where' => 'civicrm_line_item.participant_count',
342 'default' => 'NULL',
343 'table_name' => 'civicrm_line_item',
344 'entity' => 'LineItem',
345 'bao' => 'CRM_Price_BAO_LineItem',
346 'localizable' => 0,
347 'html' => [
348 'type' => 'Text',
349 ],
350 'add' => '3.2',
351 ],
352 'price_field_value_id' => [
353 'name' => 'price_field_value_id',
354 'type' => CRM_Utils_Type::T_INT,
355 'title' => ts('Option ID'),
356 'description' => ts('FK to civicrm_price_field_value'),
357 'where' => 'civicrm_line_item.price_field_value_id',
358 'default' => 'NULL',
359 'table_name' => 'civicrm_line_item',
360 'entity' => 'LineItem',
361 'bao' => 'CRM_Price_BAO_LineItem',
362 'localizable' => 0,
363 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue',
364 'html' => [
365 'label' => ts("Option"),
366 ],
367 'pseudoconstant' => [
368 'table' => 'civicrm_price_field_value',
369 'keyColumn' => 'id',
370 'labelColumn' => 'label',
371 'nameColumn' => 'name',
372 ],
373 'add' => '3.3',
374 ],
375 'financial_type_id' => [
376 'name' => 'financial_type_id',
377 'type' => CRM_Utils_Type::T_INT,
378 'title' => ts('Financial Type ID'),
379 'description' => ts('FK to Financial Type.'),
380 'where' => 'civicrm_line_item.financial_type_id',
381 'default' => 'NULL',
382 'table_name' => 'civicrm_line_item',
383 'entity' => 'LineItem',
384 'bao' => 'CRM_Price_BAO_LineItem',
385 'localizable' => 0,
386 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
387 'html' => [
388 'type' => 'Select',
389 'label' => ts("Financial Type"),
390 ],
391 'pseudoconstant' => [
392 'table' => 'civicrm_financial_type',
393 'keyColumn' => 'id',
394 'labelColumn' => 'name',
395 ],
396 'add' => '4.3',
397 ],
398 'non_deductible_amount' => [
399 'name' => 'non_deductible_amount',
400 'type' => CRM_Utils_Type::T_MONEY,
401 'title' => ts('Non-deductible Amount'),
402 'description' => ts('Portion of total amount which is NOT tax deductible.'),
403 'required' => TRUE,
404 'precision' => [
405 20,
406 2,
407 ],
408 'where' => 'civicrm_line_item.non_deductible_amount',
409 'headerPattern' => '/non?.?deduct/i',
410 'dataPattern' => '/^\d+(\.\d{2})?$/',
411 'default' => '0.0',
412 'table_name' => 'civicrm_line_item',
413 'entity' => 'LineItem',
414 'bao' => 'CRM_Price_BAO_LineItem',
415 'localizable' => 0,
416 'html' => [
417 'type' => 'Text',
418 ],
419 'add' => '4.7',
420 ],
421 'tax_amount' => [
422 'name' => 'tax_amount',
423 'type' => CRM_Utils_Type::T_MONEY,
424 'title' => ts('Tax Amount'),
425 'description' => ts('tax of each item'),
426 'precision' => [
427 20,
428 2,
429 ],
430 'import' => TRUE,
431 'where' => 'civicrm_line_item.tax_amount',
432 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
433 'dataPattern' => '/^\d+(\.\d{2})?$/',
434 'export' => TRUE,
435 'table_name' => 'civicrm_line_item',
436 'entity' => 'LineItem',
437 'bao' => 'CRM_Price_BAO_LineItem',
438 'localizable' => 0,
439 'html' => [
440 'type' => 'Text',
441 ],
442 'add' => '4.6',
443 ],
444 ];
445 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
446 }
447 return Civi::$statics[__CLASS__]['fields'];
448 }
449
450 /**
451 * Return a mapping from field-name to the corresponding key (as used in fields()).
452 *
453 * @return array
454 * Array(string $name => string $uniqueName).
455 */
456 public static function &fieldKeys() {
457 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
458 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
459 }
460 return Civi::$statics[__CLASS__]['fieldKeys'];
461 }
462
463 /**
464 * Returns the names of this table
465 *
466 * @return string
467 */
468 public static function getTableName() {
469 return self::$_tableName;
470 }
471
472 /**
473 * Returns if this table needs to be logged
474 *
475 * @return bool
476 */
477 public function getLog() {
478 return self::$_log;
479 }
480
481 /**
482 * Returns the list of fields that can be imported
483 *
484 * @param bool $prefix
485 *
486 * @return array
487 */
488 public static function &import($prefix = FALSE) {
489 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'line_item', $prefix, []);
490 return $r;
491 }
492
493 /**
494 * Returns the list of fields that can be exported
495 *
496 * @param bool $prefix
497 *
498 * @return array
499 */
500 public static function &export($prefix = FALSE) {
501 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'line_item', $prefix, []);
502 return $r;
503 }
504
505 /**
506 * Returns the list of indices
507 *
508 * @param bool $localize
509 *
510 * @return array
511 */
512 public static function indices($localize = TRUE) {
513 $indices = [
514 'index_entity' => [
515 'name' => 'index_entity',
516 'field' => [
517 0 => 'entity_table',
518 1 => 'entity_id',
519 ],
520 'localizable' => FALSE,
521 'sig' => 'civicrm_line_item::0::entity_table::entity_id',
522 ],
523 'UI_line_item_value' => [
524 'name' => 'UI_line_item_value',
525 'field' => [
526 0 => 'entity_table',
527 1 => 'entity_id',
528 2 => 'contribution_id',
529 3 => 'price_field_value_id',
530 4 => 'price_field_id',
531 ],
532 'localizable' => FALSE,
533 'unique' => TRUE,
534 'sig' => 'civicrm_line_item::1::entity_table::entity_id::contribution_id::price_field_value_id::price_field_id',
535 ],
536 ];
537 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
538 }
539
540 }