CRM-15932 - Show original in recurring preview
authorColeman Watts <coleman@civicrm.org>
Sat, 7 Mar 2015 21:57:07 +0000 (16:57 -0500)
committerColeman Watts <coleman@civicrm.org>
Sat, 7 Mar 2015 21:57:07 +0000 (16:57 -0500)
CRM/Core/Page/RecurringEntityPreview.php
templates/CRM/Core/Page/RecurringEntityPreview.tpl

index 7c6c4b5a28823d01359760a0ecae26801ebe63ab..d56b6244e6272528a1ee7d887c37943c1a7f6715 100644 (file)
@@ -41,7 +41,7 @@ class CRM_Core_Page_RecurringEntityPreview extends CRM_Core_Page {
    */
   public function run() {
     $parentEventId = $startDate = $endDate = NULL;
-    $dates = array();
+    $dates = $original = array();
     $formValues = $_REQUEST;
     if (!empty($formValues['entity_table'])) {
       $startDateColumnName = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['dateColumns'][0];
@@ -63,20 +63,23 @@ class CRM_Core_Page_RecurringEntityPreview extends CRM_Core_Page {
         $parentEventId = CRM_Core_BAO_RecurringEntity::getParentFor($formValues['entity_id'], $formValues['entity_table']);
       }
 
+      // Get original entity
+      $original[$startDateColumnName] = CRM_Utils_Date::processDate($formValues['repetition_start_date']);
+      $daoName = CRM_Core_BAO_RecurringEntity::$_tableDAOMapper[$formValues['entity_table']];
+      if ($parentEventId) {
+        $startDate = $original[$startDateColumnName] = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $startDateColumnName);
+        $endDate = $original[$startDateColumnName] = $endDateColumnName ? CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $endDateColumnName) : NULL;
+      }
+
       //Check if there is any enddate column defined to find out the interval between the two range
       if (CRM_Utils_Array::value('intervalDateColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
-        $daoName = CRM_Core_BAO_RecurringEntity::$_tableDAOMapper[$formValues['entity_table']];
-        if ($parentEventId) {
-          $startDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $startDateColumnName);
-          $endDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $endDateColumnName);
-        }
         if ($endDate) {
           $interval = $recursion->getInterval($startDate, $endDate);
           $recursion->intervalDateColumns = array($endDateColumnName => $interval);
         }
       }
 
-      $dates = $recursion->generateRecursiveDates();
+      $dates = array_merge(array($original), $recursion->generateRecursiveDates());
 
       foreach ($dates as $key => &$value) {
         if ($startDateColumnName) {
index 7451cffdac318f2277887edc52e726be9969f68f..99639714fa8d035306da561d475c0e83bd05c0c7 100644 (file)
@@ -59,7 +59,7 @@
   <tbody>
     {foreach from=$dates item="row" key="count"}
       <tr class="{cycle values="odd-row,even-row"}">
-        <td>{$count + 1}</td>
+        <td>{if $count}{$count+1}{else}{ts}Original{/ts}{/if}</td>
         <td>{$row.start_date}</td>
         {if $endDates}<td>{$row.end_date}</td>{/if}
       </tr>