Hello everybody,

I would like to change order of ticket thread. Now I see messages and replies from the oldest to the newest. Is it possible to reverse it?

Thank you.

Piotr

yep, just a single addition to the sql query

In $base_dir/include/staff/viewticket.inc.php

If you want to change the 'internal notes' to be the way then edit starting on line 229 (using current 1.6rc5 without any mods)

change this sql query...

//get messages

$sql='SELECT msg.msg_id,msg.created,msg.message,count(attach_id) as attachments FROM '.TICKET_MESSAGE_TABLE.' msg '.

' LEFT JOIN '.TICKET_ATTACHMENT_TABLE." attach ON msg.ticket_id=attach.ticket_id AND msg.msg_id=attach.ref_id AND ref_type='M' ".

' WHERE msg.ticket_id='.db_input($id).

' GROUP BY msg.msg_id ORDER BY created';

to this...

//get messages

$sql='SELECT msg.msg_id,msg.created,msg.message,count(attach_id) as attachments FROM '.TICKET_MESSAGE_TABLE.' msg '.

' LEFT JOIN '.TICKET_ATTACHMENT_TABLE." attach ON msg.ticket_id=attach.ticket_id AND msg.msg_id=attach.ref_id AND ref_type='M' ".

' WHERE msg.ticket_id='.db_input($id).

' GROUP BY msg.msg_id ORDER BY created DESC';

then to change the order of the 'Ticket Thread' start editing on line 245

change the sql query from this...

//get answers for messages

$sql='SELECT resp.*,count(attach_id) as attachments FROM '.TICKET_RESPONSE_TABLE.' resp '.

' LEFT JOIN '.TICKET_ATTACHMENT_TABLE." attach ON resp.ticket_id=attach.ticket_id AND resp.response_id=attach.ref_id AND ref_type='R' ".

' WHERE msg_id='.db_input($msg_row).' AND resp.ticket_id='.db_input($id).

' GROUP BY resp.response_id ORDER BY created';

to this...

//get answers for messages

$sql='SELECT resp.*,count(attach_id) as attachments FROM '.TICKET_RESPONSE_TABLE.' resp '.

' LEFT JOIN '.TICKET_ATTACHMENT_TABLE." attach ON resp.ticket_id=attach.ticket_id AND resp.response_id=attach.ref_id AND ref_type='R' ".

' WHERE msg_id='.db_input($msg_row).' AND resp.ticket_id='.db_input($id).

' GROUP BY resp.response_id ORDER BY created DESC';

Another minor mod that goes nicely with this

I also like to NOT show internal notes by default. The link for internal notes is there with the number of updates... clicking on it shows the... seems good enough for me. This is a super simple html/javascript change.

Change line 211

to this

If you make the changes above and this one... the first thing you see in the ticket is the latest reply or outgoing message. When tickets get longer this is a lot more convenient.

Hi,

Thank you for answer and the code.

Unfortunaltely it doesn't work for replies. Now there is a mess - requestst are from the newest to the oldest, but ansers are form thr olders to the newest.

I am not php programmer, so I do not know what to change in your code.

Do you have some solutions for this?

Thank you in advance.

Piotr

9 years later

Thread is 9 years old...
Killing zombie thread with a head shot.

Write a Reply...