3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 * This class generates form components for processing a Grant
24 class CRM_Grant_Form_GrantView
extends CRM_Core_Form
{
27 * Set variables up before form is built.
31 public function preProcess() {
32 $this->_contactID
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this);
33 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
34 $context = CRM_Utils_Request
::retrieve('context', 'Alphanumeric', $this);
35 $this->assign('context', $context);
38 $params['id'] = $this->_id
;
39 CRM_Grant_BAO_Grant
::retrieve($params, $values);
40 $grantType = CRM_Core_PseudoConstant
::get('CRM_Grant_DAO_Grant', 'grant_type_id');
41 $grantStatus = CRM_Core_PseudoConstant
::get('CRM_Grant_DAO_Grant', 'status_id');
42 $this->assign('grantType', $grantType[$values['grant_type_id']]);
43 $this->assign('grantStatus', $grantStatus[$values['status_id']]);
49 'grant_report_received',
50 'application_received_date',
52 'money_transfer_date',
56 foreach ($grantTokens as $token) {
57 $this->assign($token, CRM_Utils_Array
::value($token, $values));
60 if (isset($this->_id
)) {
61 $noteDAO = new CRM_Core_BAO_Note();
62 $noteDAO->entity_table
= 'civicrm_grant';
63 $noteDAO->entity_id
= $this->_id
;
64 if ($noteDAO->find(TRUE)) {
65 $this->_noteId
= $noteDAO->id
;
69 if (isset($this->_noteId
)) {
70 $this->assign('note', CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_Note', $this->_noteId
, 'note'));
73 // add Grant to Recent Items
74 $url = CRM_Utils_System
::url('civicrm/contact/view/grant',
75 "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"
78 $title = CRM_Contact_BAO_Contact
::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money
::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
81 if (CRM_Core_Permission
::checkActionPermission('CiviGrant', CRM_Core_Action
::UPDATE
)) {
82 $recentOther['editUrl'] = CRM_Utils_System
::url('civicrm/contact/view/grant',
83 "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"
86 if (CRM_Core_Permission
::checkActionPermission('CiviGrant', CRM_Core_Action
::DELETE
)) {
87 $recentOther['deleteUrl'] = CRM_Utils_System
::url('civicrm/contact/view/grant',
88 "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"
91 CRM_Utils_Recent
::add($title,
95 $values['contact_id'],
100 $attachment = CRM_Core_BAO_File
::attachmentInfo('civicrm_grant', $this->_id
);
101 $this->assign('attachment', $attachment);
103 $grantType = CRM_Core_DAO
::getFieldValue("CRM_Grant_DAO_Grant", $this->_id
, "grant_type_id");
104 $groupTree = CRM_Core_BAO_CustomGroup
::getTree("Grant", NULL, $this->_id
, 0, $grantType);
105 CRM_Core_BAO_CustomGroup
::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id
);
107 $this->assign('id', $this->_id
);
109 $this->setPageTitle(ts('Grant'));
113 * Build the form object.
117 public function buildQuickForm() {
121 'name' => ts('Done'),
122 'spacing' => ' ',