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