5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Grant/Grant.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:91b5f958b8bc0da93269ebc06a22e403)
13 * Database access object for the Grant entity.
15 class CRM_Grant_DAO_Grant
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.8';
18 const COMPONENT
= 'CiviGrant';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_grant';
28 * Icon associated with this entity.
32 public static $_icon = 'fa-money';
35 * Should CiviCRM log any modifications to this table in the civicrm_log table.
39 public static $_log = TRUE;
42 * Paths for accessing this entity in the UI.
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]',
61 * Contact ID of contact record given grant belongs to.
68 * Date on which grant application was received by donor.
72 public $application_received_date;
75 * Date on which grant decision was made.
79 public $decision_date;
82 * Date on which grant money transfer was made.
86 public $money_transfer_date;
89 * Date on which grant report is due.
93 public $grant_due_date;
96 * Yes/No field stating whether grant report was received by donor.
100 public $grant_report_received;
103 * Type of grant. Implicit FK to civicrm_option_value in grant_type option_group.
107 public $grant_type_id;
110 * Requested grant amount, in default currency.
114 public $amount_total;
117 * Requested grant amount, in original currency (optional).
121 public $amount_requested;
124 * Granted amount, in default currency.
128 public $amount_granted;
131 * 3 character string, value from config setting or input via user.
145 * ID of Grant status.
152 * FK to Financial Type.
156 public $financial_type_id;
161 public function __construct() {
162 $this->__table
= 'civicrm_grant';
163 parent
::__construct();
167 * Returns localized title of this entity.
169 * @param bool $plural
170 * Whether to return the plural version of the title.
172 public static function getEntityTitle($plural = FALSE) {
173 return $plural ?
ts('Grants') : ts('Grant');
177 * Returns foreign keys and entity references.
180 * [CRM_Core_Reference_Interface]
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']);
189 return Civi
::$statics[__CLASS__
]['links'];
193 * Returns all the column names of this table
197 public static function &fields() {
198 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
199 Civi
::$statics[__CLASS__
]['fields'] = [
202 'type' => CRM_Utils_Type
::T_INT
,
203 'title' => ts('Grant ID'),
204 'description' => ts('Unique Grant id'),
207 'where' => 'civicrm_grant.id',
209 'table_name' => 'civicrm_grant',
211 'bao' => 'CRM_Grant_BAO_Grant',
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.'),
225 'where' => 'civicrm_grant.contact_id',
227 'table_name' => 'civicrm_grant',
229 'bao' => 'CRM_Grant_BAO_Grant',
231 'FKClassName' => 'CRM_Contact_DAO_Contact',
233 'type' => 'EntityRef',
234 'label' => ts("Contact"),
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.'),
244 'where' => 'civicrm_grant.application_received_date',
246 'table_name' => 'civicrm_grant',
248 'bao' => 'CRM_Grant_BAO_Grant',
251 'type' => 'Select Date',
252 'formatType' => 'activityDate',
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.'),
262 'where' => 'civicrm_grant.decision_date',
264 'table_name' => 'civicrm_grant',
266 'bao' => 'CRM_Grant_BAO_Grant',
269 'type' => 'Select Date',
270 'formatType' => 'activityDate',
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.'),
280 'where' => 'civicrm_grant.money_transfer_date',
282 'table_name' => 'civicrm_grant',
284 'bao' => 'CRM_Grant_BAO_Grant',
287 'type' => 'Select Date',
288 'formatType' => 'activityDate',
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.'),
298 'where' => 'civicrm_grant.grant_due_date',
300 'table_name' => 'civicrm_grant',
302 'bao' => 'CRM_Grant_BAO_Grant',
305 'type' => 'Select Date',
306 'formatType' => 'activityDate',
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.'),
316 'where' => 'civicrm_grant.grant_report_received',
318 'table_name' => 'civicrm_grant',
320 'bao' => 'CRM_Grant_BAO_Grant',
323 'type' => 'CheckBox',
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.'),
333 'where' => 'civicrm_grant.grant_type_id',
335 'table_name' => 'civicrm_grant',
337 'bao' => 'CRM_Grant_BAO_Grant',
342 'pseudoconstant' => [
343 'optionGroupName' => 'grant_type',
344 'optionEditPath' => 'civicrm/admin/options/grant_type',
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.'),
359 'where' => 'civicrm_grant.amount_total',
360 'dataPattern' => '/^\d+(\.\d{2})?$/',
362 'table_name' => 'civicrm_grant',
364 'bao' => 'CRM_Grant_BAO_Grant',
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).'),
380 'where' => 'civicrm_grant.amount_requested',
381 'dataPattern' => '/^\d+(\.\d{2})?$/',
382 'table_name' => 'civicrm_grant',
384 'bao' => 'CRM_Grant_BAO_Grant',
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.'),
401 'where' => 'civicrm_grant.amount_granted',
402 'dataPattern' => '/^\d+(\.\d{2})?$/',
404 'table_name' => 'civicrm_grant',
406 'bao' => 'CRM_Grant_BAO_Grant',
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.'),
420 'size' => CRM_Utils_Type
::FOUR
,
421 'where' => 'civicrm_grant.currency',
422 'table_name' => 'civicrm_grant',
424 'bao' => 'CRM_Grant_BAO_Grant',
429 'pseudoconstant' => [
430 'table' => 'civicrm_currency',
431 'keyColumn' => 'name',
432 'labelColumn' => 'full_name',
433 'nameColumn' => 'name',
434 'abbrColumn' => 'symbol',
439 'name' => 'rationale',
440 'type' => CRM_Utils_Type
::T_TEXT
,
441 'title' => ts('Grant Rationale'),
442 'description' => ts('Grant rationale.'),
446 'where' => 'civicrm_grant.rationale',
448 'table_name' => 'civicrm_grant',
450 'bao' => 'CRM_Grant_BAO_Grant',
453 'type' => 'TextArea',
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.'),
464 'where' => 'civicrm_grant.status_id',
466 'table_name' => 'civicrm_grant',
468 'bao' => 'CRM_Grant_BAO_Grant',
473 'pseudoconstant' => [
474 'optionGroupName' => 'grant_status',
475 'optionEditPath' => 'civicrm/admin/options/grant_status',
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',
486 'table_name' => 'civicrm_grant',
488 'bao' => 'CRM_Grant_BAO_Grant',
490 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
492 'label' => ts("Financial Type"),
494 'pseudoconstant' => [
495 'table' => 'civicrm_financial_type',
497 'labelColumn' => 'name',
502 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
504 return Civi
::$statics[__CLASS__
]['fields'];
508 * Return a mapping from field-name to the corresponding key (as used in fields()).
511 * Array(string $name => string $uniqueName).
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()));
517 return Civi
::$statics[__CLASS__
]['fieldKeys'];
521 * Returns the names of this table
525 public static function getTableName() {
526 return self
::$_tableName;
530 * Returns if this table needs to be logged
534 public function getLog() {
539 * Returns the list of fields that can be imported
541 * @param bool $prefix
545 public static function &import($prefix = FALSE) {
546 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'grant', $prefix, []);
551 * Returns the list of fields that can be exported
553 * @param bool $prefix
557 public static function &export($prefix = FALSE) {
558 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'grant', $prefix, []);
563 * Returns the list of indices
565 * @param bool $localize
569 public static function indices($localize = TRUE) {
571 'index_grant_type_id' => [
572 'name' => 'index_grant_type_id',
574 0 => 'grant_type_id',
576 'localizable' => FALSE,
577 'sig' => 'civicrm_grant::0::grant_type_id',
579 'index_status_id' => [
580 'name' => 'index_status_id',
584 'localizable' => FALSE,
585 'sig' => 'civicrm_grant::0::status_id',
588 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;