Default sorting by date (most recent) in admin_main.php

Everything related to Hesk - helpdesk software

Moderator: mkoch227

Post Reply
m4dbra1n
Posts: 60
Joined: Sun Oct 04, 2009 10:33 am

Default sorting by date (most recent) in admin_main.php

Post by m4dbra1n »

/*************************************
Title:
Version:
Author:
Demo:
Download:
Website:

Short description:

Hi,

default sorting in admin_main.php is by status.

How can I change the default sorting to date by most recent? Or to another field?

Thanks in advance ;)
Last edited by m4dbra1n on Tue Mar 02, 2010 5:53 pm, edited 1 time in total.
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

In print_tickets.inc.php change

Code: Select all

$sort = 'status';
Valid values are: 'trackid','lastchange','name','subject','status','lastreplier','priority','category','dt' (for date of creating) or 'id'
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
m4dbra1n
Posts: 60
Joined: Sun Oct 04, 2009 10:33 am

Post by m4dbra1n »

I've found it just some minute ago!

Thanks anyway Klemen ;)
m4dbra1n
Posts: 60
Joined: Sun Oct 04, 2009 10:33 am

Post by m4dbra1n »

Sorry Klemen, but it just doesn't work.

They are not sorted.

How can I fix it?

What have I to change here?

It goes OK if I click on the lastchange field title (ULTIMO AGGIORNAMENTO for me)

Code: Select all

/* Acceptable $sort values */
$sort_possible = array('trackid','lastchange','name','subject','status','priority','category','dt','id');

if (isset($_GET['sort']) && in_array($_GET['sort'],$sort_possible))
{
	$sort = hesk_input($_GET['sort']);
    $sql .= ' ORDER BY `'.hesk_dbEscape($sort).'` ';
}
else
{
    $sql .= ' ORDER BY `status` ASC, `priority`';
    $sort = 'dt';   <-- changed as you said to me
}

if (isset($_GET['asc']) && $_GET['asc']==0)
{
    $sql .= ' DESC ';
    $asc = 0;
    $asc_rev = 1;
}
else
{
    $sql .= ' ASC ';
    $asc = 1;
    $asc_rev = 0;
    if (!isset($_GET['asc']))
    {
    	$is_default = 1;
    }
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

In this case you are trying to sort by last modified, so you should use 'lastchange' not 'dt' (dt sorts by date created).
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
m4dbra1n
Posts: 60
Joined: Sun Oct 04, 2009 10:33 am

Post by m4dbra1n »

In that way works like a charm!

Thanks man ;)
m4dbra1n
Posts: 60
Joined: Sun Oct 04, 2009 10:33 am

Post by m4dbra1n »

Hi everyone,

now that I'm using it in a hard way, I've found a bug regarding the sorting of the tickets.

Now I'm having approximately 70 tickets in 4 pages, showing 20 tickets per page.

Since I want them to be sorted by the most recent, if I click on the page, they magically don't mantain the sorting; if i came back to home they re-take the sorting as I want.

How can I make them remain sorted by the most recent? Maybe have I to change something in the print_tickets.inc.php?

Thanks in advance to everyone will help me :wink:
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

There's a little bug when it comes to sorting tickets in version 2.1, that's what you're experiencing probably. The issue has been addressed in Hesk 2.2 which should be released in early May.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
m4dbra1n
Posts: 60
Joined: Sun Oct 04, 2009 10:33 am

Post by m4dbra1n »

FINALLY I'VE MADE IT!

Around line 120 I have made this:

Code: Select all

/* Acceptable $sort values */
$sort_possible = array('trackid','lastchange','name','subject','status','category','dt','id');

if (isset($_GET['sort']) && in_array($_GET['sort'],$sort_possible))
{
	$sort = hesk_input($_GET['sort']);
    $sql .= ' ORDER BY `'.hesk_dbEscape($sort).'` ';
}
else
{
    $sql .= ' ORDER BY `lastchange` DESC, `name`';
    $sort = 'lastchange';
}

if (isset($_GET['asc']) && $_GET['asc']==0)
{
    $sql .= ' DESC ';
    $asc = 0;
    $asc_rev = 1;
}

//lines as comment to make sort work
/*else
{
    $sql .= ' ASC ';
    $asc = 1;
    $asc_rev = 0;
    if (!isset($_GET['asc']))
    {
    	$is_default = 1;
    }
}
*/
Hope this helps ;)
Post Reply