Today I realized that if staff open new ticket from staff panel in osTicket System, then the help topic value always blank being saved in ticket table, whereas if client open a new ticket, the help topic being saved properly in ticket table. So I made another modification in order to display the help topic selection on new ticket form in staff panel. When staff chose one of the help topic from the combobox, then the department related to the selected help topic will be automatically selected. This modification is an enhancement version from the similar modification made by michael.therrien in osTicket Forum. The main difference between michael.therrein’s and mine is: topicId was being saved in ticket table, whereas the modification I made is the topic description was being saved in ticket table following the default rules made by osTicket.
-
Open \include\staff\newticket.inc.php file, and find this code:
55 56
<tr> <td align="left"><b>Department:</b></td>
before the first line of that code, please insert this following code:
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
<?php // Begin of Help Topic MOD by Masino Sinaga, October 13, 2009 ?> <tr> <td align="left"><b>Help Topic:</b></td> <td> <select name="topicId" onchange="autopopulateDeptPrio(this.form)"> <option value="" selected >Select Help Topic</option> <?php $i=0; $services= db_query('SELECT topic_id,topic FROM '.TOPIC_TABLE.' WHERE isactive=1 ORDER BY topic'); while (list($topicId,$topic) = db_fetch_row($services)){ $TopicArr[$i] = $topicId; $selected = ($info['topicId']==$topicId)?'selected':''; ?> <option value="<?=$topicId?>" <?=$selected?>><?=$topic?></option> <?php $i++; }; ?> </select> <font class="error">* <?=$errors['topicId']?></font> </td> </tr> <?php // End of Help Topic MOD by Masino Sinaga, October 13, 2009 ?>
Find again this code:
164
<script type="text/javascript">
before the first line of that code above, please insert this following code:
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
<?//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[$i][topic_id]. "){form.deptId.value = '" .$TopicArr[$i][dept_id]. "'; form.pri.value = '" .$TopicArr[$i][priority_id]. "';}\n"; $i++; } ?> } </SCRIPT>
-
Open \scp\tickets.php file, and find this code:
341 342 343
case 'open': $ticket=null; $_POST['emailId']=$_POST['topicId']=0; //clean crap.
and replace with this following code:
341 342 343
case 'open': $ticket=null; $_POST['emailId']=0; //clean crap. // mod Help Topic by Masino Sinaga, October 13, 2009
-
Open \include\class.ticket.php file, and find this code:
1053 1054 1055 1056
}elseif(strcasecmp($origin,'staff')==0){ //tickets created by staff...e.g on callins. $fields['deptId'] = array('type'=>'int', 'required'=>1, 'error'=>'Dept. required'); $fields['source'] = array('type'=>'string', 'required'=>1, 'error'=>'Indicate source'); $fields['duedate'] = array('type'=>'date', 'required'=>0, 'error'=>'Invalid date - must be MM/DD/YY');
replace with this following code:
1053 1054 1055 1056 1057
}elseif(strcasecmp($origin,'staff')==0){ //tickets created by staff...e.g on callins. $fields['topicId'] = array('type'=>'int', 'required'=>1, 'error'=>'Select help topic please'); $fields['deptId'] = array('type'=>'int', 'required'=>1, 'error'=>'Dept. required'); $fields['source'] = array('type'=>'string', 'required'=>1, 'error'=>'Indicate source'); $fields['duedate'] = array('type'=>'date', 'required'=>0, 'error'=>'Invalid date - must be MM/DD/YY');
Find again this code:
1144 1145 1146
// OK...just do it. $deptId=$var['deptId']; //pre-selected Dept if any. $priorityId=$var['pri'];
then replace with this following code:
1144 1145 1146 1147
// OK...just do it. $deptId=$var['deptId']; //pre-selected Dept if any. $topicId=$var['topicId']; // added by Masino Sinaga, October 13, 2009 $priorityId=$var['pri'];
Find again this code:
1170 1171 1172 1173
}elseif($var['deptId']){ //Opened by staff. $deptId=$var['deptId']; $source=ucfirst($var['source']); }
then replace with this following code:
1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181
}elseif($var['deptId']){ //Opened by staff. $deptId=$var['deptId']; $source=ucfirst($var['source']); // Begin of MOD by Masino Sinaga, October 13, 2009, mod Help Topic in RC5 $topic= new Topic($topicId); $priorityId=$priorityId?$priorityId:$topic->getPriorityId(); $topicDesc=$topic->getName(); if($autorespond) $autorespond=$topic->autoRespond(); // End of MOD by Masino Sinaga, October 13, 2009, mod Help Topic in RC5 }
That’s all. Now the help topic, or in this case, the help topic description will be saved in ticket table when staff add new ticket from staff panel.

Error noticed in class.ticket.php where code must be replaced with:
Department now is not required field, so it has be:
Am I correct?
@vitalijusg
Although you may change it from 1 to 0, but I suggest you not to change it. Why? Because we have to overcome if staff member change the department value intuitively, for example after a staff member selected the help topic, then he/she intuitively change the department value become ‘Select Department’ value. So, in this case, we have to anticipate this possibility the department value change. This is a preventive action that we made.
i really needed to tell you that your forum is awesome
thank you
What’s up everyone, my name is Shaun. I’m new to the forum and just wanted to say hey. I hope I posted this in the right section!
Hello Masino,
Great tutorial however, every time I change the help Id, (the department not being selected yet) The department value gets to be automatically changed and most of the time the department selected in not the department suited for the help topic.
Any improvements?
Thanks
Hello Masino,
After further checking of the codes and testing it. I could not create a new ticket any more. All the fields are correct and no errors were commented by the system.
I hope you can find a solution for the problem.
Thanks
@Thun Chropeckorn
Make sure you have already followed all steps carefully, especially the Javascript code. Also, make sure the Javascript is enabled in your browser. I have tested that modification, and everything works fine here.
@Thun Chropeckorn
See my answer above. FYI, everything works fine here.
Tried it and works fine though the status is set as delayed and the user receives no confirmation’s email (Password Needed to Activate A Ticket in osTicket v1.6 RC5 MOD installed).
So you need to go to the ticket and reopen it if you want it to be seen and to be able to assign it.
Time to review the delay status ?
Regards
Masino,
If you have implemented the mod: “Password Needed to Activate A Ticket…”, then the default status is “delay”.
If Someone as staff enters a new ticket in its UI then it should be *opened* by default, shouldn’t it?
Also the default message in “xxx_ticket_message:message” is ‘Ticket created by staff’ (scp/tickets.php) and the message entered is in “xxx_ticket_response:response”.
OST doesn’t send an auto-answer in this case and, when you send a response to the customer, the system sends “%message” in the email instead of the real message placed in “xxx_ticket_response:response”. It’s not even sending the content of “xxx_ticket_message:message” : ‘Ticket created by staff’.
Did I do something wrong?
I know evreything is working well on your side but I’ve not your knowledge of the whole thing.
Regards
Hello Masino,
Java script is enabled. Again when creating the ticket in staff mode here is what I experience: When I select a help topic, the department value gets to be changed automatically but not the right department. For example in my help topic “General Inquiry” I assigned Reception Dept. to be the new ticket department. But when I select General Inquiry on the form it becomes Communications Dept. Then after this I try to submit it and it does not generate a new ticket. It just goes back again to the form. I tried using the following browsers: Safari, IE, and Firefox all with javascript enabled.
I hope you can help me solve this problem on version rc5.
Thanks and God Bless
@Thun Chropeckorn
Have you tried with another help topic besides “General Inquiry”? It should be fine since there is no “General Inquiry” item in this modification. Actually, “General Inquiry” is the original help topic item, and it does not have relationship to any department since the code you mentioned probably you got from the new ticket from at the client-side. CMIIW.
Hello Masino,
I did try and they are not also at pair with the department I assigned. The first general inquiry (original) was deleted long ago then I made another General Inquiry and assigned Reception Dept. as the new ticket department. On what php file should I look to see if the variable for help topic and the variable for department match?
Thanks again.
Will there be an error to your code if the number of departments is greater than the help topic? Because this is the situation here on my system. Plus will this script also work on rc4?
Thanks
I don’t think so, since this modification was being intended only for RC5, as stated earlier in the article’s title.
HI
may i know whether this code will work with 1.6ST?
Because i found some differences in implementing it on 1.6ST
Masino excelent mods it this work with 1.6ST? I cant implement
Thanks
ver OST 1.6.0ST
I cannot complete this MOD. the lines in step 2 do not exist in my document.
Thanks
Paul
Hi All
I have a strange issue.
I have two departments Support, Testing and both are are auto assigned to different staff. Now, if I submit a new ticket for Support topic, it is auto assigned as expected but if I submit a ticket for Testing topic, it is not auto assigned. I checked the database and staff_id in tickets table is 0. Has anyone else too faced this issue?
Thanks in advance.