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