dd5940494d7cdb8e27023271c51cad1ad3d9791b
[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:b7687297d632a4658b6686a5b540f974)
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 unsigned
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 unsigned
47 */
48 public $entity_id;
49
50 /**
51 * @var int unsigned
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 'table_name' => 'civicrm_entity_financial_trxn',
101 'entity' => 'EntityFinancialTrxn',
102 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
103 'localizable' => 0,
104 ],
105 'entity_table' => [
106 'name' => 'entity_table',
107 'type' => CRM_Utils_Type::T_STRING,
108 'title' => ts('Entity Table'),
109 'description' => ts('May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc'),
110 'required' => TRUE,
111 'maxlength' => 64,
112 'size' => CRM_Utils_Type::BIG,
113 'import' => TRUE,
114 'where' => 'civicrm_entity_financial_trxn.entity_table',
115 'headerPattern' => '',
116 'dataPattern' => '',
117 'export' => TRUE,
118 'table_name' => 'civicrm_entity_financial_trxn',
119 'entity' => 'EntityFinancialTrxn',
120 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
121 'localizable' => 0,
122 ],
123 'entity_id' => [
124 'name' => 'entity_id',
125 'type' => CRM_Utils_Type::T_INT,
126 'title' => ts('Entity ID'),
127 'required' => TRUE,
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 'table_name' => 'civicrm_entity_financial_trxn',
138 'entity' => 'EntityFinancialTrxn',
139 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
140 'localizable' => 0,
141 'FKClassName' => 'CRM_Financial_DAO_FinancialTrxn',
142 ],
143 'amount' => [
144 'name' => 'amount',
145 'type' => CRM_Utils_Type::T_MONEY,
146 'title' => ts('Amount'),
147 'description' => ts('allocated amount of transaction to this entity'),
148 'required' => TRUE,
149 'precision' => [
150 20,
151 2
152 ],
153 'import' => TRUE,
154 'where' => 'civicrm_entity_financial_trxn.amount',
155 'headerPattern' => '/amount/i',
156 'dataPattern' => '/^\d+(\.\d{2})?$/',
157 'export' => TRUE,
158 'table_name' => 'civicrm_entity_financial_trxn',
159 'entity' => 'EntityFinancialTrxn',
160 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
161 'localizable' => 0,
162 ],
163 ];
164 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
165 }
166 return Civi::$statics[__CLASS__]['fields'];
167 }
168
169 /**
170 * Return a mapping from field-name to the corresponding key (as used in fields()).
171 *
172 * @return array
173 * Array(string $name => string $uniqueName).
174 */
175 public static function &fieldKeys() {
176 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
177 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
178 }
179 return Civi::$statics[__CLASS__]['fieldKeys'];
180 }
181
182 /**
183 * Returns the names of this table
184 *
185 * @return string
186 */
187 public static function getTableName() {
188 return self::$_tableName;
189 }
190
191 /**
192 * Returns if this table needs to be logged
193 *
194 * @return bool
195 */
196 public function getLog() {
197 return self::$_log;
198 }
199
200 /**
201 * Returns the list of fields that can be imported
202 *
203 * @param bool $prefix
204 *
205 * @return array
206 */
207 public static function &import($prefix = FALSE) {
208 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'entity_financial_trxn', $prefix, []);
209 return $r;
210 }
211
212 /**
213 * Returns the list of fields that can be exported
214 *
215 * @param bool $prefix
216 *
217 * @return array
218 */
219 public static function &export($prefix = FALSE) {
220 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'entity_financial_trxn', $prefix, []);
221 return $r;
222 }
223
224 /**
225 * Returns the list of indices
226 *
227 * @param bool $localize
228 *
229 * @return array
230 */
231 public static function indices($localize = TRUE) {
232 $indices = [
233 'UI_entity_financial_trxn_entity_table' => [
234 'name' => 'UI_entity_financial_trxn_entity_table',
235 'field' => [
236 0 => 'entity_table',
237 ],
238 'localizable' => FALSE,
239 'sig' => 'civicrm_entity_financial_trxn::0::entity_table',
240 ],
241 'UI_entity_financial_trxn_entity_id' => [
242 'name' => 'UI_entity_financial_trxn_entity_id',
243 'field' => [
244 0 => 'entity_id',
245 ],
246 'localizable' => FALSE,
247 'sig' => 'civicrm_entity_financial_trxn::0::entity_id',
248 ],
249 ];
250 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
251 }
252
253 }