Page 1 of 1

Sort tickets by latest update

Posted: Sun Apr 26, 2015 11:56 am
by fanta
Hello,

How do I make the default ticket listing sorted by latest update?

Thanks.

Re: Sort tickets by latest update

Posted: Sun Apr 26, 2015 2:17 pm
by mkoch227
Around line 158, find:

Code: Select all

/* Default sorting by ticket status */
$sql .= ' `status` ';
$sort = 'status';
change to:

Code: Select all

/* Default sorting by ticket status */
$sql .= ' `lastchange` ';
$sort = 'lastchange';
This will return the oldest ticket on top with the newest update at the bottom. To reverse this, right below that, find:

Code: Select all

/* Ascending or Descending? */
if (isset($_GET['asc']) && intval($_GET['asc'])==0)
{
    $sql .= ' DESC ';
    $asc = 0;
    $asc_rev = 1;

    $sort_possible[$sort] = 1;
}
else
{
    $sql .= ' ASC ';
    $asc = 1;
    $asc_rev = 0;
    if (!isset($_GET['asc']))
    {
    	$is_default = 1;
    }

    $sort_possible[$sort] = 0;
}
and change to

Code: Select all

/* Ascending or Descending? */
if (isset($_GET['asc']) && intval($_GET['asc'])==1)
{
    $sql .= ' ASC ';
    $asc = 1;
    $asc_rev = 0;
    if (!isset($_GET['asc']))
    {
    	$is_default = 1;
    }

    $sort_possible[$sort] = 0;
}
else
{
    $sql .= ' DESC ';
    $asc = 0;
    $asc_rev = 1;

    $sort_possible[$sort] = 1;
}
Save, upload, and test.

Re: Sort tickets by latest update

Posted: Mon Apr 27, 2015 10:58 am
by fanta
Thank you for your reply, on which file is this change done?

Re: Sort tickets by latest update

Posted: Mon Apr 27, 2015 2:31 pm
by mkoch227
Whoops, that might be helpful. The file is inc/prepare_ticket_search.inc.php

Re: Sort tickets by latest update

Posted: Mon Apr 27, 2015 6:41 pm
by fanta
Thanks, that was very helpful.