diff --git a/core/ormstopwatch.class.inc.php b/core/ormstopwatch.class.inc.php index 8113c5ef6..e0e849b3b 100644 --- a/core/ormstopwatch.class.inc.php +++ b/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; } diff --git a/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml b/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml index 03515abde..14b30acf2 100755 --- a/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml +++ b/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); } diff --git a/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml b/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml index 2ecdb5268..190ddc732 100755 --- a/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml +++ b/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'); } diff --git a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml b/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml index c1ee0bfb4..135b4cd5c 100755 --- a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml +++ b/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); }