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
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,13 @@ class Config {
return $this->section;
}
function getInfo() {
$info = array();
foreach ($this->config as $key=>$setting)
$info[$key] = $setting['value'];
return $info;
}
function get($key, $default=null) {
if (isset($this->session[$key]))
return $this->session[$key];
......@@ -215,10 +222,7 @@ class OsticketConfig extends Config {
}
function getConfigInfo() {
$info = array();
foreach ($this->config as $key=>$setting)
$info[$key] = $setting['value'];
return $info;
return $this->getInfo();
}
function getTitle() {
......
......@@ -18,6 +18,7 @@ class SLA {
var $id;
var $info;
var $config;
function SLA($id) {
$this->id=0;
......@@ -53,23 +54,33 @@ class SLA {
function getGracePeriod() {
return $this->ht['grace_period'];
}
function getNotes() {
return $this->ht['notes'];
}
function getHashtable() {
return $this->ht;
return array_merge($this->getConfig()->getInfo(), $this->ht);
}
function getInfo() {
return $this->getHashtable();
}
function getConfig() {
if (!isset($this->config))
$this->config = new SlaConfig($this->getId());
return $this->config;
}
function isActive() {
return ($this->ht['isactive']);
}
function isTransient() {
return $this->getConfig()->get('transient', false);
}
function sendAlerts() {
return (!$this->ht['disable_overdue_alerts']);
}
......@@ -83,11 +94,12 @@ class SLA {
}
function update($vars,&$errors) {
if(!SLA::save($this->getId(),$vars,$errors))
return false;
$this->reload();
$this->getConfig()->set('transient', isset($vars['transient']) ? 1 : 0);
return true;
}
......@@ -111,7 +123,10 @@ class SLA {
/** static functions **/
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() {
......@@ -121,8 +136,8 @@ class SLA {
if(($res=db_query($sql)) && db_num_rows($res)) {
while($row=db_fetch_array($res))
$slas[$row['id']] = sprintf('%s (%d hrs - %s)',
$row['name'],
$row['grace_period'],
$row['name'],
$row['grace_period'],
$row['isactive']?'Active':'Disabled');
}
......@@ -150,7 +165,7 @@ class SLA {
$errors['grace_period']='Grace period required';
elseif(!is_numeric($vars['grace_period']))
$errors['grace_period']='Numeric value required (in hours)';
if(!$vars['name'])
$errors['name']='Name required';
elseif(($sid=SLA::getIdByName($vars['name'])) && $sid!=$id)
......@@ -183,4 +198,13 @@ class SLA {
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 {
/**
* Selects the appropriate service-level-agreement plan for this ticket.
* 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
* which has a shorter grace period, the ticket should be considered
* overdue in the shorter window now that it is owned by the new
......@@ -1133,7 +1133,7 @@ class Ticket {
$this->reload();
// Set SLA of the new department
if(!$this->getSLAId())
if(!$this->getSLAId() || $this->getSLA()->isTransient())
$this->selectSLAId();
/*** log the transfer comments as internal note - with alerts disabled - ***/
......@@ -1654,6 +1654,10 @@ class Ticket {
$this->logNote('Ticket Updated', $vars['note'], $thisstaff);
$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.
if($this->isOverdue()
&& (!$this->getEstDueDate() //Duedate + SLA cleared
......
......@@ -74,6 +74,16 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
<strong>Enable</strong> priority escalation on overdue tickets.
</td>
</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>
<td width="180">
Ticket Overdue Alerts:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment