From 5b971cff21996c881c35313a6233e9ef1c8d8a44 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Wed, 28 Feb 2024 05:28:57 +0000 Subject: [PATCH] Bug 36188: Sort lists by items.dateaccessioned in the OPAC WIP Sponsored-By: The Treasury, New Zealand --- .../bootstrap/en/modules/opac-shelves.tt | 18 ++++++++++++++++++ opac/opac-shelves.pl | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index 78c3c1de658..52545872b5e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -337,6 +337,19 @@ [% END %] + + [% IF sortfield == "dateaccessioned" && direction == 'asc' %] + + [% ELSE %] + + [% END %] + [% IF sortfield == "dateaccessioned" && direction == 'desc' %] + + + [% ELSE %] + + [% END %] + @@ -621,6 +634,11 @@ [% ELSE %] [% END %] + [% IF shelf.sortfield == "dateaccessioned" %] + + [% ELSE %] + + [% END %] [% IF Koha.Preference('OpacAllowPublicListCreation') OR public == 1 %] diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index 5cecfc7b969..7bed86f751d 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -147,7 +147,7 @@ if ( $op eq 'add_form' ) { if ( $shelf ) { $op = $referer; my $sortfield = $query->param('sortfield'); - $sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded ); + $sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned ); if ( $shelf->can_be_managed( $loggedinuser ) ) { $shelf->shelfname( scalar $query->param('shelfname') ); $shelf->sortfield( $sortfield ); @@ -313,7 +313,7 @@ if ( $op eq 'view' ) { } $direction = $query->param('direction') if $query->param('direction'); $direction = 'asc' if !$direction or ( $direction ne 'asc' and $direction ne 'desc' ); - $sortfield = 'title' if !$sortfield or !grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded ); + $sortfield = 'title' if !$sortfield or !grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned ); my ( $page, $rows ); unless ( $query->param('print') or $query->param('rss') ) { -- 2.20.1