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

@@ -112,7 +112,7 @@ class AbstractCases implements CasesInterface
// Filter by specific cases, know as "$appUidCheck" in the old lists classes // Filter by specific cases, know as "$appUidCheck" in the old lists classes
private $casesUids = []; private $casesUids = [];
// Filter by Send By // Filter by Send By
private $sendBy = ''; private $sendBy = '';
@@ -333,7 +333,7 @@ class AbstractCases implements CasesInterface
/** /**
* Set send by * Set send by
* *
* @param type $sendBy * @param type $sendBy
*/ */
public function setSendBy(string $sendBy) public function setSendBy(string $sendBy)
@@ -343,7 +343,7 @@ class AbstractCases implements CasesInterface
/** /**
* Get send by. * Get send by.
* *
* @return string * @return string
*/ */
public function getSendBy() public function getSendBy()
@@ -1170,8 +1170,11 @@ class AbstractCases implements CasesInterface
* *
* @return int * @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); $currentDate = new DateTime($dateToCompare);
$dueDate = new DateTime($dueDate); $dueDate = new DateTime($dueDate);
if ($currentDate > $dueDate) { if ($currentDate > $dueDate) {
@@ -1305,7 +1308,7 @@ class AbstractCases implements CasesInterface
$threadTask['delay'] = getDiffBetweenDates($thread['DEL_TASK_DUE_DATE'], $dateToCompare); $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'] = (!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_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); $threadTask['unassigned'] = ($status === 'UNASSIGNED' ? true : false);
$userInfo = User::getInformation($thread['USR_ID']); $userInfo = User::getInformation($thread['USR_ID']);
$threadTask['user_tooltip'] = $userInfo; $threadTask['user_tooltip'] = $userInfo;
@@ -1558,7 +1561,7 @@ class AbstractCases implements CasesInterface
* @param int $category * @param int $category
* @param bool $topTen * @param bool $topTen
* @param array $processes * @param array $processes
* *
* @return array * @return array
*/ */
public function getCountersByProcesses($category = null, $topTen = false, $processes = []) public function getCountersByProcesses($category = null, $topTen = false, $processes = [])
@@ -1596,12 +1599,12 @@ class AbstractCases implements CasesInterface
/** /**
* Count how many cases has each process by range of dates * Count how many cases has each process by range of dates
* *
* @param int $processId * @param int $processId
* @param string $dateFrom * @param string $dateFrom
* @param string $dateTo * @param string $dateTo
* @param string $groupBy * @param string $groupBy
* *
* @return array * @return array
*/ */
public function getCountersByRange($processId = null, $dateFrom = null, $dateTo = null, $groupBy = 'day') public function getCountersByRange($processId = null, $dateFrom = null, $dateTo = null, $groupBy = 'day')
@@ -1648,13 +1651,13 @@ class AbstractCases implements CasesInterface
/** /**
* Get cases risk by process * Get cases risk by process
* *
* @param int $processId * @param int $processId
* @param string $dateFrom * @param string $dateFrom
* @param string $dateTo * @param string $dateTo
* @param string $riskStatus * @param string $riskStatus
* @param int $topCases * @param int $topCases
* *
* @return array * @return array
*/ */
public function getCasesRisk($processId = '', $dateFrom = null, $dateTo = null, $riskStatus = 'ON_TIME', $topCases = null) public function getCasesRisk($processId = '', $dateFrom = null, $dateTo = null, $riskStatus = 'ON_TIME', $topCases = null)

View File

@@ -590,7 +590,7 @@ function toSqlWithBindings(Illuminate\Database\Eloquent\Builder $queryObject) {
/** /**
* Get the version of the mysql * Get the version of the mysql
* *
* @return string * @return string
*/ */
function getMysqlVersion() function getMysqlVersion()
@@ -642,18 +642,24 @@ function applyMaskDateEnvironment($date, $mask = '', $caseListSetting = true)
* *
* @return string * @return string
*/ */
function getDiffBetweenDates(string $startDate, string $endDate) function getDiffBetweenDates(?string $startDate, ?string $endDate)
{ {
$result = ''; $result = '';
if (!empty($startDate) && !empty($endDate)) { try {
$initDate = new DateTime($startDate); // Check if startDate and endDate are not empty
$finishDate = new DateTime($endDate); if (!empty($startDate) && !empty($endDate)) {
$diff = $initDate->diff($finishDate); $initDate = new DateTime($startDate);
$format = ' %a ' . G::LoadTranslation('ID_DAY_DAYS'); $finishDate = new DateTime($endDate);
$format .= ' %H ' . G::LoadTranslation('ID_HOUR_ABBREVIATE'); $diff = $initDate->diff($finishDate);
$format .= ' %I ' . G::LoadTranslation('ID_MINUTE_ABBREVIATE'); $format = ' %a ' . G::LoadTranslation('ID_DAY_DAYS');
$format .= ' %S ' . G::LoadTranslation('ID_SECOND_ABBREVIATE'); $format .= ' %H ' . G::LoadTranslation('ID_HOUR_ABBREVIATE');
$result = $diff->format($format); $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; return $result;
@@ -661,13 +667,13 @@ function getDiffBetweenDates(string $startDate, string $endDate)
/** /**
* Move the uploaded file to the documents folder * Move the uploaded file to the documents folder
* *
* @param array $file * @param array $file
* @param string $appUid * @param string $appUid
* @param string $appDocUid * @param string $appDocUid
* @param int $version * @param int $version
* @param bool $upload * @param bool $upload
* *
* @return string * @return string
*/ */
function saveAppDocument($file, $appUid, $appDocUid, $version = 1, $upload = true) function saveAppDocument($file, $appUid, $appDocUid, $version = 1, $upload = true)