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 provides the functionality for batch profile update for contributions.
21 class CRM_Contribute_Form_Task_PickProfile
extends CRM_Contribute_Form_Task
{
24 * The title of the group
31 * Maximum contributions that should be allowed to update
34 protected $_maxContributions = 100;
37 * Variable to store redirect path
40 protected $_userContext;
43 * Build all the data structures needed to build the form.
45 public function preProcess() {
46 // initialize the task and row fields
48 $session = CRM_Core_Session
::singleton();
49 $this->_userContext
= $session->readUserContext();
51 CRM_Utils_System
::setTitle(ts('Update multiple contributions'));
55 if (count($this->_contributionIds
) > $this->_maxContributions
) {
56 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.", [
57 1 => $this->_maxContributions
,
58 2 => count($this->_contributionIds
),
59 ]), ts('Update multiple records error'), 'error');
65 CRM_Utils_System
::redirect($this->_userContext
);
70 * Build the form object.
72 public function buildQuickForm() {
74 $types = ['Contribution'];
75 $profiles = CRM_Core_BAO_UFGroup
::getProfiles($types, TRUE);
77 if (empty($profiles)) {
78 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');
79 CRM_Utils_System
::redirect($this->_userContext
);
82 $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'),
84 '' => ts('- select profile -'),
87 $this->addDefaultButtons(ts('Continue'));
91 * Add local and global form rules.
93 public function addRules() {
94 $this->addFormRule(['CRM_Contribute_Form_Task_PickProfile', 'formRule']);
98 * Global validation rules for the form.
100 * @param array $fields
101 * Posted values of the form.
104 * list of errors to be posted back to the form
106 public static function formRule($fields) {
111 * Process the form after the input has been submitted and validated.
113 public function postProcess() {
114 $params = $this->exportValues();
116 $this->set('ufGroupId', $params['uf_group_id']);
118 // also reset the batch page so it gets new values from the db
119 $this->controller
->resetPage('Batch');