3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
35 * This class provides the functionality for batch profile update for contributions.
37 class CRM_Contribute_Form_Task_PickProfile
extends CRM_Contribute_Form_Task
{
40 * The title of the group
47 * Maximum contributions that should be allowed to update
50 protected $_maxContributions = 100;
53 * Variable to store redirect path
56 protected $_userContext;
59 * Build all the data structures needed to build the form.
61 public function preProcess() {
62 // initialize the task and row fields
64 $session = CRM_Core_Session
::singleton();
65 $this->_userContext
= $session->readUserContext();
67 CRM_Utils_System
::setTitle(ts('Update multiple contributions'));
71 if (count($this->_contributionIds
) > $this->_maxContributions
) {
72 CRM_Core_Session
::setStatus(ts("The maximum number of contributions you can select for Update multiple contributions is %1. You have selected %2. Please select fewer contributions from your search results and try again.", [
73 1 => $this->_maxContributions
,
74 2 => count($this->_contributionIds
),
75 ]), ts('Update multiple records error'), 'error');
81 CRM_Utils_System
::redirect($this->_userContext
);
86 * Build the form object.
88 public function buildQuickForm() {
90 $types = ['Contribution'];
91 $profiles = CRM_Core_BAO_UFGroup
::getProfiles($types, TRUE);
93 if (empty($profiles)) {
94 CRM_Core_Session
::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Update multiple contributions. Navigate to Administer CiviCRM > Customize Data and Screens > CiviCRM Profile to configure a Profile. Consult the online Administrator documentation for more information.", [1 => $types[0]]), ts('Profile Required'), 'error');
95 CRM_Utils_System
::redirect($this->_userContext
);
98 $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'),
100 '' => ts('- select profile -'),
103 $this->addDefaultButtons(ts('Continue'));
107 * Add local and global form rules.
109 public function addRules() {
110 $this->addFormRule(['CRM_Contribute_Form_Task_PickProfile', 'formRule']);
114 * Global validation rules for the form.
116 * @param array $fields
117 * Posted values of the form.
120 * list of errors to be posted back to the form
122 public static function formRule($fields) {
127 * Process the form after the input has been submitted and validated.
129 public function postProcess() {
130 $params = $this->exportValues();
132 $this->set('ufGroupId', $params['uf_group_id']);
134 // also reset the batch page so it gets new values from the db
135 $this->controller
->resetPage('Batch');