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