From b105ef37f060b5ee32eb03015ca9ab49ade3a1ae Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Wed, 27 Mar 2013 20:47:07 -0400
Subject: [PATCH] Clear overdue flag if duedate or SLA changes and the ticket
 is no longer overdue.

---
 include/class.ticket.php | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/class.ticket.php b/include/class.ticket.php
index 17d2c56b3..53614c5a5 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -1651,6 +1651,14 @@ class Ticket {
         $this->logNote('Ticket Updated', $vars['note'], $thisstaff);
         $this->reload();
 
+        //Clear overdue flag if duedate or SLA changes and the ticket is no longer overdue.
+        if($this->isOverdue()
+                && (!$this->getEstDueDate() //Duedate + SLA cleared
+                    || Misc::db2gmtime($this->getEstDueDate()) > Misc::gmtime() //New due date in the future.
+                    )) {
+            $this->clearOverdue();
+        }
+
         return true;
     }
 
-- 
GitLab