Merge pull request #17613 from civicrm/5.27
[civicrm-core.git] / CRM / Financial / DAO / EntityFinancialTrxn.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
ca5cec67 5 * @copyright CiviCRM LLC https://civicrm.org/licensing
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Financial/EntityFinancialTrxn.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
449c4e6b 9 * (GenCodeChecksum:2654d7bdf6a8a80e13d17a6bb88e2a1a)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the EntityFinancialTrxn entity.
f41f0342 14 */
e501603b 15class CRM_Financial_DAO_EntityFinancialTrxn extends CRM_Core_DAO {
c3fc2621 16
e501603b 17 /**
f41f0342 18 * Static instance to hold the table name.
e501603b
TO
19 *
20 * @var string
21 */
fa45b5b9 22 public static $_tableName = 'civicrm_entity_financial_trxn';
c3fc2621 23
e501603b 24 /**
f41f0342 25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 26 *
c3fc2621 27 * @var bool
e501603b 28 */
fa45b5b9 29 public static $_log = FALSE;
c3fc2621 30
e501603b
TO
31 /**
32 * ID
33 *
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc
40 *
41 * @var string
42 */
43 public $entity_table;
c3fc2621 44
e501603b 45 /**
e6ca0a57 46 * @var int
e501603b
TO
47 */
48 public $entity_id;
c3fc2621 49
e501603b 50 /**
e6ca0a57 51 * @var int
e501603b
TO
52 */
53 public $financial_trxn_id;
c3fc2621 54
e501603b
TO
55 /**
56 * allocated amount of transaction to this entity
57 *
58 * @var float
59 */
60 public $amount;
c3fc2621 61
e501603b 62 /**
f41f0342 63 * Class constructor.
e501603b 64 */
c3fc2621 65 public function __construct() {
e501603b
TO
66 $this->__table = 'civicrm_entity_financial_trxn';
67 parent::__construct();
68 }
c3fc2621 69
449c4e6b
CW
70 /**
71 * Returns localized title of this entity.
72 */
73 public static function getEntityTitle() {
74 return ts('Entity Financial Trxns');
75 }
76
e501603b 77 /**
f41f0342 78 * Returns foreign keys and entity references.
e501603b
TO
79 *
80 * @return array
81 * [CRM_Core_Reference_Interface]
82 */
c3fc2621 83 public static function getReferenceColumns() {
346aaaba 84 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 85 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
86 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_trxn_id', 'civicrm_financial_trxn', 'id');
87 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
346aaaba 88 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 89 }
346aaaba 90 return Civi::$statics[__CLASS__]['links'];
e501603b 91 }
c3fc2621 92
e501603b
TO
93 /**
94 * Returns all the column names of this table
95 *
96 * @return array
97 */
c3fc2621 98 public static function &fields() {
346aaaba 99 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
100 Civi::$statics[__CLASS__]['fields'] = [
101 'id' => [
e501603b
TO
102 'name' => 'id',
103 'type' => CRM_Utils_Type::T_INT,
c3fc2621 104 'title' => ts('Entity Financial Transaction ID'),
215b423e 105 'description' => ts('ID'),
c3fc2621 106 'required' => TRUE,
a36434b9 107 'where' => 'civicrm_entity_financial_trxn.id',
522a26c9 108 'table_name' => 'civicrm_entity_financial_trxn',
109 'entity' => 'EntityFinancialTrxn',
110 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
6a7e5e5d 111 'localizable' => 0,
c3fc2621
CW
112 ],
113 'entity_table' => [
e501603b
TO
114 'name' => 'entity_table',
115 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 116 'title' => ts('Entity Table'),
215b423e 117 'description' => ts('May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc'),
c3fc2621 118 'required' => TRUE,
e501603b
TO
119 'maxlength' => 64,
120 'size' => CRM_Utils_Type::BIG,
c3fc2621 121 'import' => TRUE,
e501603b 122 'where' => 'civicrm_entity_financial_trxn.entity_table',
c3fc2621 123 'export' => TRUE,
522a26c9 124 'table_name' => 'civicrm_entity_financial_trxn',
125 'entity' => 'EntityFinancialTrxn',
126 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
6a7e5e5d 127 'localizable' => 0,
c3fc2621
CW
128 ],
129 'entity_id' => [
e501603b
TO
130 'name' => 'entity_id',
131 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
132 'title' => ts('Entity ID'),
133 'required' => TRUE,
a36434b9 134 'where' => 'civicrm_entity_financial_trxn.entity_id',
522a26c9 135 'table_name' => 'civicrm_entity_financial_trxn',
136 'entity' => 'EntityFinancialTrxn',
137 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
6a7e5e5d 138 'localizable' => 0,
c3fc2621
CW
139 ],
140 'financial_trxn_id' => [
e501603b
TO
141 'name' => 'financial_trxn_id',
142 'type' => CRM_Utils_Type::T_INT,
c3fc2621 143 'title' => ts('Financial Transaction Id'),
a36434b9 144 'where' => 'civicrm_entity_financial_trxn.financial_trxn_id',
522a26c9 145 'table_name' => 'civicrm_entity_financial_trxn',
146 'entity' => 'EntityFinancialTrxn',
147 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
6a7e5e5d 148 'localizable' => 0,
e501603b 149 'FKClassName' => 'CRM_Financial_DAO_FinancialTrxn',
c3fc2621
CW
150 ],
151 'amount' => [
e501603b
TO
152 'name' => 'amount',
153 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 154 'title' => ts('Amount'),
215b423e 155 'description' => ts('allocated amount of transaction to this entity'),
c3fc2621
CW
156 'required' => TRUE,
157 'precision' => [
e501603b 158 20,
fb607354 159 2,
c3fc2621
CW
160 ],
161 'import' => TRUE,
e501603b
TO
162 'where' => 'civicrm_entity_financial_trxn.amount',
163 'headerPattern' => '/amount/i',
164 'dataPattern' => '/^\d+(\.\d{2})?$/',
c3fc2621 165 'export' => TRUE,
522a26c9 166 'table_name' => 'civicrm_entity_financial_trxn',
167 'entity' => 'EntityFinancialTrxn',
168 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
6a7e5e5d 169 'localizable' => 0,
c3fc2621
CW
170 ],
171 ];
346aaaba 172 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 173 }
346aaaba 174 return Civi::$statics[__CLASS__]['fields'];
e501603b 175 }
c3fc2621 176
e501603b 177 /**
bd8e0b14 178 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
179 *
180 * @return array
bd8e0b14 181 * Array(string $name => string $uniqueName).
e501603b 182 */
c3fc2621 183 public static function &fieldKeys() {
bd8e0b14
TO
184 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
185 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 186 }
bd8e0b14 187 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 188 }
c3fc2621 189
e501603b
TO
190 /**
191 * Returns the names of this table
192 *
193 * @return string
194 */
c3fc2621 195 public static function getTableName() {
e501603b
TO
196 return self::$_tableName;
197 }
c3fc2621 198
e501603b
TO
199 /**
200 * Returns if this table needs to be logged
201 *
c3fc2621 202 * @return bool
e501603b 203 */
c3fc2621 204 public function getLog() {
e501603b
TO
205 return self::$_log;
206 }
c3fc2621 207
e501603b
TO
208 /**
209 * Returns the list of fields that can be imported
210 *
211 * @param bool $prefix
212 *
213 * @return array
214 */
c3fc2621
CW
215 public static function &import($prefix = FALSE) {
216 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'entity_financial_trxn', $prefix, []);
60808919 217 return $r;
e501603b 218 }
c3fc2621 219
e501603b
TO
220 /**
221 * Returns the list of fields that can be exported
222 *
223 * @param bool $prefix
224 *
225 * @return array
226 */
c3fc2621
CW
227 public static function &export($prefix = FALSE) {
228 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'entity_financial_trxn', $prefix, []);
60808919 229 return $r;
e501603b 230 }
c3fc2621 231
e7a6b91a
AS
232 /**
233 * Returns the list of indices
c3fc2621
CW
234 *
235 * @param bool $localize
236 *
237 * @return array
e7a6b91a
AS
238 */
239 public static function indices($localize = TRUE) {
c3fc2621
CW
240 $indices = [
241 'UI_entity_financial_trxn_entity_table' => [
e7a6b91a 242 'name' => 'UI_entity_financial_trxn_entity_table',
c3fc2621 243 'field' => [
e7a6b91a 244 0 => 'entity_table',
c3fc2621
CW
245 ],
246 'localizable' => FALSE,
e7a6b91a 247 'sig' => 'civicrm_entity_financial_trxn::0::entity_table',
c3fc2621
CW
248 ],
249 'UI_entity_financial_trxn_entity_id' => [
e7a6b91a 250 'name' => 'UI_entity_financial_trxn_entity_id',
c3fc2621 251 'field' => [
e7a6b91a 252 0 => 'entity_id',
c3fc2621
CW
253 ],
254 'localizable' => FALSE,
e7a6b91a 255 'sig' => 'civicrm_entity_financial_trxn::0::entity_id',
c3fc2621
CW
256 ],
257 ];
e7a6b91a
AS
258 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
259 }
c3fc2621 260
e501603b 261}