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