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