5 * @copyright CiviCRM LLC (c) 2004-2019
7 * Generated from xml/schema/CRM/Price/LineItem.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:efca4ce3a24803ffca3180f7a81ea6f2)
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 'table_name' => 'civicrm_line_item',
171 'entity' => 'LineItem',
172 'bao' => 'CRM_Price_BAO_LineItem',
176 'name' => 'entity_table',
177 'type' => CRM_Utils_Type
::T_STRING
,
178 'title' => ts('Line Item Entity Type'),
179 'description' => ts('table which has the transaction'),
182 'size' => CRM_Utils_Type
::BIG
,
183 'table_name' => 'civicrm_line_item',
184 'entity' => 'LineItem',
185 'bao' => 'CRM_Price_BAO_LineItem',
189 'name' => 'entity_id',
190 'type' => CRM_Utils_Type
::T_INT
,
191 'title' => ts('Line Item Entity'),
192 'description' => ts('entry in table'),
194 'table_name' => 'civicrm_line_item',
195 'entity' => 'LineItem',
196 'bao' => 'CRM_Price_BAO_LineItem',
199 'contribution_id' => [
200 'name' => 'contribution_id',
201 'type' => CRM_Utils_Type
::T_INT
,
202 'title' => ts('Line Item Contribution'),
203 'description' => ts('FK to civicrm_contribution'),
204 'table_name' => 'civicrm_line_item',
205 'entity' => 'LineItem',
206 'bao' => 'CRM_Price_BAO_LineItem',
208 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
210 'price_field_id' => [
211 'name' => 'price_field_id',
212 'type' => CRM_Utils_Type
::T_INT
,
213 'title' => ts('Line Item Price Field'),
214 'description' => ts('FK to civicrm_price_field'),
215 'table_name' => 'civicrm_line_item',
216 'entity' => 'LineItem',
217 'bao' => 'CRM_Price_BAO_LineItem',
219 'FKClassName' => 'CRM_Price_DAO_PriceField',
223 'type' => CRM_Utils_Type
::T_STRING
,
224 'title' => ts('Line Item Label'),
225 'description' => ts('descriptive label for item - from price_field_value.label'),
227 'size' => CRM_Utils_Type
::HUGE
,
229 'table_name' => 'civicrm_line_item',
230 'entity' => 'LineItem',
231 'bao' => 'CRM_Price_BAO_LineItem',
239 'type' => CRM_Utils_Type
::T_MONEY
,
240 'title' => ts('Line Item Quantity'),
241 'description' => ts('How many items ordered'),
247 'table_name' => 'civicrm_line_item',
248 'entity' => 'LineItem',
249 'bao' => 'CRM_Price_BAO_LineItem',
256 'name' => 'unit_price',
257 'type' => CRM_Utils_Type
::T_MONEY
,
258 'title' => ts('Unit Price'),
259 'description' => ts('price of each item'),
265 'table_name' => 'civicrm_line_item',
266 'entity' => 'LineItem',
267 'bao' => 'CRM_Price_BAO_LineItem',
274 'name' => 'line_total',
275 'type' => CRM_Utils_Type
::T_MONEY
,
276 'title' => ts('Line Item Total'),
277 'description' => ts('qty * unit_price'),
283 'table_name' => 'civicrm_line_item',
284 'entity' => 'LineItem',
285 'bao' => 'CRM_Price_BAO_LineItem',
288 'participant_count' => [
289 'name' => 'participant_count',
290 'type' => CRM_Utils_Type
::T_INT
,
291 'title' => ts('Line Item Participant Count'),
292 'description' => ts('Participant count for field'),
294 'table_name' => 'civicrm_line_item',
295 'entity' => 'LineItem',
296 'bao' => 'CRM_Price_BAO_LineItem',
302 'price_field_value_id' => [
303 'name' => 'price_field_value_id',
304 'type' => CRM_Utils_Type
::T_INT
,
305 'title' => ts('Line Item Option'),
306 'description' => ts('FK to civicrm_price_field_value'),
308 'table_name' => 'civicrm_line_item',
309 'entity' => 'LineItem',
310 'bao' => 'CRM_Price_BAO_LineItem',
312 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue',
314 'financial_type_id' => [
315 'name' => 'financial_type_id',
316 'type' => CRM_Utils_Type
::T_INT
,
317 'title' => ts('Financial Type'),
318 'description' => ts('FK to Financial Type.'),
320 'table_name' => 'civicrm_line_item',
321 'entity' => 'LineItem',
322 'bao' => 'CRM_Price_BAO_LineItem',
324 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
328 'pseudoconstant' => [
329 'table' => 'civicrm_financial_type',
331 'labelColumn' => 'name',
334 'non_deductible_amount' => [
335 'name' => 'non_deductible_amount',
336 'type' => CRM_Utils_Type
::T_MONEY
,
337 'title' => ts('Non-deductible Amount'),
338 'description' => ts('Portion of total amount which is NOT tax deductible.'),
345 'table_name' => 'civicrm_line_item',
346 'entity' => 'LineItem',
347 'bao' => 'CRM_Price_BAO_LineItem',
354 'name' => 'tax_amount',
355 'type' => CRM_Utils_Type
::T_MONEY
,
356 'title' => ts('Tax Amount'),
357 'description' => ts('tax of each item'),
363 'where' => 'civicrm_line_item.tax_amount',
364 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
365 'dataPattern' => '/^\d+(\.\d{2})?$/',
367 'table_name' => 'civicrm_line_item',
368 'entity' => 'LineItem',
369 'bao' => 'CRM_Price_BAO_LineItem',
376 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
378 return Civi
::$statics[__CLASS__
]['fields'];
382 * Return a mapping from field-name to the corresponding key (as used in fields()).
385 * Array(string $name => string $uniqueName).
387 public static function &fieldKeys() {
388 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
389 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
391 return Civi
::$statics[__CLASS__
]['fieldKeys'];
395 * Returns the names of this table
399 public static function getTableName() {
400 return self
::$_tableName;
404 * Returns if this table needs to be logged
408 public function getLog() {
413 * Returns the list of fields that can be imported
415 * @param bool $prefix
419 public static function &import($prefix = FALSE) {
420 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'line_item', $prefix, []);
425 * Returns the list of fields that can be exported
427 * @param bool $prefix
431 public static function &export($prefix = FALSE) {
432 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'line_item', $prefix, []);
437 * Returns the list of indices
439 * @param bool $localize
443 public static function indices($localize = TRUE) {
446 'name' => 'index_entity',
451 'localizable' => FALSE,
452 'sig' => 'civicrm_line_item::0::entity_table::entity_id',
454 'UI_line_item_value' => [
455 'name' => 'UI_line_item_value',
459 2 => 'contribution_id',
460 3 => 'price_field_value_id',
461 4 => 'price_field_id',
463 'localizable' => FALSE,
465 'sig' => 'civicrm_line_item::1::entity_table::entity_id::contribution_id::price_field_value_id::price_field_id',
468 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;