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