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