فهرست منبع

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

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2968 a333f486-631f-4898-b8df-5754b55c2be0
romainq 11 سال پیش
والد
کامیت
9d96513ace

+ 7 - 10
core/ormstopwatch.class.inc.php

@@ -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;
 		}

+ 6 - 14
datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml

@@ -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);
 		}

+ 6 - 9
datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml

@@ -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');
 				}

+ 6 - 14
datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml

@@ -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);
 		}