3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * This class provides the functionality to update a group of
38 * grants. This class provides functionality for the actual
41 class CRM_Grant_Form_Task_Update
extends CRM_Grant_Form_Task
{
44 * build all the data structures needed to build the form
49 function preProcess() {
52 //check permission for update.
53 if (!CRM_Core_Permission
::checkActionPermission('CiviGrant', CRM_Core_Action
::UPDATE
)) {
54 CRM_Core_Error
::fatal(ts('You do not have permission to access this page'));
65 function buildQuickForm() {
66 $grantStatus = CRM_Core_PseudoConstant
::get('CRM_Grant_DAO_Grant', 'status_id');
67 $this->addElement('select', 'status_id', ts('Grant Status'), array('' => '') +
$grantStatus);
69 $this->addElement('text', 'amount_granted', ts('Amount Granted'));
70 $this->addRule('amount_granted', ts('Please enter a valid amount.'), 'money');
72 $this->addDate('decision_date', ts('Grant Decision'), FALSE, array('formatType' => 'custom'));
74 $this->assign('elements', array('status_id', 'amount_granted', 'decision_date'));
75 $this->assign('totalSelectedGrants', count($this->_grantIds
));
77 $this->addDefaultButtons(ts('Update Grants'), 'done');
81 * process the form after the input has been submitted and validated
87 public function postProcess() {
90 // get the submitted form values.
91 $params = $this->controller
->exportValues($this->_name
);
92 $qfKey = $params['qfKey'];
93 foreach ($params as $key => $value) {
94 if ($value == '' ||
$key == 'qfKey') {
99 if (!empty($params)) {
100 foreach ($params as $key => $value) {
101 $values[$key] = $value;
103 foreach ($this->_grantIds
as $grantId) {
104 $ids['grant_id'] = $grantId;
106 CRM_Grant_BAO_Grant
::add($values, $ids);
111 CRM_Core_Session
::setStatus(ts('Updated Grant(s): %1', array(1 => $updatedGrants)), '', 'info');
112 CRM_Core_Session
::setStatus(ts('Total Selected Grant(s): %1', array(1 => count($this->_grantIds
))), '', 'info');
113 CRM_Utils_System
::redirect(CRM_Utils_System
::url('civicrm/grant/search', 'force=1&qfKey=' . $qfKey));