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