From 92911f624169f4ff3d2ee0080f57eb0a2f175e5f Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 29 Nov 2023 09:06:26 +1300 Subject: [PATCH] Move form specific code out of shared function --- CRM/Event/Form/Participant.php | 3 +- CRM/Event/Form/ParticipantFeeSelection.php | 1 + CRM/Event/Form/Registration.php | 34 ++++++++-------------- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 280d5539d8..abf1773c41 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1253,7 +1253,8 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment CRM_Event_BAO_Event::retrieve($params, $event); //retrieve custom information - $form->_values = []; + $this->_values = []; + $this->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'participant'); CRM_Event_Form_Registration::initEventFee($form, FALSE, $this->getPriceSetID()); if ($form->_context === 'standalone' || $form->_context === 'participant') { $discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($event['id'], 'civicrm_event'); diff --git a/CRM/Event/Form/ParticipantFeeSelection.php b/CRM/Event/Form/ParticipantFeeSelection.php index cbb5c49bc8..9a9ca95276 100644 --- a/CRM/Event/Form/ParticipantFeeSelection.php +++ b/CRM/Event/Form/ParticipantFeeSelection.php @@ -176,6 +176,7 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { //retrieve custom information $this->_values = []; + $this->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant'); CRM_Event_Form_Registration::initEventFee($this, $this->_action !== CRM_Core_Action::UPDATE, $this->getPriceSetID()); CRM_Event_Form_Registration_Register::buildAmount($this, TRUE, NULL, $this->getPriceSetID()); diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index 1c7a8fd96c..d2d04ba0ce 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -315,7 +315,19 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { $priceSetID = $this->getPriceSetID(); if ($priceSetID) { + $this->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant'); self::initEventFee($this, TRUE, $priceSetID); + + //fix for non-upgraded price sets.CRM-4256. + if (isset($this->_isPaidEvent)) { + $isPaidEvent = $this->_isPaidEvent; + } + else { + $isPaidEvent = $this->_values['event']['is_monetary'] ?? NULL; + } + if ($isPaidEvent && empty($this->_values['fee'])) { + CRM_Core_Error::statusBounce(ts('No Fee Level(s) or Price Set is configured for this event.
Click CiviEvent >> Manage Event >> Configure >> Event Fees to configure the Fee Level(s) or Price Set for this event.', [1 => CRM_Utils_System::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $this->_eventId)])); + } $this->assign('quickConfig', $this->isQuickConfig()); } @@ -606,15 +618,6 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { return; } - // get price info - if ($form->_action & CRM_Core_Action::UPDATE) { - if (in_array(CRM_Utils_System::getClassName($form), ['CRM_Event_Form_Participant', 'CRM_Event_Form_Task_Register'])) { - $form->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($form->_id, 'participant'); - } - else { - $form->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($form->_participantId, 'participant'); - } - } $priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, NULL, $doNotIncludeExpiredFields); $form->_priceSet = $priceSet[$priceSetId] ?? NULL; $form->_values['fee'] = $form->_priceSet['fields'] ?? NULL; @@ -659,14 +662,6 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { if (!is_array($eventFee) || empty($eventFee)) { $form->_values['fee'] = []; } - - //fix for non-upgraded price sets.CRM-4256. - if (isset($form->_isPaidEvent)) { - $isPaidEvent = $form->_isPaidEvent; - } - else { - $isPaidEvent = $form->_values['event']['is_monetary'] ?? NULL; - } if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !empty($form->_values['fee']) ) { @@ -678,11 +673,6 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { } } } - if ($isPaidEvent && empty($form->_values['fee'])) { - if (!in_array(CRM_Utils_System::getClassName($form), ['CRM_Event_Form_Participant', 'CRM_Event_Form_Task_Register'])) { - CRM_Core_Error::statusBounce(ts('No Fee Level(s) or Price Set is configured for this event.
Click CiviEvent >> Manage Event >> Configure >> Event Fees to configure the Fee Level(s) or Price Set for this event.', [1 => CRM_Utils_System::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $form->_eventId)])); - } - } } /** -- 2.25.1