From 16ab16f1916965d9e5443951a209a7831dcb21aa Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 3 Jan 2017 11:36:25 +0100 Subject: [PATCH] Bug 17835: Remove the subroutine GetItemTypes At this point the subroutine is no longer in used. Signed-off-by: Josef Moravec --- C4/Koha.pm | 86 +-------------------------------------------------- t/db_dependent/Koha.t | 11 +------ 2 files changed, 2 insertions(+), 95 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 2884267..af5a2f2 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -41,7 +41,7 @@ BEGIN { @ISA = qw(Exporter); @EXPORT = qw( &GetPrinters &GetPrinter - &GetItemTypes &getitemtypeinfo + &getitemtypeinfo &GetItemTypesCategorized &getallthemes &getFacets @@ -87,90 +87,6 @@ Koha.pm provides many functions for Koha scripts. =cut -=head2 GetItemTypes - - $itemtypes = &GetItemTypes( style => $style ); - -Returns information about existing itemtypes. - -Params: - style: either 'array' or 'hash', defaults to 'hash'. - 'array' returns an arrayref, - 'hash' return a hashref with the itemtype value as the key - -build a HTML select with the following code : - -=head3 in PERL SCRIPT - - my $itemtypes = GetItemTypes; - my @itemtypesloop; - foreach my $thisitemtype (sort keys %$itemtypes) { - my $selected = 1 if $thisitemtype eq $itemtype; - my %row =(value => $thisitemtype, - selected => $selected, - description => $itemtypes->{$thisitemtype}->{'description'}, - ); - push @itemtypesloop, \%row; - } - $template->param(itemtypeloop => \@itemtypesloop); - -=head3 in TEMPLATE - -
- - "> - -
- -=cut - -sub GetItemTypes { - my ( %params ) = @_; - my $style = defined( $params{'style'} ) ? $params{'style'} : 'hash'; - - require C4::Languages; - my $language = C4::Languages::getlanguage(); - # returns a reference to a hash of references to itemtypes... - my $dbh = C4::Context->dbh; - my $query = q| - SELECT - itemtypes.itemtype, - itemtypes.description, - itemtypes.rentalcharge, - itemtypes.notforloan, - itemtypes.imageurl, - itemtypes.summary, - itemtypes.checkinmsg, - itemtypes.checkinmsgtype, - itemtypes.sip_media_type, - itemtypes.hideinopac, - itemtypes.searchcategory, - COALESCE( localization.translation, itemtypes.description ) AS translated_description - FROM itemtypes - LEFT JOIN localization ON itemtypes.itemtype = localization.code - AND localization.entity = 'itemtypes' - AND localization.lang = ? - ORDER BY itemtype - |; - my $sth = $dbh->prepare($query); - $sth->execute( $language ); - - if ( $style eq 'hash' ) { - my %itemtypes; - while ( my $IT = $sth->fetchrow_hashref ) { - $itemtypes{ $IT->{'itemtype'} } = $IT; - } - return ( \%itemtypes ); - } else { - return [ sort { lc $a->{translated_description} cmp lc $b->{translated_description} } @{ $sth->fetchall_arrayref( {} ) } ]; - } -} - =head2 GetItemTypesCategorized $categories = GetItemTypesCategorized(); diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t index feb4a1c..b3f51e0 100644 --- a/t/db_dependent/Koha.t +++ b/t/db_dependent/Koha.t @@ -9,7 +9,7 @@ use Koha::DateUtils qw(dt_from_string); use Koha::AuthorisedValue; use Koha::AuthorisedValueCategories; -use Test::More tests => 8; +use Test::More tests => 7; use DateTime::Format::MySQL; BEGIN { @@ -294,13 +294,4 @@ subtest 'GetItemTypesCategorized test' => sub{ is_deeply(\@results,\@expected, 'GetItemTypesCategorized: grouped and ungrouped items returned as expected.'); }; -subtest 'GetItemTypes test' => sub { - plan tests => 1; - $dbh->do(q|DELETE FROM itemtypes|); - $dbh->do(q|INSERT INTO itemtypes(itemtype, description) VALUES ('a', 'aa desc'), ('b', 'zz desc'), ('d', 'dd desc'), ('c', 'yy desc')|); - my $itemtypes = C4::Koha::GetItemTypes( style => 'array' ); - $itemtypes = [ map { $_->{itemtype} } @$itemtypes ]; - is_deeply( $itemtypes, [ 'a', 'd', 'c', 'b' ], 'GetItemTypes(array) should return itemtypes ordered by description'); -}; - $dbh->rollback(); -- 2.1.4