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:febf55259ea92f4dd6a7d1ee4b5ea93a)
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';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_grant';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-money';
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
41 * Paths for accessing this entity in the UI.
45 protected static $_paths = [
46 'add' => 'civicrm/grant/add?reset=1&action=add&context=standalone',
47 'view' => 'contact/view/grant?reset=1&action=view&id=[id]&cid=[contact_id]',
48 'update' => 'civicrm/contact/view/grant?reset=1&action=update&id=[id]&cid=[contact_id]',
49 'delete' => 'civicrm/contact/view/grant?reset=1&action=delete&id=[id]&cid=[contact_id]',
60 * Contact ID of contact record given grant belongs to.
67 * Date on which grant application was received by donor.
71 public $application_received_date;
74 * Date on which grant decision was made.
78 public $decision_date;
81 * Date on which grant money transfer was made.
85 public $money_transfer_date;
88 * Date on which grant report is due.
92 public $grant_due_date;
95 * Yes/No field stating whether grant report was received by donor.
99 public $grant_report_received;
102 * Type of grant. Implicit FK to civicrm_option_value in grant_type option_group.
106 public $grant_type_id;
109 * Requested grant amount, in default currency.
113 public $amount_total;
116 * Requested grant amount, in original currency (optional).
120 public $amount_requested;
123 * Granted amount, in default currency.
127 public $amount_granted;
130 * 3 character string, value from config setting or input via user.
144 * Id of Grant status.
151 * FK to Financial Type.
155 public $financial_type_id;
160 public function __construct() {
161 $this->__table
= 'civicrm_grant';
162 parent
::__construct();
166 * Returns localized title of this entity.
168 * @param bool $plural
169 * Whether to return the plural version of the title.
171 public static function getEntityTitle($plural = FALSE) {
172 return $plural ?
ts('Grants') : ts('Grant');
176 * Returns foreign keys and entity references.
179 * [CRM_Core_Reference_Interface]
181 public static function getReferenceColumns() {
182 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
183 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
184 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
185 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
186 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
188 return Civi
::$statics[__CLASS__
]['links'];
192 * Returns all the column names of this table
196 public static function &fields() {
197 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
198 Civi
::$statics[__CLASS__
]['fields'] = [
201 'type' => CRM_Utils_Type
::T_INT
,
202 'title' => ts('Grant ID'),
203 'description' => ts('Unique Grant id'),
206 'where' => 'civicrm_grant.id',
208 'table_name' => 'civicrm_grant',
210 'bao' => 'CRM_Grant_BAO_Grant',
214 'grant_contact_id' => [
215 'name' => 'contact_id',
216 'type' => CRM_Utils_Type
::T_INT
,
217 'title' => ts('Contact ID'),
218 'description' => ts('Contact ID of contact record given grant belongs to.'),
220 'where' => 'civicrm_grant.contact_id',
222 'table_name' => 'civicrm_grant',
224 'bao' => 'CRM_Grant_BAO_Grant',
226 'FKClassName' => 'CRM_Contact_DAO_Contact',
228 'type' => 'EntityRef',
232 'grant_application_received_date' => [
233 'name' => 'application_received_date',
234 'type' => CRM_Utils_Type
::T_DATE
,
235 'title' => ts('Application received date'),
236 'description' => ts('Date on which grant application was received by donor.'),
238 'where' => 'civicrm_grant.application_received_date',
240 'table_name' => 'civicrm_grant',
242 'bao' => 'CRM_Grant_BAO_Grant',
245 'type' => 'Select Date',
246 'formatType' => 'activityDate',
250 'grant_decision_date' => [
251 'name' => 'decision_date',
252 'type' => CRM_Utils_Type
::T_DATE
,
253 'title' => ts('Decision date'),
254 'description' => ts('Date on which grant decision was made.'),
256 'where' => 'civicrm_grant.decision_date',
258 'table_name' => 'civicrm_grant',
260 'bao' => 'CRM_Grant_BAO_Grant',
263 'type' => 'Select Date',
264 'formatType' => 'activityDate',
268 'grant_money_transfer_date' => [
269 'name' => 'money_transfer_date',
270 'type' => CRM_Utils_Type
::T_DATE
,
271 'title' => ts('Grant Money transfer date'),
272 'description' => ts('Date on which grant money transfer was made.'),
274 'where' => 'civicrm_grant.money_transfer_date',
276 'table_name' => 'civicrm_grant',
278 'bao' => 'CRM_Grant_BAO_Grant',
281 'type' => 'Select Date',
282 'formatType' => 'activityDate',
286 'grant_due_date' => [
287 'name' => 'grant_due_date',
288 'type' => CRM_Utils_Type
::T_DATE
,
289 'title' => ts('Grant Report Due Date'),
290 'description' => ts('Date on which grant report is due.'),
292 'where' => 'civicrm_grant.grant_due_date',
294 'table_name' => 'civicrm_grant',
296 'bao' => 'CRM_Grant_BAO_Grant',
299 'type' => 'Select Date',
300 'formatType' => 'activityDate',
304 'grant_report_received' => [
305 'name' => 'grant_report_received',
306 'type' => CRM_Utils_Type
::T_BOOLEAN
,
307 'title' => ts('Grant report received'),
308 'description' => ts('Yes/No field stating whether grant report was received by donor.'),
310 'where' => 'civicrm_grant.grant_report_received',
312 'table_name' => 'civicrm_grant',
314 'bao' => 'CRM_Grant_BAO_Grant',
317 'type' => 'CheckBox',
322 'name' => 'grant_type_id',
323 'type' => CRM_Utils_Type
::T_INT
,
324 'title' => ts('Grant Type'),
325 'description' => ts('Type of grant. Implicit FK to civicrm_option_value in grant_type option_group.'),
327 'where' => 'civicrm_grant.grant_type_id',
329 'table_name' => 'civicrm_grant',
331 'bao' => 'CRM_Grant_BAO_Grant',
336 'pseudoconstant' => [
337 'optionGroupName' => 'grant_type',
338 'optionEditPath' => 'civicrm/admin/options/grant_type',
343 'name' => 'amount_total',
344 'type' => CRM_Utils_Type
::T_MONEY
,
345 'title' => ts('Total Amount'),
346 'description' => ts('Requested grant amount, in default currency.'),
353 'where' => 'civicrm_grant.amount_total',
354 'dataPattern' => '/^\d+(\.\d{2})?$/',
356 'table_name' => 'civicrm_grant',
358 'bao' => 'CRM_Grant_BAO_Grant',
365 'amount_requested' => [
366 'name' => 'amount_requested',
367 'type' => CRM_Utils_Type
::T_MONEY
,
368 'title' => ts('Amount Requested'),
369 'description' => ts('Requested grant amount, in original currency (optional).'),
374 'where' => 'civicrm_grant.amount_requested',
375 'dataPattern' => '/^\d+(\.\d{2})?$/',
376 'table_name' => 'civicrm_grant',
378 'bao' => 'CRM_Grant_BAO_Grant',
385 'amount_granted' => [
386 'name' => 'amount_granted',
387 'type' => CRM_Utils_Type
::T_MONEY
,
388 'title' => ts('Amount granted'),
389 'description' => ts('Granted amount, in default currency.'),
395 'where' => 'civicrm_grant.amount_granted',
396 'dataPattern' => '/^\d+(\.\d{2})?$/',
398 'table_name' => 'civicrm_grant',
400 'bao' => 'CRM_Grant_BAO_Grant',
408 'name' => 'currency',
409 'type' => CRM_Utils_Type
::T_STRING
,
410 'title' => ts('Grant Currency'),
411 'description' => ts('3 character string, value from config setting or input via user.'),
414 'size' => CRM_Utils_Type
::FOUR
,
415 'where' => 'civicrm_grant.currency',
416 'table_name' => 'civicrm_grant',
418 'bao' => 'CRM_Grant_BAO_Grant',
423 'pseudoconstant' => [
424 'table' => 'civicrm_currency',
425 'keyColumn' => 'name',
426 'labelColumn' => 'full_name',
427 'nameColumn' => 'name',
428 'abbrColumn' => 'symbol',
433 'name' => 'rationale',
434 'type' => CRM_Utils_Type
::T_TEXT
,
435 'title' => ts('Grant Rationale'),
436 'description' => ts('Grant rationale.'),
440 'where' => 'civicrm_grant.rationale',
442 'table_name' => 'civicrm_grant',
444 'bao' => 'CRM_Grant_BAO_Grant',
447 'type' => 'TextArea',
451 'grant_status_id' => [
452 'name' => 'status_id',
453 'type' => CRM_Utils_Type
::T_INT
,
454 'title' => ts('Grant Status'),
455 'description' => ts('Id of Grant status.'),
458 'where' => 'civicrm_grant.status_id',
460 'table_name' => 'civicrm_grant',
462 'bao' => 'CRM_Grant_BAO_Grant',
467 'pseudoconstant' => [
468 'optionGroupName' => 'grant_status',
469 'optionEditPath' => 'civicrm/admin/options/grant_status',
473 'financial_type_id' => [
474 'name' => 'financial_type_id',
475 'type' => CRM_Utils_Type
::T_INT
,
476 'title' => ts('Financial Type'),
477 'description' => ts('FK to Financial Type.'),
478 'where' => 'civicrm_grant.financial_type_id',
480 'table_name' => 'civicrm_grant',
482 'bao' => 'CRM_Grant_BAO_Grant',
484 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
485 'pseudoconstant' => [
486 'table' => 'civicrm_financial_type',
488 'labelColumn' => 'name',
493 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
495 return Civi
::$statics[__CLASS__
]['fields'];
499 * Return a mapping from field-name to the corresponding key (as used in fields()).
502 * Array(string $name => string $uniqueName).
504 public static function &fieldKeys() {
505 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
506 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
508 return Civi
::$statics[__CLASS__
]['fieldKeys'];
512 * Returns the names of this table
516 public static function getTableName() {
517 return self
::$_tableName;
521 * Returns if this table needs to be logged
525 public function getLog() {
530 * Returns the list of fields that can be imported
532 * @param bool $prefix
536 public static function &import($prefix = FALSE) {
537 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'grant', $prefix, []);
542 * Returns the list of fields that can be exported
544 * @param bool $prefix
548 public static function &export($prefix = FALSE) {
549 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'grant', $prefix, []);
554 * Returns the list of indices
556 * @param bool $localize
560 public static function indices($localize = TRUE) {
562 'index_grant_type_id' => [
563 'name' => 'index_grant_type_id',
565 0 => 'grant_type_id',
567 'localizable' => FALSE,
568 'sig' => 'civicrm_grant::0::grant_type_id',
570 'index_status_id' => [
571 'name' => 'index_status_id',
575 'localizable' => FALSE,
576 'sig' => 'civicrm_grant::0::status_id',
579 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;