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