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
private $casesUids = [];
// Filter by Send By
private $sendBy = '';
@@ -333,7 +333,7 @@ class AbstractCases implements CasesInterface
/**
* Set send by
*
*
* @param type $sendBy
*/
public function setSendBy(string $sendBy)
@@ -343,7 +343,7 @@ class AbstractCases implements CasesInterface
/**
* Get send by.
*
*
* @return string
*/
public function getSendBy()
@@ -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;
@@ -1558,7 +1561,7 @@ class AbstractCases implements CasesInterface
* @param int $category
* @param bool $topTen
* @param array $processes
*
*
* @return array
*/
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
*
*
* @param int $processId
* @param string $dateFrom
* @param string $dateTo
* @param string $groupBy
*
*
* @return array
*/
public function getCountersByRange($processId = null, $dateFrom = null, $dateTo = null, $groupBy = 'day')
@@ -1648,13 +1651,13 @@ class AbstractCases implements CasesInterface
/**
* Get cases risk by process
*
*
* @param int $processId
* @param string $dateFrom
* @param string $dateTo
* @param string $riskStatus
* @param int $topCases
*
*
* @return array
*/
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
*
*
* @return string
*/
function getMysqlVersion()
@@ -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;
@@ -661,13 +667,13 @@ function getDiffBetweenDates(string $startDate, string $endDate)
/**
* Move the uploaded file to the documents folder
*
*
* @param array $file
* @param string $appUid
* @param string $appDocUid
* @param int $version
* @param bool $upload
*
*
* @return string
*/
function saveAppDocument($file, $appUid, $appDocUid, $version = 1, $upload = true)