5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Financial/FinancialItem.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:fb47253c848979ed40aae7affbc188a3)
13 * Database access object for the FinancialItem entity.
15 class CRM_Financial_DAO_FinancialItem
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '4.3';
18 const COMPONENT
= 'CiviContribute';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_financial_item';
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
32 public static $_log = TRUE;
35 * @var int|string|null
36 * (SQL type: int unsigned)
37 * Note that values will be retrieved from the database as a string.
42 * Date and time the item was created
45 * (SQL type: timestamp)
46 * Note that values will be retrieved from the database as a string.
51 * Date and time of the source transaction
54 * (SQL type: datetime)
55 * Note that values will be retrieved from the database as a string.
57 public $transaction_date;
60 * FK to Contact ID of contact the item is from
63 * (SQL type: int unsigned)
64 * Note that values will be retrieved from the database as a string.
69 * Human readable description of this item, to ease display without lookup of source item.
72 * (SQL type: varchar(255))
73 * Note that values will be retrieved from the database as a string.
78 * Total amount of this item
81 * (SQL type: decimal(20,2))
82 * Note that values will be retrieved from the database as a string.
87 * Currency for the amount
90 * (SQL type: varchar(3))
91 * Note that values will be retrieved from the database as a string.
96 * FK to civicrm_financial_account
98 * @var int|string|null
99 * (SQL type: int unsigned)
100 * Note that values will be retrieved from the database as a string.
102 public $financial_account_id;
105 * Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)
107 * @var int|string|null
108 * (SQL type: int unsigned)
109 * Note that values will be retrieved from the database as a string.
114 * May contain civicrm_line_item, civicrm_financial_trxn etc
117 * (SQL type: varchar(64))
118 * Note that values will be retrieved from the database as a string.
120 public $entity_table;
123 * The specific source item that is responsible for the creation of this financial_item
125 * @var int|string|null
126 * (SQL type: int unsigned)
127 * Note that values will be retrieved from the database as a string.
134 public function __construct() {
135 $this->__table
= 'civicrm_financial_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('Financial Items') : ts('Financial 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(), 'contact_id', 'civicrm_contact', 'id');
159 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id');
160 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
161 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
163 return Civi
::$statics[__CLASS__
]['links'];
167 * Returns all the column names of this table
171 public static function &fields() {
172 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
173 Civi
::$statics[__CLASS__
]['fields'] = [
176 'type' => CRM_Utils_Type
::T_INT
,
177 'title' => ts('Financial Item ID'),
179 'where' => 'civicrm_financial_item.id',
180 'table_name' => 'civicrm_financial_item',
181 'entity' => 'FinancialItem',
182 'bao' => 'CRM_Financial_BAO_FinancialItem',
191 'name' => 'created_date',
192 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
193 'title' => ts('Financial Item Created Date'),
194 'description' => ts('Date and time the item was created'),
196 'where' => 'civicrm_financial_item.created_date',
197 'default' => 'CURRENT_TIMESTAMP',
198 'table_name' => 'civicrm_financial_item',
199 'entity' => 'FinancialItem',
200 'bao' => 'CRM_Financial_BAO_FinancialItem',
204 'transaction_date' => [
205 'name' => 'transaction_date',
206 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
207 'title' => ts('Financial Item Transaction Date'),
208 'description' => ts('Date and time of the source transaction'),
210 'where' => 'civicrm_financial_item.transaction_date',
211 'table_name' => 'civicrm_financial_item',
212 'entity' => 'FinancialItem',
213 'bao' => 'CRM_Financial_BAO_FinancialItem',
218 'name' => 'contact_id',
219 'type' => CRM_Utils_Type
::T_INT
,
220 'title' => ts('Contact ID'),
221 'description' => ts('FK to Contact ID of contact the item is from'),
223 'where' => 'civicrm_financial_item.contact_id',
225 'table_name' => 'civicrm_financial_item',
226 'entity' => 'FinancialItem',
227 'bao' => 'CRM_Financial_BAO_FinancialItem',
229 'FKClassName' => 'CRM_Contact_DAO_Contact',
231 'label' => ts("Contact"),
236 'name' => 'description',
237 'type' => CRM_Utils_Type
::T_STRING
,
238 'title' => ts('Financial Item Description'),
239 'description' => ts('Human readable description of this item, to ease display without lookup of source item.'),
241 'size' => CRM_Utils_Type
::HUGE
,
242 'where' => 'civicrm_financial_item.description',
243 'table_name' => 'civicrm_financial_item',
244 'entity' => 'FinancialItem',
245 'bao' => 'CRM_Financial_BAO_FinancialItem',
251 'type' => CRM_Utils_Type
::T_MONEY
,
252 'title' => ts('Amount'),
253 'description' => ts('Total amount of this item'),
259 'where' => 'civicrm_financial_item.amount',
260 'headerPattern' => '/unit?.?amoun/i',
261 'dataPattern' => '/^\d+(\.\d{2})?$/',
263 'table_name' => 'civicrm_financial_item',
264 'entity' => 'FinancialItem',
265 'bao' => 'CRM_Financial_BAO_FinancialItem',
270 'name' => 'currency',
271 'type' => CRM_Utils_Type
::T_STRING
,
272 'title' => ts('Financial Item Currency'),
273 'description' => ts('Currency for the amount'),
275 'size' => CRM_Utils_Type
::FOUR
,
276 'where' => 'civicrm_financial_item.currency',
278 'table_name' => 'civicrm_financial_item',
279 'entity' => 'FinancialItem',
280 'bao' => 'CRM_Financial_BAO_FinancialItem',
285 'pseudoconstant' => [
286 'table' => 'civicrm_currency',
287 'keyColumn' => 'name',
288 'labelColumn' => 'full_name',
289 'nameColumn' => 'name',
290 'abbrColumn' => 'symbol',
294 'financial_account_id' => [
295 'name' => 'financial_account_id',
296 'type' => CRM_Utils_Type
::T_INT
,
297 'title' => ts('Financial Account ID'),
298 'description' => ts('FK to civicrm_financial_account'),
299 'where' => 'civicrm_financial_item.financial_account_id',
300 'table_name' => 'civicrm_financial_item',
301 'entity' => 'FinancialItem',
302 'bao' => 'CRM_Financial_BAO_FinancialItem',
304 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
307 'label' => ts("Financial Account"),
309 'pseudoconstant' => [
310 'table' => 'civicrm_financial_account',
312 'labelColumn' => 'name',
317 'name' => 'status_id',
318 'type' => CRM_Utils_Type
::T_INT
,
319 'title' => ts('Financial Item Status ID'),
320 'description' => ts('Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)'),
321 'where' => 'civicrm_financial_item.status_id',
323 'table_name' => 'civicrm_financial_item',
324 'entity' => 'FinancialItem',
325 'bao' => 'CRM_Financial_BAO_FinancialItem',
330 'pseudoconstant' => [
331 'optionGroupName' => 'financial_item_status',
332 'optionEditPath' => 'civicrm/admin/options/financial_item_status',
337 'name' => 'entity_table',
338 'type' => CRM_Utils_Type
::T_STRING
,
339 'title' => ts('Entity Table'),
340 'description' => ts('May contain civicrm_line_item, civicrm_financial_trxn etc'),
342 'size' => CRM_Utils_Type
::BIG
,
343 'where' => 'civicrm_financial_item.entity_table',
344 'table_name' => 'civicrm_financial_item',
345 'entity' => 'FinancialItem',
346 'bao' => 'CRM_Financial_BAO_FinancialItem',
348 'pseudoconstant' => [
349 'callback' => 'CRM_Financial_BAO_FinancialItem::entityTables',
354 'name' => 'entity_id',
355 'type' => CRM_Utils_Type
::T_INT
,
356 'title' => ts('Entity ID'),
357 'description' => ts('The specific source item that is responsible for the creation of this financial_item'),
358 'where' => 'civicrm_financial_item.entity_id',
359 'table_name' => 'civicrm_financial_item',
360 'entity' => 'FinancialItem',
361 'bao' => 'CRM_Financial_BAO_FinancialItem',
366 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
368 return Civi
::$statics[__CLASS__
]['fields'];
372 * Return a mapping from field-name to the corresponding key (as used in fields()).
375 * Array(string $name => string $uniqueName).
377 public static function &fieldKeys() {
378 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
379 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
381 return Civi
::$statics[__CLASS__
]['fieldKeys'];
385 * Returns the names of this table
389 public static function getTableName() {
390 return self
::$_tableName;
394 * Returns if this table needs to be logged
398 public function getLog() {
403 * Returns the list of fields that can be imported
405 * @param bool $prefix
409 public static function &import($prefix = FALSE) {
410 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_item', $prefix, []);
415 * Returns the list of fields that can be exported
417 * @param bool $prefix
421 public static function &export($prefix = FALSE) {
422 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_item', $prefix, []);
427 * Returns the list of indices
429 * @param bool $localize
433 public static function indices($localize = TRUE) {
435 'IX_created_date' => [
436 'name' => 'IX_created_date',
440 'localizable' => FALSE,
441 'sig' => 'civicrm_financial_item::0::created_date',
443 'IX_transaction_date' => [
444 'name' => 'IX_transaction_date',
446 0 => 'transaction_date',
448 'localizable' => FALSE,
449 'sig' => 'civicrm_financial_item::0::transaction_date',
451 'index_entity_id_entity_table' => [
452 'name' => 'index_entity_id_entity_table',
457 'localizable' => FALSE,
458 'sig' => 'civicrm_financial_item::0::entity_id::entity_table',
461 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;