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:36856b7ed6b7fc04e812c92fd42df94f)
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' => 'civicrm/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 user-friendly description of this entity.
181 public static function getEntityDescription() {
182 return ts('Funds applied for and given out by this organization.');
186 * Returns foreign keys and entity references.
189 * [CRM_Core_Reference_Interface]
191 public static function getReferenceColumns() {
192 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
193 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
194 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
195 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
196 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
198 return Civi
::$statics[__CLASS__
]['links'];
202 * Returns all the column names of this table
206 public static function &fields() {
207 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
208 Civi
::$statics[__CLASS__
]['fields'] = [
211 'type' => CRM_Utils_Type
::T_INT
,
212 'title' => ts('Grant ID'),
213 'description' => ts('Unique Grant id'),
216 'where' => 'civicrm_grant.id',
218 'table_name' => 'civicrm_grant',
220 'bao' => 'CRM_Grant_BAO_Grant',
228 'grant_contact_id' => [
229 'name' => 'contact_id',
230 'type' => CRM_Utils_Type
::T_INT
,
231 'title' => ts('Contact ID'),
232 'description' => ts('Contact ID of contact record given grant belongs to.'),
234 'where' => 'civicrm_grant.contact_id',
236 'table_name' => 'civicrm_grant',
238 'bao' => 'CRM_Grant_BAO_Grant',
240 'FKClassName' => 'CRM_Contact_DAO_Contact',
242 'type' => 'EntityRef',
243 'label' => ts("Contact"),
247 'grant_application_received_date' => [
248 'name' => 'application_received_date',
249 'type' => CRM_Utils_Type
::T_DATE
,
250 'title' => ts('Application received date'),
251 'description' => ts('Date on which grant application was received by donor.'),
253 'where' => 'civicrm_grant.application_received_date',
255 'table_name' => 'civicrm_grant',
257 'bao' => 'CRM_Grant_BAO_Grant',
260 'type' => 'Select Date',
261 'formatType' => 'activityDate',
265 'grant_decision_date' => [
266 'name' => 'decision_date',
267 'type' => CRM_Utils_Type
::T_DATE
,
268 'title' => ts('Decision date'),
269 'description' => ts('Date on which grant decision was made.'),
271 'where' => 'civicrm_grant.decision_date',
273 'table_name' => 'civicrm_grant',
275 'bao' => 'CRM_Grant_BAO_Grant',
278 'type' => 'Select Date',
279 'formatType' => 'activityDate',
283 'grant_money_transfer_date' => [
284 'name' => 'money_transfer_date',
285 'type' => CRM_Utils_Type
::T_DATE
,
286 'title' => ts('Grant Money transfer date'),
287 'description' => ts('Date on which grant money transfer was made.'),
289 'where' => 'civicrm_grant.money_transfer_date',
291 'table_name' => 'civicrm_grant',
293 'bao' => 'CRM_Grant_BAO_Grant',
296 'type' => 'Select Date',
297 'formatType' => 'activityDate',
301 'grant_due_date' => [
302 'name' => 'grant_due_date',
303 'type' => CRM_Utils_Type
::T_DATE
,
304 'title' => ts('Grant Report Due Date'),
305 'description' => ts('Date on which grant report is due.'),
307 'where' => 'civicrm_grant.grant_due_date',
309 'table_name' => 'civicrm_grant',
311 'bao' => 'CRM_Grant_BAO_Grant',
314 'type' => 'Select Date',
315 'formatType' => 'activityDate',
319 'grant_report_received' => [
320 'name' => 'grant_report_received',
321 'type' => CRM_Utils_Type
::T_BOOLEAN
,
322 'title' => ts('Grant report received'),
323 'description' => ts('Yes/No field stating whether grant report was received by donor.'),
325 'where' => 'civicrm_grant.grant_report_received',
327 'table_name' => 'civicrm_grant',
329 'bao' => 'CRM_Grant_BAO_Grant',
332 'type' => 'CheckBox',
337 'name' => 'grant_type_id',
338 'type' => CRM_Utils_Type
::T_INT
,
339 'title' => ts('Grant Type'),
340 'description' => ts('Type of grant. Implicit FK to civicrm_option_value in grant_type option_group.'),
342 'where' => 'civicrm_grant.grant_type_id',
344 'table_name' => 'civicrm_grant',
346 'bao' => 'CRM_Grant_BAO_Grant',
351 'pseudoconstant' => [
352 'optionGroupName' => 'grant_type',
353 'optionEditPath' => 'civicrm/admin/options/grant_type',
358 'name' => 'amount_total',
359 'type' => CRM_Utils_Type
::T_MONEY
,
360 'title' => ts('Total Amount'),
361 'description' => ts('Requested grant amount, in default currency.'),
368 'where' => 'civicrm_grant.amount_total',
369 'dataPattern' => '/^\d+(\.\d{2})?$/',
371 'table_name' => 'civicrm_grant',
373 'bao' => 'CRM_Grant_BAO_Grant',
380 'amount_requested' => [
381 'name' => 'amount_requested',
382 'type' => CRM_Utils_Type
::T_MONEY
,
383 'title' => ts('Amount Requested'),
384 'description' => ts('Requested grant amount, in original currency (optional).'),
389 'where' => 'civicrm_grant.amount_requested',
390 'dataPattern' => '/^\d+(\.\d{2})?$/',
391 'table_name' => 'civicrm_grant',
393 'bao' => 'CRM_Grant_BAO_Grant',
400 'amount_granted' => [
401 'name' => 'amount_granted',
402 'type' => CRM_Utils_Type
::T_MONEY
,
403 'title' => ts('Amount granted'),
404 'description' => ts('Granted amount, in default currency.'),
410 'where' => 'civicrm_grant.amount_granted',
411 'dataPattern' => '/^\d+(\.\d{2})?$/',
413 'table_name' => 'civicrm_grant',
415 'bao' => 'CRM_Grant_BAO_Grant',
423 'name' => 'currency',
424 'type' => CRM_Utils_Type
::T_STRING
,
425 'title' => ts('Grant Currency'),
426 'description' => ts('3 character string, value from config setting or input via user.'),
429 'size' => CRM_Utils_Type
::FOUR
,
430 'where' => 'civicrm_grant.currency',
431 'table_name' => 'civicrm_grant',
433 'bao' => 'CRM_Grant_BAO_Grant',
438 'pseudoconstant' => [
439 'table' => 'civicrm_currency',
440 'keyColumn' => 'name',
441 'labelColumn' => 'full_name',
442 'nameColumn' => 'name',
443 'abbrColumn' => 'symbol',
448 'name' => 'rationale',
449 'type' => CRM_Utils_Type
::T_TEXT
,
450 'title' => ts('Grant Rationale'),
451 'description' => ts('Grant rationale.'),
455 'where' => 'civicrm_grant.rationale',
457 'table_name' => 'civicrm_grant',
459 'bao' => 'CRM_Grant_BAO_Grant',
462 'type' => 'TextArea',
466 'grant_status_id' => [
467 'name' => 'status_id',
468 'type' => CRM_Utils_Type
::T_INT
,
469 'title' => ts('Grant Status'),
470 'description' => ts('ID of Grant status.'),
473 'where' => 'civicrm_grant.status_id',
475 'table_name' => 'civicrm_grant',
477 'bao' => 'CRM_Grant_BAO_Grant',
482 'pseudoconstant' => [
483 'optionGroupName' => 'grant_status',
484 'optionEditPath' => 'civicrm/admin/options/grant_status',
488 'financial_type_id' => [
489 'name' => 'financial_type_id',
490 'type' => CRM_Utils_Type
::T_INT
,
491 'title' => ts('Financial Type ID'),
492 'description' => ts('FK to Financial Type.'),
493 'where' => 'civicrm_grant.financial_type_id',
495 'table_name' => 'civicrm_grant',
497 'bao' => 'CRM_Grant_BAO_Grant',
499 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
501 'label' => ts("Financial Type"),
503 'pseudoconstant' => [
504 'table' => 'civicrm_financial_type',
506 'labelColumn' => 'name',
511 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
513 return Civi
::$statics[__CLASS__
]['fields'];
517 * Return a mapping from field-name to the corresponding key (as used in fields()).
520 * Array(string $name => string $uniqueName).
522 public static function &fieldKeys() {
523 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
524 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
526 return Civi
::$statics[__CLASS__
]['fieldKeys'];
530 * Returns the names of this table
534 public static function getTableName() {
535 return self
::$_tableName;
539 * Returns if this table needs to be logged
543 public function getLog() {
548 * Returns the list of fields that can be imported
550 * @param bool $prefix
554 public static function &import($prefix = FALSE) {
555 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'grant', $prefix, []);
560 * Returns the list of fields that can be exported
562 * @param bool $prefix
566 public static function &export($prefix = FALSE) {
567 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'grant', $prefix, []);
572 * Returns the list of indices
574 * @param bool $localize
578 public static function indices($localize = TRUE) {
580 'index_grant_type_id' => [
581 'name' => 'index_grant_type_id',
583 0 => 'grant_type_id',
585 'localizable' => FALSE,
586 'sig' => 'civicrm_grant::0::grant_type_id',
588 'index_status_id' => [
589 'name' => 'index_status_id',
593 'localizable' => FALSE,
594 'sig' => 'civicrm_grant::0::status_id',
597 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;