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