Skip to content
Snippets Groups Projects
Commit 4ab3936a authored by Peter Rotich's avatar Peter Rotich Committed by Jared Hancock
Browse files

Add ability to set thank you page specific to a help topic.

parent 2fcdd56a
No related branches found
No related tags found
No related merge requests found
...@@ -16,10 +16,12 @@ ...@@ -16,10 +16,12 @@
class Topic { class Topic {
var $id; var $id;
var $ht; var $ht;
var $parent; var $parent;
var $page;
function Topic($id) { function Topic($id) {
$this->id=0; $this->id=0;
$this->load($id); $this->load($id);
...@@ -40,11 +42,14 @@ class Topic { ...@@ -40,11 +42,14 @@ class Topic {
return false; return false;
$this->ht = db_fetch_array($res); $this->ht = db_fetch_array($res);
$this->id=$this->ht['topic_id']; $this->id = $this->ht['topic_id'];
$this->page = null;
return true; return true;
} }
function reload() { function reload() {
return $this->load(); return $this->load();
} }
...@@ -52,7 +57,7 @@ class Topic { ...@@ -52,7 +57,7 @@ class Topic {
function asVar() { function asVar() {
return $this->getName(); return $this->getName();
} }
function getId() { function getId() {
return $this->id; return $this->id;
} }
...@@ -71,7 +76,7 @@ class Topic { ...@@ -71,7 +76,7 @@ class Topic {
function getName() { function getName() {
return $this->ht['name']; return $this->ht['name'];
} }
function getDeptId() { function getDeptId() {
return $this->ht['dept_id']; return $this->ht['dept_id'];
} }
...@@ -91,7 +96,18 @@ class Topic { ...@@ -91,7 +96,18 @@ class Topic {
function getTeamId() { function getTeamId() {
return $this->ht['team_id']; return $this->ht['team_id'];
} }
function getPageId() {
return $this->ht['page_id'];
}
function getPage() {
if(!$this->page && $this->getPageId())
$this->page = Page::lookup($this->getPageId());
return $this->page;
}
function autoRespond() { function autoRespond() {
return (!$this->ht['noautoresp']); return (!$this->ht['noautoresp']);
} }
...@@ -137,7 +153,7 @@ class Topic { ...@@ -137,7 +153,7 @@ class Topic {
return $num; return $num;
} }
/*** Static functions ***/ /*** Static functions ***/
function create($vars,&$errors) { function create($vars, &$errors) {
return self::save(0, $vars, $errors); return self::save(0, $vars, $errors);
} }
...@@ -195,10 +211,10 @@ class Topic { ...@@ -195,10 +211,10 @@ class Topic {
if(!$vars['dept_id']) if(!$vars['dept_id'])
$errors['dept_id']='You must select a department'; $errors['dept_id']='You must select a department';
if(!$vars['priority_id']) if(!$vars['priority_id'])
$errors['priority_id']='You must select a priority'; $errors['priority_id']='You must select a priority';
if($errors) return false; if($errors) return false;
$sql=' updated=NOW() ' $sql=' updated=NOW() '
...@@ -207,6 +223,7 @@ class Topic { ...@@ -207,6 +223,7 @@ class Topic {
.',dept_id='.db_input($vars['dept_id']) .',dept_id='.db_input($vars['dept_id'])
.',priority_id='.db_input($vars['priority_id']) .',priority_id='.db_input($vars['priority_id'])
.',sla_id='.db_input($vars['sla_id']) .',sla_id='.db_input($vars['sla_id'])
.',page_id='.db_input($vars['page_id'])
.',isactive='.db_input($vars['isactive']) .',isactive='.db_input($vars['isactive'])
.',ispublic='.db_input($vars['ispublic']) .',ispublic='.db_input($vars['ispublic'])
.',noautoresp='.db_input(isset($vars['noautoresp'])?1:0) .',noautoresp='.db_input(isset($vars['noautoresp'])?1:0)
...@@ -219,7 +236,7 @@ class Topic { ...@@ -219,7 +236,7 @@ class Topic {
$sql.=',staff_id=0, team_id='.db_input(preg_replace("/[^0-9]/", "", $vars['assign'])); $sql.=',staff_id=0, team_id='.db_input(preg_replace("/[^0-9]/", "", $vars['assign']));
else else
$sql.=',staff_id=0, team_id=0 '; //no auto-assignment! $sql.=',staff_id=0, team_id=0 '; //no auto-assignment!
if($id) { if($id) {
$sql='UPDATE '.TOPIC_TABLE.' SET '.$sql.' WHERE topic_id='.db_input($id); $sql='UPDATE '.TOPIC_TABLE.' SET '.$sql.' WHERE topic_id='.db_input($id);
if(db_query($sql)) if(db_query($sql))
...@@ -230,10 +247,10 @@ class Topic { ...@@ -230,10 +247,10 @@ class Topic {
$sql='INSERT INTO '.TOPIC_TABLE.' SET '.$sql.',created=NOW()'; $sql='INSERT INTO '.TOPIC_TABLE.' SET '.$sql.',created=NOW()';
if(db_query($sql) && ($id=db_insert_id())) if(db_query($sql) && ($id=db_insert_id()))
return $id; return $id;
$errors['err']='Unable to create the topic. Internal error'; $errors['err']='Unable to create the topic. Internal error';
} }
return false; return false;
} }
} }
......
...@@ -149,6 +149,26 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ...@@ -149,6 +149,26 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
<em>(Overwrites department's SLA)</em> <em>(Overwrites department's SLA)</em>
</td> </td>
</tr> </tr>
<tr>
<td width="180">Thank-you Page:</td>
<td>
<select name="page_id">
<option value="">&mdash; System Default &mdash;</option>
<?php
if(($pages = Page::getActiveThankYouPages())) {
foreach($pages as $page) {
if(strcasecmp($page->getType(), 'thank-you')) continue;
echo sprintf('<option value="%d" %s>%s</option>',
$page->getId(),
($info['page_id']==$page->getId())?'selected="selected"':'',
$page->getName());
}
}
?>
</select>&nbsp;<font class="error"><?php echo $errors['page_id']; ?></font>
<em>(Overwrites global setting. Applies to web tickets only.)</em>
</td>
</tr>
<tr> <tr>
<td width="180"> <td width="180">
Auto-assign To: Auto-assign To:
...@@ -156,14 +176,9 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ...@@ -156,14 +176,9 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
<td> <td>
<select name="assign"> <select name="assign">
<option value="0">&mdash; Unassigned &mdash;</option> <option value="0">&mdash; Unassigned &mdash;</option>
<?php <?php
$sql=' SELECT staff_id,CONCAT_WS(", ",lastname,firstname) as name '. $sql=' SELECT staff_id,CONCAT_WS(", ",lastname,firstname) as name '.
' FROM '.STAFF_TABLE.' WHERE isactive=1 ORDER BY name'; ' FROM '.STAFF_TABLE.' WHERE isactive=1 ORDER BY name';
if(($res=db_query($sql)) && db_num_rows($res)){ if(($res=db_query($sql)) && db_num_rows($res)){
echo '<OPTGROUP label="Staff Members">'; echo '<OPTGROUP label="Staff Members">';
while (list($id,$name) = db_fetch_row($res)){ while (list($id,$name) = db_fetch_row($res)){
...@@ -171,10 +186,9 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ...@@ -171,10 +186,9 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
$selected = ($info['assign']==$k || $info['staff_id']==$id)?'selected="selected"':''; $selected = ($info['assign']==$k || $info['staff_id']==$id)?'selected="selected"':'';
?> ?>
<option value="<?php echo $k; ?>"<?php echo $selected; ?>><?php echo $name; ?></option> <option value="<?php echo $k; ?>"<?php echo $selected; ?>><?php echo $name; ?></option>
<?php } <?php }
echo '</OPTGROUP>'; echo '</OPTGROUP>';
} }
$sql='SELECT team_id, name FROM '.TEAM_TABLE.' WHERE isenabled=1'; $sql='SELECT team_id, name FROM '.TEAM_TABLE.' WHERE isenabled=1';
if(($res=db_query($sql)) && db_num_rows($res)){ if(($res=db_query($sql)) && db_num_rows($res)){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment