3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
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.
48 public function preProcess() {
51 //check permission for update.
52 if (!CRM_Core_Permission
::checkActionPermission('CiviGrant', CRM_Core_Action
::UPDATE
)) {
53 CRM_Core_Error
::fatal(ts('You do not have permission to access this page.'));
58 * Build the form object.
63 public function buildQuickForm() {
64 $grantStatus = CRM_Core_PseudoConstant
::get('CRM_Grant_DAO_Grant', 'status_id');
65 $this->addElement('select', 'status_id', ts('Grant Status'), array('' => '') +
$grantStatus);
67 $this->addElement('text', 'amount_granted', ts('Amount Granted'));
68 $this->addRule('amount_granted', ts('Please enter a valid amount.'), 'money');
70 $this->addDate('decision_date', ts('Grant Decision'), FALSE, array('formatType' => 'custom'));
72 $this->assign('elements', array('status_id', 'amount_granted', 'decision_date'));
73 $this->assign('totalSelectedGrants', count($this->_grantIds
));
75 $this->addDefaultButtons(ts('Update Grants'), 'done');
79 * Process the form after the input has been submitted and validated.
84 public function postProcess() {
87 // get the submitted form values.
88 $params = $this->controller
->exportValues($this->_name
);
89 $qfKey = $params['qfKey'];
90 foreach ($params as $key => $value) {
91 if ($value == '' ||
$key == 'qfKey') {
96 if (!empty($params)) {
97 foreach ($params as $key => $value) {
98 $values[$key] = $value;
100 foreach ($this->_grantIds
as $grantId) {
101 $ids['grant_id'] = $grantId;
103 CRM_Grant_BAO_Grant
::add($values, $ids);
108 $status = ts('Updated Grant(s): %1 (Total Selected: %2)', array(1 => $updatedGrants, 2 => count($this->_grantIds
)));
109 CRM_Core_Session
::setStatus($status, '', 'info');
110 CRM_Utils_System
::redirect(CRM_Utils_System
::url('civicrm/grant/search', 'force=1&qfKey=' . $qfKey));