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:588f54f07db70f636888c88374b6b5b1)
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;
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',
195 'name' => 'entity_table',
196 'type' => CRM_Utils_Type
::T_STRING
,
197 'title' => ts('Line Item Entity Type'),
198 'description' => ts('May contain civicrm_contribution, civicrm_participant or civicrm_membership'),
201 'size' => CRM_Utils_Type
::BIG
,
202 'where' => 'civicrm_line_item.entity_table',
203 'table_name' => 'civicrm_line_item',
204 'entity' => 'LineItem',
205 'bao' => 'CRM_Price_BAO_LineItem',
207 'pseudoconstant' => [
208 'callback' => 'CRM_Price_BAO_LineItem::entityTables',
213 'name' => 'entity_id',
214 'type' => CRM_Utils_Type
::T_INT
,
215 'title' => ts('Line Item Entity'),
216 'description' => ts('entry in table'),
218 'where' => 'civicrm_line_item.entity_id',
219 'table_name' => 'civicrm_line_item',
220 'entity' => 'LineItem',
221 'bao' => 'CRM_Price_BAO_LineItem',
225 'contribution_id' => [
226 'name' => 'contribution_id',
227 'type' => CRM_Utils_Type
::T_INT
,
228 'title' => ts('Contribution ID'),
229 'description' => ts('FK to civicrm_contribution'),
230 'where' => 'civicrm_line_item.contribution_id',
231 'table_name' => 'civicrm_line_item',
232 'entity' => 'LineItem',
233 'bao' => 'CRM_Price_BAO_LineItem',
235 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
237 'label' => ts("Contribution"),
241 'price_field_id' => [
242 'name' => 'price_field_id',
243 'type' => CRM_Utils_Type
::T_INT
,
244 'title' => ts('Price Field ID'),
245 'description' => ts('FK to civicrm_price_field'),
246 'where' => 'civicrm_line_item.price_field_id',
247 'table_name' => 'civicrm_line_item',
248 'entity' => 'LineItem',
249 'bao' => 'CRM_Price_BAO_LineItem',
251 'FKClassName' => 'CRM_Price_DAO_PriceField',
253 'label' => ts("Price Field"),
255 'pseudoconstant' => [
256 'table' => 'civicrm_price_field',
258 'labelColumn' => 'label',
259 'nameColumn' => 'name',
265 'type' => CRM_Utils_Type
::T_STRING
,
266 'title' => ts('Line Item Label'),
267 'description' => ts('descriptive label for item - from price_field_value.label'),
269 'size' => CRM_Utils_Type
::HUGE
,
270 'where' => 'civicrm_line_item.label',
272 'table_name' => 'civicrm_line_item',
273 'entity' => 'LineItem',
274 'bao' => 'CRM_Price_BAO_LineItem',
283 'type' => CRM_Utils_Type
::T_MONEY
,
284 'title' => ts('Line Item Quantity'),
285 'description' => ts('How many items ordered'),
291 'where' => 'civicrm_line_item.qty',
292 'table_name' => 'civicrm_line_item',
293 'entity' => 'LineItem',
294 'bao' => 'CRM_Price_BAO_LineItem',
302 'name' => 'unit_price',
303 'type' => CRM_Utils_Type
::T_MONEY
,
304 'title' => ts('Unit Price'),
305 'description' => ts('price of each item'),
311 'where' => 'civicrm_line_item.unit_price',
312 'table_name' => 'civicrm_line_item',
313 'entity' => 'LineItem',
314 'bao' => 'CRM_Price_BAO_LineItem',
318 'label' => ts("Unit Price"),
323 'name' => 'line_total',
324 'type' => CRM_Utils_Type
::T_MONEY
,
325 'title' => ts('Line Item Total'),
326 'description' => ts('qty * unit_price'),
332 'where' => 'civicrm_line_item.line_total',
333 'table_name' => 'civicrm_line_item',
334 'entity' => 'LineItem',
335 'bao' => 'CRM_Price_BAO_LineItem',
339 'participant_count' => [
340 'name' => 'participant_count',
341 'type' => CRM_Utils_Type
::T_INT
,
342 'title' => ts('Line Item Participant Count'),
343 'description' => ts('Participant count for field'),
344 'where' => 'civicrm_line_item.participant_count',
346 'table_name' => 'civicrm_line_item',
347 'entity' => 'LineItem',
348 'bao' => 'CRM_Price_BAO_LineItem',
355 'price_field_value_id' => [
356 'name' => 'price_field_value_id',
357 'type' => CRM_Utils_Type
::T_INT
,
358 'title' => ts('Option ID'),
359 'description' => ts('FK to civicrm_price_field_value'),
360 'where' => 'civicrm_line_item.price_field_value_id',
362 'table_name' => 'civicrm_line_item',
363 'entity' => 'LineItem',
364 'bao' => 'CRM_Price_BAO_LineItem',
366 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue',
368 'label' => ts("Option"),
370 'pseudoconstant' => [
371 'table' => 'civicrm_price_field_value',
373 'labelColumn' => 'label',
374 'nameColumn' => 'name',
378 'financial_type_id' => [
379 'name' => 'financial_type_id',
380 'type' => CRM_Utils_Type
::T_INT
,
381 'title' => ts('Financial Type ID'),
382 'description' => ts('FK to Financial Type.'),
383 'where' => 'civicrm_line_item.financial_type_id',
385 'table_name' => 'civicrm_line_item',
386 'entity' => 'LineItem',
387 'bao' => 'CRM_Price_BAO_LineItem',
389 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
392 'label' => ts("Financial Type"),
394 'pseudoconstant' => [
395 'table' => 'civicrm_financial_type',
397 'labelColumn' => 'name',
401 'non_deductible_amount' => [
402 'name' => 'non_deductible_amount',
403 'type' => CRM_Utils_Type
::T_MONEY
,
404 'title' => ts('Non-deductible Amount'),
405 'description' => ts('Portion of total amount which is NOT tax deductible.'),
411 'where' => 'civicrm_line_item.non_deductible_amount',
412 'headerPattern' => '/non?.?deduct/i',
413 'dataPattern' => '/^\d+(\.\d{2})?$/',
415 'table_name' => 'civicrm_line_item',
416 'entity' => 'LineItem',
417 'bao' => 'CRM_Price_BAO_LineItem',
425 'name' => 'tax_amount',
426 'type' => CRM_Utils_Type
::T_MONEY
,
427 'title' => ts('Tax Amount'),
428 'description' => ts('tax of each item'),
434 'where' => 'civicrm_line_item.tax_amount',
435 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
436 'dataPattern' => '/^\d+(\.\d{2})?$/',
438 'table_name' => 'civicrm_line_item',
439 'entity' => 'LineItem',
440 'bao' => 'CRM_Price_BAO_LineItem',
448 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
450 return Civi
::$statics[__CLASS__
]['fields'];
454 * Return a mapping from field-name to the corresponding key (as used in fields()).
457 * Array(string $name => string $uniqueName).
459 public static function &fieldKeys() {
460 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
461 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
463 return Civi
::$statics[__CLASS__
]['fieldKeys'];
467 * Returns the names of this table
471 public static function getTableName() {
472 return self
::$_tableName;
476 * Returns if this table needs to be logged
480 public function getLog() {
485 * Returns the list of fields that can be imported
487 * @param bool $prefix
491 public static function &import($prefix = FALSE) {
492 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'line_item', $prefix, []);
497 * Returns the list of fields that can be exported
499 * @param bool $prefix
503 public static function &export($prefix = FALSE) {
504 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'line_item', $prefix, []);
509 * Returns the list of indices
511 * @param bool $localize
515 public static function indices($localize = TRUE) {
517 'UI_line_item_value' => [
518 'name' => 'UI_line_item_value',
522 2 => 'contribution_id',
523 3 => 'price_field_value_id',
524 4 => 'price_field_id',
526 'localizable' => FALSE,
528 'sig' => 'civicrm_line_item::1::entity_id::entity_table::contribution_id::price_field_value_id::price_field_id',
531 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;