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

Merge pull request #613 from greezybacon/feature/transfer-sla


Allow SLA to be migrated

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 158a7cca a6e00914
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
......@@ -1134,7 +1134,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 - ***/
......@@ -1658,6 +1658,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