5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Price/LineItem.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:8455f09e75cc04248153812b7fdd6741)
13 * Database access object for the LineItem entity.
15 class CRM_Price_DAO_LineItem
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.7';
18 const COMPONENT
= 'CiviContribute';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_line_item';
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
32 public static $_log = TRUE;
42 * table which has the transaction
56 * FK to civicrm_contribution
60 public $contribution_id;
63 * FK to civicrm_price_field
67 public $price_field_id;
70 * descriptive label for item - from price_field_value.label
77 * How many items ordered
98 * Participant count for field
102 public $participant_count;
105 * FK to civicrm_price_field_value
109 public $price_field_value_id;
112 * FK to Financial Type.
116 public $financial_type_id;
119 * Portion of total amount which is NOT tax deductible.
123 public $non_deductible_amount;
135 public function __construct() {
136 $this->__table
= 'civicrm_line_item';
137 parent
::__construct();
141 * Returns localized title of this entity.
143 * @param bool $plural
144 * Whether to return the plural version of the title.
146 public static function getEntityTitle($plural = FALSE) {
147 return $plural ?
ts('Line Items') : ts('Line Item');
151 * Returns foreign keys and entity references.
154 * [CRM_Core_Reference_Interface]
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']);
166 return Civi
::$statics[__CLASS__
]['links'];
170 * Returns all the column names of this table
174 public static function &fields() {
175 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
176 Civi
::$statics[__CLASS__
]['fields'] = [
179 'type' => CRM_Utils_Type
::T_INT
,
180 'title' => ts('Line Item ID'),
181 'description' => ts('Line Item'),
183 'where' => 'civicrm_line_item.id',
184 'table_name' => 'civicrm_line_item',
185 'entity' => 'LineItem',
186 'bao' => 'CRM_Price_BAO_LineItem',
194 'name' => 'entity_table',
195 'type' => CRM_Utils_Type
::T_STRING
,
196 'title' => ts('Line Item Entity Type'),
197 'description' => ts('table which has the transaction'),
200 'size' => CRM_Utils_Type
::BIG
,
201 'where' => 'civicrm_line_item.entity_table',
202 'table_name' => 'civicrm_line_item',
203 'entity' => 'LineItem',
204 'bao' => 'CRM_Price_BAO_LineItem',
209 'name' => 'entity_id',
210 'type' => CRM_Utils_Type
::T_INT
,
211 'title' => ts('Line Item Entity'),
212 'description' => ts('entry in table'),
214 'where' => 'civicrm_line_item.entity_id',
215 'table_name' => 'civicrm_line_item',
216 'entity' => 'LineItem',
217 'bao' => 'CRM_Price_BAO_LineItem',
221 'contribution_id' => [
222 'name' => 'contribution_id',
223 'type' => CRM_Utils_Type
::T_INT
,
224 'title' => ts('Contribution ID'),
225 'description' => ts('FK to civicrm_contribution'),
226 'where' => 'civicrm_line_item.contribution_id',
227 'table_name' => 'civicrm_line_item',
228 'entity' => 'LineItem',
229 'bao' => 'CRM_Price_BAO_LineItem',
231 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
233 'label' => ts("Contribution"),
237 'price_field_id' => [
238 'name' => 'price_field_id',
239 'type' => CRM_Utils_Type
::T_INT
,
240 'title' => ts('Price Field ID'),
241 'description' => ts('FK to civicrm_price_field'),
242 'where' => 'civicrm_line_item.price_field_id',
243 'table_name' => 'civicrm_line_item',
244 'entity' => 'LineItem',
245 'bao' => 'CRM_Price_BAO_LineItem',
247 'FKClassName' => 'CRM_Price_DAO_PriceField',
249 'label' => ts("Price Field"),
251 'pseudoconstant' => [
252 'table' => 'civicrm_price_field',
254 'labelColumn' => 'label',
255 'nameColumn' => 'name',
261 'type' => CRM_Utils_Type
::T_STRING
,
262 'title' => ts('Line Item Label'),
263 'description' => ts('descriptive label for item - from price_field_value.label'),
265 'size' => CRM_Utils_Type
::HUGE
,
266 'where' => 'civicrm_line_item.label',
268 'table_name' => 'civicrm_line_item',
269 'entity' => 'LineItem',
270 'bao' => 'CRM_Price_BAO_LineItem',
279 'type' => CRM_Utils_Type
::T_MONEY
,
280 'title' => ts('Line Item Quantity'),
281 'description' => ts('How many items ordered'),
287 'where' => 'civicrm_line_item.qty',
288 'table_name' => 'civicrm_line_item',
289 'entity' => 'LineItem',
290 'bao' => 'CRM_Price_BAO_LineItem',
298 'name' => 'unit_price',
299 'type' => CRM_Utils_Type
::T_MONEY
,
300 'title' => ts('Unit Price'),
301 'description' => ts('price of each item'),
307 'where' => 'civicrm_line_item.unit_price',
308 'table_name' => 'civicrm_line_item',
309 'entity' => 'LineItem',
310 'bao' => 'CRM_Price_BAO_LineItem',
318 'name' => 'line_total',
319 'type' => CRM_Utils_Type
::T_MONEY
,
320 'title' => ts('Line Item Total'),
321 'description' => ts('qty * unit_price'),
327 'where' => 'civicrm_line_item.line_total',
328 'table_name' => 'civicrm_line_item',
329 'entity' => 'LineItem',
330 'bao' => 'CRM_Price_BAO_LineItem',
334 'participant_count' => [
335 'name' => 'participant_count',
336 'type' => CRM_Utils_Type
::T_INT
,
337 'title' => ts('Line Item Participant Count'),
338 'description' => ts('Participant count for field'),
339 'where' => 'civicrm_line_item.participant_count',
341 'table_name' => 'civicrm_line_item',
342 'entity' => 'LineItem',
343 'bao' => 'CRM_Price_BAO_LineItem',
350 'price_field_value_id' => [
351 'name' => 'price_field_value_id',
352 'type' => CRM_Utils_Type
::T_INT
,
353 'title' => ts('Option ID'),
354 'description' => ts('FK to civicrm_price_field_value'),
355 'where' => 'civicrm_line_item.price_field_value_id',
357 'table_name' => 'civicrm_line_item',
358 'entity' => 'LineItem',
359 'bao' => 'CRM_Price_BAO_LineItem',
361 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue',
363 'label' => ts("Option"),
365 'pseudoconstant' => [
366 'table' => 'civicrm_price_field_value',
368 'labelColumn' => 'label',
369 'nameColumn' => 'name',
373 'financial_type_id' => [
374 'name' => 'financial_type_id',
375 'type' => CRM_Utils_Type
::T_INT
,
376 'title' => ts('Financial Type ID'),
377 'description' => ts('FK to Financial Type.'),
378 'where' => 'civicrm_line_item.financial_type_id',
380 'table_name' => 'civicrm_line_item',
381 'entity' => 'LineItem',
382 'bao' => 'CRM_Price_BAO_LineItem',
384 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
387 'label' => ts("Financial Type"),
389 'pseudoconstant' => [
390 'table' => 'civicrm_financial_type',
392 'labelColumn' => 'name',
396 'non_deductible_amount' => [
397 'name' => 'non_deductible_amount',
398 'type' => CRM_Utils_Type
::T_MONEY
,
399 'title' => ts('Non-deductible Amount'),
400 'description' => ts('Portion of total amount which is NOT tax deductible.'),
406 'where' => 'civicrm_line_item.non_deductible_amount',
407 'headerPattern' => '/non?.?deduct/i',
408 'dataPattern' => '/^\d+(\.\d{2})?$/',
410 'table_name' => 'civicrm_line_item',
411 'entity' => 'LineItem',
412 'bao' => 'CRM_Price_BAO_LineItem',
420 'name' => 'tax_amount',
421 'type' => CRM_Utils_Type
::T_MONEY
,
422 'title' => ts('Tax Amount'),
423 'description' => ts('tax of each item'),
429 'where' => 'civicrm_line_item.tax_amount',
430 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
431 'dataPattern' => '/^\d+(\.\d{2})?$/',
433 'table_name' => 'civicrm_line_item',
434 'entity' => 'LineItem',
435 'bao' => 'CRM_Price_BAO_LineItem',
443 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
445 return Civi
::$statics[__CLASS__
]['fields'];
449 * Return a mapping from field-name to the corresponding key (as used in fields()).
452 * Array(string $name => string $uniqueName).
454 public static function &fieldKeys() {
455 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
456 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
458 return Civi
::$statics[__CLASS__
]['fieldKeys'];
462 * Returns the names of this table
466 public static function getTableName() {
467 return self
::$_tableName;
471 * Returns if this table needs to be logged
475 public function getLog() {
480 * Returns the list of fields that can be imported
482 * @param bool $prefix
486 public static function &import($prefix = FALSE) {
487 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'line_item', $prefix, []);
492 * Returns the list of fields that can be exported
494 * @param bool $prefix
498 public static function &export($prefix = FALSE) {
499 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'line_item', $prefix, []);
504 * Returns the list of indices
506 * @param bool $localize
510 public static function indices($localize = TRUE) {
513 'name' => 'index_entity',
518 'localizable' => FALSE,
519 'sig' => 'civicrm_line_item::0::entity_table::entity_id',
521 'UI_line_item_value' => [
522 'name' => 'UI_line_item_value',
526 2 => 'contribution_id',
527 3 => 'price_field_value_id',
528 4 => 'price_field_id',
530 'localizable' => FALSE,
532 'sig' => 'civicrm_line_item::1::entity_table::entity_id::contribution_id::price_field_value_id::price_field_id',
535 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;