Merge pull request #18930 from MegaphoneJon/financial-156
[civicrm-core.git] / CRM / Grant / DAO / Grant.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Grant/Grant.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:febf55259ea92f4dd6a7d1ee4b5ea93a)
10 */
11
12 /**
13 * Database access object for the Grant entity.
14 */
15 class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.8';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_grant';
25
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-money';
32
33 /**
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
35 *
36 * @var bool
37 */
38 public static $_log = TRUE;
39
40 /**
41 * Paths for accessing this entity in the UI.
42 *
43 * @var string[]
44 */
45 protected static $_paths = [
46 'add' => 'civicrm/grant/add?reset=1&action=add&context=standalone',
47 'view' => 'contact/view/grant?reset=1&action=view&id=[id]&cid=[contact_id]',
48 'update' => 'civicrm/contact/view/grant?reset=1&action=update&id=[id]&cid=[contact_id]',
49 'delete' => 'civicrm/contact/view/grant?reset=1&action=delete&id=[id]&cid=[contact_id]',
50 ];
51
52 /**
53 * Unique Grant id
54 *
55 * @var int
56 */
57 public $id;
58
59 /**
60 * Contact ID of contact record given grant belongs to.
61 *
62 * @var int
63 */
64 public $contact_id;
65
66 /**
67 * Date on which grant application was received by donor.
68 *
69 * @var date
70 */
71 public $application_received_date;
72
73 /**
74 * Date on which grant decision was made.
75 *
76 * @var date
77 */
78 public $decision_date;
79
80 /**
81 * Date on which grant money transfer was made.
82 *
83 * @var date
84 */
85 public $money_transfer_date;
86
87 /**
88 * Date on which grant report is due.
89 *
90 * @var date
91 */
92 public $grant_due_date;
93
94 /**
95 * Yes/No field stating whether grant report was received by donor.
96 *
97 * @var bool
98 */
99 public $grant_report_received;
100
101 /**
102 * Type of grant. Implicit FK to civicrm_option_value in grant_type option_group.
103 *
104 * @var int
105 */
106 public $grant_type_id;
107
108 /**
109 * Requested grant amount, in default currency.
110 *
111 * @var float
112 */
113 public $amount_total;
114
115 /**
116 * Requested grant amount, in original currency (optional).
117 *
118 * @var float
119 */
120 public $amount_requested;
121
122 /**
123 * Granted amount, in default currency.
124 *
125 * @var float
126 */
127 public $amount_granted;
128
129 /**
130 * 3 character string, value from config setting or input via user.
131 *
132 * @var string
133 */
134 public $currency;
135
136 /**
137 * Grant rationale.
138 *
139 * @var text
140 */
141 public $rationale;
142
143 /**
144 * Id of Grant status.
145 *
146 * @var int
147 */
148 public $status_id;
149
150 /**
151 * FK to Financial Type.
152 *
153 * @var int
154 */
155 public $financial_type_id;
156
157 /**
158 * Class constructor.
159 */
160 public function __construct() {
161 $this->__table = 'civicrm_grant';
162 parent::__construct();
163 }
164
165 /**
166 * Returns localized title of this entity.
167 *
168 * @param bool $plural
169 * Whether to return the plural version of the title.
170 */
171 public static function getEntityTitle($plural = FALSE) {
172 return $plural ? ts('Grants') : ts('Grant');
173 }
174
175 /**
176 * Returns foreign keys and entity references.
177 *
178 * @return array
179 * [CRM_Core_Reference_Interface]
180 */
181 public static function getReferenceColumns() {
182 if (!isset(Civi::$statics[__CLASS__]['links'])) {
183 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
184 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
185 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
186 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
187 }
188 return Civi::$statics[__CLASS__]['links'];
189 }
190
191 /**
192 * Returns all the column names of this table
193 *
194 * @return array
195 */
196 public static function &fields() {
197 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
198 Civi::$statics[__CLASS__]['fields'] = [
199 'grant_id' => [
200 'name' => 'id',
201 'type' => CRM_Utils_Type::T_INT,
202 'title' => ts('Grant ID'),
203 'description' => ts('Unique Grant id'),
204 'required' => TRUE,
205 'import' => TRUE,
206 'where' => 'civicrm_grant.id',
207 'export' => TRUE,
208 'table_name' => 'civicrm_grant',
209 'entity' => 'Grant',
210 'bao' => 'CRM_Grant_BAO_Grant',
211 'localizable' => 0,
212 'add' => '1.8',
213 ],
214 'grant_contact_id' => [
215 'name' => 'contact_id',
216 'type' => CRM_Utils_Type::T_INT,
217 'title' => ts('Contact ID'),
218 'description' => ts('Contact ID of contact record given grant belongs to.'),
219 'required' => TRUE,
220 'where' => 'civicrm_grant.contact_id',
221 'export' => TRUE,
222 'table_name' => 'civicrm_grant',
223 'entity' => 'Grant',
224 'bao' => 'CRM_Grant_BAO_Grant',
225 'localizable' => 0,
226 'FKClassName' => 'CRM_Contact_DAO_Contact',
227 'html' => [
228 'type' => 'EntityRef',
229 ],
230 'add' => '1.8',
231 ],
232 'grant_application_received_date' => [
233 'name' => 'application_received_date',
234 'type' => CRM_Utils_Type::T_DATE,
235 'title' => ts('Application received date'),
236 'description' => ts('Date on which grant application was received by donor.'),
237 'import' => TRUE,
238 'where' => 'civicrm_grant.application_received_date',
239 'export' => TRUE,
240 'table_name' => 'civicrm_grant',
241 'entity' => 'Grant',
242 'bao' => 'CRM_Grant_BAO_Grant',
243 'localizable' => 0,
244 'html' => [
245 'type' => 'Select Date',
246 'formatType' => 'activityDate',
247 ],
248 'add' => '1.8',
249 ],
250 'grant_decision_date' => [
251 'name' => 'decision_date',
252 'type' => CRM_Utils_Type::T_DATE,
253 'title' => ts('Decision date'),
254 'description' => ts('Date on which grant decision was made.'),
255 'import' => TRUE,
256 'where' => 'civicrm_grant.decision_date',
257 'export' => TRUE,
258 'table_name' => 'civicrm_grant',
259 'entity' => 'Grant',
260 'bao' => 'CRM_Grant_BAO_Grant',
261 'localizable' => 0,
262 'html' => [
263 'type' => 'Select Date',
264 'formatType' => 'activityDate',
265 ],
266 'add' => '1.8',
267 ],
268 'grant_money_transfer_date' => [
269 'name' => 'money_transfer_date',
270 'type' => CRM_Utils_Type::T_DATE,
271 'title' => ts('Grant Money transfer date'),
272 'description' => ts('Date on which grant money transfer was made.'),
273 'import' => TRUE,
274 'where' => 'civicrm_grant.money_transfer_date',
275 'export' => TRUE,
276 'table_name' => 'civicrm_grant',
277 'entity' => 'Grant',
278 'bao' => 'CRM_Grant_BAO_Grant',
279 'localizable' => 0,
280 'html' => [
281 'type' => 'Select Date',
282 'formatType' => 'activityDate',
283 ],
284 'add' => '1.8',
285 ],
286 'grant_due_date' => [
287 'name' => 'grant_due_date',
288 'type' => CRM_Utils_Type::T_DATE,
289 'title' => ts('Grant Report Due Date'),
290 'description' => ts('Date on which grant report is due.'),
291 'import' => TRUE,
292 'where' => 'civicrm_grant.grant_due_date',
293 'export' => TRUE,
294 'table_name' => 'civicrm_grant',
295 'entity' => 'Grant',
296 'bao' => 'CRM_Grant_BAO_Grant',
297 'localizable' => 0,
298 'html' => [
299 'type' => 'Select Date',
300 'formatType' => 'activityDate',
301 ],
302 'add' => '1.8',
303 ],
304 'grant_report_received' => [
305 'name' => 'grant_report_received',
306 'type' => CRM_Utils_Type::T_BOOLEAN,
307 'title' => ts('Grant report received'),
308 'description' => ts('Yes/No field stating whether grant report was received by donor.'),
309 'import' => TRUE,
310 'where' => 'civicrm_grant.grant_report_received',
311 'export' => TRUE,
312 'table_name' => 'civicrm_grant',
313 'entity' => 'Grant',
314 'bao' => 'CRM_Grant_BAO_Grant',
315 'localizable' => 0,
316 'html' => [
317 'type' => 'CheckBox',
318 ],
319 'add' => '1.8',
320 ],
321 'grant_type_id' => [
322 'name' => 'grant_type_id',
323 'type' => CRM_Utils_Type::T_INT,
324 'title' => ts('Grant Type'),
325 'description' => ts('Type of grant. Implicit FK to civicrm_option_value in grant_type option_group.'),
326 'required' => TRUE,
327 'where' => 'civicrm_grant.grant_type_id',
328 'export' => TRUE,
329 'table_name' => 'civicrm_grant',
330 'entity' => 'Grant',
331 'bao' => 'CRM_Grant_BAO_Grant',
332 'localizable' => 0,
333 'html' => [
334 'type' => 'Select',
335 ],
336 'pseudoconstant' => [
337 'optionGroupName' => 'grant_type',
338 'optionEditPath' => 'civicrm/admin/options/grant_type',
339 ],
340 'add' => '1.8',
341 ],
342 'amount_total' => [
343 'name' => 'amount_total',
344 'type' => CRM_Utils_Type::T_MONEY,
345 'title' => ts('Total Amount'),
346 'description' => ts('Requested grant amount, in default currency.'),
347 'required' => TRUE,
348 'precision' => [
349 20,
350 2,
351 ],
352 'import' => TRUE,
353 'where' => 'civicrm_grant.amount_total',
354 'dataPattern' => '/^\d+(\.\d{2})?$/',
355 'export' => TRUE,
356 'table_name' => 'civicrm_grant',
357 'entity' => 'Grant',
358 'bao' => 'CRM_Grant_BAO_Grant',
359 'localizable' => 0,
360 'html' => [
361 'type' => 'Text',
362 ],
363 'add' => '1.8',
364 ],
365 'amount_requested' => [
366 'name' => 'amount_requested',
367 'type' => CRM_Utils_Type::T_MONEY,
368 'title' => ts('Amount Requested'),
369 'description' => ts('Requested grant amount, in original currency (optional).'),
370 'precision' => [
371 20,
372 2,
373 ],
374 'where' => 'civicrm_grant.amount_requested',
375 'dataPattern' => '/^\d+(\.\d{2})?$/',
376 'table_name' => 'civicrm_grant',
377 'entity' => 'Grant',
378 'bao' => 'CRM_Grant_BAO_Grant',
379 'localizable' => 0,
380 'html' => [
381 'type' => 'Text',
382 ],
383 'add' => '1.8',
384 ],
385 'amount_granted' => [
386 'name' => 'amount_granted',
387 'type' => CRM_Utils_Type::T_MONEY,
388 'title' => ts('Amount granted'),
389 'description' => ts('Granted amount, in default currency.'),
390 'precision' => [
391 20,
392 2,
393 ],
394 'import' => TRUE,
395 'where' => 'civicrm_grant.amount_granted',
396 'dataPattern' => '/^\d+(\.\d{2})?$/',
397 'export' => TRUE,
398 'table_name' => 'civicrm_grant',
399 'entity' => 'Grant',
400 'bao' => 'CRM_Grant_BAO_Grant',
401 'localizable' => 0,
402 'html' => [
403 'type' => 'Text',
404 ],
405 'add' => '1.8',
406 ],
407 'currency' => [
408 'name' => 'currency',
409 'type' => CRM_Utils_Type::T_STRING,
410 'title' => ts('Grant Currency'),
411 'description' => ts('3 character string, value from config setting or input via user.'),
412 'required' => TRUE,
413 'maxlength' => 3,
414 'size' => CRM_Utils_Type::FOUR,
415 'where' => 'civicrm_grant.currency',
416 'table_name' => 'civicrm_grant',
417 'entity' => 'Grant',
418 'bao' => 'CRM_Grant_BAO_Grant',
419 'localizable' => 0,
420 'html' => [
421 'type' => 'Select',
422 ],
423 'pseudoconstant' => [
424 'table' => 'civicrm_currency',
425 'keyColumn' => 'name',
426 'labelColumn' => 'full_name',
427 'nameColumn' => 'name',
428 'abbrColumn' => 'symbol',
429 ],
430 'add' => '3.2',
431 ],
432 'rationale' => [
433 'name' => 'rationale',
434 'type' => CRM_Utils_Type::T_TEXT,
435 'title' => ts('Grant Rationale'),
436 'description' => ts('Grant rationale.'),
437 'rows' => 4,
438 'cols' => 60,
439 'import' => TRUE,
440 'where' => 'civicrm_grant.rationale',
441 'export' => TRUE,
442 'table_name' => 'civicrm_grant',
443 'entity' => 'Grant',
444 'bao' => 'CRM_Grant_BAO_Grant',
445 'localizable' => 0,
446 'html' => [
447 'type' => 'TextArea',
448 ],
449 'add' => '1.8',
450 ],
451 'grant_status_id' => [
452 'name' => 'status_id',
453 'type' => CRM_Utils_Type::T_INT,
454 'title' => ts('Grant Status'),
455 'description' => ts('Id of Grant status.'),
456 'required' => TRUE,
457 'import' => TRUE,
458 'where' => 'civicrm_grant.status_id',
459 'export' => FALSE,
460 'table_name' => 'civicrm_grant',
461 'entity' => 'Grant',
462 'bao' => 'CRM_Grant_BAO_Grant',
463 'localizable' => 0,
464 'html' => [
465 'type' => 'Select',
466 ],
467 'pseudoconstant' => [
468 'optionGroupName' => 'grant_status',
469 'optionEditPath' => 'civicrm/admin/options/grant_status',
470 ],
471 'add' => '1.8',
472 ],
473 'financial_type_id' => [
474 'name' => 'financial_type_id',
475 'type' => CRM_Utils_Type::T_INT,
476 'title' => ts('Financial Type'),
477 'description' => ts('FK to Financial Type.'),
478 'where' => 'civicrm_grant.financial_type_id',
479 'default' => 'NULL',
480 'table_name' => 'civicrm_grant',
481 'entity' => 'Grant',
482 'bao' => 'CRM_Grant_BAO_Grant',
483 'localizable' => 0,
484 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
485 'pseudoconstant' => [
486 'table' => 'civicrm_financial_type',
487 'keyColumn' => 'id',
488 'labelColumn' => 'name',
489 ],
490 'add' => '4.3',
491 ],
492 ];
493 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
494 }
495 return Civi::$statics[__CLASS__]['fields'];
496 }
497
498 /**
499 * Return a mapping from field-name to the corresponding key (as used in fields()).
500 *
501 * @return array
502 * Array(string $name => string $uniqueName).
503 */
504 public static function &fieldKeys() {
505 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
506 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
507 }
508 return Civi::$statics[__CLASS__]['fieldKeys'];
509 }
510
511 /**
512 * Returns the names of this table
513 *
514 * @return string
515 */
516 public static function getTableName() {
517 return self::$_tableName;
518 }
519
520 /**
521 * Returns if this table needs to be logged
522 *
523 * @return bool
524 */
525 public function getLog() {
526 return self::$_log;
527 }
528
529 /**
530 * Returns the list of fields that can be imported
531 *
532 * @param bool $prefix
533 *
534 * @return array
535 */
536 public static function &import($prefix = FALSE) {
537 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'grant', $prefix, []);
538 return $r;
539 }
540
541 /**
542 * Returns the list of fields that can be exported
543 *
544 * @param bool $prefix
545 *
546 * @return array
547 */
548 public static function &export($prefix = FALSE) {
549 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'grant', $prefix, []);
550 return $r;
551 }
552
553 /**
554 * Returns the list of indices
555 *
556 * @param bool $localize
557 *
558 * @return array
559 */
560 public static function indices($localize = TRUE) {
561 $indices = [
562 'index_grant_type_id' => [
563 'name' => 'index_grant_type_id',
564 'field' => [
565 0 => 'grant_type_id',
566 ],
567 'localizable' => FALSE,
568 'sig' => 'civicrm_grant::0::grant_type_id',
569 ],
570 'index_status_id' => [
571 'name' => 'index_status_id',
572 'field' => [
573 0 => 'status_id',
574 ],
575 'localizable' => FALSE,
576 'sig' => 'civicrm_grant::0::status_id',
577 ],
578 ];
579 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
580 }
581
582 }