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