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