Bug 23427: Fix previous checkouts sort order

In patron circulation or details page, previous checkouts are displayed sorted by due date.
Actual sort order is not honoring system preference "previousIssuesDefaultSortOrder". Todays's checkouts is correct thanks to Bug 13908.

Patch adds comments that refer to the text of system preferences "previousIssuesDefaultSortOrder" and "TodayIssuesDefaultSortOrder" :
  latest to earliest = asc
  earliest to latest = desc

Test plan :
1) Create for a patron two old issues with a few days between them
2) Set preference previousIssuesDefaultSortOrder = "latest to earliest"
3) Go to patron circulation page and check sort order is OK
4) Go to patron details page and check sort order is OK
5) Set preference previousIssuesDefaultSortOrder = "earliest to latest"
6) Go to patron circulation page and check sort order is OK
7) Go to patron details page and check sort order is OK

Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 6b2d109315)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Fridolin Somers 2019-08-05 15:11:49 +02:00 committed by Lucas Gass
parent eb4af2c0cd
commit b373be4ab3
1 changed files with 4 additions and 4 deletions

View File

@ -239,13 +239,13 @@ while ( my $c = $sth->fetchrow_hashref() ) {
}
@checkouts_today = sort { $a->{timestamp} cmp $b->{timestamp} } @checkouts_today;
@checkouts_today = sort { $a->{timestamp} cmp $b->{timestamp} } @checkouts_today; # latest to earliest
@checkouts_today = reverse(@checkouts_today)
unless ( C4::Context->preference('todaysIssuesDefaultSortOrder') eq 'desc' );
unless ( C4::Context->preference('todaysIssuesDefaultSortOrder') eq 'desc' ); # earliest to latest
@checkouts_previous = sort { $a->{date_due} cmp $b->{date_due} } @checkouts_previous;
@checkouts_previous = sort { $a->{date_due} cmp $b->{date_due} } @checkouts_previous; # latest to earliest
@checkouts_previous = reverse(@checkouts_previous)
if ( C4::Context->preference('previousIssuesDefaultSortOrder') eq 'desc' );
unless ( C4::Context->preference('previousIssuesDefaultSortOrder') eq 'desc' ); # earliest to latest
my @checkouts = ( @checkouts_today, @checkouts_previous );