Commit | Line | Data |
---|---|---|
e501603b | 1 | <?php |
c3fc2621 | 2 | |
e501603b TO |
3 | /** |
4 | * @package CRM | |
0f03f337 | 5 | * @copyright CiviCRM LLC (c) 2004-2017 |
e501603b TO |
6 | * |
7 | * Generated from xml/schema/CRM/Financial/FinancialItem.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
e7a6b91a | 9 | * (GenCodeChecksum:95e199969f4ff93ccae635fb7e0d30f2) |
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 | */ | |
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'), |
e501603b | 153 | 'description' => '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'), |
e501603b | 165 | 'description' => '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'), |
e501603b | 176 | 'description' => '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'), |
e501603b TO |
192 | 'description' => 'Human readable description of this item, to ease display without lookup of source item.', |
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'), |
e501603b | 204 | 'description' => 'Total amount of this item', |
c3fc2621 CW |
205 | 'required' => TRUE, |
206 | 'precision' => [ | |
e501603b TO |
207 | 20, |
208 | 2 | |
c3fc2621 | 209 | ], |
522a26c9 | 210 | 'table_name' => 'civicrm_financial_item', |
211 | 'entity' => 'FinancialItem', | |
212 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 213 | 'localizable' => 0, |
c3fc2621 CW |
214 | ], |
215 | 'currency' => [ | |
e501603b TO |
216 | 'name' => 'currency', |
217 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 218 | 'title' => ts('Financial Item Currency'), |
e501603b TO |
219 | 'description' => 'Currency for the amount', |
220 | 'maxlength' => 3, | |
221 | 'size' => CRM_Utils_Type::FOUR, | |
c3fc2621 | 222 | 'export' => TRUE, |
e501603b TO |
223 | 'where' => 'civicrm_financial_item.currency', |
224 | 'headerPattern' => '', | |
225 | 'dataPattern' => '', | |
522a26c9 | 226 | 'table_name' => 'civicrm_financial_item', |
227 | 'entity' => 'FinancialItem', | |
228 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 229 | 'localizable' => 0, |
c3fc2621 | 230 | 'html' => [ |
e501603b | 231 | 'type' => 'Select', |
c3fc2621 CW |
232 | ], |
233 | 'pseudoconstant' => [ | |
e501603b TO |
234 | 'table' => 'civicrm_currency', |
235 | 'keyColumn' => 'name', | |
236 | 'labelColumn' => 'full_name', | |
237 | 'nameColumn' => 'name', | |
c3fc2621 CW |
238 | ] |
239 | ], | |
240 | 'financial_account_id' => [ | |
e501603b TO |
241 | 'name' => 'financial_account_id', |
242 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 243 | 'title' => ts('Financial Account ID'), |
e501603b | 244 | 'description' => 'FK to civicrm_financial_account', |
522a26c9 | 245 | 'table_name' => 'civicrm_financial_item', |
246 | 'entity' => 'FinancialItem', | |
247 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 248 | 'localizable' => 0, |
e501603b | 249 | 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount', |
c3fc2621 | 250 | 'html' => [ |
e501603b | 251 | 'type' => 'Select', |
c3fc2621 CW |
252 | ], |
253 | 'pseudoconstant' => [ | |
e501603b TO |
254 | 'table' => 'civicrm_financial_account', |
255 | 'keyColumn' => 'id', | |
256 | 'labelColumn' => 'name', | |
c3fc2621 CW |
257 | ] |
258 | ], | |
259 | 'status_id' => [ | |
e501603b TO |
260 | 'name' => 'status_id', |
261 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 262 | 'title' => ts('Financial Item Status ID'), |
e501603b | 263 | 'description' => 'Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)', |
c3fc2621 | 264 | 'export' => TRUE, |
e501603b TO |
265 | 'where' => 'civicrm_financial_item.status_id', |
266 | 'headerPattern' => '', | |
267 | 'dataPattern' => '', | |
522a26c9 | 268 | 'table_name' => 'civicrm_financial_item', |
269 | 'entity' => 'FinancialItem', | |
270 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 271 | 'localizable' => 0, |
c3fc2621 | 272 | 'html' => [ |
e501603b | 273 | 'type' => 'Select', |
c3fc2621 CW |
274 | ], |
275 | 'pseudoconstant' => [ | |
e501603b TO |
276 | 'optionGroupName' => 'financial_item_status', |
277 | 'optionEditPath' => 'civicrm/admin/options/financial_item_status', | |
c3fc2621 CW |
278 | ] |
279 | ], | |
280 | 'entity_table' => [ | |
e501603b TO |
281 | 'name' => 'entity_table', |
282 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 283 | 'title' => ts('Entity Table'), |
e501603b TO |
284 | 'description' => 'The table providing the source of this item such as civicrm_line_item', |
285 | 'maxlength' => 64, | |
286 | 'size' => CRM_Utils_Type::BIG, | |
522a26c9 | 287 | 'table_name' => 'civicrm_financial_item', |
288 | 'entity' => 'FinancialItem', | |
289 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 290 | 'localizable' => 0, |
c3fc2621 CW |
291 | ], |
292 | 'entity_id' => [ | |
e501603b TO |
293 | 'name' => 'entity_id', |
294 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 295 | 'title' => ts('Entity ID'), |
e501603b | 296 | 'description' => 'The specific source item that is responsible for the creation of this financial_item', |
522a26c9 | 297 | 'table_name' => 'civicrm_financial_item', |
298 | 'entity' => 'FinancialItem', | |
299 | 'bao' => 'CRM_Financial_BAO_FinancialItem', | |
6a7e5e5d | 300 | 'localizable' => 0, |
c3fc2621 CW |
301 | ], |
302 | ]; | |
346aaaba | 303 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 304 | } |
346aaaba | 305 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 306 | } |
c3fc2621 | 307 | |
e501603b | 308 | /** |
bd8e0b14 | 309 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
310 | * |
311 | * @return array | |
bd8e0b14 | 312 | * Array(string $name => string $uniqueName). |
e501603b | 313 | */ |
c3fc2621 | 314 | public static function &fieldKeys() { |
bd8e0b14 TO |
315 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
316 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 317 | } |
bd8e0b14 | 318 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 319 | } |
c3fc2621 | 320 | |
e501603b TO |
321 | /** |
322 | * Returns the names of this table | |
323 | * | |
324 | * @return string | |
325 | */ | |
c3fc2621 | 326 | public static function getTableName() { |
e501603b TO |
327 | return self::$_tableName; |
328 | } | |
c3fc2621 | 329 | |
e501603b TO |
330 | /** |
331 | * Returns if this table needs to be logged | |
332 | * | |
c3fc2621 | 333 | * @return bool |
e501603b | 334 | */ |
c3fc2621 | 335 | public function getLog() { |
e501603b TO |
336 | return self::$_log; |
337 | } | |
c3fc2621 | 338 | |
e501603b TO |
339 | /** |
340 | * Returns the list of fields that can be imported | |
341 | * | |
342 | * @param bool $prefix | |
343 | * | |
344 | * @return array | |
345 | */ | |
c3fc2621 CW |
346 | public static function &import($prefix = FALSE) { |
347 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_item', $prefix, []); | |
60808919 | 348 | return $r; |
e501603b | 349 | } |
c3fc2621 | 350 | |
e501603b TO |
351 | /** |
352 | * Returns the list of fields that can be exported | |
353 | * | |
354 | * @param bool $prefix | |
355 | * | |
356 | * @return array | |
357 | */ | |
c3fc2621 CW |
358 | public static function &export($prefix = FALSE) { |
359 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_item', $prefix, []); | |
60808919 | 360 | return $r; |
e501603b | 361 | } |
c3fc2621 | 362 | |
e7a6b91a AS |
363 | /** |
364 | * Returns the list of indices | |
c3fc2621 CW |
365 | * |
366 | * @param bool $localize | |
367 | * | |
368 | * @return array | |
e7a6b91a AS |
369 | */ |
370 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
371 | $indices = [ |
372 | 'IX_created_date' => [ | |
e7a6b91a | 373 | 'name' => 'IX_created_date', |
c3fc2621 | 374 | 'field' => [ |
e7a6b91a | 375 | 0 => 'created_date', |
c3fc2621 CW |
376 | ], |
377 | 'localizable' => FALSE, | |
e7a6b91a | 378 | 'sig' => 'civicrm_financial_item::0::created_date', |
c3fc2621 CW |
379 | ], |
380 | 'IX_transaction_date' => [ | |
e7a6b91a | 381 | 'name' => 'IX_transaction_date', |
c3fc2621 | 382 | 'field' => [ |
e7a6b91a | 383 | 0 => 'transaction_date', |
c3fc2621 CW |
384 | ], |
385 | 'localizable' => FALSE, | |
e7a6b91a | 386 | 'sig' => 'civicrm_financial_item::0::transaction_date', |
c3fc2621 CW |
387 | ], |
388 | 'index_entity_id_entity_table' => [ | |
e7a6b91a | 389 | 'name' => 'index_entity_id_entity_table', |
c3fc2621 | 390 | 'field' => [ |
e7a6b91a AS |
391 | 0 => 'entity_id', |
392 | 1 => 'entity_table', | |
c3fc2621 CW |
393 | ], |
394 | 'localizable' => FALSE, | |
e7a6b91a | 395 | 'sig' => 'civicrm_financial_item::0::entity_id::entity_table', |
c3fc2621 CW |
396 | ], |
397 | ]; | |
e7a6b91a AS |
398 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
399 | } | |
c3fc2621 | 400 | |
e501603b | 401 | } |