Commit | Line | Data |
---|---|---|
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 | |
a9d0587b | 9 | * (GenCodeChecksum:4f2e977c0c7c668be342598772b0eb61) |
e501603b | 10 | */ |
c3fc2621 | 11 | |
f41f0342 | 12 | /** |
c3fc2621 | 13 | * Database access object for the FinancialItem entity. |
f41f0342 | 14 | */ |
e501603b | 15 | class 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 | */ | |
fa45b5b9 | 22 | public 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 | */ |
fa45b5b9 | 29 | public static $_log = TRUE; |
c3fc2621 | 30 | |
e501603b | 31 | /** |
e6ca0a57 | 32 | * @var int |
e501603b TO |
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 | * | |
e6ca0a57 | 53 | * @var int |
e501603b TO |
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 | * | |
e6ca0a57 | 81 | * @var int |
e501603b TO |
82 | */ |
83 | public $financial_account_id; | |
c3fc2621 | 84 | |
e501603b TO |
85 | /** |
86 | * Payment status: test, paid, part_paid, unpaid (if empty assume unpaid) | |
87 | * | |
e6ca0a57 | 88 | * @var int |
e501603b TO |
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 | * | |
e6ca0a57 | 102 | * @var int |
e501603b TO |
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 | |
449c4e6b CW |
114 | /** |
115 | * Returns localized title of this entity. | |
116 | */ | |
117 | public static function getEntityTitle() { | |
118 | return ts('Financial Items'); | |
119 | } | |
120 | ||
e501603b | 121 | /** |
f41f0342 | 122 | * Returns foreign keys and entity references. |
e501603b TO |
123 | * |
124 | * @return array | |
125 | * [CRM_Core_Reference_Interface] | |
126 | */ | |
c3fc2621 | 127 | public static function getReferenceColumns() { |
346aaaba | 128 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
fa45b5b9 | 129 | Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); |
c3fc2621 CW |
130 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); |
131 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id'); | |
132 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); | |
346aaaba | 133 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); |
e501603b | 134 | } |
346aaaba | 135 | return Civi::$statics[__CLASS__]['links']; |
e501603b | 136 | } |
c3fc2621 | 137 | |
e501603b TO |
138 | /** |
139 | * Returns all the column names of this table | |
140 | * | |
141 | * @return array | |
142 | */ | |
c3fc2621 | 143 | public static function &fields() { |
346aaaba | 144 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
c3fc2621 CW |
145 | Civi::$statics[__CLASS__]['fields'] = [ |
146 | 'id' => [ | |
e501603b TO |
147 | 'name' => 'id', |
148 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 CW |
149 | 'title' => ts('Financial Item ID'), |
150 | 'required' => TRUE, | |
a36434b9 | 151 | 'where' => 'civicrm_financial_item.id', |
522a26c9 | 152 | 'table_name' => 'civicrm_financial_item', |
153 | 'entity' => 'FinancialItem', | |
154 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 155 | 'localizable' => 0, |
a9d0587b | 156 | 'add' => '4.3', |
c3fc2621 CW |
157 | ], |
158 | 'created_date' => [ | |
e501603b TO |
159 | 'name' => 'created_date', |
160 | 'type' => CRM_Utils_Type::T_TIMESTAMP, | |
c3fc2621 | 161 | 'title' => ts('Financial Item Created Date'), |
215b423e | 162 | 'description' => ts('Date and time the item was created'), |
c3fc2621 | 163 | 'required' => TRUE, |
a36434b9 | 164 | 'where' => 'civicrm_financial_item.created_date', |
e501603b | 165 | 'default' => 'CURRENT_TIMESTAMP', |
522a26c9 | 166 | 'table_name' => 'civicrm_financial_item', |
167 | 'entity' => 'FinancialItem', | |
168 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 169 | 'localizable' => 0, |
a9d0587b | 170 | 'add' => '4.3', |
c3fc2621 CW |
171 | ], |
172 | 'transaction_date' => [ | |
e501603b TO |
173 | 'name' => 'transaction_date', |
174 | 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, | |
c3fc2621 | 175 | 'title' => ts('Financial Item Transaction Date'), |
215b423e | 176 | 'description' => ts('Date and time of the source transaction'), |
c3fc2621 | 177 | 'required' => TRUE, |
a36434b9 | 178 | 'where' => 'civicrm_financial_item.transaction_date', |
522a26c9 | 179 | 'table_name' => 'civicrm_financial_item', |
180 | 'entity' => 'FinancialItem', | |
181 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 182 | 'localizable' => 0, |
a9d0587b | 183 | 'add' => '4.3', |
c3fc2621 CW |
184 | ], |
185 | 'contact_id' => [ | |
e501603b TO |
186 | 'name' => 'contact_id', |
187 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 188 | 'title' => ts('Financial Item Contact ID'), |
215b423e | 189 | 'description' => ts('FK to Contact ID of contact the item is from'), |
c3fc2621 | 190 | 'required' => TRUE, |
e501603b | 191 | 'where' => 'civicrm_financial_item.contact_id', |
a36434b9 | 192 | 'export' => TRUE, |
522a26c9 | 193 | 'table_name' => 'civicrm_financial_item', |
194 | 'entity' => 'FinancialItem', | |
195 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 196 | 'localizable' => 0, |
e501603b | 197 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
a9d0587b | 198 | 'add' => '4.3', |
c3fc2621 CW |
199 | ], |
200 | 'description' => [ | |
e501603b TO |
201 | 'name' => 'description', |
202 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 203 | 'title' => ts('Financial Item Description'), |
215b423e | 204 | 'description' => ts('Human readable description of this item, to ease display without lookup of source item.'), |
e501603b TO |
205 | 'maxlength' => 255, |
206 | 'size' => CRM_Utils_Type::HUGE, | |
a36434b9 | 207 | 'where' => 'civicrm_financial_item.description', |
522a26c9 | 208 | 'table_name' => 'civicrm_financial_item', |
209 | 'entity' => 'FinancialItem', | |
210 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 211 | 'localizable' => 0, |
a9d0587b | 212 | 'add' => '4.3', |
c3fc2621 CW |
213 | ], |
214 | 'amount' => [ | |
e501603b TO |
215 | 'name' => 'amount', |
216 | 'type' => CRM_Utils_Type::T_MONEY, | |
c3fc2621 | 217 | 'title' => ts('Amount'), |
215b423e | 218 | 'description' => ts('Total amount of this item'), |
c3fc2621 CW |
219 | 'required' => TRUE, |
220 | 'precision' => [ | |
e501603b | 221 | 20, |
fb607354 | 222 | 2, |
c3fc2621 | 223 | ], |
a36434b9 | 224 | 'where' => 'civicrm_financial_item.amount', |
225 | 'headerPattern' => '/unit?.?amoun/i', | |
226 | 'dataPattern' => '/^\d+(\.\d{2})?$/', | |
45a83e42 | 227 | 'default' => '0', |
522a26c9 | 228 | 'table_name' => 'civicrm_financial_item', |
229 | 'entity' => 'FinancialItem', | |
230 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 231 | 'localizable' => 0, |
a9d0587b | 232 | 'add' => '4.3', |
c3fc2621 CW |
233 | ], |
234 | 'currency' => [ | |
e501603b TO |
235 | 'name' => 'currency', |
236 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 237 | 'title' => ts('Financial Item Currency'), |
215b423e | 238 | 'description' => ts('Currency for the amount'), |
e501603b TO |
239 | 'maxlength' => 3, |
240 | 'size' => CRM_Utils_Type::FOUR, | |
e501603b | 241 | 'where' => 'civicrm_financial_item.currency', |
a36434b9 | 242 | 'export' => TRUE, |
522a26c9 | 243 | 'table_name' => 'civicrm_financial_item', |
244 | 'entity' => 'FinancialItem', | |
245 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 246 | 'localizable' => 0, |
c3fc2621 | 247 | 'html' => [ |
e501603b | 248 | 'type' => 'Select', |
c3fc2621 CW |
249 | ], |
250 | 'pseudoconstant' => [ | |
e501603b TO |
251 | 'table' => 'civicrm_currency', |
252 | 'keyColumn' => 'name', | |
253 | 'labelColumn' => 'full_name', | |
254 | 'nameColumn' => 'name', | |
a8fdb24e | 255 | 'abbrColumn' => 'symbol', |
e6ca0a57 | 256 | ], |
a9d0587b | 257 | 'add' => '4.3', |
c3fc2621 CW |
258 | ], |
259 | 'financial_account_id' => [ | |
e501603b TO |
260 | 'name' => 'financial_account_id', |
261 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 262 | 'title' => ts('Financial Account ID'), |
215b423e | 263 | 'description' => ts('FK to civicrm_financial_account'), |
a36434b9 | 264 | 'where' => 'civicrm_financial_item.financial_account_id', |
522a26c9 | 265 | 'table_name' => 'civicrm_financial_item', |
266 | 'entity' => 'FinancialItem', | |
267 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 268 | 'localizable' => 0, |
e501603b | 269 | 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount', |
c3fc2621 | 270 | 'html' => [ |
e501603b | 271 | 'type' => 'Select', |
c3fc2621 CW |
272 | ], |
273 | 'pseudoconstant' => [ | |
e501603b TO |
274 | 'table' => 'civicrm_financial_account', |
275 | 'keyColumn' => 'id', | |
276 | 'labelColumn' => 'name', | |
e6ca0a57 | 277 | ], |
a9d0587b | 278 | 'add' => '4.3', |
c3fc2621 CW |
279 | ], |
280 | 'status_id' => [ | |
e501603b TO |
281 | 'name' => 'status_id', |
282 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 283 | 'title' => ts('Financial Item Status ID'), |
215b423e | 284 | 'description' => ts('Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)'), |
e501603b | 285 | 'where' => 'civicrm_financial_item.status_id', |
a36434b9 | 286 | 'export' => TRUE, |
522a26c9 | 287 | 'table_name' => 'civicrm_financial_item', |
288 | 'entity' => 'FinancialItem', | |
289 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 290 | 'localizable' => 0, |
c3fc2621 | 291 | 'html' => [ |
e501603b | 292 | 'type' => 'Select', |
c3fc2621 CW |
293 | ], |
294 | 'pseudoconstant' => [ | |
e501603b TO |
295 | 'optionGroupName' => 'financial_item_status', |
296 | 'optionEditPath' => 'civicrm/admin/options/financial_item_status', | |
e6ca0a57 | 297 | ], |
a9d0587b | 298 | 'add' => '4.3', |
c3fc2621 CW |
299 | ], |
300 | 'entity_table' => [ | |
e501603b TO |
301 | 'name' => 'entity_table', |
302 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 303 | 'title' => ts('Entity Table'), |
215b423e | 304 | 'description' => ts('The table providing the source of this item such as civicrm_line_item'), |
e501603b TO |
305 | 'maxlength' => 64, |
306 | 'size' => CRM_Utils_Type::BIG, | |
a36434b9 | 307 | 'where' => 'civicrm_financial_item.entity_table', |
522a26c9 | 308 | 'table_name' => 'civicrm_financial_item', |
309 | 'entity' => 'FinancialItem', | |
310 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 311 | 'localizable' => 0, |
a9d0587b | 312 | 'add' => '4.3', |
c3fc2621 CW |
313 | ], |
314 | 'entity_id' => [ | |
e501603b TO |
315 | 'name' => 'entity_id', |
316 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 317 | 'title' => ts('Entity ID'), |
215b423e | 318 | 'description' => ts('The specific source item that is responsible for the creation of this financial_item'), |
a36434b9 | 319 | 'where' => 'civicrm_financial_item.entity_id', |
522a26c9 | 320 | 'table_name' => 'civicrm_financial_item', |
321 | 'entity' => 'FinancialItem', | |
322 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 323 | 'localizable' => 0, |
a9d0587b | 324 | 'add' => '4.3', |
c3fc2621 CW |
325 | ], |
326 | ]; | |
346aaaba | 327 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 328 | } |
346aaaba | 329 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 330 | } |
c3fc2621 | 331 | |
e501603b | 332 | /** |
bd8e0b14 | 333 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
334 | * |
335 | * @return array | |
bd8e0b14 | 336 | * Array(string $name => string $uniqueName). |
e501603b | 337 | */ |
c3fc2621 | 338 | public static function &fieldKeys() { |
bd8e0b14 TO |
339 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
340 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 341 | } |
bd8e0b14 | 342 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 343 | } |
c3fc2621 | 344 | |
e501603b TO |
345 | /** |
346 | * Returns the names of this table | |
347 | * | |
348 | * @return string | |
349 | */ | |
c3fc2621 | 350 | public static function getTableName() { |
e501603b TO |
351 | return self::$_tableName; |
352 | } | |
c3fc2621 | 353 | |
e501603b TO |
354 | /** |
355 | * Returns if this table needs to be logged | |
356 | * | |
c3fc2621 | 357 | * @return bool |
e501603b | 358 | */ |
c3fc2621 | 359 | public function getLog() { |
e501603b TO |
360 | return self::$_log; |
361 | } | |
c3fc2621 | 362 | |
e501603b TO |
363 | /** |
364 | * Returns the list of fields that can be imported | |
365 | * | |
366 | * @param bool $prefix | |
367 | * | |
368 | * @return array | |
369 | */ | |
c3fc2621 CW |
370 | public static function &import($prefix = FALSE) { |
371 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_item', $prefix, []); | |
60808919 | 372 | return $r; |
e501603b | 373 | } |
c3fc2621 | 374 | |
e501603b TO |
375 | /** |
376 | * Returns the list of fields that can be exported | |
377 | * | |
378 | * @param bool $prefix | |
379 | * | |
380 | * @return array | |
381 | */ | |
c3fc2621 CW |
382 | public static function &export($prefix = FALSE) { |
383 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_item', $prefix, []); | |
60808919 | 384 | return $r; |
e501603b | 385 | } |
c3fc2621 | 386 | |
e7a6b91a AS |
387 | /** |
388 | * Returns the list of indices | |
c3fc2621 CW |
389 | * |
390 | * @param bool $localize | |
391 | * | |
392 | * @return array | |
e7a6b91a AS |
393 | */ |
394 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
395 | $indices = [ |
396 | 'IX_created_date' => [ | |
e7a6b91a | 397 | 'name' => 'IX_created_date', |
c3fc2621 | 398 | 'field' => [ |
e7a6b91a | 399 | 0 => 'created_date', |
c3fc2621 CW |
400 | ], |
401 | 'localizable' => FALSE, | |
e7a6b91a | 402 | 'sig' => 'civicrm_financial_item::0::created_date', |
c3fc2621 CW |
403 | ], |
404 | 'IX_transaction_date' => [ | |
e7a6b91a | 405 | 'name' => 'IX_transaction_date', |
c3fc2621 | 406 | 'field' => [ |
e7a6b91a | 407 | 0 => 'transaction_date', |
c3fc2621 CW |
408 | ], |
409 | 'localizable' => FALSE, | |
e7a6b91a | 410 | 'sig' => 'civicrm_financial_item::0::transaction_date', |
c3fc2621 CW |
411 | ], |
412 | 'index_entity_id_entity_table' => [ | |
e7a6b91a | 413 | 'name' => 'index_entity_id_entity_table', |
c3fc2621 | 414 | 'field' => [ |
e7a6b91a AS |
415 | 0 => 'entity_id', |
416 | 1 => 'entity_table', | |
c3fc2621 CW |
417 | ], |
418 | 'localizable' => FALSE, | |
e7a6b91a | 419 | 'sig' => 'civicrm_financial_item::0::entity_id::entity_table', |
c3fc2621 CW |
420 | ], |
421 | ]; | |
e7a6b91a AS |
422 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
423 | } | |
c3fc2621 | 424 | |
e501603b | 425 | } |