If any items are checked out, the return date is treated as text instead of a date, so it's sorted month first, even across years.
Created attachment 5874 [details] screenshot
Created attachment 5877 [details] [review] Proposed fix The return column sort was not using the right sort algorithm because it was confused by the combination of date data and text data ("Checked out"). I've added an explicit instruction to sort by date. The downside to this change is that checked out items are sorted with the oldest checkouts rather than the newest: Checked Out Checked Out 10/14/1988 07/14/2005 Not perfect, but an improvement over completely incorrect sorting. This patch also adds the necessary check for system dateformat preference to properly sort metric dates.
Created attachment 5891 [details] [review] [SIGNED-OFF] Fix for Bug 7019 - Circulation History Sort Order Wrong The return column sort was not using the right sort algorithm because it was confused by the combination of date data and text data ("Checked out"). I've added an explicit instruction to sort by date. The downside to this change is that checked out items are sorted with the oldest checkouts rather than the newest: Checked Out Checked Out 10/14/1988 07/14/2005 Not perfect, but an improvement over completely incorrect sorting. This patch also adds the necessary check for system dateformat preference to properly sort metric dates. Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com>
Template-only changes, string-free, improves sorting. While not perfect, it's MUCH better than what we had, so marking as Passed QA.
Pushed, please test
Using Koha 3.08.03 with Systempref dateformat= dd/mm/yyyy the date are not well sorted. If I change it to yyyy/mm/dd it's OK.
Very odd, datatables.js method "dt_add_type_uk_date" does not use UK format "MM/DD/YYYY" but metric format "DD/MM/YYYY".
Still an issue in 3.8.8. Nicole
(In reply to comment #7) > Very odd, datatables.js method "dt_add_type_uk_date" does not use UK format > "MM/DD/YYYY" but metric format "DD/MM/YYYY". My coworkers explained me : UK = metric format (for dates only), it is US format who is "MM/DD/YYYY".
Datatables looks for datas to choose the default sort algorithm. When looking at Checked Out and dates, it will use alphabetical sort algorithm. Date format must be forced for metric ('uk_date') AND us format ('date'). Note that ISO format sorted by alphabetical order is correct.
Created attachment 15589 [details] [review] Proposed patch (3.11) Proposed patch for actual master (3.11.00.018). Bug is the same but technically the table uses now JQuery datatables. Ths patch forces date format for US and UK formats. See commit message
Created attachment 15710 [details] [review] [SIGNED-OFF] Bug 7019: Circulation History Sort Order Wrong (in datatable) The return column sort is using the right sort algorithm because it was confused by the combination of date data and text data ("Checked out"). This patch adds an explicit instruction to sort by date for UK and US formats. Test plan : - set dateformat syspref to "dd/mm/yyyy" - Go to members/readingrec.pl for a borrower having a old issues and checked out issues => Check that sort of "Return date" is correct. For example : With patch : 20/01/2011 06/03/2011 20/03/2011 Checked Out Without patch : 06/03/2011 20/01/2011 20/03/2011 Checked Out - Test also with dateformat syspref "mm/dd/yyyy" Signed-off-by: Owen Leonard <oleonard@myacpl.org>
QA Comment: I have the strong impression that this is already fixed in master. Probably by the dt_add_type_uk_date stuff? Just test in current master with dd/mm/yy. If it would sort alphabetically, it would not sort right but it does on date. Same for mm/dd/yy. Please clarify.
> Comment 13 Had you a checked out row in circulation history ? It is this text "Checked Out" which, even with dt_add_type_uk_date stuff, prevents the library from sorting by date because column does not contain only dates. You should see that "Date due" column sorting is always fine whereas "Return date" not when having some "Checked Out".
Fridolyn, I reproduce the issue and your patch fixes something, but it is not perfect. I got: Checked Out 20/04/2012 13/04/2012 19/03/2013 Checked Out 12/09/2012 Checked Out 12/09/2012 12/09/2012 In fact when the sort plugin find something else than a date, it get all mixed up. But try (members/readingrec.tt ~l.83): - [% issue.returndate | $KohaDates %] + <span title="[% issue.returndate %]">[% issue.returndate | $KohaDates %]</span> It works for me.
Created attachment 19549 [details] [review] Proposed patch (revisited) Here is the patch with title argument. See commit message for more details.
Created attachment 19707 [details] [review] [SIGNED-OFF] Bug 7019: Circulation History Sort Order Wrong (in datatable) The "return date" column sort is not using the date sort algorithm because it is confused by the combination of date data and text data ("Checked out"). This patch adds the use of datatable "title-string" sort type. With that, the date in ISO format are used for sorting and because letters are before numbers, "Checked out" rows are more recent than any date. Test plan : - set dateformat syspref to "dd/mm/yyyy" - Go to members/readingrec.pl for a borrower having a old issues and checked out issues => Check that sort of "Return date" is correct. For example : With patch : 20/01/2011 06/03/2011 20/03/2011 Checked Out Without patch : 06/03/2011 20/01/2011 20/03/2011 Checked Out - Test also with dateformat syspref "mm/dd/yyyy" Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
QA comment: The last patch works great. Marked as Passed QA.
Created attachment 19723 [details] [review] Bug 7019: Circulation History Sort Order Wrong (in datatable) The "return date" column sort is not using the date sort algorithm because it is confused by the combination of date data and text data ("Checked out"). This patch adds the use of datatable "title-string" sort type. With that, the date in ISO format are used for sorting and because letters are before numbers, "Checked out" rows are more recent than any date. Test plan : - set dateformat syspref to "dd/mm/yyyy" - Go to members/readingrec.pl for a borrower having a old issues and checked out issues => Check that sort of "Return date" is correct. For example : With patch : 20/01/2011 06/03/2011 20/03/2011 Checked Out Without patch : 06/03/2011 20/01/2011 20/03/2011 Checked Out - Test also with dateformat syspref "mm/dd/yyyy" Signed-off-by: Srdjan <srdjan@catalyst.net.nz> Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Pushed to master. Thanks, Fridolyn!
This patch has been pushed to 3.12.x, will be in 3.12.4. Thanks Fridolyn!
Would it be possible to have it in 3.10.x ?
Created attachment 22305 [details] [review] Bug 7019: [3.10.x] Circulation History Sort Order Wrong (in datatable) The "return date" column sort is not using the date sort algorithm because it is confused by the combination of date data and text data ("Checked out"). This patch adds the use of datatable "title-string" sort type. With that, the date in ISO format are used for sorting and because letters are before numbers, "Checked out" rows are more recent than any date. Test plan : - set dateformat syspref to "dd/mm/yyyy" - Go to members/readingrec.pl for a borrower having a old issues and checked out issues => Check that sort of "Return date" is correct. For example : With patch : 20/01/2011 06/03/2011 20/03/2011 Checked Out Without patch : 06/03/2011 20/01/2011 20/03/2011 Checked Out - Test also with dateformat syspref "mm/dd/yyyy"