5 * @copyright CiviCRM LLC (c) 2004-2018
7 * Generated from xml/schema/CRM/Financial/FinancialItem.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:95e199969f4ff93ccae635fb7e0d30f2)
13 * Database access object for the FinancialItem entity.
15 class CRM_Financial_DAO_FinancialItem
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 static $_tableName = 'civicrm_financial_item';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
37 * Date and time the item was created
44 * Date and time of the source transaction
48 public $transaction_date;
51 * FK to Contact ID of contact the item is from
58 * Human readable description of this item, to ease display without lookup of source item.
65 * Total amount of this item
72 * Currency for the amount
79 * FK to civicrm_financial_account
83 public $financial_account_id;
86 * Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)
93 * The table providing the source of this item such as civicrm_line_item
100 * The specific source item that is responsible for the creation of this financial_item
109 public function __construct() {
110 $this->__table
= 'civicrm_financial_item';
111 parent
::__construct();
115 * Returns foreign keys and entity references.
118 * [CRM_Core_Reference_Interface]
120 public static function getReferenceColumns() {
121 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
122 Civi
::$statics[__CLASS__
]['links'] = static ::createReferenceColumns(__CLASS__
);
123 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
124 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id');
125 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
126 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
128 return Civi
::$statics[__CLASS__
]['links'];
132 * Returns all the column names of this table
136 public static function &fields() {
137 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
138 Civi
::$statics[__CLASS__
]['fields'] = [
141 'type' => CRM_Utils_Type
::T_INT
,
142 'title' => ts('Financial Item ID'),
144 'table_name' => 'civicrm_financial_item',
145 'entity' => 'FinancialItem',
146 'bao' => 'CRM_Financial_BAO_FinancialItem',
150 'name' => 'created_date',
151 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
152 'title' => ts('Financial Item Created Date'),
153 'description' => 'Date and time the item was created',
155 'default' => 'CURRENT_TIMESTAMP',
156 'table_name' => 'civicrm_financial_item',
157 'entity' => 'FinancialItem',
158 'bao' => 'CRM_Financial_BAO_FinancialItem',
161 'transaction_date' => [
162 'name' => 'transaction_date',
163 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
164 'title' => ts('Financial Item Transaction Date'),
165 'description' => 'Date and time of the source transaction',
167 'table_name' => 'civicrm_financial_item',
168 'entity' => 'FinancialItem',
169 'bao' => 'CRM_Financial_BAO_FinancialItem',
173 'name' => 'contact_id',
174 'type' => CRM_Utils_Type
::T_INT
,
175 'title' => ts('Financial Item Contact ID'),
176 'description' => 'FK to Contact ID of contact the item is from',
179 'where' => 'civicrm_financial_item.contact_id',
180 'headerPattern' => '',
182 'table_name' => 'civicrm_financial_item',
183 'entity' => 'FinancialItem',
184 'bao' => 'CRM_Financial_BAO_FinancialItem',
186 'FKClassName' => 'CRM_Contact_DAO_Contact',
189 'name' => 'description',
190 'type' => CRM_Utils_Type
::T_STRING
,
191 'title' => ts('Financial Item Description'),
192 'description' => 'Human readable description of this item, to ease display without lookup of source item.',
194 'size' => CRM_Utils_Type
::HUGE
,
195 'table_name' => 'civicrm_financial_item',
196 'entity' => 'FinancialItem',
197 'bao' => 'CRM_Financial_BAO_FinancialItem',
202 'type' => CRM_Utils_Type
::T_MONEY
,
203 'title' => ts('Amount'),
204 'description' => 'Total amount of this item',
211 'table_name' => 'civicrm_financial_item',
212 'entity' => 'FinancialItem',
213 'bao' => 'CRM_Financial_BAO_FinancialItem',
217 'name' => 'currency',
218 'type' => CRM_Utils_Type
::T_STRING
,
219 'title' => ts('Financial Item Currency'),
220 'description' => 'Currency for the amount',
222 'size' => CRM_Utils_Type
::FOUR
,
224 'where' => 'civicrm_financial_item.currency',
225 'headerPattern' => '',
227 'table_name' => 'civicrm_financial_item',
228 'entity' => 'FinancialItem',
229 'bao' => 'CRM_Financial_BAO_FinancialItem',
234 'pseudoconstant' => [
235 'table' => 'civicrm_currency',
236 'keyColumn' => 'name',
237 'labelColumn' => 'full_name',
238 'nameColumn' => 'name',
241 'financial_account_id' => [
242 'name' => 'financial_account_id',
243 'type' => CRM_Utils_Type
::T_INT
,
244 'title' => ts('Financial Account ID'),
245 'description' => 'FK to civicrm_financial_account',
246 'table_name' => 'civicrm_financial_item',
247 'entity' => 'FinancialItem',
248 'bao' => 'CRM_Financial_BAO_FinancialItem',
250 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
254 'pseudoconstant' => [
255 'table' => 'civicrm_financial_account',
257 'labelColumn' => 'name',
261 'name' => 'status_id',
262 'type' => CRM_Utils_Type
::T_INT
,
263 'title' => ts('Financial Item Status ID'),
264 'description' => 'Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)',
266 'where' => 'civicrm_financial_item.status_id',
267 'headerPattern' => '',
269 'table_name' => 'civicrm_financial_item',
270 'entity' => 'FinancialItem',
271 'bao' => 'CRM_Financial_BAO_FinancialItem',
276 'pseudoconstant' => [
277 'optionGroupName' => 'financial_item_status',
278 'optionEditPath' => 'civicrm/admin/options/financial_item_status',
282 'name' => 'entity_table',
283 'type' => CRM_Utils_Type
::T_STRING
,
284 'title' => ts('Entity Table'),
285 'description' => 'The table providing the source of this item such as civicrm_line_item',
287 'size' => CRM_Utils_Type
::BIG
,
288 'table_name' => 'civicrm_financial_item',
289 'entity' => 'FinancialItem',
290 'bao' => 'CRM_Financial_BAO_FinancialItem',
294 'name' => 'entity_id',
295 'type' => CRM_Utils_Type
::T_INT
,
296 'title' => ts('Entity ID'),
297 'description' => 'The specific source item that is responsible for the creation of this financial_item',
298 'table_name' => 'civicrm_financial_item',
299 'entity' => 'FinancialItem',
300 'bao' => 'CRM_Financial_BAO_FinancialItem',
304 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
306 return Civi
::$statics[__CLASS__
]['fields'];
310 * Return a mapping from field-name to the corresponding key (as used in fields()).
313 * Array(string $name => string $uniqueName).
315 public static function &fieldKeys() {
316 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
317 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
319 return Civi
::$statics[__CLASS__
]['fieldKeys'];
323 * Returns the names of this table
327 public static function getTableName() {
328 return self
::$_tableName;
332 * Returns if this table needs to be logged
336 public function getLog() {
341 * Returns the list of fields that can be imported
343 * @param bool $prefix
347 public static function &import($prefix = FALSE) {
348 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_item', $prefix, []);
353 * Returns the list of fields that can be exported
355 * @param bool $prefix
359 public static function &export($prefix = FALSE) {
360 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_item', $prefix, []);
365 * Returns the list of indices
367 * @param bool $localize
371 public static function indices($localize = TRUE) {
373 'IX_created_date' => [
374 'name' => 'IX_created_date',
378 'localizable' => FALSE,
379 'sig' => 'civicrm_financial_item::0::created_date',
381 'IX_transaction_date' => [
382 'name' => 'IX_transaction_date',
384 0 => 'transaction_date',
386 'localizable' => FALSE,
387 'sig' => 'civicrm_financial_item::0::transaction_date',
389 'index_entity_id_entity_table' => [
390 'name' => 'index_entity_id_entity_table',
395 'localizable' => FALSE,
396 'sig' => 'civicrm_financial_item::0::entity_id::entity_table',
399 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;