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:d8fb58f8b09009330bcb325ebfea20e0)
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;
40 * Date and time the item was created
47 * Date and time of the source transaction
51 public $transaction_date;
54 * FK to Contact ID of contact the item is from
61 * Human readable description of this item, to ease display without lookup of source item.
68 * Total amount of this item
75 * Currency for the amount
82 * FK to civicrm_financial_account
86 public $financial_account_id;
89 * Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)
96 * The table providing the source of this item such as civicrm_line_item
100 public $entity_table;
103 * The specific source item that is responsible for the creation of this financial_item
112 public function __construct() {
113 $this->__table
= 'civicrm_financial_item';
114 parent
::__construct();
118 * Returns localized title of this entity.
120 * @param bool $plural
121 * Whether to return the plural version of the title.
123 public static function getEntityTitle($plural = FALSE) {
124 return $plural ?
ts('Financial Items') : ts('Financial Item');
128 * Returns foreign keys and entity references.
131 * [CRM_Core_Reference_Interface]
133 public static function getReferenceColumns() {
134 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
135 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
136 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
137 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id');
138 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
139 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
141 return Civi
::$statics[__CLASS__
]['links'];
145 * Returns all the column names of this table
149 public static function &fields() {
150 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
151 Civi
::$statics[__CLASS__
]['fields'] = [
154 'type' => CRM_Utils_Type
::T_INT
,
155 'title' => ts('Financial Item ID'),
157 'where' => 'civicrm_financial_item.id',
158 'table_name' => 'civicrm_financial_item',
159 'entity' => 'FinancialItem',
160 'bao' => 'CRM_Financial_BAO_FinancialItem',
165 'name' => 'created_date',
166 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
167 'title' => ts('Financial Item Created Date'),
168 'description' => ts('Date and time the item was created'),
170 'where' => 'civicrm_financial_item.created_date',
171 'default' => 'CURRENT_TIMESTAMP',
172 'table_name' => 'civicrm_financial_item',
173 'entity' => 'FinancialItem',
174 'bao' => 'CRM_Financial_BAO_FinancialItem',
178 'transaction_date' => [
179 'name' => 'transaction_date',
180 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
181 'title' => ts('Financial Item Transaction Date'),
182 'description' => ts('Date and time of the source transaction'),
184 'where' => 'civicrm_financial_item.transaction_date',
185 'table_name' => 'civicrm_financial_item',
186 'entity' => 'FinancialItem',
187 'bao' => 'CRM_Financial_BAO_FinancialItem',
192 'name' => 'contact_id',
193 'type' => CRM_Utils_Type
::T_INT
,
194 'title' => ts('Financial Item Contact ID'),
195 'description' => ts('FK to Contact ID of contact the item is from'),
197 'where' => 'civicrm_financial_item.contact_id',
199 'table_name' => 'civicrm_financial_item',
200 'entity' => 'FinancialItem',
201 'bao' => 'CRM_Financial_BAO_FinancialItem',
203 'FKClassName' => 'CRM_Contact_DAO_Contact',
207 'name' => 'description',
208 'type' => CRM_Utils_Type
::T_STRING
,
209 'title' => ts('Financial Item Description'),
210 'description' => ts('Human readable description of this item, to ease display without lookup of source item.'),
212 'size' => CRM_Utils_Type
::HUGE
,
213 'where' => 'civicrm_financial_item.description',
214 'table_name' => 'civicrm_financial_item',
215 'entity' => 'FinancialItem',
216 'bao' => 'CRM_Financial_BAO_FinancialItem',
222 'type' => CRM_Utils_Type
::T_MONEY
,
223 'title' => ts('Amount'),
224 'description' => ts('Total amount of this item'),
230 'where' => 'civicrm_financial_item.amount',
231 'headerPattern' => '/unit?.?amoun/i',
232 'dataPattern' => '/^\d+(\.\d{2})?$/',
234 'table_name' => 'civicrm_financial_item',
235 'entity' => 'FinancialItem',
236 'bao' => 'CRM_Financial_BAO_FinancialItem',
241 'name' => 'currency',
242 'type' => CRM_Utils_Type
::T_STRING
,
243 'title' => ts('Financial Item Currency'),
244 'description' => ts('Currency for the amount'),
246 'size' => CRM_Utils_Type
::FOUR
,
247 'where' => 'civicrm_financial_item.currency',
249 'table_name' => 'civicrm_financial_item',
250 'entity' => 'FinancialItem',
251 'bao' => 'CRM_Financial_BAO_FinancialItem',
256 'pseudoconstant' => [
257 'table' => 'civicrm_currency',
258 'keyColumn' => 'name',
259 'labelColumn' => 'full_name',
260 'nameColumn' => 'name',
261 'abbrColumn' => 'symbol',
265 'financial_account_id' => [
266 'name' => 'financial_account_id',
267 'type' => CRM_Utils_Type
::T_INT
,
268 'title' => ts('Financial Account ID'),
269 'description' => ts('FK to civicrm_financial_account'),
270 'where' => 'civicrm_financial_item.financial_account_id',
271 'table_name' => 'civicrm_financial_item',
272 'entity' => 'FinancialItem',
273 'bao' => 'CRM_Financial_BAO_FinancialItem',
275 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
279 'pseudoconstant' => [
280 'table' => 'civicrm_financial_account',
282 'labelColumn' => 'name',
287 'name' => 'status_id',
288 'type' => CRM_Utils_Type
::T_INT
,
289 'title' => ts('Financial Item Status ID'),
290 'description' => ts('Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)'),
291 'where' => 'civicrm_financial_item.status_id',
293 'table_name' => 'civicrm_financial_item',
294 'entity' => 'FinancialItem',
295 'bao' => 'CRM_Financial_BAO_FinancialItem',
300 'pseudoconstant' => [
301 'optionGroupName' => 'financial_item_status',
302 'optionEditPath' => 'civicrm/admin/options/financial_item_status',
307 'name' => 'entity_table',
308 'type' => CRM_Utils_Type
::T_STRING
,
309 'title' => ts('Entity Table'),
310 'description' => ts('The table providing the source of this item such as civicrm_line_item'),
312 'size' => CRM_Utils_Type
::BIG
,
313 'where' => 'civicrm_financial_item.entity_table',
314 'table_name' => 'civicrm_financial_item',
315 'entity' => 'FinancialItem',
316 'bao' => 'CRM_Financial_BAO_FinancialItem',
321 'name' => 'entity_id',
322 'type' => CRM_Utils_Type
::T_INT
,
323 'title' => ts('Entity ID'),
324 'description' => ts('The specific source item that is responsible for the creation of this financial_item'),
325 'where' => 'civicrm_financial_item.entity_id',
326 'table_name' => 'civicrm_financial_item',
327 'entity' => 'FinancialItem',
328 'bao' => 'CRM_Financial_BAO_FinancialItem',
333 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
335 return Civi
::$statics[__CLASS__
]['fields'];
339 * Return a mapping from field-name to the corresponding key (as used in fields()).
342 * Array(string $name => string $uniqueName).
344 public static function &fieldKeys() {
345 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
346 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
348 return Civi
::$statics[__CLASS__
]['fieldKeys'];
352 * Returns the names of this table
356 public static function getTableName() {
357 return self
::$_tableName;
361 * Returns if this table needs to be logged
365 public function getLog() {
370 * Returns the list of fields that can be imported
372 * @param bool $prefix
376 public static function &import($prefix = FALSE) {
377 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_item', $prefix, []);
382 * Returns the list of fields that can be exported
384 * @param bool $prefix
388 public static function &export($prefix = FALSE) {
389 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_item', $prefix, []);
394 * Returns the list of indices
396 * @param bool $localize
400 public static function indices($localize = TRUE) {
402 'IX_created_date' => [
403 'name' => 'IX_created_date',
407 'localizable' => FALSE,
408 'sig' => 'civicrm_financial_item::0::created_date',
410 'IX_transaction_date' => [
411 'name' => 'IX_transaction_date',
413 0 => 'transaction_date',
415 'localizable' => FALSE,
416 'sig' => 'civicrm_financial_item::0::transaction_date',
418 'index_entity_id_entity_table' => [
419 'name' => 'index_entity_id_entity_table',
424 'localizable' => FALSE,
425 'sig' => 'civicrm_financial_item::0::entity_id::entity_table',
428 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;