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