diff --git a/modules/Calendar/actions/SaveAjax.php b/modules/Calendar/actions/SaveAjax.php index 2efc4008..8c17b14d 100644 --- a/modules/Calendar/actions/SaveAjax.php +++ b/modules/Calendar/actions/SaveAjax.php @@ -141,17 +141,19 @@ public function getRecordModelFromRequest(Vtiger_Request $request) { } $recordModel->set('visibility', ucfirst($sharedType)); } - - $time = (strtotime($endTime))- (strtotime($startTime)); - $diffinSec= (strtotime($endDate))- (strtotime($startDate)); - $diff_days=floor($diffinSec/(60*60*24)); - - $hours=((float)$time/3600)+($diff_days*24); - $minutes = ((float)$hours-(int)$hours)*60; - - $recordModel->set('duration_hours', (int)$hours); - $recordModel->set('duration_minutes', round($minutes,0)); - + + if (!empty($endTime)) { + // events only + $time = (strtotime($endTime))- (strtotime($startTime)); + $diffinSec= (strtotime($endDate))- (strtotime($startDate)); + $diff_days=floor($diffinSec/(60*60*24)); + + $hours=((float)$time/3600)+($diff_days*24); + $minutes = ((float)$hours-(int)$hours)*60; + + $recordModel->set('duration_hours', (int)$hours); + $recordModel->set('duration_minutes', round($minutes,0)); + } return $recordModel; } } diff --git a/modules/Vtiger/uitypes/Time.php b/modules/Vtiger/uitypes/Time.php index 64aad707..fb3d0213 100644 --- a/modules/Vtiger/uitypes/Time.php +++ b/modules/Vtiger/uitypes/Time.php @@ -104,9 +104,12 @@ public static function getTimeValueWithSeconds($time) { */ public function getDisplayValue($value, $record = false, $recordInstance = false) { $userModel = Users_Privileges_Model::getCurrentUserModel(); - $dateTimeValueObj = DateTimeField::convertToUserTimeZone($value); - $value = $dateTimeValueObj->format('H:i'); - if($userModel->get('hour_format') == '12'){ + // exclude UI 63 field with different time format (duration_hours) + if (strpos($value, ':') !== false) { + $dateTimeValueObj = DateTimeField::convertToUserTimeZone($value); + $value = $dateTimeValueObj->format('H:i'); + } + if($userModel->get('hour_format') == '12' && strpos($value, ':') !== false){ return self::getTimeValueInAMorPM($value); } return $value; @@ -118,7 +121,7 @@ public function getDisplayValue($value, $record = false, $recordInstance = false * @return converted value */ public function getEditViewDisplayValue($value) { - $dateTimeValueObj = DateTimeField::convertToUserTimeZone($value); + $dateTimeValueObj = DateTimeField::convertToUserTimeZone($value); $value = $dateTimeValueObj->format('H:i'); return self::getTimeValueInAMorPM($value); }