Sort tickets by latest update

Forum dedicated to Mods for HESK created by Mike Koch

Moderator: mkoch227

Post Reply
fanta
Posts: 16
Joined: Wed Dec 16, 2009 11:00 am

Sort tickets by latest update

Post by fanta »

Hello,

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

Thanks.
mkoch227
Posts: 666
Joined: Wed Jul 04, 2012 3:37 pm

Re: Sort tickets by latest update

Post 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.
Mike, Lead Developer of Image HESK: A surprisingly simple, user-friendly and FREE help desk software with integrated knowledgebase.
fanta
Posts: 16
Joined: Wed Dec 16, 2009 11:00 am

Re: Sort tickets by latest update

Post by fanta »

Thank you for your reply, on which file is this change done?
mkoch227
Posts: 666
Joined: Wed Jul 04, 2012 3:37 pm

Re: Sort tickets by latest update

Post by mkoch227 »

Whoops, that might be helpful. The file is inc/prepare_ticket_search.inc.php
Mike, Lead Developer of Image HESK: A surprisingly simple, user-friendly and FREE help desk software with integrated knowledgebase.
fanta
Posts: 16
Joined: Wed Dec 16, 2009 11:00 am

Re: Sort tickets by latest update

Post by fanta »

Thanks, that was very helpful.
Post Reply