From 1b1bde74e98fe5b91e0825826c9aa2179c9b1995 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Sep 2014 16:19:16 +0100 Subject: [PATCH] Always consider current event start date as repetition start date --- CRM/Core/Form/RecurringEntity.php | 8 +++++--- CRM/Event/Form/ManageEvent/Repeat.php | 15 +++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/CRM/Core/Form/RecurringEntity.php b/CRM/Core/Form/RecurringEntity.php index 3a6123ad09..131fa27747 100644 --- a/CRM/Core/Form/RecurringEntity.php +++ b/CRM/Core/Form/RecurringEntity.php @@ -204,12 +204,14 @@ class CRM_Core_Form_RecurringEntity { $params['used_for'] = $type; } + //Save post params to the schedule reminder table + $dbParams = CRM_Core_BAO_RecurringEntity::mapFormValuesToDB($params); + + //Delete repeat configuration and rebuild if(CRM_Utils_Array::value('id', $params)){ CRM_Core_BAO_ActionSchedule::del($params['id']); unset($params['id']); } - //Save post params to the schedule reminder table - $dbParams = CRM_Core_BAO_RecurringEntity::mapFormValuesToDB($params); $actionScheduleObj = CRM_Core_BAO_ActionSchedule::add($dbParams); //exclude dates @@ -296,7 +298,7 @@ class CRM_Core_Form_RecurringEntity { $recursion->intervalDateColumns = array('end_date' => $interval); } - $recursion->entity_id = $params['current_event_id']; + $recursion->entity_id = $params['event_id']; $recursion->entity_table = 'civicrm_event'; $recursion->linkedEntities = array( array( diff --git a/CRM/Event/Form/ManageEvent/Repeat.php b/CRM/Event/Form/ManageEvent/Repeat.php index bf10d12074..56d2bad65b 100644 --- a/CRM/Event/Form/ManageEvent/Repeat.php +++ b/CRM/Event/Form/ManageEvent/Repeat.php @@ -129,10 +129,12 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { //Set Schedule Reminder Id $this->_scheduleReminderId = $this->_scheduleReminderDetails->id; - list($defaults['repetition_start_date'], $defaults['repetition_start_date_time']) = CRM_Utils_Date::setDateDefaults($this->_parentEventStartDate, 'activityDateTime'); + //Always pass current event's start date by default + $currentEventStartDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'start_date', 'id'); + list($defaults['repetition_start_date'], $defaults['repetition_start_date_time']) = CRM_Utils_Date::setDateDefaults($currentEventStartDate, 'activityDateTime'); + // Check if there is id for this event in Reminder table if($this->_scheduleReminderId){ - list($defaults['repetition_start_date'], $defaults['repetition_start_date_time']) = CRM_Utils_Date::setDateDefaults($this->_scheduleReminderDetails->start_action_date, 'activityDateTime'); $defaults['repetition_frequency_unit'] = $this->_scheduleReminderDetails->repetition_frequency_unit; $defaults['repetition_frequency_interval'] = $this->_scheduleReminderDetails->repetition_frequency_interval; $defaults['start_action_condition'] = array_flip(explode(",",$this->_scheduleReminderDetails->start_action_condition)); @@ -160,13 +162,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { if($this->_scheduleReminderDetails->entity_status){ $defaults['repeats_by'] = 2; } - //echo "
"; print_r($this->_excludeDateInfo);
       $defaults['exclude_date_list'] = array('a', 'b');
-         /* array
-        (
-            0 => '08/25/2014',
-            1 => '08/28/2014'
-        );*/
     } 
     return $defaults;
   }
@@ -178,7 +174,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
   public function postProcess() {
     if($this->_id){
       $params = $this->controller->exportValues($this->_name); 
-      $params['current_event_id'] = $this->_id;
+      $params['event_id'] = $this->_id;
       $params['parent_event_id']  = $this->_parentEventId;
       $params['parent_event_start_date'] = $this->_parentEventStartDate;
       $params['parent_event_end_date'] = $this->_parentEventEndDate;
@@ -192,7 +188,6 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
       
       CRM_Core_Form_RecurringEntity::postProcess($params, 'event');
       CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
-      //CRM_Core_Error::debug_var('Event Recursion');
     }else{
         CRM_Core_Error::fatal("Could not find Event ID");
     }  
-- 
2.25.1