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