Skip to content
Snippets Groups Projects
Commit a6e00914 authored by Jared Hancock's avatar Jared Hancock
Browse files

Implement transient SLAs

SLAs can be marked transient. When a ticket is assigned to a transient SLA
and it is transferred to a department or help topic having a default SLA,
the SLA will change to the SLA of the new department or help topic. This
process can continue as long as the ticket has a transient SLA assigned.
Once a non-transient SLA is assigned to the ticket, the SLA will no longer
change automatically. Thereafter, the SLA can only be manually changed.
parent c31192a3
Branches
Tags
No related merge requests found
...@@ -48,6 +48,13 @@ class Config { ...@@ -48,6 +48,13 @@ class Config {
return $this->section; return $this->section;
} }
function getInfo() {
$info = array();
foreach ($this->config as $key=>$setting)
$info[$key] = $setting['value'];
return $info;
}
function get($key, $default=null) { function get($key, $default=null) {
if (isset($this->session[$key])) if (isset($this->session[$key]))
return $this->session[$key]; return $this->session[$key];
...@@ -215,10 +222,7 @@ class OsticketConfig extends Config { ...@@ -215,10 +222,7 @@ class OsticketConfig extends Config {
} }
function getConfigInfo() { function getConfigInfo() {
$info = array(); return $this->getInfo();
foreach ($this->config as $key=>$setting)
$info[$key] = $setting['value'];
return $info;
} }
function getTitle() { function getTitle() {
......
...@@ -18,6 +18,7 @@ class SLA { ...@@ -18,6 +18,7 @@ class SLA {
var $id; var $id;
var $info; var $info;
var $config;
function SLA($id) { function SLA($id) {
$this->id=0; $this->id=0;
...@@ -53,23 +54,33 @@ class SLA { ...@@ -53,23 +54,33 @@ class SLA {
function getGracePeriod() { function getGracePeriod() {
return $this->ht['grace_period']; return $this->ht['grace_period'];
} }
function getNotes() { function getNotes() {
return $this->ht['notes']; return $this->ht['notes'];
} }
function getHashtable() { function getHashtable() {
return $this->ht; return array_merge($this->getConfig()->getInfo(), $this->ht);
} }
function getInfo() { function getInfo() {
return $this->getHashtable(); return $this->getHashtable();
} }
function getConfig() {
if (!isset($this->config))
$this->config = new SlaConfig($this->getId());
return $this->config;
}
function isActive() { function isActive() {
return ($this->ht['isactive']); return ($this->ht['isactive']);
} }
function isTransient() {
return $this->getConfig()->get('transient', false);
}
function sendAlerts() { function sendAlerts() {
return (!$this->ht['disable_overdue_alerts']); return (!$this->ht['disable_overdue_alerts']);
} }
...@@ -83,11 +94,12 @@ class SLA { ...@@ -83,11 +94,12 @@ class SLA {
} }
function update($vars,&$errors) { function update($vars,&$errors) {
if(!SLA::save($this->getId(),$vars,$errors)) if(!SLA::save($this->getId(),$vars,$errors))
return false; return false;
$this->reload(); $this->reload();
$this->getConfig()->set('transient', isset($vars['transient']) ? 1 : 0);
return true; return true;
} }
...@@ -111,7 +123,10 @@ class SLA { ...@@ -111,7 +123,10 @@ class SLA {
/** static functions **/ /** static functions **/
function create($vars,&$errors) { function create($vars,&$errors) {
return SLA::save(0,$vars,$errors); if (($id = SLA::save(0,$vars,$errors)) && ($sla = self::lookup($id)))
$sla->getConfig()->set('transient',
isset($vars['transient']) ? 1 : 0);
return $id;
} }
function getSLAs() { function getSLAs() {
...@@ -121,8 +136,8 @@ class SLA { ...@@ -121,8 +136,8 @@ class SLA {
if(($res=db_query($sql)) && db_num_rows($res)) { if(($res=db_query($sql)) && db_num_rows($res)) {
while($row=db_fetch_array($res)) while($row=db_fetch_array($res))
$slas[$row['id']] = sprintf('%s (%d hrs - %s)', $slas[$row['id']] = sprintf('%s (%d hrs - %s)',
$row['name'], $row['name'],
$row['grace_period'], $row['grace_period'],
$row['isactive']?'Active':'Disabled'); $row['isactive']?'Active':'Disabled');
} }
...@@ -150,7 +165,7 @@ class SLA { ...@@ -150,7 +165,7 @@ class SLA {
$errors['grace_period']='Grace period required'; $errors['grace_period']='Grace period required';
elseif(!is_numeric($vars['grace_period'])) elseif(!is_numeric($vars['grace_period']))
$errors['grace_period']='Numeric value required (in hours)'; $errors['grace_period']='Numeric value required (in hours)';
if(!$vars['name']) if(!$vars['name'])
$errors['name']='Name required'; $errors['name']='Name required';
elseif(($sid=SLA::getIdByName($vars['name'])) && $sid!=$id) elseif(($sid=SLA::getIdByName($vars['name'])) && $sid!=$id)
...@@ -183,4 +198,13 @@ class SLA { ...@@ -183,4 +198,13 @@ class SLA {
return false; return false;
} }
} }
require_once(INCLUDE_DIR.'class.config.php');
class SlaConfig extends Config {
var $table = CONFIG_TABLE;
function SlaConfig($id) {
parent::Config("sla.$id");
}
}
?> ?>
...@@ -584,7 +584,7 @@ class Ticket { ...@@ -584,7 +584,7 @@ class Ticket {
/** /**
* Selects the appropriate service-level-agreement plan for this ticket. * Selects the appropriate service-level-agreement plan for this ticket.
* When tickets are transfered between departments, the SLA of the new * When tickets are transfered between departments, the SLA of the new
* department should be applied to the ticket. This would be usefule, * department should be applied to the ticket. This would be useful,
* for instance, if the ticket is transferred to a different department * for instance, if the ticket is transferred to a different department
* which has a shorter grace period, the ticket should be considered * which has a shorter grace period, the ticket should be considered
* overdue in the shorter window now that it is owned by the new * overdue in the shorter window now that it is owned by the new
...@@ -1133,7 +1133,7 @@ class Ticket { ...@@ -1133,7 +1133,7 @@ class Ticket {
$this->reload(); $this->reload();
// Set SLA of the new department // Set SLA of the new department
if(!$this->getSLAId()) if(!$this->getSLAId() || $this->getSLA()->isTransient())
$this->selectSLAId(); $this->selectSLAId();
/*** log the transfer comments as internal note - with alerts disabled - ***/ /*** log the transfer comments as internal note - with alerts disabled - ***/
...@@ -1654,6 +1654,10 @@ class Ticket { ...@@ -1654,6 +1654,10 @@ class Ticket {
$this->logNote('Ticket Updated', $vars['note'], $thisstaff); $this->logNote('Ticket Updated', $vars['note'], $thisstaff);
$this->reload(); $this->reload();
// Reselect SLA if transient
if(!$this->getSLAId() || $this->getSLA()->isTransient())
$this->selectSLAId();
//Clear overdue flag if duedate or SLA changes and the ticket is no longer overdue. //Clear overdue flag if duedate or SLA changes and the ticket is no longer overdue.
if($this->isOverdue() if($this->isOverdue()
&& (!$this->getEstDueDate() //Duedate + SLA cleared && (!$this->getEstDueDate() //Duedate + SLA cleared
......
...@@ -74,6 +74,16 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ...@@ -74,6 +74,16 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
<strong>Enable</strong> priority escalation on overdue tickets. <strong>Enable</strong> priority escalation on overdue tickets.
</td> </td>
</tr> </tr>
<tr>
<td width="180">
Transient:
</td>
<td>
<input type="checkbox" name="transient" value="1" <?php echo $info['transient']?'checked="checked"':''; ?> >
SLA can be overwritten on ticket transfer or help topic
change
</td>
</tr>
<tr> <tr>
<td width="180"> <td width="180">
Ticket Overdue Alerts: Ticket Overdue Alerts:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment