Jump to content

Can you sort the To-Do List?


Vox

Recommended Posts

Hi Guys,

Does anyone know if you can sort the To-Do List?

I rarely use this but have just noticed that it is ordered showing the most distant tasks first and the upcoming one's last (see screenshot).

I nearly missed an action as it was below the break in the widget display and hence not showing!

I would prefer to see the what is coming up imminently rather than what is required in 2 months time..

 

To-Do List.jpg

Link to comment
Share on other sites

I'm not aware of any way to do this in settings, but it should be possible to alter the query which the widget code uses to get the list of to-do items so that the ones you want are displayed. The widget code uses the local API to fetch the to-do items so the order you're seeing seems to be what that returns (and I can't see options for sorting it), but if you changed it to use Capsule instead you could alter the query to return the ones with the closest due date. If you're making changes to the widget you should make a copy of the widget with a different name just like for template changes, so that it won't get overridden by WHMCS updates.

Edited by steph.hope
Link to comment
Share on other sites

49 minutes ago, steph.hope said:

it should be possible to alter the query which the widget code uses to get the list of to-do items

It *should* be, but it looks like the actual query might be behind encoded files. 
I also see a lot of inline CSS styling in those widget files, again defeating the most useful point of CSS. 😉 

Link to comment
Share on other sites

I'm no expert, but changing this line:

Quote

$toDo = localAPI('GetToDoItems', array('status' => 'Incomplete', 'limitstart' => 0, 'limitnum' => 11));

to:
    

Quote

$toDo = Capsule::table('tbltodolist')->whereIn('status', ['Incomplete', 'New', 'Pending'])->orderBy('duedate', 'asc')->take(11)->get();


   making sure to include Capsule at the top of the file and making some changes to deal with the different format of the results from Capsule vs localAPI:
    

Quote

foreach($toDo as &$item){
        $item = json_decode(json_encode($item), true);
    }

     return (isset($toDo)) ? $toDo : [];

Sorts the items by closest due date first. It'll need some more work on the query in order to deal with items without a due date - at the moment they appear first in the list, which probably isn't what you'd want. You could exclude them from the widget list altogether if they're not important to see at a glance?

Please, someone who's better at coding than me fix my inevitable mistakes before doing this though!

ETA: Original on right, reordered on left. Unfortunately 0000-00-00 is always the earliest due date...

Screenshot from 2020-07-23 11-08-15.png

Edited by steph.hope
add image
Link to comment
Share on other sites

4 hours ago, yggdrasil said:

Welcome to the world of closed source code for user frontends.

Exactly........close down the "back-end" if you must but please allow us "non-coders" to configure the product....😣

Link to comment
Share on other sites

On 22/07/2020 at 22:12, steph.hope said:

The widget code uses the local API to fetch the to-do items so the order you're seeing seems to be what that returns (and I can't see options for sorting it)

it returns an array and so all PHP sort options would be available to you.

not relevant to this, but if the existing results were just in the wrong order, you could reverse the array in the foreach and that would inverse the order... but as I say, that's not relevant because the API would just be returning the results as it finds them and not doing any date sorting.

On 23/07/2020 at 00:07, steph.hope said:

Please, someone who's better at coding than me fix my inevitable mistakes before doing this though!

personally, I might have used where('status', '<>', 'Complete') in the query as that should find all incomplete records and saves defining a list of the different potential statuses.... but apart from that, you've pretty much done it.

the no date issue can be fixed if necessary, and perhaps i'll address it if the enhanced ToDo widget below needs updating for v8 - it currently has no sorting, so it's just a more visual way of identifying existing items.

Link to comment
Share on other sites

  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated