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:90fb6a08063f00282825bb1c567eea1a)
13 * Database access object for the LineItem entity.
15 class CRM_Price_DAO_LineItem
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_line_item';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
39 * table which has the transaction
53 * FK to civicrm_contribution
57 public $contribution_id;
60 * FK to civicrm_price_field
64 public $price_field_id;
67 * descriptive label for item - from price_field_value.label
74 * How many items ordered
95 * Participant count for field
99 public $participant_count;
102 * FK to civicrm_price_field_value
106 public $price_field_value_id;
109 * FK to Financial Type.
113 public $financial_type_id;
116 * Portion of total amount which is NOT tax deductible.
120 public $non_deductible_amount;
132 public function __construct() {
133 $this->__table
= 'civicrm_line_item';
134 parent
::__construct();
138 * Returns foreign keys and entity references.
141 * [CRM_Core_Reference_Interface]
143 public static function getReferenceColumns() {
144 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
145 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
146 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_id', 'civicrm_contribution', 'id');
147 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'price_field_id', 'civicrm_price_field', 'id');
148 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'price_field_value_id', 'civicrm_price_field_value', 'id');
149 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
150 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
151 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
153 return Civi
::$statics[__CLASS__
]['links'];
157 * Returns all the column names of this table
161 public static function &fields() {
162 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
163 Civi
::$statics[__CLASS__
]['fields'] = [
166 'type' => CRM_Utils_Type
::T_INT
,
167 'title' => ts('Line Item ID'),
168 'description' => ts('Line Item'),
170 'where' => 'civicrm_line_item.id',
171 'table_name' => 'civicrm_line_item',
172 'entity' => 'LineItem',
173 'bao' => 'CRM_Price_BAO_LineItem',
177 'name' => 'entity_table',
178 'type' => CRM_Utils_Type
::T_STRING
,
179 'title' => ts('Line Item Entity Type'),
180 'description' => ts('table which has the transaction'),
183 'size' => CRM_Utils_Type
::BIG
,
184 'where' => 'civicrm_line_item.entity_table',
185 'table_name' => 'civicrm_line_item',
186 'entity' => 'LineItem',
187 'bao' => 'CRM_Price_BAO_LineItem',
191 'name' => 'entity_id',
192 'type' => CRM_Utils_Type
::T_INT
,
193 'title' => ts('Line Item Entity'),
194 'description' => ts('entry in table'),
196 'where' => 'civicrm_line_item.entity_id',
197 'table_name' => 'civicrm_line_item',
198 'entity' => 'LineItem',
199 'bao' => 'CRM_Price_BAO_LineItem',
202 'contribution_id' => [
203 'name' => 'contribution_id',
204 'type' => CRM_Utils_Type
::T_INT
,
205 'title' => ts('Line Item Contribution'),
206 'description' => ts('FK to civicrm_contribution'),
207 'where' => 'civicrm_line_item.contribution_id',
208 'table_name' => 'civicrm_line_item',
209 'entity' => 'LineItem',
210 'bao' => 'CRM_Price_BAO_LineItem',
212 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
214 'price_field_id' => [
215 'name' => 'price_field_id',
216 'type' => CRM_Utils_Type
::T_INT
,
217 'title' => ts('Line Item Price Field'),
218 'description' => ts('FK to civicrm_price_field'),
219 'where' => 'civicrm_line_item.price_field_id',
220 'table_name' => 'civicrm_line_item',
221 'entity' => 'LineItem',
222 'bao' => 'CRM_Price_BAO_LineItem',
224 'FKClassName' => 'CRM_Price_DAO_PriceField',
228 'type' => CRM_Utils_Type
::T_STRING
,
229 'title' => ts('Line Item Label'),
230 'description' => ts('descriptive label for item - from price_field_value.label'),
232 'size' => CRM_Utils_Type
::HUGE
,
233 'where' => 'civicrm_line_item.label',
235 'table_name' => 'civicrm_line_item',
236 'entity' => 'LineItem',
237 'bao' => 'CRM_Price_BAO_LineItem',
245 'type' => CRM_Utils_Type
::T_MONEY
,
246 'title' => ts('Line Item Quantity'),
247 'description' => ts('How many items ordered'),
253 'where' => 'civicrm_line_item.qty',
254 'table_name' => 'civicrm_line_item',
255 'entity' => 'LineItem',
256 'bao' => 'CRM_Price_BAO_LineItem',
263 'name' => 'unit_price',
264 'type' => CRM_Utils_Type
::T_MONEY
,
265 'title' => ts('Unit Price'),
266 'description' => ts('price of each item'),
272 'where' => 'civicrm_line_item.unit_price',
273 'table_name' => 'civicrm_line_item',
274 'entity' => 'LineItem',
275 'bao' => 'CRM_Price_BAO_LineItem',
282 'name' => 'line_total',
283 'type' => CRM_Utils_Type
::T_MONEY
,
284 'title' => ts('Line Item Total'),
285 'description' => ts('qty * unit_price'),
291 'where' => 'civicrm_line_item.line_total',
292 'table_name' => 'civicrm_line_item',
293 'entity' => 'LineItem',
294 'bao' => 'CRM_Price_BAO_LineItem',
297 'participant_count' => [
298 'name' => 'participant_count',
299 'type' => CRM_Utils_Type
::T_INT
,
300 'title' => ts('Line Item Participant Count'),
301 'description' => ts('Participant count for field'),
302 'where' => 'civicrm_line_item.participant_count',
304 'table_name' => 'civicrm_line_item',
305 'entity' => 'LineItem',
306 'bao' => 'CRM_Price_BAO_LineItem',
312 'price_field_value_id' => [
313 'name' => 'price_field_value_id',
314 'type' => CRM_Utils_Type
::T_INT
,
315 'title' => ts('Line Item Option'),
316 'description' => ts('FK to civicrm_price_field_value'),
317 'where' => 'civicrm_line_item.price_field_value_id',
319 'table_name' => 'civicrm_line_item',
320 'entity' => 'LineItem',
321 'bao' => 'CRM_Price_BAO_LineItem',
323 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue',
325 'financial_type_id' => [
326 'name' => 'financial_type_id',
327 'type' => CRM_Utils_Type
::T_INT
,
328 'title' => ts('Financial Type'),
329 'description' => ts('FK to Financial Type.'),
330 'where' => 'civicrm_line_item.financial_type_id',
332 'table_name' => 'civicrm_line_item',
333 'entity' => 'LineItem',
334 'bao' => 'CRM_Price_BAO_LineItem',
336 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
340 'pseudoconstant' => [
341 'table' => 'civicrm_financial_type',
343 'labelColumn' => 'name',
346 'non_deductible_amount' => [
347 'name' => 'non_deductible_amount',
348 'type' => CRM_Utils_Type
::T_MONEY
,
349 'title' => ts('Non-deductible Amount'),
350 'description' => ts('Portion of total amount which is NOT tax deductible.'),
356 'where' => 'civicrm_line_item.non_deductible_amount',
357 'headerPattern' => '/non?.?deduct/i',
358 'dataPattern' => '/^\d+(\.\d{2})?$/',
360 'table_name' => 'civicrm_line_item',
361 'entity' => 'LineItem',
362 'bao' => 'CRM_Price_BAO_LineItem',
369 'name' => 'tax_amount',
370 'type' => CRM_Utils_Type
::T_MONEY
,
371 'title' => ts('Tax Amount'),
372 'description' => ts('tax of each item'),
378 'where' => 'civicrm_line_item.tax_amount',
379 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
380 'dataPattern' => '/^\d+(\.\d{2})?$/',
382 'table_name' => 'civicrm_line_item',
383 'entity' => 'LineItem',
384 'bao' => 'CRM_Price_BAO_LineItem',
391 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
393 return Civi
::$statics[__CLASS__
]['fields'];
397 * Return a mapping from field-name to the corresponding key (as used in fields()).
400 * Array(string $name => string $uniqueName).
402 public static function &fieldKeys() {
403 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
404 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
406 return Civi
::$statics[__CLASS__
]['fieldKeys'];
410 * Returns the names of this table
414 public static function getTableName() {
415 return self
::$_tableName;
419 * Returns if this table needs to be logged
423 public function getLog() {
428 * Returns the list of fields that can be imported
430 * @param bool $prefix
434 public static function &import($prefix = FALSE) {
435 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'line_item', $prefix, []);
440 * Returns the list of fields that can be exported
442 * @param bool $prefix
446 public static function &export($prefix = FALSE) {
447 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'line_item', $prefix, []);
452 * Returns the list of indices
454 * @param bool $localize
458 public static function indices($localize = TRUE) {
461 'name' => 'index_entity',
466 'localizable' => FALSE,
467 'sig' => 'civicrm_line_item::0::entity_table::entity_id',
469 'UI_line_item_value' => [
470 'name' => 'UI_line_item_value',
474 2 => 'contribution_id',
475 3 => 'price_field_value_id',
476 4 => 'price_field_id',
478 'localizable' => FALSE,
480 'sig' => 'civicrm_line_item::1::entity_table::entity_id::contribution_id::price_field_value_id::price_field_id',
483 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;