From f8e406f220e806767f1e6083111d06ca5a94ca5d Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 24 Sep 2023 19:42:48 +1300 Subject: [PATCH] Move participant-form-specific defaults back to participant form --- CRM/Event/Form/EventFees.php | 28 ---------------------------- CRM/Event/Form/Participant.php | 32 +++++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/CRM/Event/Form/EventFees.php b/CRM/Event/Form/EventFees.php index b0601f014b..32a3f10ead 100644 --- a/CRM/Event/Form/EventFees.php +++ b/CRM/Event/Form/EventFees.php @@ -55,19 +55,6 @@ class CRM_Event_Form_EventFees { public static function setDefaultValues(&$form) { $defaults = []; - if ($form->_eventId) { - //get receipt text and financial type - $returnProperities = ['confirm_email_text', 'financial_type_id', 'campaign_id', 'start_date']; - $details = []; - CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $form->_eventId, $details, $returnProperities); - if (!empty($details[$form->_eventId]['financial_type_id'])) { - $defaults['financial_type_id'] = $details[$form->_eventId]['financial_type_id']; - } - if (!empty($details[$form->_eventId]['confirm_email_text'])) { - $defaults['receipt_text'] = $details[$form->_eventId]['confirm_email_text']; - } - } - if ($form->_pId) { $ids = []; $params = ['id' => $form->_pId]; @@ -91,23 +78,8 @@ class CRM_Event_Form_EventFees { $form->assign('fee_amount', CRM_Utils_Array::value('fee_amount', $defaults)); $form->assign('fee_level', CRM_Utils_Array::value('fee_level', $defaults)); } - $defaults['send_receipt'] = 0; - } - else { - $defaults['send_receipt'] = (strtotime(CRM_Utils_Array::value('start_date', $details[$form->_eventId])) >= time()) ? 1 : 0; - $defaults['receive_date'] = date('Y-m-d H:i:s'); } - //CRM-11601 we should keep the record contribution - //true by default while adding participant - if ($form->_action == CRM_Core_Action::ADD && !$form->_mode && $form->_isPaidEvent) { - $defaults['record_contribution'] = 1; - } - - //CRM-13420 - if (empty($defaults['payment_instrument_id'])) { - $defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1')); - } if ($form->_mode) { $config = CRM_Core_Config::singleton(); // set default country from config if no country set diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index accef1c673..ddba11e80f 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -385,15 +385,41 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment */ public function setDefaultValues(): array { if ($this->isOverloadFeesMode()) { - return CRM_Event_Form_EventFees::setDefaultValues($this); + if ($this->getEventID()) { + //get receipt text and financial type + $returnProperities = ['confirm_email_text', 'financial_type_id', 'campaign_id', 'start_date']; + CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $this->getEventID(), $details, $returnProperities); + if (!empty($details[$this->getEventID()]['financial_type_id'])) { + $defaults['financial_type_id'] = $details[$this->getEventID()]['financial_type_id']; + } + if (!empty($details[$this->getEventID()]['confirm_email_text'])) { + $defaults['receipt_text'] = $details[$this->getEventID()]['confirm_email_text']; + } + if (!$this->getParticipantID()) { + $defaults['send_receipt'] = (strtotime(CRM_Utils_Array::value('start_date', $details[$this->getEventID()])) >= time()) ? 1 : 0; + $defaults['receive_date'] = date('Y-m-d H:i:s'); + } + } + + //CRM-11601 we should keep the record contribution + //true by default while adding participant + if ($this->getAction() === CRM_Core_Action::ADD && !$this->_mode && $this->_isPaidEvent) { + $defaults['record_contribution'] = 1; + } + + //CRM-13420 + if (empty($defaults['payment_instrument_id'])) { + $defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1')); + } + return $defaults + CRM_Event_Form_EventFees::setDefaultValues($this); } $defaults = []; - if ($this->_id) { + if ($this->getParticipantID()) { $ids = []; $params = ['id' => $this->_id]; - + $defaults['send_receipt'] = 0; CRM_Event_BAO_Participant::getValues($params, $defaults, $ids); $defaults = $defaults[$this->_id]; $sep = CRM_Core_DAO::VALUE_SEPARATOR; -- 2.25.1