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