Allow recreating recursions even from child event
authorunknown <priyanka.karan26@gmail.com>
Mon, 15 Sep 2014 17:17:26 +0000 (18:17 +0100)
committerdeepak-srivastava <deepak.srivastava.0303@gmail.com>
Fri, 3 Oct 2014 09:08:26 +0000 (10:08 +0100)
CRM/Core/BAO/RecurringEntity.php
CRM/Core/Form/RecurringEntity.php
CRM/Core/Page/AJAX/RecurringEntity.php

index 0c7253e901419174d7826bfafc72bf8b72a5ffb5..ac6b4a1aa3fd632c57df8f650998d36a583aae9f 100644 (file)
@@ -420,8 +420,13 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
       $dbParams['used_for'] = $formParams['used_for'];
     }
 
-    if(CRM_Utils_Array::value('parent_event_id', $formParams)){
-      $dbParams['entity_value'] = $formParams['parent_event_id'];
+    if(CRM_Utils_Array::value('event_id', $formParams)){
+      $parent_event_id = self::getParentFor($formParams['event_id'], 'civicrm_event');
+      if($parent_event_id){
+        $dbParams['entity_value'] = $parent_event_id;
+      }else{
+        $dbParams['entity_value'] = $formParams['event_id'];
+      }
     }
 
     if(CRM_Utils_Array::value('repetition_start_date', $formParams)) {
index 913475098e8c6c24be061af2e15d2986a1a56584..468877aeff427ed593172a9a667ff2e6ab45e158 100644 (file)
@@ -259,16 +259,16 @@ class CRM_Core_Form_RecurringEntity {
     }
 
     //Delete relations if any from recurring entity tables before inserting new relations for this entity id
-    if($params['parent_event_id']){
-      $getRelatedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($params['parent_event_id'], 'civicrm_event', FALSE);
+    if($params['event_id']){
+      $getRelatedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['event_id'], 'civicrm_event', TRUE);
       $participantDetails = CRM_Core_BAO_RecurringEntity::getParticipantCountforEvent($getRelatedEntities);
       //Check if participants exists for events
       foreach ($getRelatedEntities as $key => $value) {
-        if(!CRM_Utils_Array::value($value['id'], $participantDetails['countByID'])){
+        if(!CRM_Utils_Array::value($value['id'], $participantDetails['countByID']) && $value['id'] != $params['event_id']){
           CRM_Event_BAO_Event::del($value['id']);
         }
       }
-      CRM_Core_BAO_RecurringEntity::delEntityRelations($params['parent_event_id'], 'civicrm_event');
+      CRM_Core_BAO_RecurringEntity::delEntityRelations($params['event_id'], 'civicrm_event');
     }
 
     $recursion = new CRM_Core_BAO_RecurringEntity();
index db5cce29525a8d36b317042c0868fd5890a88191..eb81cad5a650d06a73e51ace7c91de1c6fcc3b11 100644 (file)
@@ -69,7 +69,7 @@ class CRM_Core_Page_AJAX_RecurringEntity {
       }
 
       //Show the list of participants registered for the events if any
-      $getConnectedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($parentEventId, 'civicrm_event', FALSE);
+      $getConnectedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($parentEventId, 'civicrm_event', TRUE);
       if($getConnectedEntities){
         $participantDetails = CRM_Core_BAO_RecurringEntity::getParticipantCountforEvent($getConnectedEntities);
         if(!empty($participantDetails['countByName'])){