Explorar o código

#804 tickets' highlighting is now based on the computation performed by the stopwatch, in order to support non 24x7 working hours

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2952 a333f486-631f-4898-b8df-5754b55c2be0
dflaven %!s(int64=11) %!d(string=hai) anos
pai
achega
01aaf48f9c

+ 34 - 36
datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml

@@ -1417,42 +1417,40 @@
 		$sHilightClass = '';
 		switch($this->GetState())
 		{
-			case 'new':
-			case 'approved':
-			$iEscalationDeadline  = $this->Get('tto_escalation_deadline');
-			if ($iEscalationDeadline != null)
-			{
-				// A SLA is running
-				$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
-				$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
-				if ($ratio <= 0)
-				{
-					$sHilightClass = HILIGHT_CLASS_CRITICAL;
-				}
-				else if ($ratio <= 0.25)
-				{
-					$sHilightClass = HILIGHT_CLASS_WARNING;
-				}
-			}
-			break;
-
-			case 'assigned':
-			$iEscalationDeadline = $this->Get('ttr_escalation_deadline');
-			if ($iEscalationDeadline != null)
-			{
-				// A SLA is running
-				$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
-				$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
-				if ($ratio <= 0)
-				{
-					$sHilightClass = HILIGHT_CLASS_CRITICAL;
-				}
-				else if ($ratio <= 0.25)
-				{
-					$sHilightClass = HILIGHT_CLASS_WARNING;
-				}
-			}
-			break;			
+            case 'new':
+            case 'approved':
+            $iEscalationDeadline  = $this->Get('tto_escalation_deadline');
+            if ($iEscalationDeadline != null)
+            {
+                  // A SLA is running
+                  $oTTOStopWatch = $this->Get('tto');
+                  if ($oTTOStopWatch->IsThresholdPassed(100))
+                  {
+                    $sHilightClass = HILIGHT_CLASS_CRITICAL;
+                  }
+                  else if ($oTTOStopWatch->IsThresholdPassed(75))
+                  {
+                    $sHilightClass = HILIGHT_CLASS_WARNING;
+                  }
+            }
+            break;
+      
+            case 'assigned':
+            $iEscalationDeadline = $this->Get('ttr_escalation_deadline');
+            if ($iEscalationDeadline != null)
+            {
+                // A SLA is running
+                $oTTRStopWatch = $this->Get('ttr');
+                if ($oTTRStopWatch->IsThresholdPassed(100))
+                {
+                  $sHilightClass = HILIGHT_CLASS_CRITICAL;
+                }
+                else if ($oTTRStopWatch->IsThresholdPassed(75))
+                {
+                  $sHilightClass = HILIGHT_CLASS_WARNING;
+                }
+            }
+            break;		
 			
 			case 'escalated_tto':
 			case 'escalated_ttr':

+ 35 - 38
datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml

@@ -1806,44 +1806,41 @@
 	{
 		$sHilightClass = '';
 		switch($this->GetState())
-		{
-			case 'new':
-			case 'approved':
-			$iEscalationDeadline  = $this->Get('tto_escalation_deadline');
-			if ($iEscalationDeadline != null)
-			{
-				// A SLA is running
-				$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
-				$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
-				if ($ratio <= 0)
-				{
-					$sHilightClass = HILIGHT_CLASS_CRITICAL;
-				}
-				else if ($ratio <= 0.25)
-				{
-					$sHilightClass = HILIGHT_CLASS_WARNING;
-				}
-			}
-			break;
-
-			case 'assigned':
-			$iEscalationDeadline = $this->Get('ttr_escalation_deadline');
-			if ($iEscalationDeadline != null)
-			{
-				// A SLA is running
-				$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
-				$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
-				if ($ratio <= 0)
-				{
-					$sHilightClass = HILIGHT_CLASS_CRITICAL;
-				}
-				else if ($ratio <= 0.25)
-				{
-					$sHilightClass = HILIGHT_CLASS_WARNING;
-				}
-			}
-			break;			
-			
+		{	
+            case 'new':
+            case 'approved':
+            $iEscalationDeadline  = $this->Get('tto_escalation_deadline');
+            if ($iEscalationDeadline != null)
+            {
+                // A SLA is running
+                $oTTOStopWatch = $this->Get('tto');
+                if ($oTTOStopWatch->IsThresholdPassed(100))
+                {
+                  $sHilightClass = HILIGHT_CLASS_CRITICAL;
+                }
+                else if ($oTTOStopWatch->IsThresholdPassed(75))
+                {
+                  $sHilightClass = HILIGHT_CLASS_WARNING;
+                }
+            }
+            break;
+      
+            case 'assigned':
+            $iEscalationDeadline = $this->Get('ttr_escalation_deadline');
+            if ($iEscalationDeadline != null)
+            {
+                // A SLA is running
+                $oTTRStopWatch = $this->Get('ttr');
+                if ($oTTRStopWatch->IsThresholdPassed(100))
+                {
+                  $sHilightClass = HILIGHT_CLASS_CRITICAL;
+                }
+                else if ($oTTRStopWatch->IsThresholdPassed(75))
+                {
+                  $sHilightClass = HILIGHT_CLASS_WARNING;
+                }
+            }
+            break;  
 			case 'escalated_tto':
 			case 'escalated_ttr':
 			$sHilightClass = HILIGHT_CLASS_CRITICAL;

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

@@ -1799,13 +1799,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))
 				{
 					$sHilightClass = HILIGHT_CLASS_CRITICAL;
 				}
-				else if ($ratio <= 0.25)
+				else if ($oTTOStopWatch->IsThresholdPassed(75))
 				{
 					$sHilightClass = HILIGHT_CLASS_WARNING;
 				}
@@ -1817,13 +1816,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))
 				{
 					$sHilightClass = HILIGHT_CLASS_CRITICAL;
 				}
-				else if ($ratio <= 0.25)
+				else if ($oTTRStopWatch->IsThresholdPassed(75))
 				{
 					$sHilightClass = HILIGHT_CLASS_WARNING;
 				}