From 559c0054633f7c4a13b18b5a8ca41889a4caaff6 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 | 9 +++++-- 3 files changed, 33 insertions(+), 3 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 25929c88e82..1191910515c 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 %]
  • @@ -534,6 +558,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 e3e7a868e41..b15641a7ada 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -120,7 +120,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 ); @@ -278,9 +278,13 @@ 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 ); + $sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned ); my $direction = $query->param('direction') || 'asc'; $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc'; + + # If sorting by dateaccessioned set direction to descending by default + $direction = 'desc' if $sortfield eq 'dateaccessioned'; + my $rows; if ( $query->param('print') ) { $page = ""; @@ -326,6 +330,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.39.5