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