From 7828c08ae34886a4e24397a0f7e61bee0b166c57 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Fri, 30 Mar 2012 18:33:45 -0400 Subject: [PATCH] Change cancel link & input size --- include/class.sla.php | 100 ++++++++++++++++++------------ include/staff/ticket-open.inc.php | 10 +-- 2 files changed, 67 insertions(+), 43 deletions(-) diff --git a/include/class.sla.php b/include/class.sla.php index 9ea62b052..cbd9aa430 100644 --- a/include/class.sla.php +++ b/include/class.sla.php @@ -19,91 +19,113 @@ class SLA { var $info; - function SLA($id){ + function SLA($id) { $this->id=0; $this->load($id); } - function load($id) { + function load($id=0) { + + if(!$id && !($id=$this->getId())) + return false; $sql='SELECT * FROM '.SLA_TABLE.' WHERE id='.db_input($id); - if(($res=db_query($sql)) && db_num_rows($res)) { - $info=db_fetch_array($res); - $this->id=$info['id']; - $this->info=$info; - return true; - } - return false; + if(!($res=db_query($sql)) || !db_num_rows($res)) + return false; + + $this->ht=db_fetch_array($res); + $this->id=$this->ht['id']; + return true; } function reload() { - return $this->load($this->getId()); + return $this->load(); } - function getId(){ + function getId() { return $this->id; } - function getName(){ - return $this->info['name']; + function getName() { + return $this->ht['name']; } - function getGracePeriod(){ - return $this->info['grace_period']; + function getGracePeriod() { + return $this->ht['grace_period']; } - function getNotes(){ - return $this->info['notes']; + function getNotes() { + return $this->ht['notes']; } - function getInfo(){ - return $this->info; + function getHashtable() { + return $this->ht; } - function isActive(){ - return ($this->info['isactive']); + function getInfo() { + return $this->getHashtable(); } - function sendAlerts(){ - return (!$this->info['disable_overdue_alerts']); + function isActive() { + return ($this->ht['isactive']); } - function priorityEscalation(){ - return ($this->info['enable_priority_escalation']); + function sendAlerts() { + return (!$this->ht['disable_overdue_alerts']); } - function update($vars,&$errors){ - if(SLA::save($this->getId(),$vars,$errors)){ - $this->reload(); - return true; - } + function priorityEscalation() { + return ($this->ht['enable_priority_escalation']); + } + + function update($vars,&$errors) { - return false; + if(!SLA::save($this->getId(),$vars,$errors)) + return false; + + $this->reload(); + + return true; } - function delete(){ + function delete() { global $cfg; - if($cfg && $cfg->getDefaultSLAId()==$this->getId()) + if(!$cfg || $cfg->getDefaultSLAId()==$this->getId()) return false; $id=$this->getId(); $sql='DELETE FROM '.SLA_TABLE.' WHERE id='.db_input($id).' LIMIT 1'; - if(db_query($sql) && ($num=db_affected_rows())){ + if(db_query($sql) && ($num=db_affected_rows())) { db_query('UPDATE '.DEPT_TABLE.' SET sla_id=0 WHERE sla_id='.db_input($id)); db_query('UPDATE '.TOPIC_TABLE.' SET sla_id=0 WHERE sla_id='.db_input($id)); - db_query('UPDATE '.TICKET_TABLE.' SET sla_id=0 WHERE sla_id='.db_input($id)); + db_query('UPDATE '.TICKET_TABLE.' SET sla_id='.db_input($cfg->getDefaultSLAId()).' WHERE sla_id='.db_input($id)); } return $num; } /** static functions **/ - function create($vars,&$errors){ + function create($vars,&$errors) { return SLA::save(0,$vars,$errors); } - function getIdByName($name){ + function getSLAs() { + + $slas=array(); + + $sql='SELECT id, name FROM '.SLA_TABLE; + if(($res=db_query($sql)) && db_num_rows($res)) { + while(list($id, $name)=db_fetch_row($res)) + $slas[$id]=$name; + + } + + return $slas; + } + + + function getIdByName($name) { $sql='SELECT id FROM '.SLA_TABLE.' WHERE name='.db_input($name); if(($res=db_query($sql)) && db_num_rows($res)) @@ -112,11 +134,11 @@ class SLA { return $id; } - function lookup($id){ + function lookup($id) { return ($id && is_numeric($id) && ($sla= new SLA($id)) && $sla->getId()==$id)?$sla:null; } - function save($id,$vars,&$errors){ + function save($id,$vars,&$errors) { if(!$vars['grace_period']) diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index 911666447..4ec32b342 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -22,7 +22,9 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); Email Address: </td> <td> - <input type="text" size="45" name="email" value="<?php echo $info['email']; ?>"> + + <input type="text" size="45" name="email" id="email" class="typeahead" value="<?php echo $info['email']; ?>" + autocomplete="off" autocorrect="off" autocapitalize="off"> <span class="error">* <?php echo $errors['email']; ?></span> <?php if($cfg->notifyONNewStaffTicket()) { ?> @@ -37,7 +39,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); Full Name: </td> <td> - <input type="text" size="45" name="name" value="<?php echo $info['name']; ?>"> + <input type="text" size="45" name="name" id="name" value="<?php echo $info['name']; ?>"> <span class="error">* <?php echo $errors['name']; ?></span> </td> </tr> @@ -46,9 +48,9 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); Phone Number: </td> <td> - <input type="text" size="18" name="phone" value="<?php echo $info['phone']; ?>"> + <input type="text" size="18" name="phone" id="phone" value="<?php echo $info['phone']; ?>"> <span class="error"> <?php echo $errors['phone']; ?></span> - Ext <input type="text" size="5" name="phone_ext" value="<?php echo $info['phone_ext']; ?>"> + Ext <input type="text" size="5" name="phone_ext" id="phone_ext" value="<?php echo $info['phone_ext']; ?>"> <span class="error"> <?php echo $errors['phone_ext']; ?></span> </td> </tr> -- GitLab