skip recursion start date from the generated list. solves +1 date problem
authorpriyankakaran26 <priyanka.karan26@gmail.com>
Fri, 14 Nov 2014 16:43:39 +0000 (16:43 +0000)
committerpriyankakaran26 <priyanka.karan26@gmail.com>
Fri, 14 Nov 2014 16:43:39 +0000 (16:43 +0000)
CRM/Core/BAO/RecurringEntity.php

index 0d04f43f03206d31898eba1e158c020ddcc4201d..01491656ba93a7a53c9ee786ab5a7288b6bdb30a 100644 (file)
@@ -52,6 +52,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
   public $isRecurringEntityRecord = TRUE;\r
 \r
   protected $recursion = NULL;\r
+  protected $recursion_start_date = NULL;\r
 \r
   public static $_entitiesToBeDeleted = array();\r
 \r
@@ -329,6 +330,11 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
 \r
       $count = 1;\r
       while ($result = $this->recursion->next()) {\r
+        $skip = FALSE;\r
+        if ($result == $this->recursion_start_date) {\r
+          // skip the recursion-start-date from the list we going to generate\r
+          $skip = TRUE;\r
+        }\r
         $baseDate = CRM_Utils_Date::processDate($result->format('Y-m-d H:i:s'));\r
 \r
         foreach ($this->dateColumns as $col) {\r
@@ -344,7 +350,6 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
           $exRangeEndDate   = CRM_Utils_Date::processDate($recursionDates[$count][$exRangeEnd], NULL, FALSE, 'Ymd');\r
         }\r
 \r
-        $skip = FALSE;\r
         foreach ($this->excludeDates as $exDate) {\r
           $exDate = CRM_Utils_Date::processDate($exDate, NULL, FALSE, 'Ymd');\r
           if (!$exRangeStart) {\r
@@ -830,7 +835,6 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
         $repetitionStartDate = $repetitionStartDate . " " . $formParams['repetition_start_date_time'];\r
       }\r
       $repetition_start_date = new DateTime($repetitionStartDate);\r
-      $repetition_start_date->modify('+1 day');\r
       $dbParams['start_action_date'] = CRM_Utils_Date::processDate($repetition_start_date->format('Y-m-d H:i:s'));\r
     }\r
 \r
@@ -942,6 +946,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
         $currDate = date("Y-m-d H:i:s");\r
       }\r
       $start = new DateTime($currDate);\r
+      $this->recursion_start_date = $start;\r
       if ($scheduleReminderDetails['repetition_frequency_unit']) {\r
         $repetition_frequency_unit = $scheduleReminderDetails['repetition_frequency_unit'];\r
         if ($repetition_frequency_unit == "day") {\r