From 72a72beb059f5ff4d885880b20c3f81461aa3439 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 7 Mar 2015 16:57:07 -0500 Subject: [PATCH] CRM-15932 - Show original in recurring preview --- CRM/Core/Page/RecurringEntityPreview.php | 17 ++++++++++------- .../CRM/Core/Page/RecurringEntityPreview.tpl | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CRM/Core/Page/RecurringEntityPreview.php b/CRM/Core/Page/RecurringEntityPreview.php index 7c6c4b5a28..d56b6244e6 100644 --- a/CRM/Core/Page/RecurringEntityPreview.php +++ b/CRM/Core/Page/RecurringEntityPreview.php @@ -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) { diff --git a/templates/CRM/Core/Page/RecurringEntityPreview.tpl b/templates/CRM/Core/Page/RecurringEntityPreview.tpl index 7451cffdac..99639714fa 100644 --- a/templates/CRM/Core/Page/RecurringEntityPreview.tpl +++ b/templates/CRM/Core/Page/RecurringEntityPreview.tpl @@ -59,7 +59,7 @@ {foreach from=$dates item="row" key="count"} - {$count + 1} + {if $count}{$count+1}{else}{ts}Original{/ts}{/if} {$row.start_date} {if $endDates}{$row.end_date}{/if} -- 2.25.1