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:5a365a7d4b14c9b5963aeb61576395e4)
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';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_line_item';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = TRUE;
41 * table which has the transaction
55 * FK to civicrm_contribution
59 public $contribution_id;
62 * FK to civicrm_price_field
66 public $price_field_id;
69 * descriptive label for item - from price_field_value.label
76 * How many items ordered
97 * Participant count for field
101 public $participant_count;
104 * FK to civicrm_price_field_value
108 public $price_field_value_id;
111 * FK to Financial Type.
115 public $financial_type_id;
118 * Portion of total amount which is NOT tax deductible.
122 public $non_deductible_amount;
134 public function __construct() {
135 $this->__table
= 'civicrm_line_item';
136 parent
::__construct();
140 * Returns localized title of this entity.
142 * @param bool $plural
143 * Whether to return the plural version of the title.
145 public static function getEntityTitle($plural = FALSE) {
146 return $plural ?
ts('Line Items') : ts('Line Item');
150 * Returns foreign keys and entity references.
153 * [CRM_Core_Reference_Interface]
155 public static function getReferenceColumns() {
156 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
157 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
158 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_id', 'civicrm_contribution', 'id');
159 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'price_field_id', 'civicrm_price_field', 'id');
160 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'price_field_value_id', 'civicrm_price_field_value', 'id');
161 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
162 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
163 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
165 return Civi
::$statics[__CLASS__
]['links'];
169 * Returns all the column names of this table
173 public static function &fields() {
174 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
175 Civi
::$statics[__CLASS__
]['fields'] = [
178 'type' => CRM_Utils_Type
::T_INT
,
179 'title' => ts('Line Item ID'),
180 'description' => ts('Line Item'),
182 'where' => 'civicrm_line_item.id',
183 'table_name' => 'civicrm_line_item',
184 'entity' => 'LineItem',
185 'bao' => 'CRM_Price_BAO_LineItem',
190 'name' => 'entity_table',
191 'type' => CRM_Utils_Type
::T_STRING
,
192 'title' => ts('Line Item Entity Type'),
193 'description' => ts('table which has the transaction'),
196 'size' => CRM_Utils_Type
::BIG
,
197 'where' => 'civicrm_line_item.entity_table',
198 'table_name' => 'civicrm_line_item',
199 'entity' => 'LineItem',
200 'bao' => 'CRM_Price_BAO_LineItem',
205 'name' => 'entity_id',
206 'type' => CRM_Utils_Type
::T_INT
,
207 'title' => ts('Line Item Entity'),
208 'description' => ts('entry in table'),
210 'where' => 'civicrm_line_item.entity_id',
211 'table_name' => 'civicrm_line_item',
212 'entity' => 'LineItem',
213 'bao' => 'CRM_Price_BAO_LineItem',
217 'contribution_id' => [
218 'name' => 'contribution_id',
219 'type' => CRM_Utils_Type
::T_INT
,
220 'title' => ts('Line Item Contribution'),
221 'description' => ts('FK to civicrm_contribution'),
222 'where' => 'civicrm_line_item.contribution_id',
223 'table_name' => 'civicrm_line_item',
224 'entity' => 'LineItem',
225 'bao' => 'CRM_Price_BAO_LineItem',
227 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
230 'price_field_id' => [
231 'name' => 'price_field_id',
232 'type' => CRM_Utils_Type
::T_INT
,
233 'title' => ts('Line Item Price Field'),
234 'description' => ts('FK to civicrm_price_field'),
235 'where' => 'civicrm_line_item.price_field_id',
236 'table_name' => 'civicrm_line_item',
237 'entity' => 'LineItem',
238 'bao' => 'CRM_Price_BAO_LineItem',
240 'FKClassName' => 'CRM_Price_DAO_PriceField',
245 'type' => CRM_Utils_Type
::T_STRING
,
246 'title' => ts('Line Item Label'),
247 'description' => ts('descriptive label for item - from price_field_value.label'),
249 'size' => CRM_Utils_Type
::HUGE
,
250 'where' => 'civicrm_line_item.label',
252 'table_name' => 'civicrm_line_item',
253 'entity' => 'LineItem',
254 'bao' => 'CRM_Price_BAO_LineItem',
263 'type' => CRM_Utils_Type
::T_MONEY
,
264 'title' => ts('Line Item Quantity'),
265 'description' => ts('How many items ordered'),
271 'where' => 'civicrm_line_item.qty',
272 'table_name' => 'civicrm_line_item',
273 'entity' => 'LineItem',
274 'bao' => 'CRM_Price_BAO_LineItem',
282 'name' => 'unit_price',
283 'type' => CRM_Utils_Type
::T_MONEY
,
284 'title' => ts('Unit Price'),
285 'description' => ts('price of each item'),
291 'where' => 'civicrm_line_item.unit_price',
292 'table_name' => 'civicrm_line_item',
293 'entity' => 'LineItem',
294 'bao' => 'CRM_Price_BAO_LineItem',
302 'name' => 'line_total',
303 'type' => CRM_Utils_Type
::T_MONEY
,
304 'title' => ts('Line Item Total'),
305 'description' => ts('qty * unit_price'),
311 'where' => 'civicrm_line_item.line_total',
312 'table_name' => 'civicrm_line_item',
313 'entity' => 'LineItem',
314 'bao' => 'CRM_Price_BAO_LineItem',
318 'participant_count' => [
319 'name' => 'participant_count',
320 'type' => CRM_Utils_Type
::T_INT
,
321 'title' => ts('Line Item Participant Count'),
322 'description' => ts('Participant count for field'),
323 'where' => 'civicrm_line_item.participant_count',
325 'table_name' => 'civicrm_line_item',
326 'entity' => 'LineItem',
327 'bao' => 'CRM_Price_BAO_LineItem',
334 'price_field_value_id' => [
335 'name' => 'price_field_value_id',
336 'type' => CRM_Utils_Type
::T_INT
,
337 'title' => ts('Line Item Option'),
338 'description' => ts('FK to civicrm_price_field_value'),
339 'where' => 'civicrm_line_item.price_field_value_id',
341 'table_name' => 'civicrm_line_item',
342 'entity' => 'LineItem',
343 'bao' => 'CRM_Price_BAO_LineItem',
345 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue',
348 'financial_type_id' => [
349 'name' => 'financial_type_id',
350 'type' => CRM_Utils_Type
::T_INT
,
351 'title' => ts('Financial Type'),
352 'description' => ts('FK to Financial Type.'),
353 'where' => 'civicrm_line_item.financial_type_id',
355 'table_name' => 'civicrm_line_item',
356 'entity' => 'LineItem',
357 'bao' => 'CRM_Price_BAO_LineItem',
359 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
363 'pseudoconstant' => [
364 'table' => 'civicrm_financial_type',
366 'labelColumn' => 'name',
370 'non_deductible_amount' => [
371 'name' => 'non_deductible_amount',
372 'type' => CRM_Utils_Type
::T_MONEY
,
373 'title' => ts('Non-deductible Amount'),
374 'description' => ts('Portion of total amount which is NOT tax deductible.'),
380 'where' => 'civicrm_line_item.non_deductible_amount',
381 'headerPattern' => '/non?.?deduct/i',
382 'dataPattern' => '/^\d+(\.\d{2})?$/',
384 'table_name' => 'civicrm_line_item',
385 'entity' => 'LineItem',
386 'bao' => 'CRM_Price_BAO_LineItem',
394 'name' => 'tax_amount',
395 'type' => CRM_Utils_Type
::T_MONEY
,
396 'title' => ts('Tax Amount'),
397 'description' => ts('tax of each item'),
403 'where' => 'civicrm_line_item.tax_amount',
404 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
405 'dataPattern' => '/^\d+(\.\d{2})?$/',
407 'table_name' => 'civicrm_line_item',
408 'entity' => 'LineItem',
409 'bao' => 'CRM_Price_BAO_LineItem',
417 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
419 return Civi
::$statics[__CLASS__
]['fields'];
423 * Return a mapping from field-name to the corresponding key (as used in fields()).
426 * Array(string $name => string $uniqueName).
428 public static function &fieldKeys() {
429 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
430 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
432 return Civi
::$statics[__CLASS__
]['fieldKeys'];
436 * Returns the names of this table
440 public static function getTableName() {
441 return self
::$_tableName;
445 * Returns if this table needs to be logged
449 public function getLog() {
454 * Returns the list of fields that can be imported
456 * @param bool $prefix
460 public static function &import($prefix = FALSE) {
461 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'line_item', $prefix, []);
466 * Returns the list of fields that can be exported
468 * @param bool $prefix
472 public static function &export($prefix = FALSE) {
473 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'line_item', $prefix, []);
478 * Returns the list of indices
480 * @param bool $localize
484 public static function indices($localize = TRUE) {
487 'name' => 'index_entity',
492 'localizable' => FALSE,
493 'sig' => 'civicrm_line_item::0::entity_table::entity_id',
495 'UI_line_item_value' => [
496 'name' => 'UI_line_item_value',
500 2 => 'contribution_id',
501 3 => 'price_field_value_id',
502 4 => 'price_field_id',
504 'localizable' => FALSE,
506 'sig' => 'civicrm_line_item::1::entity_table::entity_id::contribution_id::price_field_value_id::price_field_id',
509 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;