--CRM-12970, fixed for more than one event discount set
authorPradeep Nayak <pradeep@pradeep.(none)>
Sun, 15 Sep 2013 12:28:54 +0000 (17:58 +0530)
committerPradeep Nayak <pradeep@pradeep.(none)>
Sun, 15 Sep 2013 12:28:54 +0000 (17:58 +0530)
----------------------------------------
* CRM-12970: civicrm_price_field_value not removed for discount price set
  http://issues.civicrm.org/jira/browse/CRM-12970

CRM/Event/Form/ManageEvent/Fee.php

index eade71ead36de79f33d59b84b284c9829d5d4d26..fb659420c2fed361b8eb0642c090ddcafb7d4005 100644 (file)
@@ -158,6 +158,24 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent {
         }
         $rowCount++;
       }
+      //CRM-12970
+      ksort($defaults['discounted_value']);
+      $rowCount = 1;
+      foreach ($defaults['discounted_label'] as $key => $value) {
+        if ($key != $rowCount) {
+          $defaults['discounted_label'][$rowCount] = $value;
+          $defaults['discounted_value'][$rowCount] = $defaults['discounted_value'][$key];
+          unset($defaults['discounted_value'][$key]);
+          unset($defaults['discounted_label'][$key]);
+          foreach ($defaults['discount_option_id'] as &$optionIds) {
+            if (array_key_exists($key, $optionIds)) {
+              $optionIds[$rowCount] = $optionIds[$key];
+              unset($optionIds[$key]);
+            }
+          } 
+        }
+        $rowCount++;
+      }
 
       $this->set('discountSection', 1);
       $this->buildQuickForm();
@@ -542,7 +560,6 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent {
    * @access public
    */
   public function postProcess() {
-    $params     = array();
     $eventTitle = '';
     $params     = $this->exportValues();