diff --git a/include/class.config.php b/include/class.config.php index bfaa0a5fe7664b3fc41a6e587421f62da7d781f9..c1d1ce691078ad0109e7dfb849d36e036e119e44 100644 --- a/include/class.config.php +++ b/include/class.config.php @@ -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() { diff --git a/include/class.sla.php b/include/class.sla.php index a04d1d7c56bc1d417bcc0cab720ff9be0398931e..59f320472e59c95e543c7e02fca8abe8f8710a18 100644 --- a/include/class.sla.php +++ b/include/class.sla.php @@ -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"); + } +} ?> diff --git a/include/class.ticket.php b/include/class.ticket.php index 327560c551579d232ada7f16a1a833d2d0f9cc64..39b1652786b3d6be63603e43c4a67f17d37bed0c 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -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 diff --git a/include/staff/slaplan.inc.php b/include/staff/slaplan.inc.php index d9c1574feaa1a2bb80e6dc5145f1461dd0fcd0a0..541050ce846f9a65ddcf35baf868f3e4436f5275 100644 --- a/include/staff/slaplan.inc.php +++ b/include/staff/slaplan.inc.php @@ -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: