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