diff --git a/modules/Calendar/actions/DragDropAjax.php b/modules/Calendar/actions/DragDropAjax.php index b42597544ad66bc6d1916db1a9d6a5a6d7a5549f..719e9ccb1e51d0390f5ab380e65a18d7eaf13ad6 100755 --- a/modules/Calendar/actions/DragDropAjax.php +++ b/modules/Calendar/actions/DragDropAjax.php @@ -44,13 +44,9 @@ class Calendar_DragDropAjax_Action extends Calendar_SaveAjax_Action { $record = Vtiger_Record_Model::getInstanceById($recordId, $moduleName); $record->set('mode','edit'); - $startDateTime[] = $record->get('date_start'); - $startDateTime[] = $record->get('time_start'); - $startDateTime = implode(' ',$startDateTime); + $startDateTime = $this->getFormattedDateTime($record->get('date_start'), $record->get('time_start')); + $oldDateTime = $this->getFormattedDateTime($record->get('due_date'), $record->get('time_end')); - $oldDateTime[] = $record->get('due_date'); - $oldDateTime[] = $record->get('time_end'); - $oldDateTime = implode(' ',$oldDateTime); $resultDateTime = $this->changeDateTime($oldDateTime,$dayDelta,$minuteDelta,$secondsDelta); $interval = strtotime($resultDateTime) - strtotime($startDateTime); @@ -68,10 +64,7 @@ class Calendar_DragDropAjax_Action extends Calendar_SaveAjax_Action { $recordModel = Vtiger_Record_Model::getInstanceById($childId, 'Events'); $recordModel->set('mode','edit'); - $startDateTime = ''; - $startDateTime[] = $recordModel->get('date_start'); - $startDateTime[] = $recordModel->get('time_start'); - $startDateTime = implode(' ',$startDateTime); + $startDateTime = $this->getFormattedDateTime($recordModel->get('date_start'), $recordModel->get('time_start')); $dueDate = strtotime($startDateTime) + $interval; $formatDate = date("Y-m-d H:i:s", $dueDate); $parts = explode(' ',$formatDate); @@ -82,10 +75,7 @@ class Calendar_DragDropAjax_Action extends Calendar_SaveAjax_Action { $recordModel->set('time_end',$parts[1]); } - $endDateTime = ''; - $endDateTime[] = $recordModel->get('due_date'); - $endDateTime[] = $recordModel->get('time_end'); - $endDateTime = implode(' ',$endDateTime); + $endDateTime = $this->getFormattedDateTime($recordModel->get('due_date'), $recordModel->get('time_end')); $endDateTime = new DateTime($endDateTime); if($startDateTime <= $endDateTime) { @@ -97,10 +87,7 @@ class Calendar_DragDropAjax_Action extends Calendar_SaveAjax_Action { } $result['recurringRecords'] = true; } else { - $oldDateTime = ''; - $oldDateTime[] = $record->get('due_date'); - $oldDateTime[] = $record->get('time_end'); - $oldDateTime = implode(' ',$oldDateTime); + $oldDateTime = $this->getFormattedDateTime($record->get('due_date'), $record->get('time_end')); $resultDateTime = $this->changeDateTime($oldDateTime,$dayDelta,$minuteDelta,$secondsDelta); $parts = explode(' ',$resultDateTime); $record->set('due_date',$parts[0]); @@ -108,15 +95,10 @@ class Calendar_DragDropAjax_Action extends Calendar_SaveAjax_Action { $record->set('time_end',$parts[1]); } - $startDateTime = ''; - $startDateTime[] = $record->get('date_start'); - $startDateTime[] = $record->get('time_start'); - $startDateTime = implode(' ',$startDateTime); + $startDateTime = $this->getFormattedDateTime($record->get('date_start'), $record->get('time_start')); $startDateTime = new DateTime($startDateTime); - $endDateTime[] = $record->get('due_date'); - $endDateTime[] = $record->get('time_end'); - $endDateTime = implode(' ',$endDateTime); + $endDateTime = $this->getFormattedDateTime($record->get('due_date'), $record->get('time_end')); $endDateTime = new DateTime($endDateTime); //Checking if startDateTime is less than or equal to endDateTime if($startDateTime <= $endDateTime) { @@ -195,15 +177,11 @@ class Calendar_DragDropAjax_Action extends Calendar_SaveAjax_Action { $record = Vtiger_Record_Model::getInstanceById($recordId, $moduleName); $record->set('mode','edit'); - $oldStartDateTime[] = $record->get('date_start'); - $oldStartDateTime[] = $record->get('time_start'); - $oldStartDateTime = implode(' ',$oldStartDateTime); + $oldStartDateTime = $this->getFormattedDateTime($record->get('date_start'), $record->get('time_start')); $resultDateTime = $this->changeDateTime($oldStartDateTime, $dayDelta, $minuteDelta, $secondsDelta); $startDateInterval = strtotime($resultDateTime) - strtotime($oldStartDateTime); - $oldEndDateTime[] = $record->get('due_date'); - $oldEndDateTime[] = $record->get('time_end'); - $oldEndDateTime = implode(' ', $oldEndDateTime); + $oldEndDateTime = $this->getFormattedDateTime($record->get('due_date'), $record->get('time_end')); $resultDateTime = $this->changeDateTime($oldEndDateTime, $dayDelta, $minuteDelta, $secondsDelta); $endDateInterval = strtotime($resultDateTime) - strtotime($oldEndDateTime); @@ -221,10 +199,7 @@ class Calendar_DragDropAjax_Action extends Calendar_SaveAjax_Action { $recordModel = Vtiger_Record_Model::getInstanceById($childId, 'Events'); $recordModel->set('mode', 'edit'); - $startDateTime = ''; - $startDateTime[] = $recordModel->get('date_start'); - $startDateTime[] = $recordModel->get('time_start'); - $startDateTime = implode(' ', $startDateTime); + $startDateTime = $this->getFormattedDateTime($recordModel->get('date_start'), $recordModel->get('time_start')); $startDate = strtotime($startDateTime) + $startDateInterval; $formatStartDate = date("Y-m-d H:i:s", $startDate); $parts = explode(' ', $formatStartDate); @@ -234,10 +209,7 @@ class Calendar_DragDropAjax_Action extends Calendar_SaveAjax_Action { if (activitytype != 'Task') $recordModel->set('time_start', $parts[1]); - $endDateTime = ''; - $endDateTime[] = $recordModel->get('due_date'); - $endDateTime[] = $recordModel->get('time_end'); - $endDateTime = implode(' ', $endDateTime); + $endDateTime = $this->getFormattedDateTime($recordModel->get('due_date'), $recordModel->get('time_end')); $endDate = strtotime($endDateTime) + $endDateInterval; $formatEndDate = date("Y-m-d H:i:s", $endDate); $endDateParts = explode(' ', $formatEndDate); @@ -251,19 +223,13 @@ class Calendar_DragDropAjax_Action extends Calendar_SaveAjax_Action { } $result['recurringRecords'] = true; } else { - $oldStartDateTime = array(); - $oldStartDateTime[] = $record->get('date_start'); - $oldStartDateTime[] = $record->get('time_start'); - $oldStartDateTime = implode(' ', $oldStartDateTime); + $oldStartDateTime = $this->getFormattedDateTime($record->get('date_start'), $record->get('time_start')); $resultDateTime = $this->changeDateTime($oldStartDateTime,$dayDelta,$minuteDelta,$secondsDelta); $parts = explode(' ',$resultDateTime); $record->set('date_start',$parts[0]); $record->set('time_start',$parts[1]); - $oldEndDateTime = array(); - $oldEndDateTime[] = $record->get('due_date'); - $oldEndDateTime[] = $record->get('time_end'); - $oldEndDateTime = implode(' ',$oldEndDateTime); + $oldEndDateTime = $this->getFormattedDateTime($record->get('due_date'), $record->get('time_end')); $resultDateTime = $this->changeDateTime($oldEndDateTime,$dayDelta,$minuteDelta,$secondsDelta); $parts = explode(' ',$resultDateTime); $record->set('due_date',$parts[0]); diff --git a/modules/Calendar/actions/SaveAjax.php b/modules/Calendar/actions/SaveAjax.php index a82692ec96b3d793cff64bdd4fdc4a5899c4a88e..5893c853d72f27ff4b040032fe3b76666edcfe5c 100644 --- a/modules/Calendar/actions/SaveAjax.php +++ b/modules/Calendar/actions/SaveAjax.php @@ -207,4 +207,13 @@ class Calendar_SaveAjax_Action extends Vtiger_SaveAjax_Action { return $recordModel; } + + /** + * Helper API. See #1301 on code.vtiger.com + **/ + public function getFormattedDateTime($date, $time) { + return trim($date . ' ' . $time); + } + } + diff --git a/modules/Calendar/actions/SaveFollowupAjax.php b/modules/Calendar/actions/SaveFollowupAjax.php index 3e50747462c13c94e05ee7631519d40f5cba55c7..d1bf992cd51be9e8cd30bb3841e3e687e6bcaf65 100755 --- a/modules/Calendar/actions/SaveFollowupAjax.php +++ b/modules/Calendar/actions/SaveFollowupAjax.php @@ -101,9 +101,7 @@ class Calendar_SaveFollowupAjax_Action extends Calendar_SaveAjax_Action { } else{ //checking if the event can be marked as Held (status validation) - $startDateTime[] = $recordModel->get('date_start'); - $startDateTime[] = $recordModel->get('time_start'); - $startDateTime = implode(' ',$startDateTime); + $startDateTime = $this->getFormattedDateTime($recordModel->get('date_start'), $recordModel->get('time_start')); $startDateTime = new DateTime($startDateTime); $currentDateTime = date("Y-m-d H:i:s"); $currentDateTime = new DateTime($currentDateTime);