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