Page 1 of 1

Sort tickets by Status

Posted: Thu Nov 08, 2012 12:50 am
by steve
When sorting ticket, they are sorted numerically.

How can we sort the statuses by their name?

Here is an example

Status 1 = Open
Status 2 = Closed
Status 3 = Monitor

So if i sort by status, they will list as open, closed, monitor or the other way around which obviously is not alphabetical.

Re: Sort tickets by Status

Posted: Thu Nov 08, 2012 3:46 pm
by Klemen
Since the status names aren't in the database but numbers representing statuses, you would need a custom ORDER BY CASE query. Something like

Code: Select all

ORDER BY CASE status
                 WHEN '3' THEN 1
                 WHEN '4' THEN 2
                 WHEN '1' THEN 3
                 WHEN '0' THEN 4
                 WHEN '2' THEN 5
END
This would sort by status 3, 4, 1, 0 and last status 2.

Of course, you will need to modify this to fit your needs/exact status values and names.

Re: Sort tickets by Status

Posted: Thu Nov 08, 2012 4:08 pm
by steve
Thanks you!

Where am I to put this?

Re: Sort tickets by Status

Posted: Mon Nov 19, 2012 6:26 pm
by steve
Where does this need to be placed?

Re: Sort tickets by Status

Posted: Mon Nov 19, 2012 6:44 pm
by Klemen
The order by code is generated inside inc/prepare_ticket_search.inc.php, you will need to do some tweaking to fit the required order by correctly. The exact code is up to you I'm afraid as it's not officially supported.

Re: Sort tickets by Status

Posted: Thu Dec 06, 2012 9:45 am
by deserteagle369
The status and priority value are not stored in the table, made it difficult to manage it.

Re: Sort tickets by Status

Posted: Thu Dec 06, 2012 12:04 pm
by Klemen
Of course they are, just not as words (because these change with translations), but as digits representing them.

If you look inside "inc/print_tickets.inc.php" you will find these matching values:

Statuses:

Code: Select all

0 => 'NEW'
1 => 'WAITING REPLY'
2 => 'REPLIED'
3 => 'RESOLVED (CLOSED)'
4 => 'IN PROGRESS'
5 => 'ON HOLD'
Priority:

Code: Select all

0 => 'CRITICAL'
1 => 'HIGH'
2 => 'MEDIUM'
3 => 'LOW'

Re: Sort tickets by Status

Posted: Thu Dec 06, 2012 3:22 pm
by steve
Unfortunately, I was never able to make this work.