fix issue when app_delegation does not have due date

This commit is contained in:
Fernando Ontiveros
2025-05-07 19:27:28 -04:00
parent e95884f100
commit 6e1eaf31b8
2 changed files with 32 additions and 23 deletions

View File

@@ -1170,8 +1170,11 @@ class AbstractCases implements CasesInterface
*
* @return int
*/
public function getTaskColor(string $dueDate, string $statusThread = '', $dateToCompare = 'now')
public function getTaskColor(?string $dueDate, string $statusThread = '', $dateToCompare = 'now')
{
if (empty($dueDate)) {
return self::COLOR_DRAFT;
}
$currentDate = new DateTime($dateToCompare);
$dueDate = new DateTime($dueDate);
if ($currentDate > $dueDate) {
@@ -1305,7 +1308,7 @@ class AbstractCases implements CasesInterface
$threadTask['delay'] = getDiffBetweenDates($thread['DEL_TASK_DUE_DATE'], $dateToCompare);
$threadTask['tas_color'] = (!empty($thread['DEL_TASK_DUE_DATE'])) ? $this->getTaskColor($thread['DEL_TASK_DUE_DATE'], $status, $finishDate) : '';
$threadTask['tas_color_label'] = (!empty($threadTask['tas_color'])) ? self::TASK_COLORS[$threadTask['tas_color']] : '';
$threadTask['tas_status'] = self::TASK_STATUS[$threadTask['tas_color']];
$threadTask['tas_status'] = (!empty($threadTask['tas_color'])) ? self::TASK_STATUS[$threadTask['tas_color']] : '';
$threadTask['unassigned'] = ($status === 'UNASSIGNED' ? true : false);
$userInfo = User::getInformation($thread['USR_ID']);
$threadTask['user_tooltip'] = $userInfo;

View File

@@ -642,18 +642,24 @@ function applyMaskDateEnvironment($date, $mask = '', $caseListSetting = true)
*
* @return string
*/
function getDiffBetweenDates(string $startDate, string $endDate)
function getDiffBetweenDates(?string $startDate, ?string $endDate)
{
$result = '';
if (!empty($startDate) && !empty($endDate)) {
$initDate = new DateTime($startDate);
$finishDate = new DateTime($endDate);
$diff = $initDate->diff($finishDate);
$format = ' %a ' . G::LoadTranslation('ID_DAY_DAYS');
$format .= ' %H ' . G::LoadTranslation('ID_HOUR_ABBREVIATE');
$format .= ' %I ' . G::LoadTranslation('ID_MINUTE_ABBREVIATE');
$format .= ' %S ' . G::LoadTranslation('ID_SECOND_ABBREVIATE');
$result = $diff->format($format);
try {
// Check if startDate and endDate are not empty
if (!empty($startDate) && !empty($endDate)) {
$initDate = new DateTime($startDate);
$finishDate = new DateTime($endDate);
$diff = $initDate->diff($finishDate);
$format = ' %a ' . G::LoadTranslation('ID_DAY_DAYS');
$format .= ' %H ' . G::LoadTranslation('ID_HOUR_ABBREVIATE');
$format .= ' %I ' . G::LoadTranslation('ID_MINUTE_ABBREVIATE');
$format .= ' %S ' . G::LoadTranslation('ID_SECOND_ABBREVIATE');
$result = $diff->format($format);
}
} catch (Exception $e) {
// Handle exception if the date format is invalid
$result = $e->getMessage();
}
return $result;