Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] return determination of whether to show expired fields to the calling function #15934

Merged
merged 1 commit into from
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion CRM/Event/Form/ParticipantFeeSelection.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ public function setDefaultValues() {
return $defaults;
}

/**
* Build form.
*
* @throws \CRM_Core_Exception
*/
public function buildQuickForm() {

$statuses = CRM_Event_PseudoConstant::participantStatus();
Expand All @@ -152,7 +157,8 @@ public function buildQuickForm() {

//retrieve custom information
$this->_values = [];
CRM_Event_Form_Registration::initEventFee($this, $event['id']);

CRM_Event_Form_Registration::initEventFee($this, $event['id'], $this->_action !== CRM_Core_Action::UPDATE);
CRM_Event_Form_Registration_Register::buildAmount($this, TRUE);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ie FALSE if $form->_action == CRM_Core_Action::UPDATE


if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $this->_values))) {
Expand Down Expand Up @@ -217,6 +223,12 @@ public static function formRule($fields, $files, $self) {
return $errors;
}

/**
* Post process form.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function postProcess() {
$params = $this->controller->exportValues($this->_name);

Expand Down
15 changes: 5 additions & 10 deletions CRM/Event/Form/Registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,10 +600,12 @@ public function buildCustom($id, $name, $viewOnly = FALSE) {
*
* @param CRM_Core_Form $form
* @param int $eventID
* @param bool $includeExpiredFields
* See CRM-16456.
*
* @throws Exception
*/
public static function initEventFee(&$form, $eventID) {
public static function initEventFee(&$form, $eventID, $includeExpiredFields = TRUE) {
// get price info

// retrive all active price set fields.
Expand All @@ -612,20 +614,13 @@ public static function initEventFee(&$form, $eventID) {
$discountId = $form->_discountId;
}

//CRM-16456 get all price field including expired one.
$getAllPriceField = TRUE;
$className = CRM_Utils_System::getClassName($form);
if ($className == 'CRM_Event_Form_ParticipantFeeSelection' && $form->_action == CRM_Core_Action::UPDATE) {
$getAllPriceField = FALSE;
}

if ($discountId) {
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Discount', $discountId, 'price_set_id');
CRM_Price_BAO_PriceSet::initSet($form, 'civicrm_event', $getAllPriceField, $priceSetId);
CRM_Price_BAO_PriceSet::initSet($form, 'civicrm_event', $includeExpiredFields, $priceSetId);
}
else {
$priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventID);
CRM_Price_BAO_PriceSet::initSet($form, 'civicrm_event', $getAllPriceField, $priceSetId);
CRM_Price_BAO_PriceSet::initSet($form, 'civicrm_event', $includeExpiredFields, $priceSetId);
}

if (property_exists($form, '_context') && ($form->_context == 'standalone'
Expand Down