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:352b3e74d3a66e445f53670cecaf6d02)
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',
191 'name' => 'entity_table',
192 'type' => CRM_Utils_Type
::T_STRING
,
193 'title' => ts('Line Item Entity Type'),
194 'description' => ts('table which has the transaction'),
197 'size' => CRM_Utils_Type
::BIG
,
198 'where' => 'civicrm_line_item.entity_table',
199 'table_name' => 'civicrm_line_item',
200 'entity' => 'LineItem',
201 'bao' => 'CRM_Price_BAO_LineItem',
206 'name' => 'entity_id',
207 'type' => CRM_Utils_Type
::T_INT
,
208 'title' => ts('Line Item Entity'),
209 'description' => ts('entry in table'),
211 'where' => 'civicrm_line_item.entity_id',
212 'table_name' => 'civicrm_line_item',
213 'entity' => 'LineItem',
214 'bao' => 'CRM_Price_BAO_LineItem',
218 'contribution_id' => [
219 'name' => 'contribution_id',
220 'type' => CRM_Utils_Type
::T_INT
,
221 'title' => ts('Line Item Contribution'),
222 'description' => ts('FK to civicrm_contribution'),
223 'where' => 'civicrm_line_item.contribution_id',
224 'table_name' => 'civicrm_line_item',
225 'entity' => 'LineItem',
226 'bao' => 'CRM_Price_BAO_LineItem',
228 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
231 'price_field_id' => [
232 'name' => 'price_field_id',
233 'type' => CRM_Utils_Type
::T_INT
,
234 'title' => ts('Line Item Price Field'),
235 'description' => ts('FK to civicrm_price_field'),
236 'where' => 'civicrm_line_item.price_field_id',
237 'table_name' => 'civicrm_line_item',
238 'entity' => 'LineItem',
239 'bao' => 'CRM_Price_BAO_LineItem',
241 'FKClassName' => 'CRM_Price_DAO_PriceField',
242 'pseudoconstant' => [
243 'table' => 'civicrm_price_field',
245 'labelColumn' => 'label',
246 'nameColumn' => 'name',
252 'type' => CRM_Utils_Type
::T_STRING
,
253 'title' => ts('Line Item Label'),
254 'description' => ts('descriptive label for item - from price_field_value.label'),
256 'size' => CRM_Utils_Type
::HUGE
,
257 'where' => 'civicrm_line_item.label',
259 'table_name' => 'civicrm_line_item',
260 'entity' => 'LineItem',
261 'bao' => 'CRM_Price_BAO_LineItem',
270 'type' => CRM_Utils_Type
::T_MONEY
,
271 'title' => ts('Line Item Quantity'),
272 'description' => ts('How many items ordered'),
278 'where' => 'civicrm_line_item.qty',
279 'table_name' => 'civicrm_line_item',
280 'entity' => 'LineItem',
281 'bao' => 'CRM_Price_BAO_LineItem',
289 'name' => 'unit_price',
290 'type' => CRM_Utils_Type
::T_MONEY
,
291 'title' => ts('Unit Price'),
292 'description' => ts('price of each item'),
298 'where' => 'civicrm_line_item.unit_price',
299 'table_name' => 'civicrm_line_item',
300 'entity' => 'LineItem',
301 'bao' => 'CRM_Price_BAO_LineItem',
309 'name' => 'line_total',
310 'type' => CRM_Utils_Type
::T_MONEY
,
311 'title' => ts('Line Item Total'),
312 'description' => ts('qty * unit_price'),
318 'where' => 'civicrm_line_item.line_total',
319 'table_name' => 'civicrm_line_item',
320 'entity' => 'LineItem',
321 'bao' => 'CRM_Price_BAO_LineItem',
325 'participant_count' => [
326 'name' => 'participant_count',
327 'type' => CRM_Utils_Type
::T_INT
,
328 'title' => ts('Line Item Participant Count'),
329 'description' => ts('Participant count for field'),
330 'where' => 'civicrm_line_item.participant_count',
332 'table_name' => 'civicrm_line_item',
333 'entity' => 'LineItem',
334 'bao' => 'CRM_Price_BAO_LineItem',
341 'price_field_value_id' => [
342 'name' => 'price_field_value_id',
343 'type' => CRM_Utils_Type
::T_INT
,
344 'title' => ts('Line Item Option'),
345 'description' => ts('FK to civicrm_price_field_value'),
346 'where' => 'civicrm_line_item.price_field_value_id',
348 'table_name' => 'civicrm_line_item',
349 'entity' => 'LineItem',
350 'bao' => 'CRM_Price_BAO_LineItem',
352 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue',
353 'pseudoconstant' => [
354 'table' => 'civicrm_price_field_value',
356 'labelColumn' => 'label',
357 'nameColumn' => 'name',
361 'financial_type_id' => [
362 'name' => 'financial_type_id',
363 'type' => CRM_Utils_Type
::T_INT
,
364 'title' => ts('Financial Type ID'),
365 'description' => ts('FK to Financial Type.'),
366 'where' => 'civicrm_line_item.financial_type_id',
368 'table_name' => 'civicrm_line_item',
369 'entity' => 'LineItem',
370 'bao' => 'CRM_Price_BAO_LineItem',
372 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
375 'label' => ts("Financial Type"),
377 'pseudoconstant' => [
378 'table' => 'civicrm_financial_type',
380 'labelColumn' => 'name',
384 'non_deductible_amount' => [
385 'name' => 'non_deductible_amount',
386 'type' => CRM_Utils_Type
::T_MONEY
,
387 'title' => ts('Non-deductible Amount'),
388 'description' => ts('Portion of total amount which is NOT tax deductible.'),
394 'where' => 'civicrm_line_item.non_deductible_amount',
395 'headerPattern' => '/non?.?deduct/i',
396 'dataPattern' => '/^\d+(\.\d{2})?$/',
398 'table_name' => 'civicrm_line_item',
399 'entity' => 'LineItem',
400 'bao' => 'CRM_Price_BAO_LineItem',
408 'name' => 'tax_amount',
409 'type' => CRM_Utils_Type
::T_MONEY
,
410 'title' => ts('Tax Amount'),
411 'description' => ts('tax of each item'),
417 'where' => 'civicrm_line_item.tax_amount',
418 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
419 'dataPattern' => '/^\d+(\.\d{2})?$/',
421 'table_name' => 'civicrm_line_item',
422 'entity' => 'LineItem',
423 'bao' => 'CRM_Price_BAO_LineItem',
431 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
433 return Civi
::$statics[__CLASS__
]['fields'];
437 * Return a mapping from field-name to the corresponding key (as used in fields()).
440 * Array(string $name => string $uniqueName).
442 public static function &fieldKeys() {
443 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
444 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
446 return Civi
::$statics[__CLASS__
]['fieldKeys'];
450 * Returns the names of this table
454 public static function getTableName() {
455 return self
::$_tableName;
459 * Returns if this table needs to be logged
463 public function getLog() {
468 * Returns the list of fields that can be imported
470 * @param bool $prefix
474 public static function &import($prefix = FALSE) {
475 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'line_item', $prefix, []);
480 * Returns the list of fields that can be exported
482 * @param bool $prefix
486 public static function &export($prefix = FALSE) {
487 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'line_item', $prefix, []);
492 * Returns the list of indices
494 * @param bool $localize
498 public static function indices($localize = TRUE) {
501 'name' => 'index_entity',
506 'localizable' => FALSE,
507 'sig' => 'civicrm_line_item::0::entity_table::entity_id',
509 'UI_line_item_value' => [
510 'name' => 'UI_line_item_value',
514 2 => 'contribution_id',
515 3 => 'price_field_value_id',
516 4 => 'price_field_id',
518 'localizable' => FALSE,
520 'sig' => 'civicrm_line_item::1::entity_table::entity_id::contribution_id::price_field_value_id::price_field_id',
523 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;