HelpTopic based on department for staff new ticket form
I have tested it for v1.7 and it worked fine.
1. Open your \include\staff\ticket-open.inc.php file, add this code:
Department:
Select Department
<?
$services= db_query('SELECT dept_id,dept_name FROM '.DEPT_TABLE.' ORDER BY dept_name');
while (list($deptId,$dept) = db_fetch_row($services)){
$selected = ($info==$deptId)?'selected':''; ?>
"<?=$selected?>><?=$dept?>
<?
}?>
* <?=$errors?>
Help Topic:
Select Help Topic
<?
if ($info=='' || is_null($info)) { $info='0'; }
$services= db_query('SELECT topic_id,topic FROM '.TOPIC_TABLE.' WHERE isactive=1 AND dept_id = '.$info.' ORDER BY topic');
while (list($topicId,$topic) = db_fetch_row($services)){
$selected = ($info==$topicId)?'selected':''; ?>
"<?=$selected?>><?=$topic?>
<?
}?>
General Inquiry
* <?=$errors?>
Find and paste this code after it:
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getTopic(strURL)
{
var req = getXMLHTTP(); // fuction to get xmlhttp object
if (req)
{
req.onreadystatechange = function()
{
if (req.readyState == 4) { //data is retrieved from server
if (req.status == 200) { // which reprents ok status
document.getElementById('topicdiv').innerHTML=req.responseText;
}
else
{
alert("There was a problem while using XMLHTTP:\n");
}
}
}
req.open("GET", strURL, true); //open url using get method
req.send(null);
}
}
2. Create a new file named findtopic.php, then put it in upload/scp folder. Copy-paste this following code into that file:
<?php
require_once('../main.inc.php');
if(!defined('INCLUDE_DIR')) die('Fatal Error');
define('STAFFINC_DIR',INCLUDE_DIR.'staff/');
define('OSTSCPINC',TRUE); //make includes happy
$topic_id=$_GET;
$query="SELECT topic_id,topic FROM ".TOPIC_TABLE."
WHERE isactive=1 AND dept_id = ".$topic_id."
ORDER BY topic";
$result=db_query($query);
?>
Select Help Topic
<?php while (list($topicId,$topic) = db_fetch_row($result)){ ?>
"><? echo $topic; ?>
<?php } ?>
After these steps, follow the steps 4 to 6 of this link: http://www.openscriptsolution.com/ticket-system/osticket/displaying-help-topic-based-on-selected-department-in-new-ticket-form-at-client-side-of-osticket-v1-6-rc5(http://www.openscriptsolution.com/ticket-system/osticket/displaying-help-topic-based-on-selected-department-in-new-ticket-form-at-client-side-of-osticket-v1-6-rc5)