Skip to content
Permalink
Browse files

Clear Overdue On Reopen

Commit 8c76d70 changed how SLA due date is updated but failed to clear
existing & expired due dates when a ticket gets reopened.

We also previously removed the SLA on  expired SLA due dates but this commit
simply clears old date and recalculates new one based on reopen date.
  • Loading branch information...
protich committed Nov 21, 2019
1 parent 9ea8e77 commit 6dc0b749b2a330a5786fbf832dbe88c4f78a035a
Showing with 10 additions and 17 deletions.
  1. +10 −17 include/class.ticket.php
@@ -547,16 +547,10 @@ function getSLADueDate($recompute=false) {
}
function updateEstDueDate($clearOverdue=true) {
if ($this->isOverdue() && $clearOverdue)
$this->clearOverdue(false);
$this->est_duedate = $this->getSLADueDate(true) ?: null;
// Clear overdue flag if duedate or SLA changes and the ticket is no longer overdue.
$DueDate = $this->getEstDueDate();
if ($this->isOverdue()
&& $clearOverdue
&& (!$DueDate // Duedate + SLA cleared
|| Misc::db2gmtime($DueDate) > Misc::gmtime() //New due date in the future.
)) {
$this->isoverdue = 0;
}
return $this->save();
}
@@ -1492,16 +1486,15 @@ function setStatus($status, $comments='', &$errors=array(), $set_closing_agent=t
$refer = $this->staff ?: $thisstaff;
$this->closed = $this->lastupdate = SqlFunction::NOW();
$this->duedate = null;
if ($thisstaff && $set_closing_agent)
$this->staff = $thisstaff;
// Clear overdue flags & due dates
$this->clearOverdue(false);
$ecb = function($t) use ($status) {
$t->logEvent('closed', array('status' => array($status->getId(), $status->getName())), null, 'closed');
$type = array('type' => 'closed');
Signal::send('object.edited', $t, $type);
$t->deleteDrafts();
};
break;
@@ -1529,6 +1522,8 @@ function setStatus($status, $comments='', &$errors=array(), $set_closing_agent=t
$this->lastupdate = $this->reopened = SqlFunction::NOW();
$ecb = function ($t) {
$t->logEvent('reopened', false, null, 'closed');
// Set new sla duedate if any
$t->updateEstDuedate();
};
}
@@ -1542,7 +1537,7 @@ function setStatus($status, $comments='', &$errors=array(), $set_closing_agent=t
}
$this->status = $status;
if (!$this->save())
if (!$this->save(true))
return false;
// Refer thread to previously assigned or closing agent
@@ -2407,20 +2402,18 @@ function markOverdue($whine=true) {
}
function clearOverdue($save=true) {
if (!$this->isOverdue())
return true;
//NOTE: Previously logged overdue event is NOT annuled.
$this->isoverdue = 0;
if (!$this->isOverdue())
$this->isoverdue = 0;
// clear due date if it's in the past
if ($this->getDueDate() && Misc::db2gmtime($this->getDueDate()) <= Misc::gmtime())
$this->duedate = null;
// Clear SLA if est. due date is in the past
if ($this->getSLADueDate() && Misc::db2gmtime($this->getSLADueDate()) <= Misc::gmtime())
$this->sla = null;
$this->est_duedate = null;
return $save ? $this->save() : true;
}

0 comments on commit 6dc0b74

Please sign in to comment.
You can’t perform that action at this time.