Ok, here's the implementation of adding Help Topics and auto-population of department and priority based on the chosen Help Topic when submitting them as Staff (within /scp/)
**THIS ONLY WORKS FOR RC5. If you don't have RC5, get it. You'll be glad you did!**
**Also, it was designed for a system where the "topic" field in the ticket table is numeric, as opposed to Text (I might add this MOD soon)**
First, we must add a "Help Topic" table row () to /include/staff/newticket.inc.php (You choose where it goes...I have mine above Department)
<?//MOD by michael.therrien 7/7/09?>
<tr>
<td align="left"><b>Help Topic:</b></td>
<td>
<select name="topicId" onchange="autopopulateDeptPrio(this.form)">
<option value="" selected >Select One</option>
<?
$i=0;
$services= mysql_query('SELECT topic_id,topic,dept_id,priority_id FROM '.TOPIC_TABLE.' WHERE isactive=1 ORDER BY topic');
while($row=mysql_fetch_assoc($services))
{
$TopicArr = $row;
echo"<option value=\"" .$row. "\">" .$row. "</option>";
$i++;
};
?>
</select>
<font class="error">* <?=$errors?></font>
</td>
</tr>
Then we must add the following javascript at the end of /include/staff/newticket.php:
<?//MOD by michael.therrien 7/2/09?>
<SCRIPT LANGUAGE="JavaScript">
function autopopulateDeptPrio(form)
{
<?php
$i=0;
$count = count($TopicArr) - 1;
while($i<=$count)
{
echo"if(form.topicId.value == " .$TopicArr. "){form.deptId.value = '" .$TopicArr. "'; form.pri.value = '" .$TopicArr. "';}\n";
$i++;
}
?>
}
</SCRIPT>
Then on /include/class.ticket.php, we need to ADD
var $topicId;
below var $topic;
and ADD //MOD by michael.therrien 7/2/09
$fields = array('type'=>'int', 'required'=>1, 'error'=>'Select help topic'); below $fields = array('type'=>'int', 'required'=>1, 'error'=>'Dept. required');
and ADD //MOD by michael.therrien 7/2/09
$topicId=$var; below $topic=NULL;
and ADD //MOD by michael.therrien 7/2/09
',topic='.db_input($var). below ',subject='.db_input(Format:($var)).
and MODIFY ~line 337 of /scp/tickets.php//MOD by michael.therrien 7/2/09 - Why discard topicId? That's not cool.
$_POST=0; //clean crap.
//ORIGINAL CODE WAS:
// $_POST=$_POST=0; //clean crap. Just remove=$_POST
LET ME KNOW if you have problems.