From 79061cd9a821d990d0ac2fa3d0aca10d26dc7684 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Wed, 28 Feb 2024 05:26:25 +0000 Subject: [PATCH] Bug 36188: Sort lists by Date acquired (items.dateaccessioned) in the staff client When a list is sorted by date acquired it should be ordered descending by default. This is to ensure the newest items are displayed first. Test plan: 1. Apply patches and restart services 2. Go to the Lists module and create a new list 3. Set the 'Sort this list by' dropdown = 'Date acquired' 4. Add several barcodes to the list belonging to items with a range of different items.dateaccessioned dates (952$d subfields) 5. Observe the list records are ordered by the 'Date acquired' column: - Records with the newest date acquired values displayed first. - The date acquired value for each title item record is listed in this column. 6. Switch to order date acquired ascending by clicking on the 'Date acquired' column label - records with the oldest date acquired should be displayed first. 7. Edit the list. Change the 'Sort this list by' dropdown to 'Title' 8. Notice the list records are ordered by the 'Title' column in an ascending order - A-Z alphabetically. Sponsored-By: The Treasury, New Zealand --- .../prog/en/modules/virtualshelves/shelves.tt | 25 +++++++++++++++++++ .../virtualshelves/tables/shelves_results.tt | 2 +- virtualshelves/shelves.pl | 16 +++++++++--- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt index 6fe89d86eb9..648ef73ce97 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -315,6 +315,14 @@ [% END %] Call number + [% IF sortfield == 'dateaccessioned' %] + + [% ELSE %] + + [% END %] + Date acquired + + [% FOREACH itemsloo IN itemsloop %] @@ -383,6 +391,17 @@ [% END # /FOREACH item %] + + + [% END #/FOREACH itemsloo %] @@ -452,6 +471,11 @@ [% ELSE %] [% END %] + [% IF shelf.sortfield == "dateaccessioned" %] + + [% ELSE %] + + [% END %]
  • @@ -526,6 +550,7 @@ + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt index de301479f3a..900bfdfbdcd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt @@ -20,7 +20,7 @@ "dt_owner": "[% d.firstname | html | $To %] [% d.surname | html | $To %]", "dt_sortby": - [% IF d.sortby == "author" %]"Author"[% ELSIF d.sortby == "copyrightdate" %]"Year"[% ELSIF d.sortby == "itemcallnumber" %]"Call number"[% ELSIF d.sortby == "dateadded" %]"Date added"[% ELSE %]"Title"[% END %], + [% IF d.sortby == "author" %]"Author"[% ELSIF d.sortby == "copyrightdate" %]"Year"[% ELSIF d.sortby == "itemcallnumber" %]"Call number"[% ELSIF d.sortby == "dateadded" %]"Date added"[% ELSIF d.sortby == "dateaccessioned" %]"Date acquired"[% ELSE %]"Title"[% END %], "dt_created_on": "[% d.created_on | $KohaDates %]", "dt_modification_time": diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index ecf08fa9c7e..d2580f14696 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -113,7 +113,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 ); @@ -271,9 +271,16 @@ if ( $op eq 'view' ) { if ( $shelf ) { if ( $shelf->can_be_viewed( $loggedinuser ) ) { my $sortfield = $query->param('sortfield') || $shelf->sortfield || 'title'; # Passed in sorting overrides default sorting - $sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded ); - my $direction = $query->param('direction') || 'asc'; - $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc'; + $sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned ); + + # If sorting by dateaccessioned set direction to descending by default + my $direction = $query->param('direction'); + if ( $sortfield eq 'dateaccessioned' and $direction ne 'asc' and $direction ne 'desc' ) { + $direction = 'desc'; + } elsif ( $direction ne 'asc' and $direction ne 'desc' ) { + $direction = 'asc'; + } + my ( $rows, $page ); unless ( $query->param('print') ) { $rows = C4::Context->preference('numSearchResults') || 20; @@ -317,6 +324,7 @@ if ( $op eq 'view' ) { $this_item->{part_name} = $biblio->part_name; $this_item->{author} = $biblio->author; $this_item->{dateadded} = $content->dateadded; + $this_item->{dateaccessioned} = $biblio->items->get_column("dateaccessioned"); $this_item->{imageurl} = $itemtype ? C4::Koha::getitemtypeimagelocation( 'intranet', $itemtype->imageurl ) : q{}; $this_item->{description} = $itemtype ? $itemtype->description : q{}; #FIXME Should this be translated_description ? $this_item->{notforloan} = $itemtype->notforloan if $itemtype; -- 2.20.1