From b050210737c7455ba28ba717eb5518dc84532f9a Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 8 Nov 2018 08:55:17 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B01374=20-=20Fix=20TTR=20deadline=20wrong?= =?UTF-8?q?=20value=20when=20re-assigning=20overdue=20tickets=20outside=20?= =?UTF-8?q?open=20hours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/ormstopwatch.class.inc.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/core/ormstopwatch.class.inc.php b/core/ormstopwatch.class.inc.php index 8a8616831..366cf8861 100644 --- a/core/ormstopwatch.class.inc.php +++ b/core/ormstopwatch.class.inc.php @@ -402,7 +402,20 @@ class ormStopWatch $sAttCode = $oAttDef->GetCode(); WorkingTimeRecorder::Start($oObject, $iComputationRefTime, "ormStopWatch-Deadline-$iPercent-$sAttCode", 'Core:ExplainWTC:StopWatch-Deadline', array("Class:$sClass/Attribute:$sAttCode", $iPercent)); } - $aThresholdData['deadline'] = $this->ComputeDeadline($oObject, $oAttDef, $iPercent, $this->iLastStart, $iThresholdDuration - $this->iTimeSpent); + $iRemaining = $iThresholdDuration - $this->iTimeSpent; + if ($iRemaining < 0) + { + if (class_exists('WorkingTimeRecorder')) + { + $sClass = get_class($oObject); + $sKey = $oObject->GetKey(); + $sAttCode = $oAttDef->GetCode(); + $sDate = date('Y-m-d H:i:s', $aThresholdData['deadline']); + WorkingTimeRecorder::Log(WorkingTimeRecorder::TRACE_INFO, "$sClass($sKey) ormStopWatch-Deadline-$iPercent-$sAttCode ($sDate) already reached, not changed."); + } + continue; + } + $aThresholdData['deadline'] = $this->ComputeDeadline($oObject, $oAttDef, $iPercent, $this->iLastStart, $iRemaining); // OR $aThresholdData['deadline'] = $this->ComputeDeadline($oObject, $oAttDef, $iPercent, $this->iStarted, $iThresholdDuration); if (class_exists('WorkingTimeRecorder')) @@ -472,7 +485,10 @@ class ormStopWatch $aThresholdData['overrun'] = $iOverrun; } } - $aThresholdData['deadline'] = null; + if ($aThresholdData['overrun'] == 0) + { + $aThresholdData['deadline'] = null; + } } $this->iLastStart = null;