Skip to content
Snippets Groups Projects
Commit 2224afb0 authored by Peter Rotich's avatar Peter Rotich
Browse files

Add SLA overdue alert overwrite

parent e454500f
Branches
Tags
No related merge requests found
...@@ -74,6 +74,10 @@ class SLA { ...@@ -74,6 +74,10 @@ class SLA {
return (!$this->ht['disable_overdue_alerts']); return (!$this->ht['disable_overdue_alerts']);
} }
function alertOnOverdue() {
return $this->sendAlerts();
}
function priorityEscalation() { function priorityEscalation() {
return ($this->ht['enable_priority_escalation']); return ($this->ht['enable_priority_escalation']);
} }
......
...@@ -1019,13 +1019,13 @@ class Ticket{ ...@@ -1019,13 +1019,13 @@ class Ticket{
function onOverdue($whine=true) { function onOverdue($whine=true) {
global $cfg; global $cfg;
// TODO: log overdue events here if($whine && ($sla=$this->getSLA()) && !$sla->alertOnOverdue())
$whine = false;
//check if we need to send alerts. //check if we need to send alerts.
if(!$whine || !$cfg->alertONOverdueTicket()) if(!$whine || !$cfg->alertONOverdueTicket())
return true; return true;
//Get template. //Get template.
if(!($tpl = $dept->getTemplate())) if(!($tpl = $dept->getTemplate()))
$tpl= $cfg->getDefaultTemplate(); $tpl= $cfg->getDefaultTemplate();
...@@ -1120,15 +1120,15 @@ class Ticket{ ...@@ -1120,15 +1120,15 @@ class Ticket{
if($this->isOverdue()) if($this->isOverdue())
return true; return true;
$sql='UPDATE '.TICKET_TABLE.' SET isoverdue=1,updated=NOW() ' $sql='UPDATE '.TICKET_TABLE.' SET isoverdue=1, updated=NOW() '
.' WHERE ticket_id='.db_input($this->getId()); .' WHERE ticket_id='.db_input($this->getId());
if(!db_query($sql) || !db_affected_rows()) if(!db_query($sql) || !db_affected_rows())
return false; return false;
$this->onOverdue($whine); $this->onOverdue($whine);
$this->track('overdue'); $this->track('overdue');
return true; return true;
} }
...@@ -2043,23 +2043,24 @@ class Ticket{ ...@@ -2043,23 +2043,24 @@ class Ticket{
} }
function checkOverdue(){ function checkOverdue() {
$sql='SELECT ticket_id FROM '.TICKET_TABLE.' T1 JOIN '. $sql='SELECT ticket_id FROM '.TICKET_TABLE.' T1 '
SLA_TABLE.' T2 ON T1.sla_id=T2.id '. .' JOIN '.SLA_TABLE.' T2 ON (T1.sla_id=T2.id) '
'WHERE status=\'open\' AND isoverdue=0 '. .' WHERE status=\'open\' AND isoverdue=0 '
' AND ((reopened is NULL AND duedate is NULL AND TIME_TO_SEC(TIMEDIFF(NOW(),T1.created))>=grace_period*3600)'. .' AND ((reopened is NULL AND duedate is NULL AND TIME_TO_SEC(TIMEDIFF(NOW(),T1.created))>=T2.grace_period*3600) '
' OR (reopened is NOT NULL AND duedate is NULL AND TIME_TO_SEC(TIMEDIFF(NOW(),reopened))>=grace_period*3600)'. .' OR (reopened is NOT NULL AND duedate is NULL AND TIME_TO_SEC(TIMEDIFF(NOW(),reopened))>=T2.grace_period*3600) '
' OR (duedate is NOT NULL AND duedate<NOW()) '. .' OR (duedate is NOT NULL AND duedate<NOW()) '
') ORDER BY T1.created LIMIT 50'; //Age upto 50 tickets at a time? .' ) ORDER BY T1.created LIMIT 50'; //Age upto 50 tickets at a time?
//echo $sql; //echo $sql;
if(($stale=db_query($sql)) && db_num_rows($stale)){ if(($res=db_query($sql)) && db_num_rows($res)) {
while(list($id)=db_fetch_row($stale)){ while(list($id)=db_fetch_row($res)) {
if(($ticket=Ticket::lookup($id)) && $ticket->markOverdue()) if(($ticket=Ticket::lookup($id)) && $ticket->markOverdue())
$ticket->logActivity('Ticket Marked Overdue','Ticket flagged as overdue by the system.'); $ticket->logActivity('Ticket Marked Overdue', 'Ticket flagged as overdue by the system.');
# TODO: Send out notifications about the now-overdue
# ticket XXX: markOverdue sends out notifications.
} }
} else {
//TODO: Trigger escalation on already overdue tickets - make sure last overdue event > grace_period.
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment