From e9bb507e97adeaf13192c14ea58f56e1fa29a372 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Fri, 26 Sep 2014 19:40:50 +0530 Subject: [PATCH] CRM-15364 fix - Change Registration Selections: problems handling discounted line items and full options https://issues.civicrm.org/jira/browse/CRM-15364 --- CRM/Event/Form/Registration/Register.php | 19 ++++++++++++++++++- .../Event/Form/ParticipantFeeSelection.tpl | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index 72a8ef6e42..f8690503d0 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -693,6 +693,12 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { public static function formatFieldsForOptionFull(&$form) { $priceSet = $form->get('priceSet'); $priceSetId = $form->get('priceSetId'); + $defaultPricefieldIds = array(); + if (!empty($form->_values['line_items'])) { + foreach ($form->_values['line_items'] as $lineItem) { + $defaultPricefieldIds[] = $lineItem['price_field_value_id']; + } + } if (!$priceSetId || !is_array($priceSet) || empty($priceSet) || empty($priceSet['optionsMaxValueTotal'])) { @@ -721,6 +727,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { //get the current price event price set options count. $currentOptionsCount = self::getPriceSetOptionCount($form); $recordedOptionsCount = CRM_Event_BAO_Participant::priceSetOptionsCount($form->_eventId, $skipParticipants); + $optionFullTotalAmount = 0; foreach ($form->_feeBlock as & $field) { $optionFullIds = array(); @@ -750,8 +757,17 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { ) { $isFull = TRUE; $optionFullIds[$optId] = $optId; + if ($field['html_type'] != 'Select') { + if (in_array($optId, $defaultPricefieldIds)) { + $optionFullTotalAmount += CRM_Utils_Array::value('amount', $option); + } + } + else { + if (!empty($defaultPricefieldIds) && in_array($optId, $defaultPricefieldIds)) { + unset($optionFullIds[$optId]); + } + } } - //here option is not full, //but we don't want to allow participant to increase //seats at the time of re-walking registration. @@ -777,6 +793,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { //finally get option ids in. $field['option_full_ids'] = $optionFullIds; } + $form->assign('optionFullTotalAmount', $optionFullTotalAmount); } /** diff --git a/templates/CRM/Event/Form/ParticipantFeeSelection.tpl b/templates/CRM/Event/Form/ParticipantFeeSelection.tpl index 60f0b9044f..79163bc48c 100644 --- a/templates/CRM/Event/Form/ParticipantFeeSelection.tpl +++ b/templates/CRM/Event/Form/ParticipantFeeSelection.tpl @@ -27,6 +27,7 @@ {literal}