From a7dd3ed764affafe92400839117aad4a9e0c881d Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Wed, 19 Apr 2017 11:27:45 +0000 Subject: [PATCH] Bug 12388: IssueSlip output should be sorted by date_due, not timestamp Sponsored-by: Koha-Suomi Oy Signed-off-by: Emmi Takkinen --- C4/Members.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 205f45bd7b..0edb8d8dc9 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -534,6 +534,11 @@ sub IssueSlip { lastreneweddate => { '>=' => $today_start, '<=' => $today_end, } } + }, { + order_by => [ + { -asc => 'date_due' }, + { -asc => 'issuedate' }, + ] } ); my @checkouts; @@ -557,7 +562,12 @@ sub IssueSlip { else { my $today = Koha::Database->new->schema->storage->datetime_parser->format_datetime( dt_from_string ); # Checkouts due in the future - my $checkouts = $pending_checkouts->search({ date_due => { '>' => $today } }); + my $checkouts = $pending_checkouts->search({ date_due => { '>' => $today } }, { + order_by => [ + { -asc => 'date_due' }, + { -asc => 'issuedate' }, + ] + }); my @checkouts; my @overdues; while ( my $c = $checkouts->next ) { my $all = $c->unblessed_all_relateds; @@ -570,7 +580,12 @@ sub IssueSlip { } # Checkouts due in the past are overdues - my $overdues = $pending_checkouts->search({ date_due => { '<=' => $today } }); + my $overdues = $pending_checkouts->search({ date_due => { '<=' => $today } }, { + order_by => [ + { -asc => 'date_due' }, + { -asc => 'issuedate' }, + ] + }); while ( my $o = $overdues->next ) { my $all = $o->unblessed_all_relateds; push @overdues, { -- 2.17.1