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

I've got this working if anyone is interested.

6 days later

I've got this working if anyone is interested.

Yes, please ... Can you tell how to fix this ?

25 days later

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='Perm. Denied. You are not allowed to change ticket\'s help topic';

}elseif(!$_POST or !is_numeric($_POST)){

$errors='You must select help topic';

}

if(!$errors){

if($ticket->setHelpTopic($_POST)){

$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='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.options.value,'change_priority','reopen','overdue')?false;this.form.help_topic.disabled=strcmp(this.options.value,'change_help_topic')?false;"

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?'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?>" <?=$topicId==$row?'disabled':''?> ><?=$row?></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

3 months later

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

Problem solved

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?'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==$row?'disabled':''?> ><?=$row?></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!

9 days later

Thanks bawbagg, this works great for me.

Only had to add in viewticket.inc.php:

<option value="change_help_topic" <?=$info=='change_help_topic'?'selected':''?> >Change Help Topic</option>

after Select Action

8 days later

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 :).

I've not tried your fix as everything seems to work fine for me with my code above :)

BB

Write a Reply...