View Full Version : Set Help Topic of Open Ticket
bawbagg
10-26-2010, 10:26 AM
Hi,
I run OSTicket on an internal server, and use it to grab enquiries submitted via email.
We receive a number of these from customers and prospective customers, and have someone appointed to perform initial "triage" on the incoming enquiry, and assign it to the right department (using the Help Topic) for resolution.
At the moment, that involves editing the ticket itself, however it would seem to make much more sense if that field were available on open tickets received via email - much like the Action/Priority fields currently are.
I've had a good search through the forum, and can't find this exactly. I could probably have a go at doing it myself, although would much prefer if someone could provide any pointers to help speed up the process for me!
Many thanks,
BB
bawbagg
10-29-2010, 01:19 PM
I've got this working if anyone is interested.
passenger
11-04-2010, 10:45 AM
I've got this working if anyone is interested.
Yes, please ... Can you tell how to fix this ?
bawbagg
11-29-2010, 09:48 PM
Yikes, I didn't have the forum settings correct, and it didn't notify me of this post. Apologies for the delay.
I didn't comment my changes too well..... hopefully I've captured them all.
Here goes:
in scp/tickets.php, around line 225, before case 'close': add the following block:
case 'change_help_topic':
if(!$thisuser->canManageTickets() && !$thisuser->isManager()){
$errors['err']='Perm. Denied. You are not allowed to change ticket\'s help topic';
}elseif(!$_POST['help_topic'] or !is_numeric($_POST['help_topic'])){
$errors['err']='You must select help topic';
}
if(!$errors){
if($ticket->setHelpTopic($_POST['help_topic'])){
$msg='Help Topic Changed Successfully';
$ticket->reload();
$note='Ticket help topic set to '.$ticket->getHelpTopic().' by '.$thisuser->getName();
$ticket->logActivity('Help Topic Changed',$note);
}else{
$errors['err']='Problems changing Help Topic. Try again';
}
}
break;
in include/staff/viewticket.inc.php, around line 160, modify the line beginning onChange="this.form.ticket_priority.disabled to be
onChange="this.form.ticket_priority.disabled=strcmp(this.opt ions[this.selectedIndex].value,'change_priority','reopen','overdue')?false :true;this.form.help_topic.disabled=strcmp(this.op tions[this.selectedIndex].value,'change_help_topic')?false:true;"
in the same file, around line 206, insert the following code
<span for="help_topic">Help Topic:</span>
<select id="help_topic" name="help_topic" <?=!$info['do']?'disabled':''?> >
<option value="0" selected="selected">-Unchanged-</option>
<?
$topicId=$ticket->getTopicId();
$resp=db_query('SELECT topic_id,topic,isactive FROM '.TOPIC_TABLE.' ORDER BY topic');
while($row=db_fetch_array($resp)){ ?>
<option value="<?=$row['topic_id']?>" <?=$topicId==$row['topic_id']?'disabled':''?> ><?=$row['topic']?></option>
<?}?>
</select>
and finally, in include/class.ticket.php, around line 345 before the line with comment //DeptId can NOT be 0. No orphans please!, add a new function:
function setHelpTopic($topic_id){
if(!$topic_id)
return false;
$sql='UPDATE '.TICKET_TABLE.' SET topic_id='.db_input($topic_id).',updated=NOW() WHERE ticket_id='.db_input($this->getId());
if(db_query($sql) && db_affected_rows($res)){
//TODO: escalate the ticket params??
return true;
}
return false;
}
I think that's everything you need. YMMV. Let me know if it works.
BB
ryanp
03-14-2011, 11:54 AM
Hi bawbagg,
This has been great until today when we realized there is a bug in it.
This script is only updating the topic_id field in the ost_ticket table but not the helptopic field. Any idea on getting this script to update both the topic_id and helptopic cells?
Thanks in advance
ryanp
03-15-2011, 07:44 AM
This script is only updating the topic_id field in the ost_ticket table but not the helptopic field
I have found the issue and below is the fix that works for us...
In viewticket.inc.php find
<span for="help_topic">Help Topic:</span>
and update the entry to
<span for="help_topic">Help Topic:</span>
<select id="help_topic" name="help_topic" <?=!$info['do']?'disabled':''?> >
<option value="0" selected="selected">-Unchanged-</option>
<?
$helptopic=$ticket->getHelpTopic();
$resp=db_query('SELECT topic_id,topic,isactive FROM '.TOPIC_TABLE.' ORDER BY topic');
while($row=db_fetch_array($resp)){ ?>
<option value="<?=$row['topic']?>" <?=$topic==$row['topic']?'disabled':''?> ><?=$row['topic']?></option>
Next, in include/class.ticket.php find the lines added by searching for
function setHelpTopic($topic_id){
Change the following lines to
function setHelpTopic($helptopic){
if(!$helptopic)
return false;
$sql='UPDATE '.TICKET_TABLE.' SET helptopic='.db_input($helptopic).',updated=NOW() WHERE ticket_id='.db_input($this->getId());
if(db_query($sql) && db_affected_rows($res)){
//TODO: escalate the ticket params??
return true;
}
return false;
}
This works for us, it is updating both the field topic_id and helptopic in the ticket.
I hope this helps others!
stepukas
03-24-2011, 03:40 AM
Thanks bawbagg, this works great for me.
Only had to add <option> in viewticket.inc.php:
<option value="change_help_topic" <?=$info['do']=='change_help_topic'?'selected':''?> >Change Help Topic</option>
after <option value="">Select Action</option>
bawbagg
04-01-2011, 04:56 AM
This script is only updating the topic_id field in the ost_ticket table but not the helptopic field. Any idea on getting this script to update both the topic_id and helptopic cells?
I must confess, I never even noticed that the helptopic was also identified as a text field in the ost_ticket - I always link from topic_id to ost_help_topic table (as you might expect in a relational database :cool:).
I've not tried your fix as everything seems to work fine for me with my code above :)
BB