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:27940b7d9e1152223c1fde0e32a8e909)
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 * May contain civicrm_contribution, civicrm_participant or civicrm_membership
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;
133 * Number of terms for this membership (only supported in Order->Payment flow). If the field is NULL it means unknown and it will be assumed to be 1 during payment.create if entity_table is civicrm_membership
137 public $membership_num_terms;
142 public function __construct() {
143 $this->__table
= 'civicrm_line_item';
144 parent
::__construct();
148 * Returns localized title of this entity.
150 * @param bool $plural
151 * Whether to return the plural version of the title.
153 public static function getEntityTitle($plural = FALSE) {
154 return $plural ?
ts('Line Items') : ts('Line Item');
158 * Returns foreign keys and entity references.
161 * [CRM_Core_Reference_Interface]
163 public static function getReferenceColumns() {
164 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
165 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
166 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_id', 'civicrm_contribution', 'id');
167 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'price_field_id', 'civicrm_price_field', 'id');
168 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'price_field_value_id', 'civicrm_price_field_value', 'id');
169 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
170 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
171 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
173 return Civi
::$statics[__CLASS__
]['links'];
177 * Returns all the column names of this table
181 public static function &fields() {
182 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
183 Civi
::$statics[__CLASS__
]['fields'] = [
186 'type' => CRM_Utils_Type
::T_INT
,
187 'title' => ts('Line Item ID'),
188 'description' => ts('Line Item'),
190 'where' => 'civicrm_line_item.id',
191 'table_name' => 'civicrm_line_item',
192 'entity' => 'LineItem',
193 'bao' => 'CRM_Price_BAO_LineItem',
202 'name' => 'entity_table',
203 'type' => CRM_Utils_Type
::T_STRING
,
204 'title' => ts('Line Item Entity Type'),
205 'description' => ts('May contain civicrm_contribution, civicrm_participant or civicrm_membership'),
208 'size' => CRM_Utils_Type
::BIG
,
209 'where' => 'civicrm_line_item.entity_table',
210 'table_name' => 'civicrm_line_item',
211 'entity' => 'LineItem',
212 'bao' => 'CRM_Price_BAO_LineItem',
214 'pseudoconstant' => [
215 'callback' => 'CRM_Price_BAO_LineItem::entityTables',
220 'name' => 'entity_id',
221 'type' => CRM_Utils_Type
::T_INT
,
222 'title' => ts('Line Item Entity'),
223 'description' => ts('entry in table'),
225 'where' => 'civicrm_line_item.entity_id',
226 'table_name' => 'civicrm_line_item',
227 'entity' => 'LineItem',
228 'bao' => 'CRM_Price_BAO_LineItem',
232 'contribution_id' => [
233 'name' => 'contribution_id',
234 'type' => CRM_Utils_Type
::T_INT
,
235 'title' => ts('Contribution ID'),
236 'description' => ts('FK to civicrm_contribution'),
237 'where' => 'civicrm_line_item.contribution_id',
238 'table_name' => 'civicrm_line_item',
239 'entity' => 'LineItem',
240 'bao' => 'CRM_Price_BAO_LineItem',
242 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
244 'label' => ts("Contribution"),
248 'price_field_id' => [
249 'name' => 'price_field_id',
250 'type' => CRM_Utils_Type
::T_INT
,
251 'title' => ts('Price Field ID'),
252 'description' => ts('FK to civicrm_price_field'),
253 'where' => 'civicrm_line_item.price_field_id',
254 'table_name' => 'civicrm_line_item',
255 'entity' => 'LineItem',
256 'bao' => 'CRM_Price_BAO_LineItem',
258 'FKClassName' => 'CRM_Price_DAO_PriceField',
260 'label' => ts("Price Field"),
262 'pseudoconstant' => [
263 'table' => 'civicrm_price_field',
265 'labelColumn' => 'label',
266 'nameColumn' => 'name',
272 'type' => CRM_Utils_Type
::T_STRING
,
273 'title' => ts('Line Item Label'),
274 'description' => ts('descriptive label for item - from price_field_value.label'),
276 'size' => CRM_Utils_Type
::HUGE
,
277 'where' => 'civicrm_line_item.label',
279 'table_name' => 'civicrm_line_item',
280 'entity' => 'LineItem',
281 'bao' => 'CRM_Price_BAO_LineItem',
290 'type' => CRM_Utils_Type
::T_MONEY
,
291 'title' => ts('Line Item Quantity'),
292 'description' => ts('How many items ordered'),
298 'where' => 'civicrm_line_item.qty',
299 'table_name' => 'civicrm_line_item',
300 'entity' => 'LineItem',
301 'bao' => 'CRM_Price_BAO_LineItem',
309 'name' => 'unit_price',
310 'type' => CRM_Utils_Type
::T_MONEY
,
311 'title' => ts('Unit Price'),
312 'description' => ts('price of each item'),
318 'where' => 'civicrm_line_item.unit_price',
319 'table_name' => 'civicrm_line_item',
320 'entity' => 'LineItem',
321 'bao' => 'CRM_Price_BAO_LineItem',
325 'label' => ts("Unit Price"),
330 'name' => 'line_total',
331 'type' => CRM_Utils_Type
::T_MONEY
,
332 'title' => ts('Line Item Total'),
333 'description' => ts('qty * unit_price'),
339 'where' => 'civicrm_line_item.line_total',
340 'table_name' => 'civicrm_line_item',
341 'entity' => 'LineItem',
342 'bao' => 'CRM_Price_BAO_LineItem',
346 'participant_count' => [
347 'name' => 'participant_count',
348 'type' => CRM_Utils_Type
::T_INT
,
349 'title' => ts('Line Item Participant Count'),
350 'description' => ts('Participant count for field'),
351 'where' => 'civicrm_line_item.participant_count',
353 'table_name' => 'civicrm_line_item',
354 'entity' => 'LineItem',
355 'bao' => 'CRM_Price_BAO_LineItem',
362 'price_field_value_id' => [
363 'name' => 'price_field_value_id',
364 'type' => CRM_Utils_Type
::T_INT
,
365 'title' => ts('Option ID'),
366 'description' => ts('FK to civicrm_price_field_value'),
367 'where' => 'civicrm_line_item.price_field_value_id',
369 'table_name' => 'civicrm_line_item',
370 'entity' => 'LineItem',
371 'bao' => 'CRM_Price_BAO_LineItem',
373 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue',
375 'label' => ts("Option"),
377 'pseudoconstant' => [
378 'table' => 'civicrm_price_field_value',
380 'labelColumn' => 'label',
381 'nameColumn' => 'name',
385 'financial_type_id' => [
386 'name' => 'financial_type_id',
387 'type' => CRM_Utils_Type
::T_INT
,
388 'title' => ts('Financial Type ID'),
389 'description' => ts('FK to Financial Type.'),
390 'where' => 'civicrm_line_item.financial_type_id',
392 'table_name' => 'civicrm_line_item',
393 'entity' => 'LineItem',
394 'bao' => 'CRM_Price_BAO_LineItem',
396 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
399 'label' => ts("Financial Type"),
401 'pseudoconstant' => [
402 'table' => 'civicrm_financial_type',
404 'labelColumn' => 'name',
408 'non_deductible_amount' => [
409 'name' => 'non_deductible_amount',
410 'type' => CRM_Utils_Type
::T_MONEY
,
411 'title' => ts('Non-deductible Amount'),
412 'description' => ts('Portion of total amount which is NOT tax deductible.'),
418 'where' => 'civicrm_line_item.non_deductible_amount',
419 'headerPattern' => '/non?.?deduct/i',
420 'dataPattern' => '/^\d+(\.\d{2})?$/',
422 'table_name' => 'civicrm_line_item',
423 'entity' => 'LineItem',
424 'bao' => 'CRM_Price_BAO_LineItem',
432 'name' => 'tax_amount',
433 'type' => CRM_Utils_Type
::T_MONEY
,
434 'title' => ts('Tax Amount'),
435 'description' => ts('tax of each item'),
441 'where' => 'civicrm_line_item.tax_amount',
442 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
443 'dataPattern' => '/^\d+(\.\d{2})?$/',
445 'table_name' => 'civicrm_line_item',
446 'entity' => 'LineItem',
447 'bao' => 'CRM_Price_BAO_LineItem',
454 'membership_num_terms' => [
455 'name' => 'membership_num_terms',
456 'type' => CRM_Utils_Type
::T_INT
,
457 'title' => ts('Number of membership terms purchased'),
458 'description' => ts('Number of terms for this membership (only supported in Order->Payment flow). If the field is NULL it means unknown and it will be assumed to be 1 during payment.create if entity_table is civicrm_membership'),
459 'where' => 'civicrm_line_item.membership_num_terms',
461 'table_name' => 'civicrm_line_item',
462 'entity' => 'LineItem',
463 'bao' => 'CRM_Price_BAO_LineItem',
468 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
470 return Civi
::$statics[__CLASS__
]['fields'];
474 * Return a mapping from field-name to the corresponding key (as used in fields()).
477 * Array(string $name => string $uniqueName).
479 public static function &fieldKeys() {
480 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
481 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
483 return Civi
::$statics[__CLASS__
]['fieldKeys'];
487 * Returns the names of this table
491 public static function getTableName() {
492 return self
::$_tableName;
496 * Returns if this table needs to be logged
500 public function getLog() {
505 * Returns the list of fields that can be imported
507 * @param bool $prefix
511 public static function &import($prefix = FALSE) {
512 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'line_item', $prefix, []);
517 * Returns the list of fields that can be exported
519 * @param bool $prefix
523 public static function &export($prefix = FALSE) {
524 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'line_item', $prefix, []);
529 * Returns the list of indices
531 * @param bool $localize
535 public static function indices($localize = TRUE) {
537 'UI_line_item_value' => [
538 'name' => 'UI_line_item_value',
542 2 => 'contribution_id',
543 3 => 'price_field_value_id',
544 4 => 'price_field_id',
546 'localizable' => FALSE,
548 'sig' => 'civicrm_line_item::1::entity_id::entity_table::contribution_id::price_field_value_id::price_field_id',
551 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;