From 7ac55bd88bbf9ba3349830d672ddebe5defcc7fb Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 5 Jan 2016 14:25:35 +0000 Subject: [PATCH] Bug 15337: Make itemtypes retrieved with GetItemTypes ordered by descriptions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Prior to this patch, the itemtypes were displayed ordered by the code (itemtypes.itemtype DB column). This patch will make them displayed by the description displayed (the translated description). Test plan: 0/ Do not apply this patch set 1/ Confirm that the itemtypes are displayed ordered by code (when adding an item, cataloguing/additem.pl) 2/ Confirm that t/db_dependent/Koha.t does not pass 3/ Apply the test patch 4/ Confirm that t/db_dependent/Koha.t pass 5/ Confirm that the itemtypes are not displayed by description (on additem.pl) See comment #3 Signed-off-by: Marc Véron Signed-off-by: Katrin Fischer Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com (cherry picked from commit 96ba9a0d6bc37c5a8d8e1edc29f5736230e9d68f) Signed-off-by: Julian Maurice --- C4/Koha.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 747610677f..32386a72f3 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -250,7 +250,6 @@ sub GetItemTypes { require C4::Languages; my $language = C4::Languages::getlanguage(); # returns a reference to a hash of references to itemtypes... - my %itemtypes; my $dbh = C4::Context->dbh; my $query = q| SELECT @@ -276,12 +275,13 @@ sub GetItemTypes { $sth->execute( $language ); if ( $style eq 'hash' ) { + my %itemtypes; while ( my $IT = $sth->fetchrow_hashref ) { $itemtypes{ $IT->{'itemtype'} } = $IT; } return ( \%itemtypes ); } else { - return $sth->fetchall_arrayref({}); + return [ sort { lc $a->{translated_description} cmp lc $b->{translated_description} } @{ $sth->fetchall_arrayref( {} ) } ]; } } -- 2.39.5