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