Merge pull request #17298 from demeritcowboy/activity-attachment-delete
[civicrm-core.git] / CRM / Member / Form / MembershipBlock.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035 11
6a488035
TO
12/**
13 * form to process actions on Membership
14 */
15class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPage {
16
17 /**
100fef9d 18 * Store membership price set id
971e129b 19 * @var int
6a488035
TO
20 */
21 protected $_memPriceSetId = NULL;
22
7885e669
MW
23 /**
24 * Set variables up before form is built.
25 */
26 public function preProcess() {
27 parent::preProcess();
28 $this->setSelectedChild('membership');
29 }
30
6a488035 31 /**
c490a46a 32 * Set default values for the form. Note that in edit/view mode
6a488035 33 * the default values are retrieved from the database
fd726496 34 */
00be9182 35 public function setDefaultValues() {
be2fb01f 36 $defaults = [];
6a488035
TO
37 if (isset($this->_id)) {
38 $defaults = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
39 }
40 $defaults['member_is_active'] = $defaults['is_active'];
41
42 // Set Display Minimum Fee default to true if we are adding a new membership block
43 if (!isset($defaults['id'])) {
44 $defaults['display_min_fee'] = 1;
45 }
46 else {
47 $this->assign('membershipBlockId', $defaults['id']);
48 }
49 if ($this->_id &&
9da8dc8c 50 ($priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 3, 1))
6a488035
TO
51 ) {
52 $defaults['member_price_set_id'] = $priceSetId;
53 $this->_memPriceSetId = $priceSetId;
54 }
55 else {
56 // for membership_types
57 // if ( isset( $defaults['membership_types'] ) ) {
9da8dc8c 58 $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 3);
6a488035
TO
59 $this->assign('isQuick', 1);
60 $this->_memPriceSetId = $priceSetId;
be2fb01f 61 $pFIDs = [];
6a488035 62 if ($priceSetId) {
be2fb01f 63 CRM_Core_DAO::commonRetrieveAll('CRM_Price_DAO_PriceField', 'price_set_id', $priceSetId, $pFIDs, $return = [
c5c263ca
AH
64 'html_type',
65 'name',
66 'label',
be2fb01f 67 ]);
6a488035
TO
68 foreach ($pFIDs as $pid => $pValue) {
69 if ($pValue['html_type'] == 'Radio' && $pValue['name'] == 'membership_amount') {
70 $defaults['mem_price_field_id'] = $pValue['id'];
21f4797a 71 $defaults['membership_type_label'] = $pValue['label'];
6a488035
TO
72 }
73 }
74
a7488080 75 if (!empty($defaults['mem_price_field_id'])) {
be2fb01f 76 $options = [];
9da8dc8c 77 $priceFieldOptions = CRM_Price_BAO_PriceFieldValue::getValues($defaults['mem_price_field_id'], $options, 'id', 1);
6a488035
TO
78 foreach ($options as $k => $v) {
79 $newMembershipType[$v['membership_type_id']] = 1;
3476772a 80 if (!empty($defaults['auto_renew'])) {
92fcb95f 81 $defaults["auto_renew_" . $v['membership_type_id']] = $defaults['auto_renew'][$v['membership_type_id']];
6a488035
TO
82 }
83 }
84 $defaults['membership_type'] = $newMembershipType;
85 }
86 }
87 }
88
89 return $defaults;
90 }
91
92 /**
fe482240 93 * Build the form object.
6a488035 94 *
7885e669
MW
95 * @throws \CRM_Core_Exception
96 * @throws \CiviCRM_API3_Exception
6a488035
TO
97 */
98 public function buildQuickForm() {
99 $membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypes();
100
101 if (!empty($membershipTypes)) {
102 $this->addElement('checkbox', 'member_is_active', ts('Membership Section Enabled?'));
103
104 $this->addElement('text', 'new_title', ts('Title - New Membership'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'new_title'));
105
5d51a2f9 106 $this->add('wysiwyg', 'new_text', ts('Introductory Message - New Memberships'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'new_text'));
6a488035
TO
107
108 $this->addElement('text', 'renewal_title', ts('Title - Renewals'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'renewal_title'));
109
5d51a2f9 110 $this->add('wysiwyg', 'renewal_text', ts('Introductory Message - Renewals'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'renewal_text'));
6a488035
TO
111
112 $this->addElement('checkbox', 'is_required', ts('Require Membership Signup'));
113 $this->addElement('checkbox', 'display_min_fee', ts('Display Membership Fee'));
114 $this->addElement('checkbox', 'is_separate_payment', ts('Separate Membership Payment'));
be2fb01f 115 $this->addElement('text', 'membership_type_label', ts('Membership Types Label'), ['placeholder' => ts('Membership')]);
6a488035
TO
116
117 $paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'is_recur = 1');
118 $paymentProcessorIds = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage',
119 $this->_id, 'payment_processor'
120 );
121 $paymentProcessorId = explode(CRM_Core_DAO::VALUE_SEPARATOR, $paymentProcessorIds);
122 $isRecur = TRUE;
123 foreach ($paymentProcessorId as $dontCare => $id) {
124 if (!array_key_exists($id, $paymentProcessor)) {
125 $isRecur = FALSE;
126 continue;
127 }
128 }
129
be2fb01f 130 $membership = $membershipDefault = $params = [];
6a488035
TO
131 foreach ($membershipTypes as $k => $v) {
132 $membership[] = $this->createElement('advcheckbox', $k, NULL, $v);
133 $membershipDefault[] = $this->createElement('radio', NULL, NULL, NULL, $k);
3476772a 134 $membershipRequired[$k] = NULL;
6a488035 135 if ($isRecur) {
353ffa53 136 $autoRenew = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $k, 'auto_renew');
3476772a 137 $membershipRequired[$k] = $autoRenew;
be2fb01f 138 $autoRenewOptions = [];
6a488035 139 if ($autoRenew) {
be2fb01f 140 $autoRenewOptions = [ts('Not offered'), ts('Give option'), ts('Required')];
6a488035 141 $this->addElement('select', "auto_renew_$k", ts('Auto-renew'), $autoRenewOptions);
3476772a 142 //CRM-15573
22e263ad 143 if ($autoRenew == 2) {
3476772a 144 $this->freeze("auto_renew_$k");
b09fe5ed 145 $params['id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipBlock', $this->_id, 'id', 'entity_id');
3476772a 146 }
6a488035
TO
147 $this->_renewOption[$k] = $autoRenew;
148 }
149 }
150 }
151
3476772a 152 //CRM-15573
153 if (!empty($params['id'])) {
154 $params['membership_types'] = serialize($membershipRequired);
155 CRM_Member_BAO_MembershipBlock::create($params);
156 }
be2fb01f 157 $this->add('hidden', "mem_price_field_id", '', ['id' => "mem_price_field_id"]);
6a488035
TO
158 $this->assign('is_recur', $isRecur);
159 if (isset($this->_renewOption)) {
160 $this->assign('auto_renew', $this->_renewOption);
161 }
162 $this->addGroup($membership, 'membership_type', ts('Membership Types'));
353ffa53
TO
163 $this->addGroup($membershipDefault, 'membership_type_default', ts('Membership Types Default'))
164 ->setAttribute('allowClear', TRUE);
6a488035 165
be2fb01f 166 $this->addFormRule(['CRM_Member_Form_MembershipBlock', 'formRule'], $this->_id);
6a488035 167 }
9da8dc8c 168 $price = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviMember');
6a488035
TO
169 if (CRM_Utils_System::isNull($price)) {
170 $this->assign('price', FALSE);
171 }
172 else {
173 $this->assign('price', TRUE);
174 }
a0a2c91d
MWMC
175 //$this->add('select', 'member_price_set_id', ts('Membership Price Set'), (['' => ts('- none -')] + $price));
176
177 $this->addField('member_price_set_id', [
178 'entity' => 'PriceSet',
179 'name' => 'price_set_id',
180 'options' => $price,
181 ]);
6a488035
TO
182
183 $session = CRM_Core_Session::singleton();
184 $single = $session->get('singleForm');
185 if ($single) {
be2fb01f
CW
186 $this->addButtons([
187 [
c5c263ca
AH
188 'type' => 'next',
189 'name' => ts('Save'),
190 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
191 'isDefault' => TRUE,
be2fb01f
CW
192 ],
193 [
c5c263ca
AH
194 'type' => 'cancel',
195 'name' => ts('Cancel'),
be2fb01f
CW
196 ],
197 ]);
6a488035
TO
198 }
199 else {
200 parent::buildQuickForm();
201 }
202 }
203
204 /**
fe482240 205 * Validation.
6a488035 206 *
b2363ea8
TO
207 * @param array $params
208 * (ref.) an assoc array of name/value pairs.
da6b46f4 209 * @param $files
100fef9d 210 * @param int $contributionPageId
da6b46f4 211 *
72b3a70c
CW
212 * @return bool|array
213 * mixed true or array of errors
7885e669
MW
214 * @throws \CRM_Core_Exception
215 * @throws \CiviCRM_API3_Exception
6a488035 216 */
00be9182 217 public static function formRule($params, $files, $contributionPageId = NULL) {
be2fb01f 218 $errors = [];
6a488035 219
a7488080 220 if (!empty($params['member_price_set_id'])) {
fd726496 221 //check if this price set has membership type both auto-renew and non-auto-renew memberships.
f72e6e2c 222 $bothTypes = CRM_Price_BAO_PriceSet::isMembershipPriceSetContainsMixOfRenewNonRenew($params['member_price_set_id']);
6a488035
TO
223
224 //check for supporting payment processors
225 //if both auto-renew and non-auto-renew memberships
226 if ($bothTypes) {
b09fe5ed 227 $paymentProcessorIds = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage',
353ffa53
TO
228 $contributionPageId, 'payment_processor'
229 );
6a488035 230
b09fe5ed 231 $paymentProcessorId = explode(CRM_Core_DAO::VALUE_SEPARATOR, $paymentProcessorIds);
6a488035
TO
232
233 if (!empty($paymentProcessorId)) {
22e263ad 234 foreach ($paymentProcessorId as $pid) {
6a488035 235 if ($pid) {
b6ffdf22
EM
236 $processor = Civi\Payment\System::singleton()->getById($pid);
237 if (!$processor->supports('MultipleConcurrentPayments')) {
238 $errors['member_price_set_id'] = ts('The membership price set associated with this online contribution allows a user to select BOTH an auto-renew AND a non-auto-renew membership. This requires submitting multiple processor transactions, and is not supported for one or more of the payment processors enabled under the Amounts tab.');
239 }
6a488035 240 }
6a488035
TO
241 }
242 }
fd726496 243 }
6a488035 244 }
a7488080 245 if (!empty($params['member_is_active'])) {
6a488035
TO
246
247 // don't allow price set w/ membership signup, CRM-5095
9da8dc8c 248 if ($contributionPageId && ($setID = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $contributionPageId, NULL, 1))) {
6a488035 249
9da8dc8c 250 $extends = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $setID, 'extends');
6a488035
TO
251 if ($extends != CRM_Core_Component::getComponentID('CiviMember')) {
252 $errors['member_is_active'] = ts('You cannot enable both Membership Signup and a Contribution Price Set on the same online contribution page.');
253 return $errors;
254 }
255 }
256
a7488080 257 if (!empty($params['member_price_set_id'])) {
6a488035
TO
258 return $errors;
259 }
260
261 if (!isset($params['membership_type']) ||
262 (!is_array($params['membership_type']))
263 ) {
264 $errors['membership_type'] = ts('Please select at least one Membership Type to include in the Membership section of this page.');
265 }
266 else {
267 $membershipType = array_values($params['membership_type']);
9cc96227 268 $isRecur = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageId, 'is_recur');
6a488035
TO
269 if (array_sum($membershipType) == 0) {
270 $errors['membership_type'] = ts('Please select at least one Membership Type to include in the Membership section of this page.');
271 }
0c165e1c
DG
272 elseif (array_sum($membershipType) > CRM_Price_Form_Field::NUM_OPTION) {
273 // for CRM-13079
be2fb01f 274 $errors['membership_type'] = ts('You cannot select more than %1 choices. For more complex functionality, please use a Price Set.', [1 => CRM_Price_Form_Field::NUM_OPTION]);
0c165e1c 275 }
9cc96227 276 elseif ($isRecur) {
277 if (empty($params['is_separate_payment']) && array_sum($membershipType) != 0) {
278 $errors['is_separate_payment'] = ts('You need to enable Separate Membership Payment when online contribution page is configured for both Membership and Recurring Contribution');
279 }
280 elseif (!empty($params['is_separate_payment'])) {
281 foreach ($params['membership_type'] as $mt => $dontCare) {
282 if (!empty($params["auto_renew_$mt"])) {
283 $errors["auto_renew_$mt"] = ts('You cannot enable both Recurring Contributions and Auto-renew memberships on the same online contribution page');
284 break;
285 }
286 }
287 }
288 }
6a488035
TO
289 }
290
291 //for CRM-1302
292 //if Membership status is not present, then display an error message
293 $dao = new CRM_Member_BAO_MembershipStatus();
294 if (!$dao->find()) {
295 $errors['_qf_default'] = ts('Add status rules, before configuring membership');
296 }
297
298 //give error if default is selected for an unchecked membership type
0c165e1c 299 if (!empty($params['membership_type_default']) && !$params['membership_type'][$params['membership_type_default']]) {
6a488035
TO
300 $errors['membership_type_default'] = ts('Can\'t set default option for an unchecked membership type.');
301 }
302
303 if ($contributionPageId) {
304 $amountBlock = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageId, 'amount_block_is_active');
305
8cc574cf 306 if (!$amountBlock && !empty($params['is_separate_payment'])) {
6a488035
TO
307 $errors['is_separate_payment'] = ts('Please enable the contribution amount section to use this option.');
308 }
309 }
fd726496 310
6a488035
TO
311 }
312
313 return empty($errors) ? TRUE : $errors;
314 }
315
316 /**
fe482240 317 * Process the form.
6a488035
TO
318 */
319 public function postProcess() {
320 // get the submitted form values.
321 $params = $this->controller->exportValues($this->_name);
322 $deletePriceSet = 0;
323 if ($params['membership_type']) {
324 // we do this in case the user has hit the forward/back button
353ffa53 325 $dao = new CRM_Member_DAO_MembershipBlock();
6a488035 326 $dao->entity_table = 'civicrm_contribution_page';
353ffa53 327 $dao->entity_id = $this->_id;
6a488035
TO
328 $dao->find(TRUE);
329 $membershipID = $dao->id;
330 if ($membershipID) {
331 $params['id'] = $membershipID;
332 }
333
be2fb01f 334 $membershipTypes = [];
6a488035
TO
335 if (is_array($params['membership_type'])) {
336 foreach ($params['membership_type'] as $k => $v) {
337 if ($v) {
9c1bc317 338 $membershipTypes[$k] = $params["auto_renew_$k"] ?? NULL;
6a488035
TO
339 }
340 }
341 }
342
2d8ae2ae
CW
343 if ($this->_id && !empty($params['member_price_set_id'])) {
344 CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'amount_block_is_active', 0);
345 }
346
6a488035 347 // check for price set.
9c1bc317 348 $priceSetID = $params['member_price_set_id'] ?? NULL;
a7488080 349 if (!empty($params['member_is_active']) && is_array($membershipTypes) && !$priceSetID) {
9da8dc8c 350 $usedPriceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 2);
a7488080 351 if (empty($params['mem_price_field_id']) && !$usedPriceSetId) {
6a488035
TO
352 $pageTitle = strtolower(CRM_Utils_String::munge($this->_values['title'], '_', 245));
353 $setParams['title'] = $this->_values['title'];
9da8dc8c 354 if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle, 'id', 'name')) {
6a488035
TO
355 $setParams['name'] = $pageTitle;
356 }
9da8dc8c 357 elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle . '_' . $this->_id, 'id', 'name')) {
6a488035
TO
358 $setParams['name'] = $pageTitle . '_' . $this->_id;
359 }
360 else {
b09fe5ed 361 $timeSec = explode(".", microtime(TRUE));
6a488035
TO
362 $setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
363 }
364 $setParams['is_quick_config'] = 1;
365 $setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
9c1bc317 366 $setParams['financial_type_id'] = $this->_values['financial_type_id'] ?? NULL;
9da8dc8c 367 $priceSet = CRM_Price_BAO_PriceSet::create($setParams);
6a488035
TO
368 $priceSetID = $priceSet->id;
369 $fieldParams['price_set_id'] = $priceSet->id;
370 }
371 elseif ($usedPriceSetId) {
372 $setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
9c1bc317 373 $setParams['financial_type_id'] = $this->_values['financial_type_id'] ?? NULL;
6a488035 374 $setParams['id'] = $usedPriceSetId;
9da8dc8c 375 $priceSet = CRM_Price_BAO_PriceSet::create($setParams);
6a488035
TO
376 $priceSetID = $priceSet->id;
377 $fieldParams['price_set_id'] = $priceSet->id;
378 }
379 else {
9c1bc317 380 $fieldParams['id'] = $params['mem_price_field_id'] ?? NULL;
9da8dc8c 381 $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('mem_price_field_id', $params), 'price_set_id');
6a488035 382 }
be2fb01f 383 $editedFieldParams = [
6a488035
TO
384 'price_set_id' => $priceSetID,
385 'name' => 'membership_amount',
be2fb01f
CW
386 ];
387 $editedResults = [];
9da8dc8c 388 CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults);
a7488080 389 if (empty($editedResults['id'])) {
6a488035 390 $fieldParams['name'] = strtolower(CRM_Utils_String::munge('Membership Amount', '_', 245));
a7488080 391 if (empty($params['mem_price_field_id'])) {
be2fb01f 392 CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceField', 0, 1, ['price_set_id' => $priceSetID]);
6a488035
TO
393 }
394 $fieldParams['weight'] = 1;
395 }
396 else {
9c1bc317 397 $fieldParams['id'] = $editedResults['id'] ?? NULL;
6a488035
TO
398 }
399
21f4797a 400 $fieldParams['label'] = !empty($params['membership_type_label']) ? $params['membership_type_label'] : ts('Membership');
6a488035
TO
401 $fieldParams['is_active'] = 1;
402 $fieldParams['html_type'] = 'Radio';
0d8afee2
CW
403 $fieldParams['is_required'] = !empty($params['is_required']) ? 1 : 0;
404 $fieldParams['is_display_amounts'] = !empty($params['display_min_fee']) ? 1 : 0;
6a488035 405 $rowCount = 1;
be2fb01f 406 $options = [];
a7488080 407 if (!empty($fieldParams['id'])) {
9da8dc8c 408 CRM_Core_PseudoConstant::populate($options, 'CRM_Price_DAO_PriceFieldValue', TRUE, 'membership_type_id', NULL, " price_field_id = {$fieldParams['id']} ");
6a488035
TO
409 }
410
411 foreach ($membershipTypes as $memType => $memAutoRenew) {
412 if ($priceFieldID = CRM_Utils_Array::key($memType, $options)) {
413 $fieldParams['option_id'][$rowCount] = $priceFieldID;
414 unset($options[$priceFieldID]);
415 }
416 $membetype = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($memType);
9c1bc317 417 $fieldParams['option_label'][$rowCount] = $membetype['name'] ?? NULL;
353ffa53 418 $fieldParams['option_amount'][$rowCount] = CRM_Utils_Array::value('minimum_fee', $membetype, 0);
9c1bc317
CW
419 $fieldParams['option_weight'][$rowCount] = $membetype['weight'] ?? NULL;
420 $fieldParams['option_description'][$rowCount] = $membetype['description'] ?? NULL;
421 $fieldParams['default_option'] = $params['membership_type_default'] ?? NULL;
422 $fieldParams['option_financial_type_id'][$rowCount] = $membetype['financial_type_id'] ?? NULL;
6a488035
TO
423
424 $fieldParams['membership_type_id'][$rowCount] = $memType;
425 // [$rowCount] = $membetype[''];
426 $rowCount++;
427 }
428 foreach ($options as $priceFieldID => $memType) {
9da8dc8c 429 CRM_Price_BAO_PriceFieldValue::setIsActive($priceFieldID, '0');
6a488035 430 }
9da8dc8c 431 $priceField = CRM_Price_BAO_PriceField::create($fieldParams);
6a488035 432 }
9b873358 433 elseif (!$priceSetID) {
6a488035
TO
434 $deletePriceSet = 1;
435 }
436
437 $params['is_required'] = CRM_Utils_Array::value('is_required', $params, FALSE);
438 $params['is_active'] = CRM_Utils_Array::value('member_is_active', $params, FALSE);
439
440 if ($priceSetID) {
441 $params['membership_types'] = 'null';
442 $params['membership_type_default'] = CRM_Utils_Array::value('membership_type_default', $params, 'null');
353ffa53
TO
443 $params['membership_types'] = serialize($membershipTypes);
444 $params['display_min_fee'] = CRM_Utils_Array::value('display_min_fee', $params, FALSE);
445 $params['is_separate_payment'] = CRM_Utils_Array::value('is_separate_payment', $params, FALSE);
6a488035
TO
446 }
447 $params['entity_table'] = 'civicrm_contribution_page';
448 $params['entity_id'] = $this->_id;
449
450 $dao = new CRM_Member_DAO_MembershipBlock();
451 $dao->copyValues($params);
452 $dao->save();
453
454 if ($priceSetID && $params['is_active']) {
9da8dc8c 455 CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $this->_id, $priceSetID);
6a488035
TO
456 }
457
458 if ($deletePriceSet || !CRM_Utils_Array::value('member_is_active', $params, FALSE)) {
459
460 if ($this->_memPriceSetId) {
be2fb01f
CW
461 $pFIDs = [];
462 $conditionParams = [
6a488035
TO
463 'price_set_id' => $this->_memPriceSetId,
464 'html_type' => 'radio',
465 'name' => 'contribution_amount',
be2fb01f 466 ];
6a488035 467
9da8dc8c 468 CRM_Core_DAO::commonRetrieve('CRM_Price_DAO_PriceField', $conditionParams, $pFIDs);
a7488080 469 if (empty($pFIDs['id'])) {
9da8dc8c 470 CRM_Price_BAO_PriceSet::removeFrom('civicrm_contribution_page', $this->_id);
471 CRM_Price_BAO_PriceSet::setIsQuickConfig($this->_memPriceSetId, '0');
6a488035
TO
472 }
473 else {
474
9da8dc8c 475 CRM_Price_BAO_PriceField::setIsActive($params['mem_price_field_id'], '0');
6a488035
TO
476 }
477 }
478 }
479 }
480 parent::endPostProcess();
481 }
482
483 /**
484 * Return a descriptive name for the page, used in wizard header
485 *
486 * @return string
6a488035
TO
487 */
488 public function getTitle() {
489 return ts('Memberships');
490 }
96025800 491
6a488035 492}