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