From 52459cc0c0088d45c331644b111d72608e953f77 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 13 Nov 2014 09:54:45 -0500 Subject: [PATCH] Bug 13237 - Regression: List of previous checkouts should be ordered by due date ascending Before Bug 11703 the list of previous checkouts on a patrons account were ordered with the oldest checkouts first. Now previous checkouts are shown with the newest checkouts first, breaking a sorting default which has been in place for years. Note, the sorting of the checkouts was previously controlled by previousIssuesDefaultSortOrder & todaysIssuesDefaultSortOrder. These settings were taken into account in svc/checkouts but at some point the datatables took over the initial sorting, which broke the feature afaict. Test Plan: 1) Find a patron with a set of previous and today's checkouts 2) Note the system preferences previousIssuesDefaultSortOrder and todaysIssuesDefaultSortOrder are ignored for the initial sorting view. Also not the sorting by due date does not work correctly. 3) Apply this patch 4) Test both system preferences with each setting, note the correct sort order. 5) Sort the checkouts by due date, note the correct sort order. --- .../prog/en/includes/checkouts-table.inc | 7 ++++--- koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js | 16 ++++++++++++++-- svc/checkouts | 7 +++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc index fc6d4ed..94e90ac 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc @@ -9,9 +9,10 @@ - - - + + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js index e333776..bdd67aa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js @@ -159,6 +159,7 @@ $(document).ready(function() { "sDom": "<'row-fluid'<'span6'><'span6'>r>t<'row-fluid'>t", "aoColumns": [ { + "bVisible": false, "mDataProp": function( oObj ) { if ( oObj.issued_today ) { return "1" + oObj.timestamp; @@ -168,6 +169,7 @@ $(document).ready(function() { } }, { + "bVisible": false, "mDataProp": function( oObj ) { if ( oObj.issued_today ) { return "" + TODAYS_CHECKOUTS + ""; @@ -177,11 +179,21 @@ $(document).ready(function() { } }, { + "bVisible": false, "mDataProp": "date_due", + }, + { "bVisible": false, + "mDataProp": function( oObj ) { + if ( oObj.issued_today ) { + return "1" + oObj.sort_order; + } else { + return "0" + oObj.sort_order; + } + } }, { - "iDataSort": 1, // Sort on hidden unformatted date due column + "iDataSort": 0, // Sort on hidden unformatted date due column "mDataProp": function( oObj ) { if ( oObj.date_due_overdue ) { return "" + oObj.date_due_formatted + ""; @@ -379,7 +391,7 @@ $(document).ready(function() { }).rowGrouping( { iGroupingColumnIndex: 1, - iGroupingOrderByColumnIndex: 0, + iGroupingOrderByColumnIndex: 3, sGroupingColumnSortDirection: "desc" } ); diff --git a/svc/checkouts b/svc/checkouts index 9dc4881..ef66cd0 100755 --- a/svc/checkouts +++ b/svc/checkouts @@ -191,10 +191,17 @@ while ( my $c = $sth->fetchrow_hashref() ) { } } +my $i; + @checkouts_today = reverse(@checkouts_today) if ( C4::Context->preference('todaysIssuesDefaultSortOrder') eq 'desc' ); +$i = 0; +map { $_->{sort_order} = $i++ } @checkouts_today; + @checkouts_previous = reverse(@checkouts_previous) if ( C4::Context->preference('previousIssuesDefaultSortOrder') eq 'desc' ); +$i = 0; +map { $_->{sort_order} = $i++ } @checkouts_previous; my @checkouts = ( @checkouts_today, @checkouts_previous ); -- 1.7.2.5
  Due dateDate sorting (hidden)Today or previous (hidden)Due date, unformatted (hidden)Initial sort order (hidden) Due date Title Item type