CRM-15364 fix - Change Registration Selections: problems handling discounted line...
authormonishdeb <monish.deb@webaccessglobal.com>
Fri, 26 Sep 2014 14:10:50 +0000 (19:40 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Fri, 26 Sep 2014 14:10:50 +0000 (19:40 +0530)
https://issues.civicrm.org/jira/browse/CRM-15364

CRM/Event/Form/Registration/Register.php
templates/CRM/Event/Form/ParticipantFeeSelection.tpl

index 72a8ef6e4217d4af24874a28b3ccaa6cb256bab9..f8690503d06f73a502cfab8c4d49507aa56149ea 100644 (file)
@@ -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);
   }
 
   /**
index 60f0b9044fd861fa94da1769c9c60f5a27102170..79163bc48c83c1d7c68838c92cb09626a6369867 100644 (file)
@@ -27,6 +27,7 @@
 {literal}
 <script type='text/javascript'>
 function display(totalfee) {
+  totalfee += {/literal}{$optionFullTotalAmount}{literal};
   // totalfee is monetary, round it to 2 decimal points so it can
   // go as a float - CRM-13491
   totalfee = Math.round(totalfee*100)/100;