#804 (Continued) Fix for GetHilightClass (previous revision: 2952) was not sufficient + applied the same fix for GetIcon!

SVN:trunk[2968]
This commit is contained in:
Romain Quetiez
2013-10-29 15:55:00 +00:00
parent bc14ad9e80
commit d912e7f4fb
4 changed files with 25 additions and 47 deletions

View File

@@ -66,7 +66,6 @@ class ormStopWatch
{
$this->aThresholds[$iPercent] = array(
'deadline' => $tDeadline, // unix time (seconds)
'passed' => $bPassed,
'triggered' => $bTriggered,
'overrun' => $iOverrun
);
@@ -122,14 +121,16 @@ class ormStopWatch
}
public function IsThresholdPassed($iPercent)
{
$bRet = false;
if (array_key_exists($iPercent, $this->aThresholds))
{
return $this->aThresholds[$iPercent]['passed'];
}
else
{
return false;
$aThresholdData = $this->aThresholds[$iPercent];
if (!is_null($aThresholdData['deadline']) && ($aThresholdData['deadline'] <= time()))
{
$bRet = true;
}
}
return $bRet;
}
public function IsThresholdTriggered($iPercent)
{
@@ -263,7 +264,6 @@ class ormStopWatch
foreach ($this->aThresholds as $iPercent => &$aThresholdData)
{
$aThresholdData['passed'] = false;
$aThresholdData['triggered'] = false;
$aThresholdData['deadline'] = null;
$aThresholdData['overrun'] = null;
@@ -322,14 +322,12 @@ class ormStopWatch
if (is_null($aThresholdData['deadline']) || ($aThresholdData['deadline'] > time()))
{
// The threshold is in the future, reset
$aThresholdData['passed'] = false;
$aThresholdData['triggered'] = false;
$aThresholdData['overrun'] = null;
}
else
{
// The new threshold is in the past
$aThresholdData['passed'] = true;
// Note: the overrun can be wrong, but the correct algorithm to compute
// the overrun of a deadline in the past requires that the ormStopWatch keeps track of all its history!!!
}
@@ -367,7 +365,6 @@ class ormStopWatch
$iOverrun = $this->ComputeDuration($oObject, $oAttDef, $aThresholdData['deadline'], time());
$aThresholdData['overrun'] = $iOverrun;
}
$aThresholdData['passed'] = true;
}
$aThresholdData['deadline'] = null;
}

View File

@@ -1336,14 +1336,12 @@
if ($iEscalationDeadline != null)
{
// A SLA is running
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
if ($ratio <= 0)
$oTTOStopWatch = $this->Get('tto');
if ($oTTOStopWatch->IsThresholdPassed(100))
{
$sIcon = self::MakeIconFromName('incident-escalated.png');
}
else if ($ratio <= 0.25)
else if ($oTTOStopWatch->IsThresholdPassed(75))
{
$sIcon = self::MakeIconFromName('incident-deadline.png');
}
@@ -1356,24 +1354,18 @@
if ($iEscalationDeadline != null)
{
// A SLA is running
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
if ($ratio <= 0)
$oTTRStopWatch = $this->Get('ttr');
if ($oTTRStopWatch->IsThresholdPassed(100))
{
$sIcon = self::MakeIconFromName('incident-escalated.png');
}
else if ($ratio <= 0.25)
else if ($oTTRStopWatch->IsThresholdPassed(75))
{
$sIcon = self::MakeIconFromName('incident-deadline.png');
}
}
break;
default:
$sIcon = MetaModel::GetClassIcon(get_class($this), $bImgTag);
}

View File

@@ -1752,14 +1752,12 @@
if ($iEscalationDeadline != null)
{
// A SLA is running
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
if ($ratio <= 0)
$oTTOStopWatch = $this->Get('tto');
if ($oTTOStopWatch->IsThresholdPassed(100))
{
$sIcon = self::MakeIconFromName('user-request-escalated.png');
}
else if ($ratio <= 0.25)
else if ($oTTOStopWatch->IsThresholdPassed(75))
{
$sIcon = self::MakeIconFromName('user-request-deadline.png');
}
@@ -1772,13 +1770,12 @@
if ($iEscalationDeadline != null)
{
// A SLA is running
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
if ($ratio <= 0)
$oTTRStopWatch = $this->Get('ttr');
if ($oTTRStopWatch->IsThresholdPassed(100))
{
$sIcon = self::MakeIconFromName('user-request-escalated.png');
}
else if ($ratio <= 0.25)
else if ($oTTRStopWatch->IsThresholdPassed(75))
{
$sIcon = self::MakeIconFromName('user-request-deadline.png');
}

View File

@@ -1730,14 +1730,12 @@
if ($iEscalationDeadline != null)
{
// A SLA is running
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
if ($ratio <= 0)
$oTTOStopWatch = $this->Get('tto');
if ($oTTOStopWatch->IsThresholdPassed(100))
{
$sIcon = self::MakeIconFromName('user-request-escalated.png');
}
else if ($ratio <= 0.25)
else if ($oTTOStopWatch->IsThresholdPassed(75))
{
$sIcon = self::MakeIconFromName('user-request-deadline.png');
}
@@ -1750,24 +1748,18 @@
if ($iEscalationDeadline != null)
{
// A SLA is running
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
if ($ratio <= 0)
$oTTRStopWatch = $this->Get('ttr');
if ($oTTRStopWatch->IsThresholdPassed(100))
{
$sIcon = self::MakeIconFromName('user-request-escalated.png');
}
else if ($ratio <= 0.25)
else if ($oTTRStopWatch->IsThresholdPassed(75))
{
$sIcon = self::MakeIconFromName('user-request-deadline.png');
}
}
break;
default:
$sIcon = MetaModel::GetClassIcon(get_class($this), $bImgTag);
}