Merge pull request #14059 from Stoob/patch-2
[civicrm-core.git] / CRM / Financial / DAO / FinancialItem.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Financial/FinancialItem.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:8ebea76ed5ae2b3e7fe0ddafa55a4aed)
10 */
11
12 /**
13 * Database access object for the FinancialItem entity.
14 */
15 class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_financial_item';
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 = TRUE;
30
31 /**
32 * @var int unsigned
33 */
34 public $id;
35
36 /**
37 * Date and time the item was created
38 *
39 * @var timestamp
40 */
41 public $created_date;
42
43 /**
44 * Date and time of the source transaction
45 *
46 * @var datetime
47 */
48 public $transaction_date;
49
50 /**
51 * FK to Contact ID of contact the item is from
52 *
53 * @var int unsigned
54 */
55 public $contact_id;
56
57 /**
58 * Human readable description of this item, to ease display without lookup of source item.
59 *
60 * @var string
61 */
62 public $description;
63
64 /**
65 * Total amount of this item
66 *
67 * @var float
68 */
69 public $amount;
70
71 /**
72 * Currency for the amount
73 *
74 * @var string
75 */
76 public $currency;
77
78 /**
79 * FK to civicrm_financial_account
80 *
81 * @var int unsigned
82 */
83 public $financial_account_id;
84
85 /**
86 * Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)
87 *
88 * @var int unsigned
89 */
90 public $status_id;
91
92 /**
93 * The table providing the source of this item such as civicrm_line_item
94 *
95 * @var string
96 */
97 public $entity_table;
98
99 /**
100 * The specific source item that is responsible for the creation of this financial_item
101 *
102 * @var int unsigned
103 */
104 public $entity_id;
105
106 /**
107 * Class constructor.
108 */
109 public function __construct() {
110 $this->__table = 'civicrm_financial_item';
111 parent::__construct();
112 }
113
114 /**
115 * Returns foreign keys and entity references.
116 *
117 * @return array
118 * [CRM_Core_Reference_Interface]
119 */
120 public static function getReferenceColumns() {
121 if (!isset(Civi::$statics[__CLASS__]['links'])) {
122 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
123 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
124 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id');
125 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
126 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
127 }
128 return Civi::$statics[__CLASS__]['links'];
129 }
130
131 /**
132 * Returns all the column names of this table
133 *
134 * @return array
135 */
136 public static function &fields() {
137 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
138 Civi::$statics[__CLASS__]['fields'] = [
139 'id' => [
140 'name' => 'id',
141 'type' => CRM_Utils_Type::T_INT,
142 'title' => ts('Financial Item ID'),
143 'required' => TRUE,
144 'where' => 'civicrm_financial_item.id',
145 'table_name' => 'civicrm_financial_item',
146 'entity' => 'FinancialItem',
147 'bao' => 'CRM_Financial_BAO_FinancialItem',
148 'localizable' => 0,
149 ],
150 'created_date' => [
151 'name' => 'created_date',
152 'type' => CRM_Utils_Type::T_TIMESTAMP,
153 'title' => ts('Financial Item Created Date'),
154 'description' => ts('Date and time the item was created'),
155 'required' => TRUE,
156 'where' => 'civicrm_financial_item.created_date',
157 'default' => 'CURRENT_TIMESTAMP',
158 'table_name' => 'civicrm_financial_item',
159 'entity' => 'FinancialItem',
160 'bao' => 'CRM_Financial_BAO_FinancialItem',
161 'localizable' => 0,
162 ],
163 'transaction_date' => [
164 'name' => 'transaction_date',
165 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
166 'title' => ts('Financial Item Transaction Date'),
167 'description' => ts('Date and time of the source transaction'),
168 'required' => TRUE,
169 'where' => 'civicrm_financial_item.transaction_date',
170 'table_name' => 'civicrm_financial_item',
171 'entity' => 'FinancialItem',
172 'bao' => 'CRM_Financial_BAO_FinancialItem',
173 'localizable' => 0,
174 ],
175 'contact_id' => [
176 'name' => 'contact_id',
177 'type' => CRM_Utils_Type::T_INT,
178 'title' => ts('Financial Item Contact ID'),
179 'description' => ts('FK to Contact ID of contact the item is from'),
180 'required' => TRUE,
181 'where' => 'civicrm_financial_item.contact_id',
182 'export' => TRUE,
183 'table_name' => 'civicrm_financial_item',
184 'entity' => 'FinancialItem',
185 'bao' => 'CRM_Financial_BAO_FinancialItem',
186 'localizable' => 0,
187 'FKClassName' => 'CRM_Contact_DAO_Contact',
188 ],
189 'description' => [
190 'name' => 'description',
191 'type' => CRM_Utils_Type::T_STRING,
192 'title' => ts('Financial Item Description'),
193 'description' => ts('Human readable description of this item, to ease display without lookup of source item.'),
194 'maxlength' => 255,
195 'size' => CRM_Utils_Type::HUGE,
196 'where' => 'civicrm_financial_item.description',
197 'table_name' => 'civicrm_financial_item',
198 'entity' => 'FinancialItem',
199 'bao' => 'CRM_Financial_BAO_FinancialItem',
200 'localizable' => 0,
201 ],
202 'amount' => [
203 'name' => 'amount',
204 'type' => CRM_Utils_Type::T_MONEY,
205 'title' => ts('Amount'),
206 'description' => ts('Total amount of this item'),
207 'required' => TRUE,
208 'precision' => [
209 20,
210 2
211 ],
212 'where' => 'civicrm_financial_item.amount',
213 'headerPattern' => '/unit?.?amoun/i',
214 'dataPattern' => '/^\d+(\.\d{2})?$/',
215 'default' => '0',
216 'table_name' => 'civicrm_financial_item',
217 'entity' => 'FinancialItem',
218 'bao' => 'CRM_Financial_BAO_FinancialItem',
219 'localizable' => 0,
220 ],
221 'currency' => [
222 'name' => 'currency',
223 'type' => CRM_Utils_Type::T_STRING,
224 'title' => ts('Financial Item Currency'),
225 'description' => ts('Currency for the amount'),
226 'maxlength' => 3,
227 'size' => CRM_Utils_Type::FOUR,
228 'where' => 'civicrm_financial_item.currency',
229 'export' => TRUE,
230 'table_name' => 'civicrm_financial_item',
231 'entity' => 'FinancialItem',
232 'bao' => 'CRM_Financial_BAO_FinancialItem',
233 'localizable' => 0,
234 'html' => [
235 'type' => 'Select',
236 ],
237 'pseudoconstant' => [
238 'table' => 'civicrm_currency',
239 'keyColumn' => 'name',
240 'labelColumn' => 'full_name',
241 'nameColumn' => 'name',
242 ]
243 ],
244 'financial_account_id' => [
245 'name' => 'financial_account_id',
246 'type' => CRM_Utils_Type::T_INT,
247 'title' => ts('Financial Account ID'),
248 'description' => ts('FK to civicrm_financial_account'),
249 'where' => 'civicrm_financial_item.financial_account_id',
250 'table_name' => 'civicrm_financial_item',
251 'entity' => 'FinancialItem',
252 'bao' => 'CRM_Financial_BAO_FinancialItem',
253 'localizable' => 0,
254 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
255 'html' => [
256 'type' => 'Select',
257 ],
258 'pseudoconstant' => [
259 'table' => 'civicrm_financial_account',
260 'keyColumn' => 'id',
261 'labelColumn' => 'name',
262 ]
263 ],
264 'status_id' => [
265 'name' => 'status_id',
266 'type' => CRM_Utils_Type::T_INT,
267 'title' => ts('Financial Item Status ID'),
268 'description' => ts('Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)'),
269 'where' => 'civicrm_financial_item.status_id',
270 'export' => TRUE,
271 'table_name' => 'civicrm_financial_item',
272 'entity' => 'FinancialItem',
273 'bao' => 'CRM_Financial_BAO_FinancialItem',
274 'localizable' => 0,
275 'html' => [
276 'type' => 'Select',
277 ],
278 'pseudoconstant' => [
279 'optionGroupName' => 'financial_item_status',
280 'optionEditPath' => 'civicrm/admin/options/financial_item_status',
281 ]
282 ],
283 'entity_table' => [
284 'name' => 'entity_table',
285 'type' => CRM_Utils_Type::T_STRING,
286 'title' => ts('Entity Table'),
287 'description' => ts('The table providing the source of this item such as civicrm_line_item'),
288 'maxlength' => 64,
289 'size' => CRM_Utils_Type::BIG,
290 'where' => 'civicrm_financial_item.entity_table',
291 'table_name' => 'civicrm_financial_item',
292 'entity' => 'FinancialItem',
293 'bao' => 'CRM_Financial_BAO_FinancialItem',
294 'localizable' => 0,
295 ],
296 'entity_id' => [
297 'name' => 'entity_id',
298 'type' => CRM_Utils_Type::T_INT,
299 'title' => ts('Entity ID'),
300 'description' => ts('The specific source item that is responsible for the creation of this financial_item'),
301 'where' => 'civicrm_financial_item.entity_id',
302 'table_name' => 'civicrm_financial_item',
303 'entity' => 'FinancialItem',
304 'bao' => 'CRM_Financial_BAO_FinancialItem',
305 'localizable' => 0,
306 ],
307 ];
308 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
309 }
310 return Civi::$statics[__CLASS__]['fields'];
311 }
312
313 /**
314 * Return a mapping from field-name to the corresponding key (as used in fields()).
315 *
316 * @return array
317 * Array(string $name => string $uniqueName).
318 */
319 public static function &fieldKeys() {
320 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
321 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
322 }
323 return Civi::$statics[__CLASS__]['fieldKeys'];
324 }
325
326 /**
327 * Returns the names of this table
328 *
329 * @return string
330 */
331 public static function getTableName() {
332 return self::$_tableName;
333 }
334
335 /**
336 * Returns if this table needs to be logged
337 *
338 * @return bool
339 */
340 public function getLog() {
341 return self::$_log;
342 }
343
344 /**
345 * Returns the list of fields that can be imported
346 *
347 * @param bool $prefix
348 *
349 * @return array
350 */
351 public static function &import($prefix = FALSE) {
352 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_item', $prefix, []);
353 return $r;
354 }
355
356 /**
357 * Returns the list of fields that can be exported
358 *
359 * @param bool $prefix
360 *
361 * @return array
362 */
363 public static function &export($prefix = FALSE) {
364 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_item', $prefix, []);
365 return $r;
366 }
367
368 /**
369 * Returns the list of indices
370 *
371 * @param bool $localize
372 *
373 * @return array
374 */
375 public static function indices($localize = TRUE) {
376 $indices = [
377 'IX_created_date' => [
378 'name' => 'IX_created_date',
379 'field' => [
380 0 => 'created_date',
381 ],
382 'localizable' => FALSE,
383 'sig' => 'civicrm_financial_item::0::created_date',
384 ],
385 'IX_transaction_date' => [
386 'name' => 'IX_transaction_date',
387 'field' => [
388 0 => 'transaction_date',
389 ],
390 'localizable' => FALSE,
391 'sig' => 'civicrm_financial_item::0::transaction_date',
392 ],
393 'index_entity_id_entity_table' => [
394 'name' => 'index_entity_id_entity_table',
395 'field' => [
396 0 => 'entity_id',
397 1 => 'entity_table',
398 ],
399 'localizable' => FALSE,
400 'sig' => 'civicrm_financial_item::0::entity_id::entity_table',
401 ],
402 ];
403 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
404 }
405
406 }