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
19 * This class generates form components for processing a Grant
22 class CRM_Grant_Form_GrantView
extends CRM_Core_Form
{
25 * Set variables up before form is built.
29 public function preProcess() {
30 $this->_contactID
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this);
31 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
32 $context = CRM_Utils_Request
::retrieve('context', 'Alphanumeric', $this);
33 $this->assign('context', $context);
36 $params['id'] = $this->_id
;
37 CRM_Grant_BAO_Grant
::retrieve($params, $values);
38 $grantType = CRM_Core_PseudoConstant
::get('CRM_Grant_DAO_Grant', 'grant_type_id');
39 $grantStatus = CRM_Core_PseudoConstant
::get('CRM_Grant_DAO_Grant', 'status_id');
40 $this->assign('grantType', $grantType[$values['grant_type_id']]);
41 $this->assign('grantStatus', $grantStatus[$values['status_id']]);
47 'grant_report_received',
48 'application_received_date',
50 'money_transfer_date',
54 foreach ($grantTokens as $token) {
55 $this->assign($token, CRM_Utils_Array
::value($token, $values));
58 if (isset($this->_id
)) {
59 $noteDAO = new CRM_Core_BAO_Note();
60 $noteDAO->entity_table
= 'civicrm_grant';
61 $noteDAO->entity_id
= $this->_id
;
62 if ($noteDAO->find(TRUE)) {
63 $this->_noteId
= $noteDAO->id
;
67 if (isset($this->_noteId
)) {
68 $this->assign('note', CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_Note', $this->_noteId
, 'note'));
71 // add Grant to Recent Items
72 $url = CRM_Utils_System
::url('civicrm/contact/view/grant',
73 "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"
76 $title = CRM_Contact_BAO_Contact
::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money
::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
79 if (CRM_Core_Permission
::checkActionPermission('CiviGrant', CRM_Core_Action
::UPDATE
)) {
80 $recentOther['editUrl'] = CRM_Utils_System
::url('civicrm/contact/view/grant',
81 "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"
84 if (CRM_Core_Permission
::checkActionPermission('CiviGrant', CRM_Core_Action
::DELETE
)) {
85 $recentOther['deleteUrl'] = CRM_Utils_System
::url('civicrm/contact/view/grant',
86 "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home"
89 CRM_Utils_Recent
::add($title,
93 $values['contact_id'],
98 $attachment = CRM_Core_BAO_File
::attachmentInfo('civicrm_grant', $this->_id
);
99 $this->assign('attachment', $attachment);
101 $grantType = CRM_Core_DAO
::getFieldValue("CRM_Grant_DAO_Grant", $this->_id
, "grant_type_id");
102 $groupTree = CRM_Core_BAO_CustomGroup
::getTree("Grant", NULL, $this->_id
, 0, $grantType);
103 CRM_Core_BAO_CustomGroup
::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id
);
105 $this->assign('id', $this->_id
);
107 $this->setPageTitle(ts('Grant'));
111 * Build the form object.
115 public function buildQuickForm() {
119 'name' => ts('Done'),
120 'spacing' => ' ',