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