Merge pull request #17491 from eileenmcnaughton/toemail
[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:2654d7bdf6a8a80e13d17a6bb88e2a1a)
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 localized title of this entity.
72 */
73 public static function getEntityTitle() {
74 return ts('Entity Financial Trxns');
75 }
76
77 /**
78 * Returns foreign keys and entity references.
79 *
80 * @return array
81 * [CRM_Core_Reference_Interface]
82 */
83 public static function getReferenceColumns() {
84 if (!isset(Civi::$statics[__CLASS__]['links'])) {
85 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
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');
88 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
89 }
90 return Civi::$statics[__CLASS__]['links'];
91 }
92
93 /**
94 * Returns all the column names of this table
95 *
96 * @return array
97 */
98 public static function &fields() {
99 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
100 Civi::$statics[__CLASS__]['fields'] = [
101 'id' => [
102 'name' => 'id',
103 'type' => CRM_Utils_Type::T_INT,
104 'title' => ts('Entity Financial Transaction ID'),
105 'description' => ts('ID'),
106 'required' => TRUE,
107 'where' => 'civicrm_entity_financial_trxn.id',
108 'table_name' => 'civicrm_entity_financial_trxn',
109 'entity' => 'EntityFinancialTrxn',
110 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
111 'localizable' => 0,
112 ],
113 'entity_table' => [
114 'name' => 'entity_table',
115 'type' => CRM_Utils_Type::T_STRING,
116 'title' => ts('Entity Table'),
117 'description' => ts('May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc'),
118 'required' => TRUE,
119 'maxlength' => 64,
120 'size' => CRM_Utils_Type::BIG,
121 'import' => TRUE,
122 'where' => 'civicrm_entity_financial_trxn.entity_table',
123 'export' => TRUE,
124 'table_name' => 'civicrm_entity_financial_trxn',
125 'entity' => 'EntityFinancialTrxn',
126 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
127 'localizable' => 0,
128 ],
129 'entity_id' => [
130 'name' => 'entity_id',
131 'type' => CRM_Utils_Type::T_INT,
132 'title' => ts('Entity ID'),
133 'required' => TRUE,
134 'where' => 'civicrm_entity_financial_trxn.entity_id',
135 'table_name' => 'civicrm_entity_financial_trxn',
136 'entity' => 'EntityFinancialTrxn',
137 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
138 'localizable' => 0,
139 ],
140 'financial_trxn_id' => [
141 'name' => 'financial_trxn_id',
142 'type' => CRM_Utils_Type::T_INT,
143 'title' => ts('Financial Transaction Id'),
144 'where' => 'civicrm_entity_financial_trxn.financial_trxn_id',
145 'table_name' => 'civicrm_entity_financial_trxn',
146 'entity' => 'EntityFinancialTrxn',
147 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
148 'localizable' => 0,
149 'FKClassName' => 'CRM_Financial_DAO_FinancialTrxn',
150 ],
151 'amount' => [
152 'name' => 'amount',
153 'type' => CRM_Utils_Type::T_MONEY,
154 'title' => ts('Amount'),
155 'description' => ts('allocated amount of transaction to this entity'),
156 'required' => TRUE,
157 'precision' => [
158 20,
159 2,
160 ],
161 'import' => TRUE,
162 'where' => 'civicrm_entity_financial_trxn.amount',
163 'headerPattern' => '/amount/i',
164 'dataPattern' => '/^\d+(\.\d{2})?$/',
165 'export' => TRUE,
166 'table_name' => 'civicrm_entity_financial_trxn',
167 'entity' => 'EntityFinancialTrxn',
168 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
169 'localizable' => 0,
170 ],
171 ];
172 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
173 }
174 return Civi::$statics[__CLASS__]['fields'];
175 }
176
177 /**
178 * Return a mapping from field-name to the corresponding key (as used in fields()).
179 *
180 * @return array
181 * Array(string $name => string $uniqueName).
182 */
183 public static function &fieldKeys() {
184 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
185 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
186 }
187 return Civi::$statics[__CLASS__]['fieldKeys'];
188 }
189
190 /**
191 * Returns the names of this table
192 *
193 * @return string
194 */
195 public static function getTableName() {
196 return self::$_tableName;
197 }
198
199 /**
200 * Returns if this table needs to be logged
201 *
202 * @return bool
203 */
204 public function getLog() {
205 return self::$_log;
206 }
207
208 /**
209 * Returns the list of fields that can be imported
210 *
211 * @param bool $prefix
212 *
213 * @return array
214 */
215 public static function &import($prefix = FALSE) {
216 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'entity_financial_trxn', $prefix, []);
217 return $r;
218 }
219
220 /**
221 * Returns the list of fields that can be exported
222 *
223 * @param bool $prefix
224 *
225 * @return array
226 */
227 public static function &export($prefix = FALSE) {
228 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'entity_financial_trxn', $prefix, []);
229 return $r;
230 }
231
232 /**
233 * Returns the list of indices
234 *
235 * @param bool $localize
236 *
237 * @return array
238 */
239 public static function indices($localize = TRUE) {
240 $indices = [
241 'UI_entity_financial_trxn_entity_table' => [
242 'name' => 'UI_entity_financial_trxn_entity_table',
243 'field' => [
244 0 => 'entity_table',
245 ],
246 'localizable' => FALSE,
247 'sig' => 'civicrm_entity_financial_trxn::0::entity_table',
248 ],
249 'UI_entity_financial_trxn_entity_id' => [
250 'name' => 'UI_entity_financial_trxn_entity_id',
251 'field' => [
252 0 => 'entity_id',
253 ],
254 'localizable' => FALSE,
255 'sig' => 'civicrm_entity_financial_trxn::0::entity_id',
256 ],
257 ];
258 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
259 }
260
261 }