View | Details | Raw Unified | Return to bug 24975
Collapse All | Expand All

(-)a/C4/Biblio.pm (-16 / +9 lines)
Lines 1384-1398 sub GetAuthorisedValueDesc { Link Here
1384
1384
1385
    return q{} unless defined($value);
1385
    return q{} unless defined($value);
1386
1386
1387
    my $cache     = Koha::Caches->get_instance();
1388
    my $cache_key;
1389
    if ( !$category ) {
1387
    if ( !$category ) {
1390
1388
1391
        return $value unless defined $tagslib->{$tag}->{$subfield}->{'authorised_value'};
1389
        return $value unless defined $tagslib->{$tag}->{$subfield}->{'authorised_value'};
1392
1390
1393
        #---- branch
1391
        #---- branch
1394
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
1392
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
1395
            $cache_key = "libraries:name";
1393
            my $cache     = Koha::Caches->get_instance();
1394
            my $cache_key = "libraries:name";
1396
            my $libraries = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1395
            my $libraries = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1397
            if ( !$libraries ) {
1396
            if ( !$libraries ) {
1398
                $libraries = {
1397
                $libraries = {
Lines 1408-1428 sub GetAuthorisedValueDesc { Link Here
1408
1407
1409
        #---- itemtypes
1408
        #---- itemtypes
1410
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
1409
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
1411
            my $lang = C4::Languages::getlanguage;
1410
            my $itemtype = Koha::ItemType->get_from_cache($value);
1412
            $lang //= 'en';
1411
            # FIXME Should we raise an error if the item type does not exist?
1413
            $cache_key = 'itemtype:description:' . $lang;
1412
            return $itemtype ? db_t('itemtype', $itemtype->{translation_key}) : q{};
1414
            my $itypes = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1415
            if ( !$itypes ) {
1416
                $itypes =
1417
                  { map { $_->itemtype => $_->translated_description }
1418
                      Koha::ItemTypes->search()->as_list };
1419
                $cache->set_in_cache( $cache_key, $itypes );
1420
            }
1421
            return $itypes->{$value};
1422
        }
1413
        }
1423
1414
1424
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "cn_source" ) {
1415
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "cn_source" ) {
1425
            $cache_key = "cn_sources:description";
1416
            my $cache = Koha::Caches->get_instance();
1417
            my $cache_key = "cn_sources:description";
1426
            my $cn_sources = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1418
            my $cn_sources = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1427
            if ( !$cn_sources ) {
1419
            if ( !$cn_sources ) {
1428
                $cn_sources = {
1420
                $cn_sources = {
Lines 1442-1448 sub GetAuthorisedValueDesc { Link Here
1442
1434
1443
    my $dbh = C4::Context->dbh;
1435
    my $dbh = C4::Context->dbh;
1444
    if ( $category ne "" ) {
1436
    if ( $category ne "" ) {
1445
        $cache_key = "AV_descriptions:" . $category;
1437
        my $cache     = Koha::Caches->get_instance();
1438
        my $cache_key = "AV_descriptions:" . $category;
1446
        my $av_descriptions = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1439
        my $av_descriptions = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1447
        if ( !$av_descriptions ) {
1440
        if ( !$av_descriptions ) {
1448
            $av_descriptions = {
1441
            $av_descriptions = {
(-)a/C4/Items.pm (-1 lines)
Lines 61-67 use Koha::Database; Link Here
61
61
62
use Koha::Biblios;
62
use Koha::Biblios;
63
use Koha::Biblioitems;
63
use Koha::Biblioitems;
64
use Koha::I18N;
65
use Koha::Items;
64
use Koha::Items;
66
use Koha::ItemTypes;
65
use Koha::ItemTypes;
67
use Koha::SearchEngine;
66
use Koha::SearchEngine;
(-)a/C4/Search.pm (-22 / +15 lines)
Lines 284-290 sub SimpleSearch { Link Here
284
( undef, $results_hashref, \@facets_loop ) = getRecords (
284
( undef, $results_hashref, \@facets_loop ) = getRecords (
285
285
286
        $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
286
        $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
287
        $results_per_page, $offset,       $branches,       $itemtypes,
287
        $results_per_page, $offset,       $branches,
288
        $query_type,       $scan,         $opac
288
        $query_type,       $scan,         $opac
289
    );
289
    );
290
290
Lines 298-304 See verbose embedded documentation. Link Here
298
sub getRecords {
298
sub getRecords {
299
    my (
299
    my (
300
        $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
300
        $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
301
        $results_per_page, $offset,       $branches,         $itemtypes,
301
        $results_per_page, $offset,       $branches,
302
        $query_type,       $scan,         $opac
302
        $query_type,       $scan,         $opac
303
    ) = @_;
303
    ) = @_;
304
304
Lines 411-416 sub getRecords { Link Here
411
        }
411
        }
412
    }    # finished looping through servers
412
    }    # finished looping through servers
413
413
414
    my $itemtypes = Koha::ItemTypes->get_from_cache;
415
    my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes };
416
414
    # The big moment: asynchronously retrieve results from all servers
417
    # The big moment: asynchronously retrieve results from all servers
415
        _ZOOM_event_loop(
418
        _ZOOM_event_loop(
416
            \@zconns,
419
            \@zconns,
Lines 533-545 sub getRecords { Link Here
533
536
534
                      # if it's a itemtype, label by the name, not the code,
537
                      # if it's a itemtype, label by the name, not the code,
535
                            if ( $link_value =~ /itype/ ) {
538
                            if ( $link_value =~ /itype/ ) {
536
                                if (   defined $itemtypes
539
                                if ( exists $itemtypes->{$one_facet} ) {
537
                                    && ref($itemtypes) eq "HASH"
540
                                    $facet_label_value = db_t('itemtype', $itemtypes->{$one_facet}->{translation_key});
538
                                    && defined $itemtypes->{$one_facet}
539
                                    && ref( $itemtypes->{$one_facet} ) eq
540
                                    "HASH" )
541
                                {
542
                                    $facet_label_value = db_t('itemtype', $itemtypes->{$one_facet}->{itemtype});
543
                                }
541
                                }
544
                            }
542
                            }
545
543
Lines 1669-1676 sub searchResults { Link Here
1669
    my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef;
1667
    my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef;
1670
1668
1671
    #Get itemtype hash
1669
    #Get itemtype hash
1672
    my $itemtypes = Koha::ItemTypes->search;
1670
    my $itemtypes = Koha::ItemTypes->get_from_cache;
1673
    my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes->unblessed };
1671
    my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes };
1674
1672
1675
    #search item field code
1673
    #search item field code
1676
    my ($itemtag, undef) = &GetMarcFromKohaField( "items.itemnumber" );
1674
    my ($itemtag, undef) = &GetMarcFromKohaField( "items.itemnumber" );
Lines 1748-1757 sub searchResults { Link Here
1748
        $oldbiblio->{edition} = $oldbiblio->{editionstatement};
1746
        $oldbiblio->{edition} = $oldbiblio->{editionstatement};
1749
1747
1750
        my $itemtype = $oldbiblio->{itemtype} ? $itemtypes{$oldbiblio->{itemtype}} : undef;
1748
        my $itemtype = $oldbiblio->{itemtype} ? $itemtypes{$oldbiblio->{itemtype}} : undef;
1751
        # add imageurl to itemtype if there is one
1749
1752
        $oldbiblio->{imageurl} = $itemtype ? getitemtypeimagelocation( $search_context->{'interface'}, $itemtype->{imageurl} ) : q{};
1750
        $oldbiblio->{itemtype} = $itemtype;
1753
        # Build summary if there is one (the summary is defined in the itemtypes table)
1754
        $oldbiblio->{description} = $itemtype ? db_t('itemtype', $itemtype->{itemtype}) : q{};
1755
1751
1756
        # Pull out the items fields
1752
        # Pull out the items fields
1757
        my @fields = $marcrecord->field($itemtag);
1753
        my @fields = $marcrecord->field($itemtag);
Lines 1823-1829 sub searchResults { Link Here
1823
                next;
1819
                next;
1824
            }
1820
            }
1825
1821
1826
            $item->{description} = db_t('itemtype', $itemtypes{ $item->{itype} }{itemtype}) if $item->{itype};
1822
            $item->{itemtype} = $itemtypes{ $item->{itype} } if $item->{itype};
1827
1823
1828
            # OPAC hidden items
1824
            # OPAC hidden items
1829
            if ($is_opac) {
1825
            if ($is_opac) {
Lines 1865-1873 sub searchResults { Link Here
1865
                $onloan_items->{$key}->{branchname}     = $item->{branchname};
1861
                $onloan_items->{$key}->{branchname}     = $item->{branchname};
1866
                $onloan_items->{$key}->{location}       = $shelflocations->{ $item->{location} } if $item->{location};
1862
                $onloan_items->{$key}->{location}       = $shelflocations->{ $item->{location} } if $item->{location};
1867
                $onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber};
1863
                $onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber};
1868
                $onloan_items->{$key}->{description}    = $item->{description};
1864
                $onloan_items->{$key}->{itemtype}       = $itemtypes{ $item->{itype} };
1869
                $onloan_items->{$key}->{imageurl} =
1870
                  getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype} }->{imageurl} );
1871
1865
1872
                # if something's checked out and lost, mark it as 'long overdue'
1866
                # if something's checked out and lost, mark it as 'long overdue'
1873
                if ( $item->{itemlost} ) {
1867
                if ( $item->{itemlost} ) {
Lines 1965-1972 sub searchResults { Link Here
1965
                    $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan};
1959
                    $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan};
1966
                    $other_items->{$key}->{count}++ if $item->{$hbranch};
1960
                    $other_items->{$key}->{count}++ if $item->{$hbranch};
1967
                    $other_items->{$key}->{location} = $shelflocations->{ $item->{location} } if $item->{location};
1961
                    $other_items->{$key}->{location} = $shelflocations->{ $item->{location} } if $item->{location};
1968
                    $other_items->{$key}->{description} = $item->{description};
1962
                    $other_items->{$key}->{itemtype} = $itemtypes{ $item->{itype} };
1969
                    $other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype}//q{} }->{imageurl} );
1970
                }
1963
                }
1971
                # item is available
1964
                # item is available
1972
                else {
1965
                else {
Lines 1976-1982 sub searchResults { Link Here
1976
                        $available_items->{$prefix}->{$_} = $item->{$_};
1969
                        $available_items->{$prefix}->{$_} = $item->{$_};
1977
                    }
1970
                    }
1978
                    $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} } if $item->{location};
1971
                    $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} } if $item->{location};
1979
                    $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype}//q{} }->{imageurl} );
1972
                    $available_items->{$prefix}->{itemtype} = $itemtypes{ $item->{itype} };
1980
                }
1973
                }
1981
            }
1974
            }
1982
        }    # notforloan, item level and biblioitem level
1975
        }    # notforloan, item level and biblioitem level
(-)a/Koha/I18N.pm (-2 / +2 lines)
Lines 2-8 package Koha::I18N; Link Here
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
5
# Copyright 2012-2014 BibLibre
5
# Copyright 2012-2023 BibLibre
6
# Copyright 2023 Koha Development Team
6
#
7
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# under the terms of the GNU General Public License as published by
Lines 241-247 sub db_t { Link Here
241
242
242
    my $cache = Koha::Caches->get_instance();
243
    my $cache = Koha::Caches->get_instance();
243
    unless ($cache->is_cache_active) {
244
    unless ($cache->is_cache_active) {
244
        warn "Using Koha::Cache::Memory::Lite";
245
        $cache = Koha::Cache::Memory::Lite->get_instance();
245
        $cache = Koha::Cache::Memory::Lite->get_instance();
246
    }
246
    }
247
247
(-)a/Koha/ItemType.pm (-19 / +11 lines)
Lines 27-34 use Koha::I18N; Link Here
27
27
28
use base qw(Koha::Object Koha::Object::Limit::Library);
28
use base qw(Koha::Object Koha::Object::Limit::Library);
29
29
30
my $cache = Koha::Caches->get_instance();
31
32
=head1 NAME
30
=head1 NAME
33
31
34
Koha::ItemType - Koha Item type Object class
32
Koha::ItemType - Koha Item type Object class
Lines 48-69 ItemType specific store to ensure relevant caches are flushed on change Link Here
48
sub store {
46
sub store {
49
    my ($self) = @_;
47
    my ($self) = @_;
50
48
51
    my $flush = 0;
49
    Koha::Caches->get_instance('itemtypes')->flush_all;
52
53
    if ( !$self->in_storage ) {
54
        $flush = 1;
55
    }
56
    else {
57
        my $self_from_storage = $self->get_from_storage;
58
        $flush = 1 if ( $self_from_storage->description ne $self->description );
59
    }
60
61
    $self = $self->SUPER::store;
62
63
    if ($flush) {
64
        my $key = "itemtype:description:en";
65
        $cache->clear_from_cache($key);
66
    }
67
50
68
    return $self;
51
    return $self;
69
}
52
}
Lines 76-82 ItemType specific C<delete> to clear relevant caches on delete. Link Here
76
59
77
sub delete {
60
sub delete {
78
    my $self = shift @_;
61
    my $self = shift @_;
79
    $cache->clear_from_cache('itemtype:description:en');
62
63
    Koha::Caches->get_instance('itemtypes')->flush_all;
64
80
    $self->SUPER::delete(@_);
65
    $self->SUPER::delete(@_);
81
}
66
}
82
67
Lines 106-111 sub translation_key { Link Here
106
    return $self->itemtype;
91
    return $self->itemtype;
107
}
92
}
108
93
94
sub get_from_cache {
95
    my ( $class, $itemtype ) = @_;
96
    my @itemtypes = @{Koha::ItemTypes->get_from_cache};
97
    my ( $cached ) = grep {($_->{itemtype} eq $itemtype) ? $_ : ()} @itemtypes;
98
    return $cached;
99
}
100
109
=head3 image_location
101
=head3 image_location
110
102
111
=cut
103
=cut
(-)a/Koha/ItemTypes.pm (-4 / +45 lines)
Lines 17-26 package Koha::ItemTypes; Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
20
use Koha::Caches;
21
use C4::Languages;
22
23
use Koha::Database;
24
use Koha::ItemType;
21
use Koha::ItemType;
25
22
26
use base qw(Koha::Objects Koha::Objects::Limit::Library);
23
use base qw(Koha::Objects Koha::Objects::Limit::Library);
Lines 31-36 Koha::ItemTypes - Koha ItemType Object set class Link Here
31
28
32
=head1 API
29
=head1 API
33
30
31
=head2 Class Methods
32
33
=head3 get_from_cache
34
35
  my $itemtypes = Koha::ItemTypes->get_from_cache([{ library_limit => $library_id } ]);
36
37
Returns an array of hashrefs representing itemtypes.
38
39
A library_limit parameter can be passed to limit the result to a given library.
40
41
The translation_key and image_location are added to the list of item type's attributes
42
43
=cut
44
45
sub get_from_cache {
46
    my ($self, $params) = @_;
47
48
    my $library_limit =
49
      ( $params && $params->{library_limit} )
50
      ? $params->{library_limit} || q{}
51
      : q{};
52
53
    my $cache     = Koha::Caches->get_instance('itemtypes');
54
    my $cache_key = "ItemTypes:$library_limit";
55
    my $cached    = $cache->get_from_cache($cache_key);
56
    return $cached if $cached;
57
58
    my $itemtypes = $library_limit
59
      ? $self->search_with_library_limits(
60
        undef, undef, $params->{library_limit} )
61
        : $self->search;
62
63
    return [
64
        map {
65
            {
66
                %{ $_->unblessed },
67
                  translation_key      => $_->translation_key,
68
                  image_location_opac  => $_->image_location('opac'),
69
                  image_location_staff => $_->image_location('intranet'),
70
            }
71
        } $itemtypes->as_list
72
    ];
73
}
74
34
=head2 Internal methods
75
=head2 Internal methods
35
76
36
=head3 type
77
=head3 type
(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (-3 / +3 lines)
Lines 138-144 sub count { Link Here
138
138
139
    my ( $error, $results, $facets ) = $search->search_compat(
139
    my ( $error, $results, $facets ) = $search->search_compat(
140
        $query,            $simple_query, \@sort_by,       \@servers,
140
        $query,            $simple_query, \@sort_by,       \@servers,
141
        $results_per_page, $offset,       undef,           $item_types,
141
        $results_per_page, $offset,       undef,
142
        $query_type,       $scan
142
        $query_type,       $scan
143
      )
143
      )
144
144
Lines 152-158 sub search_compat { Link Here
152
    my (
152
    my (
153
        $self,       $query,            $simple_query, $sort_by,
153
        $self,       $query,            $simple_query, $sort_by,
154
        $servers,    $results_per_page, $offset,       $branches,
154
        $servers,    $results_per_page, $offset,       $branches,
155
        $item_types, $query_type,       $scan
155
        $query_type,       $scan
156
    ) = @_;
156
    ) = @_;
157
157
158
    if ( $scan ) {
158
    if ( $scan ) {
Lines 471-477 sub _convert_facets { Link Here
471
    my @locations = Koha::AuthorisedValues->search( { category => 'LOC' } )->as_list;
471
    my @locations = Koha::AuthorisedValues->search( { category => 'LOC' } )->as_list;
472
    my $opac = C4::Context->interface eq 'opac' ;
472
    my $opac = C4::Context->interface eq 'opac' ;
473
    my %special = (
473
    my %special = (
474
        itype    => { map { $_->itemtype         => $_->description } @itypes },
474
        itype    => { map { $_->itemtype         => $_->translated_description } @itypes },
475
        location => { map { $_->authorised_value => ( $opac ? ( $_->lib_opac || $_->lib ) : $_->lib ) } @locations },
475
        location => { map { $_->authorised_value => ( $opac ? ( $_->lib_opac || $_->lib ) : $_->lib ) } @locations },
476
        holdingbranch => $library_names,
476
        holdingbranch => $library_names,
477
        homebranch => $library_names
477
        homebranch => $library_names
(-)a/Koha/Template/Plugin/ItemTypes.pm (-2 / +22 lines)
Lines 32-42 sub GetDescription { Link Here
32
    return q{} unless defined $itemtype;
32
    return q{} unless defined $itemtype;
33
    my $parent;
33
    my $parent;
34
    $parent = $itemtype->parent if $want_parent;
34
    $parent = $itemtype->parent if $want_parent;
35
    return $parent ? $self->t($parent->description) . "->" . $self->t($itemtype->description) : $self->t($itemtype->description);
35
    return $parent ? $self->t($parent->translation_key) . "->" . $self->t($itemtype->translation_key) : $self->t($itemtype->translation_key);
36
}
36
}
37
37
38
sub Get {
38
sub Get {
39
    return Koha::ItemTypes->search->unblessed;
39
    return Koha::ItemTypes->get_from_cache;
40
}
41
42
sub GetSorted {
43
    my ( $self ) = @_;
44
45
    my $itemtypes = [
46
        map {
47
            {
48
                %$_,
49
                  translated_description =>
50
                  db_t( 'itemtype', $_->{translation_key} )
51
            }
52
        } @{Koha::ItemTypes->get_from_cache}
53
    ];
54
55
    return [
56
        sort {
57
            $self->t( $a->{translation_key} ) cmp $self->t( $b->{translation_key} )
58
        } @$itemtypes
59
    ];
40
}
60
}
41
61
42
sub t {
62
sub t {
(-)a/Koha/UI/Form/Builder/Item.pm (-12 / +5 lines)
Lines 207-224 sub generate_subfield_form { Link Here
207
        }
207
        }
208
        elsif ( $subfield->{authorised_value} eq "itemtypes" ) {
208
        elsif ( $subfield->{authorised_value} eq "itemtypes" ) {
209
            push @authorised_values, "";
209
            push @authorised_values, "";
210
            my $itemtypes;
210
            my $itemtypes = Koha::ItemTypes->get_from_cache({ library_limit => $branch_limit });
211
            if ($branch_limit) {
211
            for my $itemtype ( @$itemtypes ) {
212
                $itemtypes = Koha::ItemTypes->search(
212
                push @authorised_values, $itemtype->{itemtype};
213
                    { branchcode => $branch_limit } );
213
                $authorised_lib{ $itemtype->{itemtype} } =
214
            }
214
                  db_t('itemtype', $itemtype->{translation_key});
215
            else {
216
                $itemtypes = Koha::ItemTypes->search;
217
            }
218
            while ( my $itemtype = $itemtypes->next ) {
219
                push @authorised_values, $itemtype->itemtype;
220
                $authorised_lib{ $itemtype->itemtype } =
221
                  db_t('itemtype', $itemtype->translation_key);
222
            }
215
            }
223
216
224
            if (!$value && $biblionumber) {
217
            if (!$value && $biblionumber) {
(-)a/acqui/orderreceive.pl (-1 lines)
Lines 74-80 use Koha::Acquisition::Booksellers; Link Here
74
use Koha::Acquisition::Currencies qw( get_active );
74
use Koha::Acquisition::Currencies qw( get_active );
75
use Koha::Acquisition::Orders;
75
use Koha::Acquisition::Orders;
76
use Koha::DateUtils qw( dt_from_string );
76
use Koha::DateUtils qw( dt_from_string );
77
use Koha::I18N;
78
use Koha::ItemTypes;
77
use Koha::ItemTypes;
79
use Koha::Patrons;
78
use Koha::Patrons;
80
79
(-)a/authorities/authorities.pl (-1 lines)
Lines 32-38 use C4::Biblio qw( TransformHtmlToMarc ); Link Here
32
use Koha::Authority::Types;
32
use Koha::Authority::Types;
33
use Koha::Import::Records;
33
use Koha::Import::Records;
34
use Koha::ItemTypes;
34
use Koha::ItemTypes;
35
use Koha::I18N;
36
use vars qw( $tagslib);
35
use vars qw( $tagslib);
37
use vars qw( $authorised_values_sth);
36
use vars qw( $authorised_values_sth);
38
use vars qw( $is_a_modif );
37
use vars qw( $is_a_modif );
(-)a/catalogue/detail.pl (-1 / +2 lines)
Lines 189-195 $template->param( Link Here
189
    content_identifier_exists =>  $content_identifier_exists,
189
    content_identifier_exists =>  $content_identifier_exists,
190
);
190
);
191
191
192
my $itemtypes = { map { $_->itemtype => $_ } @{ Koha::ItemTypes->search_with_localization->as_list } };
192
my $itemtypes = { map { $_->itemtype => $_ } @{ Koha::ItemTypes->search->as_list } };
193
193
my $all_items = $biblio->items->search_ordered;
194
my $all_items = $biblio->items->search_ordered;
194
my @items;
195
my @items;
195
my $patron = Koha::Patrons->find( $borrowernumber );
196
my $patron = Koha::Patrons->find( $borrowernumber );
(-)a/catalogue/getitem-ajax.pl (-1 lines)
Lines 27-33 use C4::Output qw( output_with_http_headers ); Link Here
27
use Koha::Libraries;
27
use Koha::Libraries;
28
28
29
use Koha::AuthorisedValues;
29
use Koha::AuthorisedValues;
30
use Koha::I18N;
31
use Koha::Items;
30
use Koha::Items;
32
use Koha::ItemTypes;
31
use Koha::ItemTypes;
33
32
(-)a/catalogue/itemsearch.pl (-1 lines)
Lines 28-34 use C4::Koha qw( GetAuthorisedValues ); Link Here
28
28
29
use Koha::AuthorisedValues;
29
use Koha::AuthorisedValues;
30
use Koha::Biblios;
30
use Koha::Biblios;
31
use Koha::I18N;
32
use Koha::Item::Search::Field qw(GetItemSearchFields);
31
use Koha::Item::Search::Field qw(GetItemSearchFields);
33
use Koha::ItemTypes;
32
use Koha::ItemTypes;
34
use Koha::Libraries;
33
use Koha::Libraries;
(-)a/catalogue/moredetail.pl (-6 / +5 lines)
Lines 35-41 use Koha::AuthorisedValues; Link Here
35
use Koha::Biblios;
35
use Koha::Biblios;
36
use Koha::Items;
36
use Koha::Items;
37
use Koha::Patrons;
37
use Koha::Patrons;
38
use Koha::I18N;
39
38
40
my $query=CGI->new;
39
my $query=CGI->new;
41
40
Lines 139-148 my $ccodes = Link Here
139
my $copynumbers =
138
my $copynumbers =
140
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
139
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
141
140
142
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
141
my $itemtypes = { map { $_->itemtype => $_ } @{ Koha::ItemTypes->search->as_list } };
142
143
$data->{itemtype} = $itemtypes->{ $data->{itemtype} };
143
144
144
$data->{'itemtypename'} = db_t('itemtype', $itemtypes->{ $data->{'itemtype'} }->{itemtype})
145
  if $data->{itemtype} && exists $itemtypes->{ $data->{itemtype} };
146
foreach ( keys %{$data} ) {
145
foreach ( keys %{$data} ) {
147
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
146
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
148
}
147
}
Lines 155-162 foreach my $item (@items){ Link Here
155
154
156
    my $item_info = $item->unblessed;
155
    my $item_info = $item->unblessed;
157
    $item_info->{object} = $item;
156
    $item_info->{object} = $item;
158
    $item_info->{itype}                = db_t('itemtype', $itemtypes->{ $item_info->{itype} }->{itemtype}) if exists $itemtypes->{ $item_info->{itype} };
157
    $item_info->{itemtype}             = $itemtypes->{$item_info->{itype}};
159
    $item_info->{effective_itemtype} = $itemtypes->{$item->effective_itemtype};
158
    $item_info->{effective_itemtype}   = $itemtypes->{$item->effective_itemtype};
160
    $item_info->{'ccode'}              = $ccodes->{ $item->ccode } if $ccodes && $item->ccode && exists $ccodes->{ $item->ccode };
159
    $item_info->{'ccode'}              = $ccodes->{ $item->ccode } if $ccodes && $item->ccode && exists $ccodes->{ $item->ccode };
161
    if ( defined $item->copynumber ) {
160
    if ( defined $item->copynumber ) {
162
        $item_info->{'displaycopy'} = 1;
161
        $item_info->{'displaycopy'} = 1;
(-)a/catalogue/search.pl (-13 / +9 lines)
Lines 158-164 use Koha::SearchEngine::QueryBuilder; Link Here
158
use Koha::Virtualshelves;
158
use Koha::Virtualshelves;
159
use Koha::SearchFields;
159
use Koha::SearchFields;
160
use Koha::SearchFilters;
160
use Koha::SearchFilters;
161
use Koha::I18N;
162
161
163
use URI::Escape;
162
use URI::Escape;
164
use JSON qw( decode_json encode_json );
163
use JSON qw( decode_json encode_json );
Lines 543-552 my $facets; # this object stores the faceted results that display on the left-ha Link Here
543
my $results_hashref;
542
my $results_hashref;
544
543
545
eval {
544
eval {
546
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
547
    ( $error, $results_hashref, $facets ) = $searcher->search_compat(
545
    ( $error, $results_hashref, $facets ) = $searcher->search_compat(
548
        $query,            $simple_query, \@sort_by,       \@servers,
546
        $query,            $simple_query, \@sort_by,       \@servers,
549
        $results_per_page, $offset,       undef,           $itemtypes,
547
        $results_per_page, $offset,       undef,
550
        $query_type,       $scan
548
        $query_type,       $scan
551
    );
549
    );
552
};
550
};
Lines 579-588 for (my $i=0;$i<@servers;$i++) { Link Here
579
                \@sort_by, $scan, $lang, { weighted_fields => $weight_search, whole_record => $whole_record });
577
                \@sort_by, $scan, $lang, { weighted_fields => $weight_search, whole_record => $whole_record });
580
            my $quoted_results_hashref;
578
            my $quoted_results_hashref;
581
            eval {
579
            eval {
582
                my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
583
                ( $error, $quoted_results_hashref, $facets ) = $searcher->search_compat(
580
                ( $error, $quoted_results_hashref, $facets ) = $searcher->search_compat(
584
                    $query,            $simple_query, \@sort_by,       ['biblioserver'],
581
                    $query,            $simple_query, \@sort_by,       ['biblioserver'],
585
                    $results_per_page, $offset,       undef,           $itemtypes,
582
                    $results_per_page, $offset,       undef,
586
                    $query_type,       $scan
583
                    $query_type,       $scan
587
                );
584
                );
588
            };
585
            };
Lines 811-824 sub prepare_adv_search_types { Link Here
811
    # the index parameter is different for item-level itemtypes
808
    # the index parameter is different for item-level itemtypes
812
    my $itype_or_itemtype =
809
    my $itype_or_itemtype =
813
      ( C4::Context->preference("item-level_itypes") ) ? 'itype' : 'itemtype';
810
      ( C4::Context->preference("item-level_itypes") ) ? 'itype' : 'itemtype';
814
    my $itemtypes = {
811
815
        map {
812
    # FIXME We should retrieve the ItemTypes from the cache
816
            $_->{itemtype} => {
813
    my $itemtypes =
817
                %$_,
814
      map {
818
                description => db_t( 'itemtype', $_->{itemtype} ),
815
        $_->itemtype =>
819
              }
816
          { %{ $_->unblessed }, description => $_->translated_description, }
820
        } @{ Koha::ItemTypes->search->unblessed }
817
      } @{ Koha::ItemTypes->search->as_list };
821
    };
822
818
823
    my ( $cnt, @result );
819
    my ( $cnt, @result );
824
    foreach my $advanced_srch_type (@advanced_search_types) {
820
    foreach my $advanced_srch_type (@advanced_search_types) {
(-)a/cataloguing/addbiblio.pl (-1 lines)
Lines 57-63 use Koha::Patrons; Link Here
57
use MARC::File::USMARC;
57
use MARC::File::USMARC;
58
use MARC::File::XML;
58
use MARC::File::XML;
59
use URI::Escape qw( uri_escape_utf8 );
59
use URI::Escape qw( uri_escape_utf8 );
60
use Koha::I18N;
61
60
62
if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
61
if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
63
    MARC::File::XML->default_record_format('UNIMARC');
62
    MARC::File::XML->default_record_format('UNIMARC');
(-)a/cataloguing/additem.pl (-1 lines)
Lines 34-40 use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_htt Link Here
34
use C4::Search qw( enabled_staff_search_views );
34
use C4::Search qw( enabled_staff_search_views );
35
use Koha::Biblios;
35
use Koha::Biblios;
36
use Koha::Item::Templates;
36
use Koha::Item::Templates;
37
use Koha::I18N;
38
use Koha::ItemTypes;
37
use Koha::ItemTypes;
39
use Koha::Items;
38
use Koha::Items;
40
use Koha::Libraries;
39
use Koha::Libraries;
(-)a/circ/transferstoreceive.pl (-1 lines)
Lines 28-34 use C4::Members; Link Here
28
use Date::Calc qw( Add_Delta_Days Date_to_Days Today );
28
use Date::Calc qw( Add_Delta_Days Date_to_Days Today );
29
29
30
use C4::Reserves;
30
use C4::Reserves;
31
use Koha::I18N;
32
use Koha::Items;
31
use Koha::Items;
33
use Koha::ItemTypes;
32
use Koha::ItemTypes;
34
use Koha::Libraries;
33
use Koha::Libraries;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +1 lines)
Lines 405-411 Link Here
405
                            [% IF !noItemTypeImages && itemtype.image_location('intranet') %]
405
                            [% IF !noItemTypeImages && itemtype.image_location('intranet') %]
406
                                <img src="[% itemtype.image_location('intranet') | html %]" alt="[% ItemTypes.t(itemtype.translation_key) | html %]" title="[% ItemTypes.t(itemtype.translation_key) | html %]" />
406
                                <img src="[% itemtype.image_location('intranet') | html %]" alt="[% ItemTypes.t(itemtype.translation_key) | html %]" title="[% ItemTypes.t(itemtype.translation_key) | html %]" />
407
                            [% END %]
407
                            [% END %]
408
                            <span class="itypedesc itypetext">[% ItemTypes.t(item.translation_key) | html %]</span>
408
                            <span class="itypedesc itypetext">[% ItemTypes.t(itemtype.translation_key) | html %]</span>
409
                        </td>
409
                        </td>
410
                    [% END %]
410
                    [% END %]
411
                    <td class="location">[% UNLESS ( singlebranchmode ) %][% Branches.GetName( item.holdingbranch ) | html %] [% END %]</td>
411
                    <td class="location">[% UNLESS ( singlebranchmode ) %][% Branches.GetName( item.holdingbranch ) | html %] [% END %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-2 / +3 lines)
Lines 4-9 Link Here
4
[% USE Koha %]
4
[% USE Koha %]
5
[% USE Branches %]
5
[% USE Branches %]
6
[% USE Price %]
6
[% USE Price %]
7
[% USE ItemTypes %]
7
[% SET footerjs = 1 %]
8
[% SET footerjs = 1 %]
8
[% INCLUDE 'doc-head-open.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
9
<title>Item details for [% INCLUDE 'biblio-title-head.inc' %] &rsaquo; Catalog &rsaquo; Koha</title>
10
<title>Item details for [% INCLUDE 'biblio-title-head.inc' %] &rsaquo; Catalog &rsaquo; Koha</title>
Lines 53-59 Link Here
53
                                <ol class="bibliodetails">
54
                                <ol class="bibliodetails">
54
                                    <li><span class="label">Biblionumber:</span> [% biblionumber | html %]&nbsp;</li>
55
                                    <li><span class="label">Biblionumber:</span> [% biblionumber | html %]&nbsp;</li>
55
                                    [% UNLESS ( item_level_itypes ) %]
56
                                    [% UNLESS ( item_level_itypes ) %]
56
                                        <li><span class="label">Item type:</span> [% itemtypename | html %]&nbsp;</li>
57
                                        <li><span class="label">Item type:</span> [% ItemTypes.t(itemtype.translation_key) | html %]&nbsp;</li>
57
                                    [% END %]
58
                                    [% END %]
58
                                    [% IF ( rentalcharge ) %]
59
                                    [% IF ( rentalcharge ) %]
59
                                        <li><span class="label">Rental charge:</span>[% rentalcharge | $Price %]&nbsp;</li>
60
                                        <li><span class="label">Rental charge:</span>[% rentalcharge | $Price %]&nbsp;</li>
Lines 125-131 Link Here
125
                                    <ol class="bibliodetails">
126
                                    <ol class="bibliodetails">
126
                                        <li><span class="label">Home library:</span> [% Branches.GetName( ITEM_DAT.homebranch ) | html %]&nbsp;</li>
127
                                        <li><span class="label">Home library:</span> [% Branches.GetName( ITEM_DAT.homebranch ) | html %]&nbsp;</li>
127
                                        [% IF ( item_level_itypes ) %]
128
                                        [% IF ( item_level_itypes ) %]
128
                                            <li><span class="label">Item type:</span> [% ITEM_DAT.itype | html %]&nbsp;</li>
129
                                            <li><span class="label">Item type:</span> [% ItemTypes.t(ITEM_DAT.itemtype.translation_key) | html %]&nbsp;</li>
129
                                        [% END %]
130
                                        [% END %]
130
                                        [% IF ( ITEM_DAT.ccode) %]
131
                                        [% IF ( ITEM_DAT.ccode) %]
131
                                            <li><span class="label">Collection:</span> [% ITEM_DAT.ccode | html %]</li>
132
                                            <li><span class="label">Collection:</span> [% ITEM_DAT.ccode | html %]</li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt (-7 / +7 lines)
Lines 527-536 Link Here
527
                                            <td>
527
                                            <td>
528
                                                [% IF ( !item_level_itypes ) || Koha.Preference('BiblioItemtypeInfo') %]
528
                                                [% IF ( !item_level_itypes ) || Koha.Preference('BiblioItemtypeInfo') %]
529
                                                    <div class="result-biblio-itemtype">
529
                                                    <div class="result-biblio-itemtype">
530
                                                        [% IF !noItemTypeImages && SEARCH_RESULT.imageurl %]
530
                                                        [% IF !noItemTypeImages && SEARCH_RESULT.itemtype.image_location_staff %]
531
                                                            <img src="[% SEARCH_RESULT.imageurl | html %]" alt="[%  SEARCH_RESULT.description | html %]" />
531
                                                            <img src="[% SEARCH_RESULT.itemtype.image_location_staff | url %]" alt="[% ItemTypes.t(SEARCH_RESULT.translation_key) | uri %]" />
532
                                                        [% END %]
532
                                                        [% END %]
533
                                                        <span class="itypetext">[% SEARCH_RESULT.description | html %]</span>
533
                                                        <span class="itypetext">[% ItemTypes.t(SEARCH_RESULT.itemtype.translation_key) | html %]</span>
534
                                                    </div>
534
                                                    </div>
535
                                                [% END %]
535
                                                [% END %]
536
536
Lines 614-622 Link Here
614
                                                            [% IF SEARCH_RESULT.${items_loop}.size > 0 %]
614
                                                            [% IF SEARCH_RESULT.${items_loop}.size > 0 %]
615
                                                                <ul class="[% items_loop | html %]_items">
615
                                                                <ul class="[% items_loop | html %]_items">
616
                                                                    [% FOREACH items_loo IN SEARCH_RESULT.${items_loop} %]
616
                                                                    [% FOREACH items_loo IN SEARCH_RESULT.${items_loop} %]
617
                                                                        [% IF item_level_itypes && !noItemTypeImages && items_loo.imageurl %]
617
                                                                        [% IF item_level_itypes && !noItemTypeImages && items_loo.itemtype.image_location_staff %]
618
                                                                            <li class="result_itype_image">
618
                                                                            <li class="result_itype_image">
619
                                                                                <img src="[% items_loo.imageurl | html %]" title="[% items_loo.description | html %]" alt="[% items_loo.description | html %]" />
619
                                                                                <img src="[% items_loo.itemtype.image_location_staff | url %]" title="[% ItemTypes.t(items_loo.itemtype.translation_key) | html %]" alt="[% ItemTypes.t(items_loo.itemtype.translation_key) | html %]" />
620
                                                                        [% ELSE %]
620
                                                                        [% ELSE %]
621
                                                                            <li>
621
                                                                            <li>
622
                                                                        [% END %]
622
                                                                        [% END %]
Lines 658-665 Link Here
658
                                                                                </span>
658
                                                                                </span>
659
                                                                            [% END %]
659
                                                                            [% END %]
660
660
661
                                                                            [% IF item_level_itypes && items_loo.description %]
661
                                                                            [% IF item_level_itypes %]
662
                                                                                <span class="item-itype-desc itypetext">[% items_loo.description | html %]</span>
662
                                                                                <span class="item-itype-desc itypetext">[% ItemTypes.t(items_loo.itemtype.translation_key) | html %]</span>
663
                                                                            [% END %]
663
                                                                            [% END %]
664
                                                                        </li>
664
                                                                        </li>
665
                                                                    [% END # /FOREACH other_items_loo %]
665
                                                                    [% END # /FOREACH other_items_loo %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-bib-search.tt (-3 / +3 lines)
Lines 24-32 Link Here
24
            <label for="itemtypelimit">Limit item type to: </label>
24
            <label for="itemtypelimit">Limit item type to: </label>
25
            <select name="itemtypelimit" id="itemtypelimit">
25
            <select name="itemtypelimit" id="itemtypelimit">
26
                <option value="">All</option>
26
                <option value="">All</option>
27
                [%- FOREACH itemtypeloo IN itemtypeloop %]
27
                [%- FOREACH itemtype IN ItemTypes.GetSorted() %]
28
                <option value="[% itemtypeloo.code | html %]">
28
                <option value="[% itemtype.itemtype | html %]">
29
                    [% ItemTypes.t(itemtypeloo.translation_key) | html %]
29
                    [% itemtype.translated_description | html %]
30
                </option>
30
                </option>
31
                [%- END %]
31
                [%- END %]
32
            </select>
32
            </select>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt (-10 / +12 lines)
Lines 6-11 Link Here
6
[% USE Branches %]
6
[% USE Branches %]
7
[% USE TablesSettings %]
7
[% USE TablesSettings %]
8
[% USE AuthorisedValues %]
8
[% USE AuthorisedValues %]
9
[% USE ItemTypes %]
9
[% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsShowOnDetail ) %]
10
[% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsShowOnDetail ) %]
10
[% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsInputOnDetail ) %]
11
[% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsInputOnDetail ) %]
11
[% IF Koha.Preference('AmazonAssocTag') %]
12
[% IF Koha.Preference('AmazonAssocTag') %]
Lines 167-180 Link Here
167
168
168
                    [% IF ( !item_level_itypes || Koha.Preference('BiblioItemtypeInfo') ) %]
169
                    [% IF ( !item_level_itypes || Koha.Preference('BiblioItemtypeInfo') ) %]
169
                        <span class="results_summary itemtype"><span class="label">Item type: </span>
170
                        <span class="results_summary itemtype"><span class="label">Item type: </span>
170
                            [% IF ( imageurl && !Koha.Preference('OpacNoItemTypeImages') ) %]
171
                            [% IF ( !Koha.Preference('OpacNoItemTypeImages') ) %]
171
                                <img src="[% imageurl | html %]" alt="" />
172
                                [% SET image_url = itemtype.image_location_opac %]
172
                            [% END %]
173
                                [% IF image_url %]
173
                            [% IF ( description ) %]
174
                                    <img src="[% image_url | html %]" alt="" />
174
                                <span class="itypetext">[% description | html %]</span>
175
                                [% END %]
175
                            [% ELSE %]
176
                               <span class="itypetext">[% itemtype | html %]</span>
177
                            [% END %]
176
                            [% END %]
177
                            <span class="itypetext">[% ItemTypes.t(itemtype.translation_key) | html %]</span>
178
                        </span>
178
                        </span>
179
                    [% END %]
179
                    [% END %]
180
180
Lines 1237-1248 Link Here
1237
1237
1238
                [% IF ( item_level_itypes ) %]
1238
                [% IF ( item_level_itypes ) %]
1239
                    <td class="itype">
1239
                    <td class="itype">
1240
                        [% SET itemtype_description = ItemTypes.t(ITEM_RESULT.itemtype.translation_key) %]
1240
                        [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
1241
                        [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
1241
                            [% IF ( ITEM_RESULT.imageurl ) %]
1242
                            [% SET image_url = ITEM_RESULT.itemtype.image_location_opac %]
1242
                                <img src="[% ITEM_RESULT.imageurl | html %]" title="[% ITEM_RESULT.description | html %]" alt="[% ITEM_RESULT.description | html %]" />
1243
                            [% IF image_url %]
1244
                                <img src="[% image_url | html %]" title="[% itemtype_description | html %]" alt="[% itemtype_description | html %]" />
1243
                            [% END %]
1245
                            [% END %]
1244
                        [% END %]
1246
                        [% END %]
1245
                       <span class="itypetext">[% ITEM_RESULT.description | html %]</span>
1247
                       <span class="itypetext">[% ITEM_RESULT.itemtype.description | html %]</span>
1246
                    </td>
1248
                    </td>
1247
                [% END %]
1249
                [% END %]
1248
                [% IF ( OpacLocationBranchToDisplay == 'holding' || OpacLocationBranchToDisplay == 'both' ) %]
1250
                [% IF ( OpacLocationBranchToDisplay == 'holding' || OpacLocationBranchToDisplay == 'both' ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-5 / +5 lines)
Lines 231-238 Link Here
231
                                            [% UNLESS ( item_level_itypes ) %]
231
                                            [% UNLESS ( item_level_itypes ) %]
232
                                                <li class="itype">
232
                                                <li class="itype">
233
                                                    <span class="label">Item type: </span>
233
                                                    <span class="label">Item type: </span>
234
                                                    [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl | html %]" alt="" />[% END %]
234
                                                    [% IF ( bibitemloo.itemtype.image_location_opac ) %]<img src="[% bibitemloo.itemtype.image_location_opac | url %]" alt="" />[% END %]
235
                                                    <span class="itypetext">[% ItemTypes.t(bibitemloo.translation_key) | html %]</span>
235
                                                    <span class="itypetext">[% ItemTypes.t(bibitemloo.itemtype.translation_key) | html %]</span>
236
                                                </li>
236
                                                </li>
237
                                            [% END %]
237
                                            [% END %]
238
238
Lines 417-427 Link Here
417
                                                            [% IF ( item_level_itypes ) %]
417
                                                            [% IF ( item_level_itypes ) %]
418
                                                                <td class="itype">
418
                                                                <td class="itype">
419
                                                                    [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
419
                                                                    [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
420
                                                                        [% IF ( itemLoo.imageurl ) %]
420
                                                                        [% IF ( itemLoo.itemtype.image_location_opac ) %]
421
                                                                            <img src="[% itemLoo.imageurl | html %]" alt="" />
421
                                                                            <img src="[% itemLoo.itemtype.image_location_opac | html %]" alt="" />
422
                                                                        [% END %]
422
                                                                        [% END %]
423
                                                                    [% END %]
423
                                                                    [% END %]
424
                                                                    <span class="itypetext">[% ItemTypes.t(itemLoo.translation_key) | html %]</span>
424
                                                                    <span class="itypetext">[% ItemTypes.t(itemLoo.itemtype.translation_key) | html %]</span>
425
                                                                </td>
425
                                                                </td>
426
                                                            [% END %]
426
                                                            [% END %]
427
427
(-)a/opac/opac-detail.pl (-17 / +4 lines)
Lines 26-32 use CGI qw ( -utf8 ); Link Here
26
use C4::Acquisition qw( SearchOrders );
26
use C4::Acquisition qw( SearchOrders );
27
use C4::Auth qw( get_template_and_user get_session );
27
use C4::Auth qw( get_template_and_user get_session );
28
use C4::Koha qw(
28
use C4::Koha qw(
29
    getitemtypeimagelocation
30
    GetNormalizedEAN
29
    GetNormalizedEAN
31
    GetNormalizedISBN
30
    GetNormalizedISBN
32
    GetNormalizedOCLCNumber
31
    GetNormalizedOCLCNumber
Lines 71-77 use Koha::Biblios; Link Here
71
use Koha::RecordProcessor;
70
use Koha::RecordProcessor;
72
use Koha::AuthorisedValues;
71
use Koha::AuthorisedValues;
73
use Koha::CirculationRules;
72
use Koha::CirculationRules;
74
use Koha::I18N;
75
use Koha::Items;
73
use Koha::Items;
76
use Koha::ItemTypes;
74
use Koha::ItemTypes;
77
use Koha::Acquisition::Orders;
75
use Koha::Acquisition::Orders;
Lines 233-239 if ($session->param('busc')) { Link Here
233
    {
231
    {
234
        my ($arrParamsBusc, $offset, $results_per_page, $patron) = @_;
232
        my ($arrParamsBusc, $offset, $results_per_page, $patron) = @_;
235
233
236
        my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
237
        my @servers;
234
        my @servers;
238
        @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
235
        @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
239
        @servers = ("biblioserver") unless (@servers);
236
        @servers = ("biblioserver") unless (@servers);
Lines 247-253 if ($session->param('busc')) { Link Here
247
            my $searcher = Koha::SearchEngine::Search->new(
244
            my $searcher = Koha::SearchEngine::Search->new(
248
                { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
245
                { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
249
            my $json = JSON->new->utf8->allow_nonref(1);
246
            my $json = JSON->new->utf8->allow_nonref(1);
250
            ($error, $results_hashref, $facets) = $searcher->search_compat($json->decode($arrParamsBusc->{'query'}),$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'});
247
            ($error, $results_hashref, $facets) = $searcher->search_compat($json->decode($arrParamsBusc->{'query'}),$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,undef,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'});
251
        };
248
        };
252
        my $hits;
249
        my $hits;
253
        my @newresults;
250
        my @newresults;
Lines 508-520 my $HideMARC = $record_processor->filters->[0]->should_hide_marc( Link Here
508
        interface     => 'opac',
505
        interface     => 'opac',
509
    } );
506
    } );
510
507
511
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
508
my $itemtype = Koha::ItemTypes->find($dat->{itemtype});
512
# imageurl:
509
$dat->{itemtype} = $itemtype;
513
my $itemtype = $dat->{'itemtype'};
514
if ( $itemtype ) {
515
    $dat->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
516
    $dat->{'description'} = db_t('itemtype', $itemtypes->{$itemtype}->{itemtype});
517
}
518
510
519
my $shelflocations =
511
my $shelflocations =
520
  { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
512
  { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
Lines 705-715 else { Link Here
705
              $shelflocations->{ $item->location };
697
              $shelflocations->{ $item->location };
706
        }
698
        }
707
699
708
        my $itemtype = $item->itemtype;
700
        $item_info->{itemtype} = Koha::ItemType->get_from_cache($item->effective_itemtype);
709
        $item_info->{'imageurl'} = getitemtypeimagelocation( 'opac',
710
            $itemtypes->{ $itemtype->itemtype }->{'imageurl'} );
711
        $item_info->{'description'} =
712
          db_t('itemtype', $itemtypes->{ $itemtype->itemtype }->{itemtype});
713
701
714
        foreach my $field (
702
        foreach my $field (
715
            qw(ccode materials enumchron copynumber itemnotes location_description uri)
703
            qw(ccode materials enumchron copynumber itemnotes location_description uri)
Lines 781-787 my $marcnotesarray = $biblio->get_marc_notes({ opac => 1, record => $record }); Link Here
781
769
782
if( C4::Context->preference('ArticleRequests') ) {
770
if( C4::Context->preference('ArticleRequests') ) {
783
    my $patron = $borrowernumber ? Koha::Patrons->find($borrowernumber) : undef;
771
    my $patron = $borrowernumber ? Koha::Patrons->find($borrowernumber) : undef;
784
    my $itemtype = Koha::ItemTypes->find($biblio->itemtype);
785
    my $artreqpossible = $patron
772
    my $artreqpossible = $patron
786
        ? $biblio->can_article_request( $patron )
773
        ? $biblio->can_article_request( $patron )
787
        : $itemtype
774
        : $itemtype
(-)a/opac/opac-reserve.pl (-9 / +4 lines)
Lines 72-78 unless ( $can_place_hold_if_available_at_pickup ) { Link Here
72
    }
72
    }
73
}
73
}
74
74
75
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
75
# FIXME Should not we pass a library limit?
76
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->get_from_cache } };
76
77
77
# There are two ways of calling this script, with a single biblio num
78
# There are two ways of calling this script, with a single biblio num
78
# or multiple biblio nums.
79
# or multiple biblio nums.
Lines 413-423 foreach my $biblioNum (@biblionumbers) { Link Here
413
    $biblioLoopIter{object} = $biblio;
414
    $biblioLoopIter{object} = $biblio;
414
415
415
    if (!$itemLevelTypes && $biblioData->{itemtype}) {
416
    if (!$itemLevelTypes && $biblioData->{itemtype}) {
416
        $biblioLoopIter{description} = $itemtypes->{$biblioData->{itemtype}}{description};
417
        $biblioLoopIter{itemtype} = $itemtypes->{$biblioData->{itemtype}};
417
        $biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$biblioData->{itemtype}}{imageurl};
418
    }
418
    }
419
419
420
421
    $biblioLoopIter{itemLoop} = [];
420
    $biblioLoopIter{itemLoop} = [];
422
    my $numCopiesAvailable = 0;
421
    my $numCopiesAvailable = 0;
423
    my $numCopiesOPACAvailable = 0;
422
    my $numCopiesOPACAvailable = 0;
Lines 433-443 foreach my $biblioNum (@biblionumbers) { Link Here
433
        $item_info->{holding_branch} = $item->holding_branch;
432
        $item_info->{holding_branch} = $item->holding_branch;
434
        $item_info->{home_branch}    = $item->home_branch;
433
        $item_info->{home_branch}    = $item->home_branch;
435
        if ($itemLevelTypes) {
434
        if ($itemLevelTypes) {
436
            my $itemtype = $item->itemtype;
435
            $item_info->{itemtype} = $itemtypes->{$item->effective_itemtype};
437
            $item_info->{'imageurl'} = getitemtypeimagelocation( 'opac',
438
                $itemtypes->{ $itemtype->itemtype }->{'imageurl'} );
439
            $item_info->{'description'} =
440
                db_t('itemtype', $itemtypes->{ $itemtype->itemtype }->{description});
441
        }
436
        }
442
437
443
        # checking for holds
438
        # checking for holds
(-)a/opac/opac-search.pl (-5 / +5 lines)
Lines 57-63 use C4::External::BakerTaylor qw( image_url link_url ); Link Here
57
57
58
use Koha::CirculationRules;
58
use Koha::CirculationRules;
59
use Koha::Libraries;
59
use Koha::Libraries;
60
use Koha::I18N;
61
use Koha::ItemTypes;
60
use Koha::ItemTypes;
62
use Koha::Ratings;
61
use Koha::Ratings;
63
use Koha::Virtualshelves;
62
use Koha::Virtualshelves;
Lines 234-239 my $languages_limit_loop = getLanguages($lang, 1); Link Here
234
$template->param(search_languages_loop => $languages_limit_loop,);
233
$template->param(search_languages_loop => $languages_limit_loop,);
235
234
236
# load the Type stuff
235
# load the Type stuff
236
# FIXME This is not using the ItemTypes cache
237
my $itemtypes = GetItemTypesCategorized;
237
my $itemtypes = GetItemTypesCategorized;
238
foreach my $itemtype ( keys %{$itemtypes} ) {
238
foreach my $itemtype ( keys %{$itemtypes} ) {
239
    # Itemtypes search categories don't have (yet) translated descriptions, they are auth values (and could still have no descriptions too BZ 18400)
239
    # Itemtypes search categories don't have (yet) translated descriptions, they are auth values (and could still have no descriptions too BZ 18400)
Lines 577-585 if ($tag) { Link Here
577
    $pasarParams .= '&amp;count=' . uri_escape_utf8($results_per_page);
577
    $pasarParams .= '&amp;count=' . uri_escape_utf8($results_per_page);
578
    $pasarParams .= '&amp;simple_query=' . uri_escape_utf8($simple_query);
578
    $pasarParams .= '&amp;simple_query=' . uri_escape_utf8($simple_query);
579
    $pasarParams .= '&amp;query_type=' . uri_escape_utf8($query_type) if ($query_type);
579
    $pasarParams .= '&amp;query_type=' . uri_escape_utf8($query_type) if ($query_type);
580
    my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
580
581
    eval {
581
    eval {
582
        ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes_nocategory,$query_type,$scan,1);
582
        ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$query_type,$scan,1);
583
};
583
};
584
}
584
}
585
585
Lines 638-646 for (my $i=0;$i<@servers;$i++) { Link Here
638
                }
638
                }
639
            );
639
            );
640
            my $quoted_results_hashref;
640
            my $quoted_results_hashref;
641
            my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
641
642
            eval {
642
            eval {
643
                ($error, $quoted_results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes_nocategory,$query_type,$scan,1);
643
                ($error, $quoted_results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$query_type,$scan,1);
644
            };
644
            };
645
            my $quoted_hits = $quoted_results_hashref->{$server}->{"hits"} // 0;
645
            my $quoted_hits = $quoted_results_hashref->{$server}->{"hits"} // 0;
646
            if ( $quoted_hits ){
646
            if ( $quoted_hits ){
(-)a/reports/issues_stats.pl (-3 / +3 lines)
Lines 75-81 our $sep = C4::Context->csv_delimiter(scalar $input->param("sep")); Link Here
75
$template->param(do_it => $do_it,
75
$template->param(do_it => $do_it,
76
);
76
);
77
77
78
our $itemtypes = Koha::ItemTypes->search->unblessed;
78
our $itemtypes = Koha::ItemTypes->get_from_cache;
79
79
80
our @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']})->as_list;
80
our @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']})->as_list;
81
81
Lines 340-346 sub calculate { Link Here
340
        $cell{rowtitle_display} =
340
        $cell{rowtitle_display} =
341
            ( $line =~ /ccode/ )    ? $ccodes->{$celvalue}
341
            ( $line =~ /ccode/ )    ? $ccodes->{$celvalue}
342
          : ( $line =~ /location/ ) ? $locations->{$celvalue}
342
          : ( $line =~ /location/ ) ? $locations->{$celvalue}
343
          : ( $line =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{itemtype})
343
          : ( $line =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{translation_key})
344
          :                           $celvalue;                               # default fallback
344
          :                           $celvalue;                               # default fallback
345
        if ( $line =~ /sort1/ ) {
345
        if ( $line =~ /sort1/ ) {
346
            foreach (@$Bsort1) {
346
            foreach (@$Bsort1) {
Lines 429-435 sub calculate { Link Here
429
        $cell{coltitle_display} =
429
        $cell{coltitle_display} =
430
            ( $column =~ /ccode/ )    ? $ccodes->{$celvalue}
430
            ( $column =~ /ccode/ )    ? $ccodes->{$celvalue}
431
          : ( $column =~ /location/ ) ? $locations->{$celvalue}
431
          : ( $column =~ /location/ ) ? $locations->{$celvalue}
432
          : ( $column =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{itemtype})
432
          : ( $column =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{translation_key})
433
          :                             $celvalue;                               # default fallback
433
          :                             $celvalue;                               # default fallback
434
        if ( $column =~ /sort1/ ) {
434
        if ( $column =~ /sort1/ ) {
435
            foreach (@$Bsort1) {
435
            foreach (@$Bsort1) {
(-)a/reports/reserves_stats.pl (-1 lines)
Lines 28-34 use C4::Output qw( output_html_with_http_headers ); Link Here
28
use C4::Reports qw( GetDelimiterChoices );
28
use C4::Reports qw( GetDelimiterChoices );
29
use C4::Members;
29
use C4::Members;
30
use Koha::AuthorisedValues;
30
use Koha::AuthorisedValues;
31
use Koha::I18N;
32
use Koha::ItemTypes;
31
use Koha::ItemTypes;
33
use Koha::Libraries;
32
use Koha::Libraries;
34
use Koha::Patron::Categories;
33
use Koha::Patron::Categories;
(-)a/serials/subscription-bib-search.pl (-19 lines)
Lines 192-215 else { Link Here
192
        }
192
        }
193
    );
193
    );
194
194
195
    # load the itemtypes
196
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
197
    my @itemtypesloop;
198
    # FIXME This is uselessly complex, the iterator should be send to the template
199
    foreach my $thisitemtype (
200
        sort {
201
            $itemtypes->{$a}->{'description'}
202
              cmp $itemtypes->{$b}->{'description'}
203
        } keys %$itemtypes
204
      )
205
    {
206
        my %row = (
207
            code        => $thisitemtype,
208
            description => $itemtypes->{$thisitemtype}->{'description'},
209
        );
210
        push @itemtypesloop, \%row;
211
    }
212
213
    # load Collection Codes
195
    # load Collection Codes
214
    my $authvalues = GetAuthorisedValues('CCODE');
196
    my $authvalues = GetAuthorisedValues('CCODE');
215
    my @ccodesloop;
197
    my @ccodesloop;
Lines 223-229 else { Link Here
223
    }
205
    }
224
206
225
    $template->param(
207
    $template->param(
226
        itemtypeloop => \@itemtypesloop,
227
        ccodeloop    => \@ccodesloop,
208
        ccodeloop    => \@ccodesloop,
228
        no_query     => $op eq "do_search" ? 1 : 0,
209
        no_query     => $op eq "do_search" ? 1 : 0,
229
    );
210
    );
(-)a/svc/checkouts (-1 / +1 lines)
Lines 147-153 my $item_level_itypes = C4::Context->preference('item-level_itypes'); Link Here
147
my $claims_returned_lost_value = C4::Context->preference('ClaimReturnedLostValue');
147
my $claims_returned_lost_value = C4::Context->preference('ClaimReturnedLostValue');
148
my $confirm_parts_required = C4::Context->preference("CircConfirmItemParts");
148
my $confirm_parts_required = C4::Context->preference("CircConfirmItemParts");
149
149
150
my $itemtypes = { map { $_->{itemtype} => db_t('itemtype', $_->{itemtype}) } @{ Koha::ItemTypes->search->unblessed } };
150
my $itemtypes = { map { $_->{itemtype} => db_t('itemtype', $_->{translation_key}) } @{ Koha::ItemTypes->get_from_cache } };
151
151
152
my @checkouts_today;
152
my @checkouts_today;
153
my @checkouts_previous;
153
my @checkouts_previous;
(-)a/t/db_dependent/Koha/Filter/ExpandCodedFields.t (-1 lines)
Lines 68-74 subtest 'ExpandCodedFields tests' => sub { Link Here
68
    $cache->clear_from_cache("MarcCodedFields-");
68
    $cache->clear_from_cache("MarcCodedFields-");
69
    # Clear GetAuthorisedValueDesc-generated cache
69
    # Clear GetAuthorisedValueDesc-generated cache
70
    $cache->clear_from_cache("libraries:name");
70
    $cache->clear_from_cache("libraries:name");
71
    $cache->clear_from_cache("itemtype:description:en");
72
    $cache->clear_from_cache("cn_sources:description");
71
    $cache->clear_from_cache("cn_sources:description");
73
    $cache->clear_from_cache("AV_descriptions:" . $av->category);
72
    $cache->clear_from_cache("AV_descriptions:" . $av->category);
74
73
(-)a/t/db_dependent/Koha/Item.t (-4 lines)
Lines 1398-1404 subtest 'columns_to_str' => sub { Link Here
1398
    $cache->clear_from_cache("MarcStructure-1-");
1398
    $cache->clear_from_cache("MarcStructure-1-");
1399
    $cache->clear_from_cache("MarcSubfieldStructure-");
1399
    $cache->clear_from_cache("MarcSubfieldStructure-");
1400
    $cache->clear_from_cache("libraries:name");
1400
    $cache->clear_from_cache("libraries:name");
1401
    $cache->clear_from_cache("itemtype:description:en");
1402
    $cache->clear_from_cache("cn_sources:description");
1401
    $cache->clear_from_cache("cn_sources:description");
1403
    $cache->clear_from_cache("AV_descriptions:LOST");
1402
    $cache->clear_from_cache("AV_descriptions:LOST");
1404
1403
Lines 1480-1486 subtest 'columns_to_str' => sub { Link Here
1480
    $cache->clear_from_cache("MarcStructure-1-");
1479
    $cache->clear_from_cache("MarcStructure-1-");
1481
    $cache->clear_from_cache("MarcSubfieldStructure-");
1480
    $cache->clear_from_cache("MarcSubfieldStructure-");
1482
    $cache->clear_from_cache("libraries:name");
1481
    $cache->clear_from_cache("libraries:name");
1483
    $cache->clear_from_cache("itemtype:description:en");
1484
    $cache->clear_from_cache("cn_sources:description");
1482
    $cache->clear_from_cache("cn_sources:description");
1485
    $cache->clear_from_cache("AV_descriptions:LOST");
1483
    $cache->clear_from_cache("AV_descriptions:LOST");
1486
1484
Lines 1500-1506 subtest 'strings_map() tests' => sub { Link Here
1500
    $cache->clear_from_cache("MarcStructure-1-");
1498
    $cache->clear_from_cache("MarcStructure-1-");
1501
    $cache->clear_from_cache("MarcSubfieldStructure-");
1499
    $cache->clear_from_cache("MarcSubfieldStructure-");
1502
    $cache->clear_from_cache("libraries:name");
1500
    $cache->clear_from_cache("libraries:name");
1503
    $cache->clear_from_cache("itemtype:description:en");
1504
    $cache->clear_from_cache("cn_sources:description");
1501
    $cache->clear_from_cache("cn_sources:description");
1505
    $cache->clear_from_cache("AV_descriptions:LOST");
1502
    $cache->clear_from_cache("AV_descriptions:LOST");
1506
1503
Lines 1684-1690 subtest 'strings_map() tests' => sub { Link Here
1684
    $cache->clear_from_cache("MarcStructure-1-");
1681
    $cache->clear_from_cache("MarcStructure-1-");
1685
    $cache->clear_from_cache("MarcSubfieldStructure-");
1682
    $cache->clear_from_cache("MarcSubfieldStructure-");
1686
    $cache->clear_from_cache("libraries:name");
1683
    $cache->clear_from_cache("libraries:name");
1687
    $cache->clear_from_cache("itemtype:description:en");
1688
    $cache->clear_from_cache("cn_sources:description");
1684
    $cache->clear_from_cache("cn_sources:description");
1689
1685
1690
    $schema->storage->txn_rollback;
1686
    $schema->storage->txn_rollback;
(-)a/tools/batchMod.pl (-2 lines)
Lines 31-37 use List::MoreUtils qw( uniq ); Link Here
31
use Encode qw( encode_utf8 );
31
use Encode qw( encode_utf8 );
32
32
33
use Koha::Database;
33
use Koha::Database;
34
use Koha::I18N;
35
use Koha::Exception;
34
use Koha::Exception;
36
use Koha::Biblios;
35
use Koha::Biblios;
37
use Koha::Items;
36
use Koha::Items;
38
- 

Return to bug 24975