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

(-)a/C4/Biblio.pm (-1 / +2 lines)
Lines 108-113 use Koha::Authority::Types; Link Here
108
use Koha::Acquisition::Currencies;
108
use Koha::Acquisition::Currencies;
109
use Koha::Biblio::Metadatas;
109
use Koha::Biblio::Metadatas;
110
use Koha::Holds;
110
use Koha::Holds;
111
use Koha::I18N;
111
use Koha::ItemTypes;
112
use Koha::ItemTypes;
112
use Koha::MarcOverlayRules;
113
use Koha::MarcOverlayRules;
113
use Koha::Plugins;
114
use Koha::Plugins;
Lines 1447-1453 sub GetAuthorisedValueDesc { Link Here
1447
        #---- itemtypes
1448
        #---- itemtypes
1448
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
1449
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
1449
            my $itemtype = Koha::ItemTypes->find( $value );
1450
            my $itemtype = Koha::ItemTypes->find( $value );
1450
            return $itemtype ? $itemtype->translated_description : q||;
1451
            return $itemtype ? db_t('itemtype', $itemtype->description) : q||;
1451
        }
1452
        }
1452
1453
1453
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "cn_source" ) {
1454
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "cn_source" ) {
(-)a/C4/Items.pm (-7 / +4 lines)
Lines 65-70 use Koha::DateUtils qw( dt_from_string output_pref ); Link Here
65
use Koha::Database;
65
use Koha::Database;
66
66
67
use Koha::Biblioitems;
67
use Koha::Biblioitems;
68
use Koha::I18N;
68
use Koha::Items;
69
use Koha::Items;
69
use Koha::ItemTypes;
70
use Koha::ItemTypes;
70
use Koha::SearchEngine;
71
use Koha::SearchEngine;
Lines 730-736 sub GetItemsInfo { Link Here
730
           serial.serialseq,
731
           serial.serialseq,
731
           serial.publisheddate,
732
           serial.publisheddate,
732
           itemtypes.description,
733
           itemtypes.description,
733
           COALESCE( localization.translation, itemtypes.description ) AS translated_description,
734
           itemtypes.notforloan as notforloan_per_itemtype,
734
           itemtypes.notforloan as notforloan_per_itemtype,
735
           holding.branchurl,
735
           holding.branchurl,
736
           holding.branchcode,
736
           holding.branchcode,
Lines 751-764 sub GetItemsInfo { Link Here
751
     . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype');
751
     . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype');
752
    $query .= q|
752
    $query .= q|
753
    LEFT JOIN tmp_holdsqueue USING (itemnumber)
753
    LEFT JOIN tmp_holdsqueue USING (itemnumber)
754
    LEFT JOIN localization ON itemtypes.itemtype = localization.code
755
        AND localization.entity = 'itemtypes'
756
        AND localization.lang = ?
757
    |;
754
    |;
758
755
759
    $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
756
    $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
760
    my $sth = $dbh->prepare($query);
757
    my $sth = $dbh->prepare($query);
761
    $sth->execute($language, $biblionumber);
758
    $sth->execute($biblionumber);
762
    my $i = 0;
759
    my $i = 0;
763
    my @results;
760
    my @results;
764
    my $serial;
761
    my $serial;
Lines 1722-1732 sub PrepareItemrecordDisplay { Link Here
1722
1719
1723
                        #----- itemtypes
1720
                        #----- itemtypes
1724
                    } elsif ( $subfield->{authorised_value} eq "itemtypes" ) {
1721
                    } elsif ( $subfield->{authorised_value} eq "itemtypes" ) {
1725
                        my $itemtypes = Koha::ItemTypes->search_with_localization;
1722
                        my $itemtypes = Koha::ItemTypes->search;
1726
                        push @authorised_values, "";
1723
                        push @authorised_values, "";
1727
                        while ( my $itemtype = $itemtypes->next ) {
1724
                        while ( my $itemtype = $itemtypes->next ) {
1728
                            push @authorised_values, $itemtype->itemtype;
1725
                            push @authorised_values, $itemtype->itemtype;
1729
                            $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
1726
                            $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->description);
1730
                        }
1727
                        }
1731
                        if ($defaultvalues && $defaultvalues->{'itemtype'}) {
1728
                        if ($defaultvalues && $defaultvalues->{'itemtype'}) {
1732
                            $defaultvalue = $defaultvalues->{'itemtype'};
1729
                            $defaultvalue = $defaultvalues->{'itemtype'};
(-)a/C4/Search.pm (-6 / +5 lines)
Lines 27-32 use C4::XSLT qw( XSLTParse4Display ); Link Here
27
use C4::Reserves qw( GetReserveStatus );
27
use C4::Reserves qw( GetReserveStatus );
28
use C4::Charset qw( SetUTF8Flag );
28
use C4::Charset qw( SetUTF8Flag );
29
use Koha::AuthorisedValues;
29
use Koha::AuthorisedValues;
30
use Koha::I18N;
30
use Koha::ItemTypes;
31
use Koha::ItemTypes;
31
use Koha::Libraries;
32
use Koha::Libraries;
32
use Koha::Logger;
33
use Koha::Logger;
Lines 529-537 sub getRecords { Link Here
529
                                    && ref( $itemtypes->{$one_facet} ) eq
530
                                    && ref( $itemtypes->{$one_facet} ) eq
530
                                    "HASH" )
531
                                    "HASH" )
531
                                {
532
                                {
532
                                    $facet_label_value =
533
                                    $facet_label_value = db_t('itemtype', $itemtypes->{$one_facet}->{description});
533
                                      $itemtypes->{$one_facet}
534
                                      ->{translated_description};
535
                                }
534
                                }
536
                            }
535
                            }
537
536
Lines 1652-1658 sub searchResults { Link Here
1652
    my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef;
1651
    my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef;
1653
1652
1654
    #Get itemtype hash
1653
    #Get itemtype hash
1655
    my $itemtypes = Koha::ItemTypes->search_with_localization;
1654
    my $itemtypes = Koha::ItemTypes->search;
1656
    my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes->unblessed };
1655
    my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes->unblessed };
1657
1656
1658
    #search item field code
1657
    #search item field code
Lines 1734-1740 sub searchResults { Link Here
1734
        # add imageurl to itemtype if there is one
1733
        # add imageurl to itemtype if there is one
1735
        $oldbiblio->{imageurl} = $itemtype ? getitemtypeimagelocation( $search_context->{'interface'}, $itemtype->{imageurl} ) : q{};
1734
        $oldbiblio->{imageurl} = $itemtype ? getitemtypeimagelocation( $search_context->{'interface'}, $itemtype->{imageurl} ) : q{};
1736
        # Build summary if there is one (the summary is defined in the itemtypes table)
1735
        # Build summary if there is one (the summary is defined in the itemtypes table)
1737
        $oldbiblio->{description} = $itemtype ? $itemtype->{translated_description} : q{};
1736
        $oldbiblio->{description} = $itemtype ? db_t('itemtype', $itemtype->{description}) : q{};
1738
1737
1739
        # Pull out the items fields
1738
        # Pull out the items fields
1740
        my @fields = $marcrecord->field($itemtag);
1739
        my @fields = $marcrecord->field($itemtag);
Lines 1800-1806 sub searchResults { Link Here
1800
            foreach my $code ( keys %subfieldstosearch ) {
1799
            foreach my $code ( keys %subfieldstosearch ) {
1801
                $item->{$code} = $field->subfield( $subfieldstosearch{$code} );
1800
                $item->{$code} = $field->subfield( $subfieldstosearch{$code} );
1802
            }
1801
            }
1803
            $item->{description} = $itemtypes{ $item->{itype} }{translated_description} if $item->{itype};
1802
            $item->{description} = db_t('itemtype', $itemtypes{ $item->{itype} }{description}) if $item->{itype};
1804
1803
1805
	        # OPAC hidden items
1804
	        # OPAC hidden items
1806
            if ($is_opac) {
1805
            if ($is_opac) {
(-)a/Koha/DBIx/Component/L10nSource.pm (+73 lines)
Line 0 Link Here
1
package Koha::DBIx::Component::L10nSource;
2
3
use Modern::Perl;
4
use base 'DBIx::Class';
5
6
=head1 NAME
7
8
Koha::DBIx::Component::L10nSource
9
10
=head1 SYNOPSIS
11
12
    __PACKAGE__->load_components('+Koha::DBIx::Component::L10nSource')
13
14
    sub insert {
15
        my $self = shift;
16
        my $result = $self->next::method(@_);
17
        my @sources = $self->result_source->resultset->get_column('label')->all;
18
        $self->update_l10n_source('somecontext', @sources);
19
        return $result;
20
    }
21
22
    sub update {
23
        my $self = shift;
24
        my $is_column_changed = $self->is_column_changed('label');
25
        my $result = $self->next::method(@_);
26
        if ($is_column_changed) {
27
            my @sources = $self->result_source->resultset->get_column('label')->all;
28
            $self->update_l10n_source('somecontext', @sources);
29
        }
30
        return $result;
31
    }
32
33
    sub delete {
34
        my $self = shift;
35
        my $result = $self->next::method(@_);
36
        my @sources = $self->result_source->resultset->get_column('label')->all;
37
        $self->update_l10n_source('somecontext', @sources);
38
        return $result;
39
    }
40
41
=head1 METHODS
42
43
=head2 update_l10n_source
44
45
    $self->update_l10n_source($context, @sources)
46
47
Ensure that all sources in C<@sources>and only them are present in l10n_source
48
for a given C<$context>
49
50
=cut
51
52
sub update_l10n_source {
53
    my ($self, $context, @sources) = @_;
54
55
    my $l10n_source_rs = $self->result_source->schema->resultset('L10nSource')->search({ context => $context });
56
57
    # Insert missing l10n_source rows
58
    foreach my $source (@sources) {
59
        my $count = $l10n_source_rs->search({ source => $source })->count;
60
        if ($count == 0) {
61
            $l10n_source_rs->create({ source => $source });
62
        }
63
    }
64
65
    # Remove l10n_source rows that do not match an existing source
66
    my %sources = map { $_ => undef } @sources;
67
    my @l10n_sources = grep { !exists $sources{$_->source} } $l10n_source_rs->all;
68
    foreach my $l10n_source (@l10n_sources) {
69
        $l10n_source->delete;
70
    }
71
}
72
73
1;
(-)a/Koha/I18N.pm (+49 lines)
Lines 35-40 use Locale::Messages qw( Link Here
35
);
35
);
36
use POSIX qw();
36
use POSIX qw();
37
use Koha::Cache::Memory::Lite;
37
use Koha::Cache::Memory::Lite;
38
use Koha::Caches;
39
use Koha::Database;
38
40
39
use parent 'Exporter';
41
use parent 'Exporter';
40
our @EXPORT = qw(
42
our @EXPORT = qw(
Lines 51-56 our @EXPORT = qw( Link Here
51
    N__n
53
    N__n
52
    N__p
54
    N__p
53
    N__np
55
    N__np
56
57
    db_t
54
);
58
);
55
59
56
our $textdomain = 'Koha';
60
our $textdomain = 'Koha';
Lines 222-225 sub _expand { Link Here
222
    return $text;
226
    return $text;
223
}
227
}
224
228
229
=head2 db_t
230
231
    db_t($context, $source)
232
    db_t('itemtype', $itemtype->description)
233
234
Search for a translation in l10n_target table and return it if found
235
Return source string otherwise
236
237
=cut
238
239
sub db_t {
240
    my ($context, $source) = @_;
241
242
    my $cache = Koha::Caches->get_instance();
243
    my $language = C4::Languages::getlanguage();
244
    my $cache_key = sprintf('%s:%s', $context, $language);
245
246
    my $translations = $cache->get_from_cache($cache_key);
247
    unless ($translations) {
248
        my $schema = Koha::Database->new->schema;
249
        my $rs = $schema->resultset('L10nTarget');
250
251
        my @targets = $rs->search(
252
            {
253
                'l10n_source.context' => $context,
254
                language => $language,
255
            },
256
            {
257
                join => 'l10n_source',
258
                prefetch => 'l10n_source',
259
                result_class => 'DBIx::Class::ResultClass::HashRefInflator',
260
            },
261
        );
262
        $translations = { map { $_->{l10n_source}->{source} => $_->{translation} } @targets };
263
264
        $cache->set_in_cache($cache_key, $translations);
265
    }
266
267
    if (exists $translations->{$source}) {
268
        return $translations->{$source};
269
    }
270
271
    return $source;
272
}
273
225
1;
274
1;
(-)a/Koha/ItemType.pm (-48 / +3 lines)
Lines 22-28 use C4::Koha qw( getitemtypeimagelocation ); Link Here
22
use C4::Languages;
22
use C4::Languages;
23
use Koha::Database;
23
use Koha::Database;
24
use Koha::CirculationRules;
24
use Koha::CirculationRules;
25
use Koha::Localizations;
26
25
27
use base qw(Koha::Object Koha::Object::Limit::Library);
26
use base qw(Koha::Object Koha::Object::Limit::Library);
28
27
Lines 45-94 sub image_location { Link Here
45
    return C4::Koha::getitemtypeimagelocation( $interface, $self->SUPER::imageurl );
44
    return C4::Koha::getitemtypeimagelocation( $interface, $self->SUPER::imageurl );
46
}
45
}
47
46
48
=head3 translated_description
49
50
=cut
51
52
sub translated_description {
53
    my ( $self, $lang ) = @_;
54
    if ( my $translated_description = eval { $self->get_column('translated_description') } ) {
55
        # If the value has already been fetched (eg. from sarch_with_localization),
56
        # do not search for it again
57
        # Note: This is a bit hacky but should be fast
58
        return $translated_description
59
             ? $translated_description
60
             : $self->description;
61
    }
62
    $lang ||= C4::Languages::getlanguage;
63
    my $translated_description = Koha::Localizations->search({
64
        code => $self->itemtype,
65
        entity => 'itemtypes',
66
        lang => $lang
67
    })->next;
68
    return $translated_description
69
         ? $translated_description->translation
70
         : $self->description;
71
}
72
73
=head3 translated_descriptions
74
75
=cut
76
77
sub translated_descriptions {
78
    my ( $self ) = @_;
79
    my @translated_descriptions = Koha::Localizations->search(
80
        {   entity => 'itemtypes',
81
            code   => $self->itemtype,
82
        }
83
    )->as_list;
84
    return [ map {
85
        {
86
            lang => $_->lang,
87
            translation => $_->translation,
88
        }
89
    } @translated_descriptions ];
90
}
91
92
=head3 can_be_deleted
47
=head3 can_be_deleted
93
48
94
my $can_be_deleted = Koha::ItemType->can_be_deleted();
49
my $can_be_deleted = Koha::ItemType->can_be_deleted();
Lines 152-166 sub parent { Link Here
152
107
153
}
108
}
154
109
155
=head3 children_with_localization
110
=head3 children
156
111
157
    Returns the ItemType objects of the children of this type or undef.
112
    Returns the ItemType objects of the children of this type or undef.
158
113
159
=cut
114
=cut
160
115
161
sub children_with_localization {
116
sub children {
162
    my ( $self ) = @_;
117
    my ( $self ) = @_;
163
    return Koha::ItemTypes->search_with_localization({ parent_type => $self->itemtype });
118
    return Koha::ItemTypes->search({ parent_type => $self->itemtype });
164
}
119
}
165
120
166
=head3 type
121
=head3 type
(-)a/Koha/ItemTypes.pm (-31 lines)
Lines 31-67 Koha::ItemTypes - Koha ItemType Object set class Link Here
31
31
32
=head1 API
32
=head1 API
33
33
34
=head2 Class methods
35
36
=cut
37
38
=head3 search_with_localization
39
40
my $itemtypes = Koha::ItemTypes->search_with_localization
41
42
=cut
43
44
sub search_with_localization {
45
    my ( $self, $params, $attributes ) = @_;
46
47
    my $language = C4::Languages::getlanguage();
48
    $Koha::Schema::Result::Itemtype::LANGUAGE = $language;
49
    $attributes->{order_by} = 'translated_description' unless exists $attributes->{order_by};
50
    $attributes->{join} = 'localization';
51
    $attributes->{'+select'} = [
52
        {
53
            coalesce => [qw( localization.translation me.description )],
54
            -as      => 'translated_description'
55
        }
56
    ];
57
    if(defined $params->{branchcode}) {
58
        my $branchcode = delete $params->{branchcode};
59
        $self->search_with_library_limits( $params, $attributes, $branchcode );
60
    } else {
61
        $self->SUPER::search( $params, $attributes );
62
    }
63
}
64
65
=head2 Internal methods
34
=head2 Internal methods
66
35
67
=head3 type
36
=head3 type
(-)a/Koha/Localization.pm (-28 lines)
Lines 1-28 Link Here
1
package Koha::Localization;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
22
use base qw(Koha::Object);
23
24
sub _type {
25
    return 'Localization';
26
}
27
28
1;
(-)a/Koha/Localizations.pm (-34 lines)
Lines 1-34 Link Here
1
package Koha::Localizations;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
22
use Koha::Localization;
23
24
use base qw(Koha::Objects);
25
26
sub _type {
27
    return 'Localization';
28
}
29
30
sub object_class {
31
    return 'Koha::Localization';
32
}
33
34
1;
(-)a/Koha/Schema/Result/Itemtype.pm (-16 / +38 lines)
Lines 342-363 __PACKAGE__->add_columns( Link Here
342
    '+automatic_checkin'            => { is_boolean => 1 },
342
    '+automatic_checkin'            => { is_boolean => 1 },
343
);
343
);
344
344
345
# Use the ItemtypeLocalization view to create the join on localization
345
__PACKAGE__->load_components('+Koha::DBIx::Component::L10nSource');
346
our $LANGUAGE;
347
__PACKAGE__->has_many(
348
  "localization" => "Koha::Schema::Result::ItemtypeLocalization",
349
    sub {
350
        my $args = shift;
351
352
        die "no lang specified!" unless $LANGUAGE;
353
354
        return ({
355
            "$args->{self_alias}.itemtype" => { -ident => "$args->{foreign_alias}.code" },
356
            "$args->{foreign_alias}.lang" => $LANGUAGE,
357
        });
358
359
    }
360
);
361
346
362
sub koha_object_class {
347
sub koha_object_class {
363
    'Koha::ItemType';
348
    'Koha::ItemType';
Lines 366-369 sub koha_objects_class { Link Here
366
    'Koha::ItemTypes';
351
    'Koha::ItemTypes';
367
}
352
}
368
353
354
sub insert {
355
    my $self = shift;
356
357
    my $result = $self->next::method(@_);
358
359
    my @sources = $self->result_source->resultset->get_column('description')->all;
360
    $self->update_l10n_source('itemtype', @sources);
361
362
    return $result;
363
}
364
365
sub update {
366
    my $self = shift;
367
368
    my $is_description_changed = $self->is_column_changed('description');
369
370
    my $result = $self->next::method(@_);
371
372
    if ($is_description_changed) {
373
        my @sources = $self->result_source->resultset->get_column('description')->all;
374
        $self->update_l10n_source('itemtype', @sources);
375
    }
376
377
    return $result;
378
}
379
380
sub delete {
381
    my $self = shift;
382
383
    my $result = $self->next::method(@_);
384
385
    my @sources = $self->result_source->resultset->get_column('description')->all;
386
    $self->update_l10n_source('itemtype', @sources);
387
388
    return $result;
389
}
390
369
1;
391
1;
(-)a/Koha/Schema/Result/ItemtypeLocalization.pm (-32 lines)
Lines 1-32 Link Here
1
package Koha::Schema::Result::ItemtypeLocalization;
2
3
use base 'DBIx::Class::Core';
4
5
use Modern::Perl;
6
7
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
8
9
__PACKAGE__->table('itemtype_localizations');
10
__PACKAGE__->result_source_instance->is_virtual(1);
11
__PACKAGE__->result_source_instance->view_definition(
12
    "SELECT localization_id, code, lang, translation FROM localization WHERE entity='itemtypes'"
13
);
14
15
__PACKAGE__->add_columns(
16
  "localization_id",
17
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
18
  "code",
19
  { data_type => "varchar", is_nullable => 0, size => 64 },
20
  "lang",
21
  { data_type => "varchar", is_nullable => 0, size => 25 },
22
  "translation",
23
  { data_type => "text", is_nullable => 1 },
24
);
25
26
__PACKAGE__->belongs_to(
27
    "itemtype",
28
    "Koha::Schema::Result::Itemtype",
29
    { code => 'itemtype' }
30
);
31
32
1;
(-)a/Koha/Template/Plugin/ItemTypes.pm (-2 / +9 lines)
Lines 22-27 use Modern::Perl; Link Here
22
use Template::Plugin;
22
use Template::Plugin;
23
use base qw( Template::Plugin );
23
use base qw( Template::Plugin );
24
24
25
use Koha::I18N;
25
use Koha::ItemTypes;
26
use Koha::ItemTypes;
26
27
27
sub GetDescription {
28
sub GetDescription {
Lines 30-40 sub GetDescription { Link Here
30
    return q{} unless $itemtype;
31
    return q{} unless $itemtype;
31
    my $parent;
32
    my $parent;
32
    $parent = $itemtype->parent if $want_parent;
33
    $parent = $itemtype->parent if $want_parent;
33
    return $parent ? $parent->translated_description . "->" . $itemtype->translated_description : $itemtype->translated_description;
34
    return $parent ? $self->t($parent->description) . "->" . $self->t($itemtype->description) : $self->t($itemtype->description);
34
}
35
}
35
36
36
sub Get {
37
sub Get {
37
    return Koha::ItemTypes->search_with_localization->unblessed;
38
    return Koha::ItemTypes->search->unblessed;
39
}
40
41
sub t {
42
    my ($self, $description) = @_;
43
44
    return db_t('itemtype', $description);
38
}
45
}
39
46
40
1;
47
1;
(-)a/acqui/orderreceive.pl (+1 lines)
Lines 74-79 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;
77
use Koha::ItemTypes;
78
use Koha::ItemTypes;
78
use Koha::Patrons;
79
use Koha::Patrons;
79
80
(-)a/admin/itemtypes.pl (-3 / +1 lines)
Lines 32-38 use C4::Auth qw( get_template_and_user ); Link Here
32
use C4::Output qw( output_html_with_http_headers );
32
use C4::Output qw( output_html_with_http_headers );
33
use Koha::ItemTypes;
33
use Koha::ItemTypes;
34
use Koha::ItemType;
34
use Koha::ItemType;
35
use Koha::Localizations;
36
35
37
my $input         = CGI->new;
36
my $input         = CGI->new;
38
my $searchfield   = $input->param('description');
37
my $searchfield   = $input->param('description');
Lines 60-66 if ( $op eq 'add_form' ) { Link Here
60
    my $parent_types = Koha::ItemTypes->search({parent_type=>undef,itemtype => {'!='=>$itemtype_code}});
59
    my $parent_types = Koha::ItemTypes->search({parent_type=>undef,itemtype => {'!='=>$itemtype_code}});
61
    my $imagesets = C4::Koha::getImageSets( checked => ( $itemtype ? $itemtype->imageurl : undef ) );
60
    my $imagesets = C4::Koha::getImageSets( checked => ( $itemtype ? $itemtype->imageurl : undef ) );
62
    my $searchcategory = GetAuthorisedValues("ITEMTYPECAT");
61
    my $searchcategory = GetAuthorisedValues("ITEMTYPECAT");
63
    my $translated_languages = C4::Languages::getTranslatedLanguages( "both", C4::Context->preference('template') );
64
    $template->param(
62
    $template->param(
65
        itemtype  => $itemtype,
63
        itemtype  => $itemtype,
66
        parent_type => $parent_type,
64
        parent_type => $parent_type,
Lines 68-74 if ( $op eq 'add_form' ) { Link Here
68
        is_a_parent => $itemtype ? Koha::ItemTypes->search({parent_type=>$itemtype_code})->count : 0,
66
        is_a_parent => $itemtype ? Koha::ItemTypes->search({parent_type=>$itemtype_code})->count : 0,
69
        imagesets => $imagesets,
67
        imagesets => $imagesets,
70
        searchcategory => $searchcategory,
68
        searchcategory => $searchcategory,
71
        can_be_translated => ( scalar(@$translated_languages) > 1 ? 1 : 0 ),
69
        branches_loop    => \@branches_loop,
72
    );
70
    );
73
} elsif ( $op eq 'add_validate' ) {
71
} elsif ( $op eq 'add_validate' ) {
74
    my $is_a_modif   = $input->param('is_a_modif');
72
    my $is_a_modif   = $input->param('is_a_modif');
(-)a/admin/localization.pl (-20 lines)
Lines 21-29 use Modern::Perl; Link Here
21
use C4::Auth qw( get_template_and_user );
21
use C4::Auth qw( get_template_and_user );
22
use C4::Output qw( output_html_with_http_headers );
22
use C4::Output qw( output_html_with_http_headers );
23
23
24
use Koha::Localization;
25
use Koha::Localizations;
26
27
use CGI qw( -utf8 );
24
use CGI qw( -utf8 );
28
25
29
my $query = CGI->new;
26
my $query = CGI->new;
Lines 36-62 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
36
    }
33
    }
37
);
34
);
38
35
39
my $entity = $query->param('entity');
40
my $code   = $query->param('code');
41
my $rs     = Koha::Localizations->search( { entity => $entity, code => $code } );
42
my @translations;
43
while ( my $s = $rs->next ) {
44
    push @translations,
45
      { id          => $s->localization_id,
46
        entity      => $s->entity,
47
        code        => $s->code,
48
        lang        => $s->lang,
49
        translation => $s->translation,
50
      };
51
}
52
53
my $translated_languages = C4::Languages::getTranslatedLanguages( 'intranet', C4::Context->preference('template') );
36
my $translated_languages = C4::Languages::getTranslatedLanguages( 'intranet', C4::Context->preference('template') );
54
37
55
$template->param(
38
$template->param(
56
    translations => \@translations,
57
    languages    => $translated_languages,
39
    languages    => $translated_languages,
58
    entity       => $entity,
59
    code         => $code,
60
);
40
);
61
41
62
output_html_with_http_headers $query, $cookie, $template->output;
42
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/admin/smart-rules.pl (-31 / +1 lines)
Lines 671-677 $template->param( Link Here
671
671
672
my $patron_categories = Koha::Patron::Categories->search({}, { order_by => ['description'] });
672
my $patron_categories = Koha::Patron::Categories->search({}, { order_by => ['description'] });
673
673
674
my $itemtypes = Koha::ItemTypes->search_with_localization;
674
my $itemtypes = Koha::ItemTypes->search;
675
675
676
my $humanbranch = ( $branch ne '*' ? $branch : undef );
676
my $humanbranch = ( $branch ne '*' ? $branch : undef );
677
677
Lines 698-733 output_html_with_http_headers $input, $cookie, $template->output; Link Here
698
698
699
exit 0;
699
exit 0;
700
700
701
# sort by patron category, then item type, putting
702
# default entries at the bottom
703
sub by_category_and_itemtype {
704
    unless (by_category($a, $b)) {
705
        return by_itemtype($a, $b);
706
    }
707
}
708
709
sub by_category {
710
    my ($a, $b) = @_;
711
    if ($a->{'default_humancategorycode'}) {
712
        return ($b->{'default_humancategorycode'} ? 0 : 1);
713
    } elsif ($b->{'default_humancategorycode'}) {
714
        return -1;
715
    } else {
716
        return $a->{'humancategorycode'} cmp $b->{'humancategorycode'};
717
    }
718
}
719
720
sub by_itemtype {
721
    my ($a, $b) = @_;
722
    if ($a->{default_translated_description}) {
723
        return ($b->{'default_translated_description'} ? 0 : 1);
724
    } elsif ($b->{'default_translated_description'}) {
725
        return -1;
726
    } else {
727
        return lc $a->{'translated_description'} cmp lc $b->{'translated_description'};
728
    }
729
}
730
731
sub strip_non_numeric {
701
sub strip_non_numeric {
732
    my $string = shift;
702
    my $string = shift;
733
    $string =~ s/\s//g;
703
    $string =~ s/\s//g;
(-)a/authorities/authorities.pl (-2 / +6 lines)
Lines 32-37 use MARC::File::XML; Link Here
32
use C4::Biblio qw( TransformHtmlToMarc );
32
use C4::Biblio qw( TransformHtmlToMarc );
33
use Koha::Authority::Types;
33
use Koha::Authority::Types;
34
use Koha::ItemTypes;
34
use Koha::ItemTypes;
35
use Koha::I18N;
35
use vars qw( $tagslib);
36
use vars qw( $tagslib);
36
use vars qw( $authorised_values_sth);
37
use vars qw( $authorised_values_sth);
37
use vars qw( $is_a_modif );
38
use vars qw( $is_a_modif );
Lines 81-90 sub build_authorized_values_list { Link Here
81
        }
82
        }
82
    }
83
    }
83
    elsif ( $category eq "itemtypes" ) {
84
    elsif ( $category eq "itemtypes" ) {
84
        my $itemtypes = Koha::ItemTypes->search_with_localization;
85
        my $itemtypes = Koha::ItemTypes->search;
85
        while ( my $itemtype = $itemtypes->next ) {
86
        while ( my $itemtype = $itemtypes->next ) {
87
        push @authorised_values, ""
88
          unless ( $tagslib->{$tag}->{$subfield}->{mandatory}
89
            && ( $value || $tagslib->{$tag}->{$subfield}->{defaultvalue} ) );
86
            push @authorised_values, $itemtype->itemtype;
90
            push @authorised_values, $itemtype->itemtype;
87
            $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
91
            $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->description);
88
        }
92
        }
89
    }
93
    }
90
    else { # "true" authorised value
94
    else { # "true" authorised value
(-)a/catalogue/getitem-ajax.pl (-1 / +2 lines)
Lines 27-32 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;
30
use Koha::Items;
31
use Koha::Items;
31
use Koha::ItemTypes;
32
use Koha::ItemTypes;
32
33
Lines 75-81 if($itemnumber) { Link Here
75
76
76
    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
77
    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
77
    # We should not do that here, but call ->itemtype->description when needed instea
78
    # We should not do that here, but call ->itemtype->description when needed instea
78
    $item_unblessed->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description?
79
    $item_unblessed->{itemtype} = db_t('itemtype', $itemtype->description);
79
}
80
}
80
81
81
my $json_text = to_json( $item_unblessed, { utf8 => 1 } );
82
my $json_text = to_json( $item_unblessed, { utf8 => 1 } );
(-)a/catalogue/itemsearch.pl (-1 / +8 lines)
Lines 28-33 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;
31
use Koha::Item::Search::Field qw(GetItemSearchFields);
32
use Koha::Item::Search::Field qw(GetItemSearchFields);
32
use Koha::ItemTypes;
33
use Koha::ItemTypes;
33
use Koha::Libraries;
34
use Koha::Libraries;
Lines 277-283 if ( defined $format ) { Link Here
277
# Display the search form
278
# Display the search form
278
279
279
my @branches = map { value => $_->branchcode, label => $_->branchname }, Koha::Libraries->search( {}, { order_by => 'branchname' } )->as_list;
280
my @branches = map { value => $_->branchcode, label => $_->branchname }, Koha::Libraries->search( {}, { order_by => 'branchname' } )->as_list;
280
my @itemtypes = map { value => $_->itemtype, label => $_->translated_description }, Koha::ItemTypes->search_with_localization->as_list;
281
my @itemtypes;
282
foreach my $itemtype ( Koha::ItemTypes->search->as_list ) {
283
    push @itemtypes, {
284
        value => $itemtype->itemtype,
285
        label => db_t('itemtype', $itemtype->description),
286
    };
287
}
281
288
282
my @ccodes = Koha::AuthorisedValues->get_descriptions_by_koha_field({ kohafield => 'items.ccode' });
289
my @ccodes = Koha::AuthorisedValues->get_descriptions_by_koha_field({ kohafield => 'items.ccode' });
283
foreach my $ccode (@ccodes) {
290
foreach my $ccode (@ccodes) {
(-)a/catalogue/moredetail.pl (-3 / +4 lines)
Lines 36-41 use Koha::AuthorisedValues; Link Here
36
use Koha::Biblios;
36
use Koha::Biblios;
37
use Koha::Items;
37
use Koha::Items;
38
use Koha::Patrons;
38
use Koha::Patrons;
39
use Koha::I18N;
39
40
40
my $query=CGI->new;
41
my $query=CGI->new;
41
42
Lines 142-150 my $ccodes = Link Here
142
my $copynumbers =
143
my $copynumbers =
143
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
144
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
144
145
145
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
146
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
146
147
147
$data->{'itemtypename'} = $itemtypes->{ $data->{'itemtype'} }->{'translated_description'}
148
$data->{'itemtypename'} = db_t('itemtype', $itemtypes->{ $data->{'itemtype'} }->{description});
148
  if $data->{itemtype} && exists $itemtypes->{ $data->{itemtype} };
149
  if $data->{itemtype} && exists $itemtypes->{ $data->{itemtype} };
149
foreach ( keys %{$data} ) {
150
foreach ( keys %{$data} ) {
150
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
151
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
Lines 154-160 foreach ( keys %{$data} ) { Link Here
154
foreach my $item (@items){
155
foreach my $item (@items){
155
    $item->{object} = Koha::Items->find( $item->{itemnumber} );
156
    $item->{object} = Koha::Items->find( $item->{itemnumber} );
156
    $item->{'collection'}              = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} };
157
    $item->{'collection'}              = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} };
157
    $item->{'itype'}                   = $itemtypes->{ $item->{'itype'} }->{'translated_description'} if exists $itemtypes->{ $item->{'itype'} };
158
    $item->{'itype'}                   = db_t('itemtype', $itemtypes->{ $item->{'itype'} }->{description}) if exists $itemtypes->{ $item->{'itype'} };
158
    $item->{'replacementprice'}        = $item->{'replacementprice'};
159
    $item->{'replacementprice'}        = $item->{'replacementprice'};
159
    if ( defined $item->{'copynumber'} ) {
160
    if ( defined $item->{'copynumber'} ) {
160
        $item->{'displaycopy'} = 1;
161
        $item->{'displaycopy'} = 1;
(-)a/catalogue/search.pl (-5 / +13 lines)
Lines 156-161 use Koha::SearchEngine::Search; Link Here
156
use Koha::SearchEngine::QueryBuilder;
156
use Koha::SearchEngine::QueryBuilder;
157
use Koha::Virtualshelves;
157
use Koha::Virtualshelves;
158
use Koha::SearchFields;
158
use Koha::SearchFields;
159
use Koha::I18N;
159
160
160
use URI::Escape;
161
use URI::Escape;
161
162
Lines 502-508 my $facets; # this object stores the faceted results that display on the left-ha Link Here
502
my $results_hashref;
503
my $results_hashref;
503
504
504
eval {
505
eval {
505
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
506
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
506
    ( $error, $results_hashref, $facets ) = $searcher->search_compat(
507
    ( $error, $results_hashref, $facets ) = $searcher->search_compat(
507
        $query,            $simple_query, \@sort_by,       \@servers,
508
        $query,            $simple_query, \@sort_by,       \@servers,
508
        $results_per_page, $offset,       undef,           $itemtypes,
509
        $results_per_page, $offset,       undef,           $itemtypes,
Lines 729-735 sub prepare_adv_search_types { Link Here
729
    # the index parameter is different for item-level itemtypes
730
    # the index parameter is different for item-level itemtypes
730
    my $itype_or_itemtype =
731
    my $itype_or_itemtype =
731
      ( C4::Context->preference("item-level_itypes") ) ? 'itype' : 'itemtype';
732
      ( C4::Context->preference("item-level_itypes") ) ? 'itype' : 'itemtype';
732
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
733
    my $itemtypes = {
734
        map {
735
            $_->{itemtype} => {
736
                %$_,
737
                description => db_t( 'itemtype', $_->{description} ),
738
              }
739
        } @{ Koha::ItemTypes->search->unblessed }
740
    };
733
741
734
    my ( $cnt, @result );
742
    my ( $cnt, @result );
735
    foreach my $advanced_srch_type (@advanced_search_types) {
743
    foreach my $advanced_srch_type (@advanced_search_types) {
Lines 741-748 sub prepare_adv_search_types { Link Here
741
            my @itypesloop;
749
            my @itypesloop;
742
            foreach my $thisitemtype (
750
            foreach my $thisitemtype (
743
                sort {
751
                sort {
744
                    $itemtypes->{$a}->{'translated_description'}
752
                    $itemtypes->{$a}->{'description'}
745
                      cmp $itemtypes->{$b}->{'translated_description'}
753
                      cmp $itemtypes->{$b}->{'description'}
746
                } keys %$itemtypes
754
                } keys %$itemtypes
747
              )
755
              )
748
            {
756
            {
Lines 750-756 sub prepare_adv_search_types { Link Here
750
                    number      => $cnt++,
758
                    number      => $cnt++,
751
                    ccl         => "$itype_or_itemtype,phr",
759
                    ccl         => "$itype_or_itemtype,phr",
752
                    code        => $thisitemtype,
760
                    code        => $thisitemtype,
753
                    description => $itemtypes->{$thisitemtype}->{'translated_description'},
761
                    description => $itemtypes->{$thisitemtype}->{'description'},
754
                    imageurl    => getitemtypeimagelocation(
762
                    imageurl    => getitemtypeimagelocation(
755
                        'intranet', $itemtypes->{$thisitemtype}->{'imageurl'}
763
                        'intranet', $itemtypes->{$thisitemtype}->{'imageurl'}
756
                    ),
764
                    ),
(-)a/cataloguing/addbiblio.pl (-2 / +3 lines)
Lines 56-61 use Koha::Patrons; Link Here
56
use MARC::File::USMARC;
56
use MARC::File::USMARC;
57
use MARC::File::XML;
57
use MARC::File::XML;
58
use URI::Escape qw( uri_escape_utf8 );
58
use URI::Escape qw( uri_escape_utf8 );
59
use Koha::I18N;
59
60
60
if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
61
if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
61
    MARC::File::XML->default_record_format('UNIMARC');
62
    MARC::File::XML->default_record_format('UNIMARC');
Lines 192-201 sub build_authorized_values_list { Link Here
192
        push @authorised_values, "";
193
        push @authorised_values, "";
193
194
194
        my $itemtype;
195
        my $itemtype;
195
        my $itemtypes = Koha::ItemTypes->search_with_localization;
196
        my $itemtypes = Koha::ItemTypes->search;
196
        while ( $itemtype = $itemtypes->next ) {
197
        while ( $itemtype = $itemtypes->next ) {
197
            push @authorised_values, $itemtype->itemtype;
198
            push @authorised_values, $itemtype->itemtype;
198
            $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
199
            $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->description);
199
        }
200
        }
200
        $value = $itemtype unless ($value);
201
        $value = $itemtype unless ($value);
201
    }
202
    }
(-)a/cataloguing/additem.pl (+5 lines)
Lines 37-42 use C4::Circulation qw( barcodedecode LostItem ); Link Here
37
use C4::Barcodes;
37
use C4::Barcodes;
38
use C4::Barcodes::ValueBuilder;
38
use C4::Barcodes::ValueBuilder;
39
use Koha::DateUtils qw( dt_from_string );
39
use Koha::DateUtils qw( dt_from_string );
40
use Koha::I18N;
40
use Koha::Items;
41
use Koha::Items;
41
use Koha::ItemTypes;
42
use Koha::ItemTypes;
42
use Koha::Libraries;
43
use Koha::Libraries;
Lines 92-97 if( $input->param('itemnumber') && !$input->param('biblionumber') ){ Link Here
92
93
93
my $biblio = Koha::Biblios->find($biblionumber);
94
my $biblio = Koha::Biblios->find($biblionumber);
94
95
96
my $input        = new CGI;
97
my $error        = $input->param('error');
98
my $biblionumber = $input->param('biblionumber');
99
my $itemnumber   = $input->param('itemnumber');
95
my $op           = $input->param('op') || q{};
100
my $op           = $input->param('op') || q{};
96
my $hostitemnumber = $input->param('hostitemnumber');
101
my $hostitemnumber = $input->param('hostitemnumber');
97
my $marcflavour  = C4::Context->preference("marcflavour");
102
my $marcflavour  = C4::Context->preference("marcflavour");
(-)a/circ/transferstoreceive.pl (-1 / +2 lines)
Lines 28-33 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;
31
use Koha::Items;
32
use Koha::Items;
32
use Koha::ItemTypes;
33
use Koha::ItemTypes;
33
use Koha::Libraries;
34
use Koha::Libraries;
Lines 87-93 while ( my $library = $libraries->next ) { Link Here
87
            my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
88
            my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
88
89
89
            $getransf{'datetransfer'} = $num->{'datesent'};
90
            $getransf{'datetransfer'} = $num->{'datesent'};
90
            $getransf{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description?
91
            $getransf{'itemtype'} = db_t('itemtype', $itemtype->description);
91
            %getransf = (
92
            %getransf = (
92
                %getransf,
93
                %getransf,
93
                title          => $biblio->title,
94
                title          => $biblio->title,
(-)a/course_reserves/add_items.pl (-1 / +1 lines)
Lines 98-104 if ( $action eq 'lookup' and $item ) { Link Here
98
98
99
        ccodes    => GetAuthorisedValues('CCODE'),
99
        ccodes    => GetAuthorisedValues('CCODE'),
100
        locations => GetAuthorisedValues('LOC'),
100
        locations => GetAuthorisedValues('LOC'),
101
        itypes    => $itemtypes, # FIXME We certainly want to display the translated_description in the template
101
        itypes    => $itemtypes,
102
        return    => $return,
102
        return    => $return,
103
    );
103
    );
104
104
(-)a/installer/data/mysql/atomicupdate/bug-24975.perl (+48 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{
4
        CREATE TABLE IF NOT EXISTS l10n_source (
5
            l10n_source_id INT(11) NOT NULL AUTO_INCREMENT,
6
            context VARCHAR(100) NULL DEFAULT NULL,
7
            source TEXT NOT NULL,
8
            PRIMARY KEY (l10n_source_id),
9
            KEY context_source (context, source(60))
10
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
11
    });
12
13
    $dbh->do(q{
14
        CREATE TABLE IF NOT EXISTS l10n_target (
15
            l10n_target_id INT(11) NOT NULL AUTO_INCREMENT,
16
            l10n_source_id INT(11) NOT NULL,
17
            language VARCHAR(10) NOT NULL,
18
            translation TEXT NOT NULL,
19
            PRIMARY KEY (l10n_target_id),
20
            UNIQUE KEY l10n_source_language (l10n_source_id, language),
21
            FOREIGN KEY l10n_source (l10n_source_id) REFERENCES l10n_source (l10n_source_id)
22
                ON DELETE CASCADE ON UPDATE CASCADE
23
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
24
    });
25
26
    # Populate l10n_source and l10n_target for itemtypes
27
    $dbh->do(q{
28
        INSERT INTO l10n_source (context, source)
29
        SELECT DISTINCT 'itemtype', description FROM itemtypes
30
    });
31
32
    if (TableExists('localization')) {
33
        $dbh->do(q{
34
            INSERT INTO l10n_target (l10n_source_id, language, translation)
35
            SELECT DISTINCT l10n_source_id, lang, translation
36
            FROM localization
37
            JOIN itemtypes ON (localization.code = itemtypes.itemtype)
38
            JOIN l10n_source ON (itemtypes.description = l10n_source.source AND l10n_source.context = 'itemtype')
39
            WHERE entity = 'itemtypes'
40
        });
41
42
        $dbh->do('DROP TABLE localization');
43
    }
44
45
46
    SetVersion( $DBversion );
47
    print "Upgrade to $DBversion done (Bug 24975 - l10n_source, l10n_target)\n";
48
}
(-)a/installer/data/mysql/kohastructure.sql (+22 lines)
Lines 3203-3208 CREATE TABLE `keyboard_shortcuts` ( Link Here
3203
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3203
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3204
/*!40101 SET character_set_client = @saved_cs_client */;
3204
/*!40101 SET character_set_client = @saved_cs_client */;
3205
3205
3206
3207
DROP TABLE IF EXISTS l10n_source;
3208
CREATE TABLE l10n_source (
3209
    l10n_source_id INT(11) NOT NULL AUTO_INCREMENT,
3210
    context VARCHAR(100) NULL DEFAULT NULL,
3211
    source TEXT NOT NULL,
3212
    PRIMARY KEY (l10n_source_id),
3213
    KEY context_source (context, source(60))
3214
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
3215
3216
DROP TABLE IF EXISTS l10n_target;
3217
CREATE TABLE l10n_target (
3218
    l10n_target_id INT(11) NOT NULL AUTO_INCREMENT,
3219
    l10n_source_id INT(11) NOT NULL,
3220
    language VARCHAR(10) NOT NULL,
3221
    translation TEXT NOT NULL,
3222
    PRIMARY KEY (l10n_target_id),
3223
    UNIQUE KEY l10n_source_language (l10n_source_id, language),
3224
    FOREIGN KEY l10n_source (l10n_source_id) REFERENCES l10n_source (l10n_source_id)
3225
        ON DELETE CASCADE ON UPDATE CASCADE
3226
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
3227
3206
--
3228
--
3207
-- Table structure for table `language_descriptions`
3229
-- Table structure for table `language_descriptions`
3208
--
3230
--
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc (+1 lines)
Lines 166-171 Link Here
166
            [% IF ( Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts ) %]
166
            [% IF ( Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts ) %]
167
                <li><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></li>
167
                <li><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></li>
168
            [% END %]
168
            [% END %]
169
            <li><a href="/cgi-bin/koha/admin/localization.pl">Localization</a></li>
169
        </ul>
170
        </ul>
170
    [% END %]
171
    [% END %]
171
</div>
172
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (-1 / +2 lines)
Lines 1-3 Link Here
1
[% USE ItemTypes %]
1
[% BLOCK options_for_libraries %]
2
[% BLOCK options_for_libraries %]
2
    [% FOREACH l IN libraries %]
3
    [% FOREACH l IN libraries %]
3
        [% IF l.selected %]
4
        [% IF l.selected %]
Lines 64-70 Link Here
64
        [% ELSE %]
65
        [% ELSE %]
65
            <option value="[% itemtype.itemtype | html %]">
66
            <option value="[% itemtype.itemtype | html %]">
66
        [% END %]
67
        [% END %]
67
            [% itemtype.translated_description | html %]
68
            [% ItemTypes.t(itemtype.description) | html %]
68
        </option>
69
        </option>
69
    [% END %]
70
    [% END %]
70
[% END %]
71
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt (+3 lines)
Lines 268-273 Link Here
268
                        <dt><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></dt>
268
                        <dt><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></dt>
269
                        <dd>Define which keys trigger actions in the advanced cataloging editor</dd>
269
                        <dd>Define which keys trigger actions in the advanced cataloging editor</dd>
270
                    [% END %]
270
                    [% END %]
271
272
                    <dt><a href="/cgi-bin/koha/admin/localization.pl">Localization</a></dt>
273
                    <dd>Translate user-defined strings</dd>
271
                </dl>
274
                </dl>
272
            [% END %]
275
            [% END %]
273
            </div>
276
            </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (-4 / +2 lines)
Lines 1-5 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE ItemTypes %]
3
[% USE Koha %]
4
[% USE Koha %]
4
[% USE Branches %]
5
[% USE Branches %]
5
[% USE AuthorisedValues %]
6
[% USE AuthorisedValues %]
Lines 200-208 Item types &rsaquo; Administration &rsaquo; Koha Link Here
200
                <li>
201
                <li>
201
                    <label for="description" class="required">Description: </label>
202
                    <label for="description" class="required">Description: </label>
202
                    <input type="text" id="description" name="description" size="48" value="[% itemtype.description | html %]" required="required" /> <span class="required">Required</span>
203
                    <input type="text" id="description" name="description" size="48" value="[% itemtype.description | html %]" required="required" /> <span class="required">Required</span>
203
                    [% IF can_be_translated %]
204
                        <a href="/cgi-bin/koha/admin/localization.pl?entity=itemtypes&code=[% itemtype.itemtype | uri %]" title="Translate item type [% itemtype.itemtype | html %]" rel="gb_page_center[600,500]"><i class="fa fa-pencil"></i> Translate into other languages</a>
205
                    [% END %]
206
                </li>
204
                </li>
207
                <li>
205
                <li>
208
                    <label for="searchcategory">Search category: </label>
206
                    <label for="searchcategory">Search category: </label>
Lines 443-449 Item types &rsaquo; Administration &rsaquo; Koha Link Here
443
                <th scope="row">Item type</th>
441
                <th scope="row">Item type</th>
444
                <td>[% itemtype.itemtype | html %]</td>
442
                <td>[% itemtype.itemtype | html %]</td>
445
            </tr>
443
            </tr>
446
            <tr><th scope="row">Description</th><td>[% itemtype.translated_description | html %]</td></tr>
444
            <tr><th scope="row">Description</th><td>[% ItemTypes.t(itemtype.description) | html %]</td></tr>
447
            [% UNLESS Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') %]
445
            [% UNLESS Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') %]
448
                <tr>
446
                <tr>
449
                    <th scope="row">Image</th>
447
                    <th scope="row">Image</th>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/localization.tt (-243 / +128 lines)
Lines 1-277 Link Here
1
[% USE raw %]
1
[% USE JSON.Escape %]
2
[% USE Asset %]
3
[% SET footerjs = 1 %]
2
[% SET footerjs = 1 %]
4
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Localization &rsaquo; Koha</title>
4
<title>Localization &rsaquo; Koha</title>
6
[% INCLUDE 'doc-head-close.inc' popup => 1 %]
5
[% INCLUDE 'doc-head-close.inc' %]
7
<style>#localization { margin-top: 1em; }</style>
6
<style>
7
    #localization { margin-top: 1em; }
8
9
    .add-translation-block {
10
        margin-bottom: 5px;
11
    }
12
13
    .add-translation-block form {
14
        display: inline-flex;
15
        align-items: center;
16
    }
17
    code {
18
        background-color: lightgrey;
19
        font-weight: bold;
20
        display: inline-block;
21
        padding: 2px 4px;
22
    }
23
</style>
8
</head>
24
</head>
9
25
10
<body id="admin_localization" class="admin">
26
<body id="admin_localization" class="admin">
11
    <div class="container-fluid">
27
    [% INCLUDE 'header.inc' %]
12
        <div class="row">
28
    [% INCLUDE 'prefs-admin-search.inc' %]
13
            <div class="col-sm-12">
14
<form id="add_translation" method="post">
15
    <input type="hidden" name="entity" value="[% entity | html %]" />
16
    <input type="hidden" name="code" value="[% code | html %]" />
17
    <input type="hidden" name="interface" value="[% interface_side | html %]" />
18
    <fieldset class="rows clearfix">
19
        <ol>
20
            <li>
21
                <span class="label">Authorized value:</span>
22
                [% code | html %]
23
            </li>
24
            <li>
25
                <label for="lang">Language:</label>
26
                <select name="lang" id="lang">
27
                    [% FOR language IN languages %]
28
                        [% FOR sublanguage IN language.sublanguages_loop %]
29
                            [% IF language.plural %]
30
                                <option value="[% sublanguage.rfc4646_subtag | html %]">[% sublanguage.native_description | html %] [% sublanguage.region_description | html %] ([% sublanguage.rfc4646_subtag | html %])</option>
31
                            [% ELSE %]
32
                                <option value="[% sublanguage.rfc4646_subtag | html %]">[% sublanguage.native_description | html %] ([% sublanguage.rfc4646_subtag | html %])</option>
33
                            [% END %]
34
                        [% END %]
35
                    [% END %]
36
                </select>
37
            </li>
38
            <li>
39
                <label for="translation">Translation:</label>
40
                <input type="text" size="40" name="translation" id="translation" />
41
            </li>
42
            <li>
43
                <span class="label">&nbsp;</span>
44
                <input type="submit" value="Add" />
45
            </li>
46
        </ol>
47
    </fieldset>
48
</form>
49
            </div> <!-- /.col-sm-12 -->
50
        </div> <!-- /.row -->
51
29
52
        <div class="row">
30
    <div id="breadcrumbs">
53
            <div class="col-sm-12">
31
        <a href="/cgi-bin/koha/mainpage.pl">Home</a>
54
<div id="messages"></div>
32
        &rsaquo;
55
            </div> <!-- /.col-sm-12 -->
33
        <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
56
        </div> <!-- /.row -->
34
        &rsaquo;
35
        Localization
36
    </div>
37
38
    <div class="main container-fluid">
57
39
58
        <div class="row">
40
        <div class="row">
59
            <div class="col-sm-12">
41
            <div class="col-sm-10 col-sm-push-2">
60
<table id="localization">
42
                <main>
61
    <thead>
43
                    <h2>Localization</h2>
62
        <tr>
44
63
            <th>Id</th>
45
                    <table id="localization">
64
            <th>Entity</th>
46
                        <thead>
65
            <th>Code</th>
47
                            <tr>
66
            <th>Language</th>
48
                                <th>Context</th>
67
            <th>Translation</th>
49
                                <th>Source</th>
68
            <th class="NoSort">&nbsp;</th>
50
                                <th>Translations</th>
69
        </tr>
51
                            </tr>
70
    </thead>
52
                        </thead>
71
    <tbody>
53
                        <tbody>
72
        [% FOR t IN translations %]
54
                        </tbody>
73
        <tr id="row_id_[% t.id | html %]" data-id="[% t.id | html %]">
55
                    </table>
74
            <td>[% t.id | html %]</td>
56
                </main>
75
            <td>[% t.entity | html %]</td>
57
            </div>
76
            <td>[% t.code | html %]</td>
58
77
            <td class="lang">[% t.lang | html %]</td>
59
            <div class="col-sm-2 col-sm-pull-10">
78
            <td class="translation" contenteditable="true">[% t.translation | html %]</td>
60
                <aside>
79
            <td class="actions"><a href="#" class="delete"><i class="fa fa-trash"></i> Delete</a></td>
61
                    [% INCLUDE 'admin-menu.inc' %]
80
        </tr>
62
                </aside>
81
        [% END %]
63
            </div>
82
    </tbody>
64
        </div>
83
</table>
65
    </div>
84
            </div> <!-- /.col-sm-12 -->
85
        </div> <!-- /.row -->
86
    </div> <!-- /.container-fluid -->
87
66
88
[% MACRO jsinclude BLOCK %]
67
[% MACRO jsinclude BLOCK %]
89
    [% INCLUDE 'datatables.inc' %]
68
    [% INCLUDE 'datatables.inc' %]
90
    <script>
69
    <script>
91
70
92
        function show_message( params ) {
93
            var type = params.type;
94
            var data = params.data;
95
            var messages = $("#messages");
96
            var message;
97
            if ( type == 'success_on_update' ) {
98
                message = $('<div class="dialog message"></div>');
99
                message.text(_("Entity %s (code %s) for lang %s has correctly been updated with '%s'").format(data.entity, data.code, data.lang, data.translation));
100
            } else if ( type == 'error_on_update' ) {
101
                message = $('<div class="dialog alert"></div>');
102
                if ( data.error_code == 'already_exists' ) {
103
                    message.text(_("A translation already exists for this language."));
104
                } else {
105
                    message.text(_("An error occurred when updating this translation."));
106
                }
107
            } else if ( type == 'success_on_delete' ) {
108
                message = $('<div class="dialog message"></div>');
109
                message.text(_("The translation (id %s) has been removed successfully").format(data.id));
110
            } else if ( type == 'error_on_delete' ) {
111
                message = $('<div class="dialog alert"></div>');
112
                message.text(_("An error occurred when deleting this translation"));
113
            } else if ( type == 'success_on_insert' ) {
114
                message = $('<div class="dialog message"></div>');
115
                message.text(_("Translation (id %s) has been added successfully").format(data.id));
116
            } else if ( type == 'error_on_insert' ) {
117
                message = $('<div class="dialog alert"></div>');
118
                if ( data.error_code == 'already_exists' ) {
119
                    message.text(_("A translation already exists for this language."));
120
                } else {
121
                    message.text(_("An error occurred when adding this translation"));
122
                }
123
            }
124
125
            $(messages).append(message);
126
127
            setTimeout(function(){
128
                message.hide()
129
            }, 3000);
130
        }
131
132
        function send_update_request( data, cell ) {
71
        function send_update_request( data, cell ) {
133
            $.ajax({
72
            $.ajax({
134
                data: data,
73
                data: data,
135
                type: 'PUT',
74
                type: 'PUT',
136
                url: '/cgi-bin/koha/svc/localization',
75
                url: '/cgi-bin/koha/svc/localization',
137
                success: function (data) {
76
                success: function (data) {
138
                    if ( data.error ) {
77
                    $("#localization").DataTable().draw(false);
139
                        $(cell).css('background-color', '#FF0000');
140
                        show_message({ type: 'error_on_update', data: data });
141
                    } else if ( data.is_changed == 1 ) {
142
                        $(cell).css('background-color', '#00FF00');
143
                        show_message({ type: 'success_on_update', data: data });
144
                    }
145
146
                    if ( $(cell).hasClass('lang') ) {
147
                        $(cell).text(data.lang)
148
                    } else if ( $(cell).hasClass('translation') ) {
149
                        $(cell).text(data.translation)
150
                    }
151
                },
152
                error: function (data) {
153
                    $(cell).css('background-color', '#FF9090');
154
                    if ( $(cell).hasClass('lang') ) {
155
                        $(cell).text(data.lang)
156
                    } else if ( $(cell).hasClass('translation') ) {
157
                        $(cell).text(data.translation)
158
                    }
159
                    show_message({ type: 'error_on_update', data: data });
160
                },
161
            });
162
        }
163
164
        function send_delete_request( id, cell ) {
165
            $.ajax({
166
                type: 'DELETE',
167
                url: '/cgi-bin/koha/svc/localization/?id='+id,
168
                success: function (data) {
169
                    $("#localization").DataTable().row( '#row_id_' + id ).remove().draw();
170
                    show_message({ type: 'success_on_delete', data: data });
171
                },
172
                error: function (data) {
173
                    $(cell).css('background-color', '#FF9090');
174
                    show_message({ type: 'error_on_delete', data: data });
175
                },
78
                },
176
            });
79
            });
177
        }
80
        }
178
81
179
        $(document).ready(function() {
82
        $(document).ready(function() {
180
            $(".dialog").hide();
181
182
            var table = $("#localization").DataTable($.extend(true, {}, dataTablesDefaults, {
83
            var table = $("#localization").DataTable($.extend(true, {}, dataTablesDefaults, {
183
                "dom": 't',
84
                autoWidth: true,
184
                "columnDefs": [
85
                serverSide: true,
185
                    { 'sortable': false, 'targets': [ 'NoSort' ] }
86
                ordering: false,
186
                ],
87
                ajax: {
187
                'bPaginate': false,
188
                'autoWidth': false,
189
            }));
190
191
            var languages_select = $('<select name="lang" id="lang"></select>');
192
            [% FOR language IN languages %]
193
                [% FOR sublanguage IN language.sublanguages_loop %]
194
                    var option;
195
                    [% IF language.plural %]
196
                        option = $('<option value="[% sublanguage.rfc4646_subtag | html %]">[% sublanguage.native_description | html %] [% sublanguage.region_description | html %] ([% sublanguage.rfc4646_subtag | html %])</option>');
197
                        $(languages_select).append(option);
198
                    [% ELSE %]
199
                        option = $('<option value="[% sublanguage.rfc4646_subtag | html %]">[% sublanguage.native_description | html %] ([% sublanguage.rfc4646_subtag | html %])</option>');
200
                    [% END %]
201
                    $(languages_select).append(option);
202
                [% END %]
203
            [% END %]
204
205
            $("td.translation").on('focus', function(){
206
                $(this).css('background-color', '');
207
            });
208
            $("td.lang").on('click', function(){
209
                var td = this;
210
                var lang = $(td).text();
211
                $(td).css('background-color', '');
212
                var my_select = $(languages_select).clone();
213
                $(my_select).find('option[value="' + lang + '"]').attr('selected', 'selected');
214
                $(my_select).on('click', function(e){
215
                    e.stopPropagation();
216
                });
217
                $(my_select).on('change', function(){
218
                    var tr = $(this).parent().parent();
219
                    var id = $(tr).data('id');
220
                    var lang = $(this).find('option:selected').val();
221
                    var data = "id=" + encodeURIComponent(id) + "&lang=" + encodeURIComponent(lang);
222
                    send_update_request( data, td );
223
                });
224
                $(my_select).on('blur', function(){
225
                    $(td).html(lang);
226
                });
227
                $(this).html(my_select);
228
            });
229
230
            $("td.translation").on('blur', function(){
231
                var tr = $(this).parent();
232
                var id = $(tr).data('id');
233
                var translation = $(this).text();
234
                var data = "id=" + encodeURIComponent(id) + "&translation=" + encodeURIComponent(translation);
235
                send_update_request( data, this );
236
            });
237
238
            $("body").on("click", "a.delete", function(e){
239
                e.preventDefault();
240
                if ( confirm(_("Are you sure you want to delete this translation?")) ) {
241
                    var td = $(this).parent();
242
                    var tr = $(td).parent();
243
                    var id = $(tr).data('id');
244
                    send_delete_request( id, td );
245
                }
246
            });
247
248
            $("#add_translation").on('submit', function(e){
249
                e.preventDefault();
250
                var entity = $(this).find('input[name="entity"]').val();
251
                var code = $(this).find('input[name="code"]').val();
252
                var lang = $(this).find('select[name="lang"] option:selected').val();
253
                var translation = $(this).find('input[name="translation"]').val();
254
                var data = "entity=" + encodeURIComponent(entity) + "&code=" + encodeURIComponent(code) + "&lang=" + encodeURIComponent(lang) + "&translation=" + encodeURIComponent(translation);
255
                $.ajax({
256
                    data: data,
257
                    type: 'POST',
258
                    url: '/cgi-bin/koha/svc/localization',
88
                    url: '/cgi-bin/koha/svc/localization',
259
                    success: function (data) {
89
                },
260
                        if ( data.error ) {
90
                columns: [
261
                            show_message({ type: 'error_on_insert', data: data });
91
                    {
262
                        } else {
92
                        name: 'context',
263
                            var new_row = table.row.add( [ data.id, data.entity, data.code, data.lang, data.translation, "<a href=\"#\" class=\"delete\"><i class=\"fa fa-trash\"></i> Delete</a>" ] ).draw().node();
93
                        data: 'context',
264
                            $( new_row ).attr("id", "row_id_" + data.id ).data("id", data.id );
94
                    },
265
                            show_message({ type: 'success_on_insert', data: data });
95
                    {
266
                        }
96
                        name: 'source',
97
                        data: 'source',
267
                    },
98
                    },
268
                    error: function (data) {
99
                    {
269
                        show_message({ type: 'error_on_insert', data: data });
100
                        name: 'targets',
101
                        data: 'l10n_targets',
102
                        render: function (data, type, row, meta) {
103
                            const languages = [% languages.json %];
104
                            const translations = Object.fromEntries(data.map(translation => [translation.language, translation]));
105
                            let output = '';
106
                            for (const language of languages) {
107
                                const div = $('<div>');
108
                                div.addClass('add-translation-block');
109
                                const languageCode = $('<code>').text(language.rfc4646_subtag);
110
                                const translationSpan = $('<span>');
111
                                if (translations[language.rfc4646_subtag]) {
112
                                    const translation = translations[language.rfc4646_subtag].translation;
113
                                    translationSpan.text(translation);
114
                                } else {
115
                                    languageCode.html('<del>' + languageCode.text() + '</del>');
116
                                }
117
                                const translateLink = $('<a>');
118
                                translateLink.text('Translate');
119
                                translateLink.addClass('add-translation');
120
                                translateLink.attr('href', '#');
121
                                translateLink.attr('data-l10n-source-id', row.l10n_source_id);
122
                                translateLink.attr('data-language', language.rfc4646_subtag);
123
                                translateLink.attr('data-source', row.source);
124
                                if (translations[language.rfc4646_subtag]) {
125
                                    translateLink.attr('data-translation', translations[language.rfc4646_subtag].translation);
126
                                }
127
128
                                div.append(languageCode, ' ', translationSpan, ' ', translateLink);
129
130
                                output += ' ' + div[0].outerHTML;
131
                            }
132
133
                            return output;
134
                        },
270
                    },
135
                    },
136
                ],
137
            }));
138
139
            $('#localization').on('click', '.add-translation', function (ev) {
140
                ev.preventDefault();
141
                const form = $('<form>');
142
                const textarea = $('<textarea>').attr('rows', '1');
143
                textarea.text(ev.target.getAttribute('data-translation'));
144
                form.append(textarea);
145
                form.append('<button type="submit">Save</button>');
146
                const l10n_source_id = ev.target.getAttribute('data-l10n-source-id');
147
                const language = ev.target.getAttribute('data-language');
148
                form.on('submit', function (ev) {
149
                    ev.preventDefault();
150
                    send_update_request({
151
                        id: l10n_source_id,
152
                        lang: language,
153
                        translation: textarea.val(),
154
                    });
271
                });
155
                });
156
                $(ev.target).hide();
157
                $(ev.target).after(form);
272
            });
158
            });
273
274
         });
159
         });
275
    </script>
160
    </script>
276
[% END %]
161
[% END %]
277
[% INCLUDE 'popup-bottom.inc' %]
162
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-7 / +7 lines)
Lines 396-411 Link Here
396
                            <option value="*">All</option>
396
                            <option value="*">All</option>
397
                            [% FOREACH itemtypeloo IN itemtypeloop %]
397
                            [% FOREACH itemtypeloo IN itemtypeloop %]
398
                                [% NEXT IF itemtypeloo.parent_type %]
398
                                [% NEXT IF itemtypeloo.parent_type %]
399
                                [% SET children = itemtypeloo.children_with_localization %]
399
                                [% SET children = itemtypeloo.children %]
400
                                [% IF children.count %]
400
                                [% IF children.count %]
401
                                    <optgroup label="[% itemtypeloo.translated_description | html %]">
401
                                    <optgroup label="[% ItemTypes.t(itemtypeloo.description) | html %]">
402
                                        <option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %] (All)</option>
402
                                        <option value="[% itemtypeloo.itemtype | html %]">[% ItemTypes.t(itemtypeloo.description) | html %] (All)</option>
403
                                        [% FOREACH child IN children %]
403
                                        [% FOREACH child IN children %]
404
                                            <option value="[% child.itemtype | html %]">[% child.translated_description | html %]</option>
404
                                            <option value="[% child.itemtype | html %]">[% ItemTypes.t(child.description) | html %]</option>
405
                                        [% END %]
405
                                        [% END %]
406
                                    </optgroup>
406
                                    </optgroup>
407
                                [% ELSE %]
407
                                [% ELSE %]
408
                                    <option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %]</option>
408
                                    <option value="[% itemtypeloo.itemtype | html %]">[% ItemTypes.t(itemtypeloo.description) | html %]</option>
409
                                [% END %]
409
                                [% END %]
410
                            [% END %]
410
                            [% END %]
411
                        </select>
411
                        </select>
Lines 1094-1100 Link Here
1094
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
1094
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
1095
                        <tr>
1095
                        <tr>
1096
                            <td>
1096
                            <td>
1097
                                [% i.translated_description | html %]
1097
                                [% ItemTypes.t(i.description) | html %]
1098
                            </td>
1098
                            </td>
1099
                            <td>
1099
                            <td>
1100
                                [% IF holdallowed == 'from_any_library' %]
1100
                                [% IF holdallowed == 'from_any_library' %]
Lines 1139-1145 Link Here
1139
                    <td>
1139
                    <td>
1140
                        <select name="itemtype">
1140
                        <select name="itemtype">
1141
                        [% FOREACH itemtypeloo IN itemtypeloop %]
1141
                        [% FOREACH itemtypeloo IN itemtypeloop %]
1142
                            <option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %]</option>
1142
                            <option value="[% itemtypeloo.itemtype | html %]">[% ItemTypes.t(itemtypeloo.description) | html %]</option>
1143
                        [% END %]
1143
                        [% END %]
1144
                        </select>
1144
                        </select>
1145
                    </td>
1145
                    </td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt (-1 / +2 lines)
Lines 1-4 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE ItemTypes %]
2
[% USE Koha %]
3
[% USE Koha %]
3
[% USE Asset %]
4
[% USE Asset %]
4
[% USE Branches %]
5
[% USE Branches %]
Lines 198-204 Link Here
198
            [% END %]
199
            [% END %]
199
                &nbsp;
200
                &nbsp;
200
        [% END %]
201
        [% END %]
201
        [% itemtypeloo.description | html %]
202
        [% ItemTypes.t(itemtypeloo.description) | html %]
202
            </label>
203
            </label>
203
        </td>
204
        </td>
204
        [% IF ( loop.last ) %]
205
        [% IF ( loop.last ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +3 lines)
Lines 1-5 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE ItemTypes %]
3
[% USE Koha %]
4
[% USE Koha %]
4
[% USE KohaDates %]
5
[% USE KohaDates %]
5
[% USE KohaPlugins %]
6
[% USE KohaPlugins %]
Lines 370-378 Link Here
370
                    [% IF ( item_level_itypes ) %]
371
                    [% IF ( item_level_itypes ) %]
371
                        <td class="itype">
372
                        <td class="itype">
372
                            [% IF !noItemTypeImages && item.imageurl %]
373
                            [% IF !noItemTypeImages && item.imageurl %]
373
                                <img src="[% item.imageurl | html %]" alt="[% item.translated_description | html %]" title="[% item.translated_description | html %]" />
374
                                <img src="[% item.imageurl | html %]" alt="[% ItemTypes.t(item.description) | html %]" title="[% ItemTypes.t(item.description) | html %]" />
374
                            [% END %]
375
                            [% END %]
375
                            <span class="itypedesc">[% item.translated_description | html %]</span>
376
                            <span class="itypedesc">[% ItemTypes.t(item.description) | html %]</span>
376
                        </td>
377
                        </td>
377
                    [% END %]
378
                    [% END %]
378
                    <td class="location">[% UNLESS ( singlebranchmode ) %][% Branches.GetName( item.branchcode ) | html %] [% END %]</td>
379
                    <td class="location">[% UNLESS ( singlebranchmode ) %][% Branches.GetName( item.branchcode ) | html %] [% END %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt (-2 / +3 lines)
Lines 1-4 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% USE ItemTypes %]
2
[% SET footerjs = 1 %]
3
[% SET footerjs = 1 %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>[% IF is_edit || course_reserve %]Edit item[% ELSE %]Add items[% END %] &rsaquo; Course reserves &rsaquo; Koha</title>
5
<title>[% IF is_edit || course_reserve %]Edit item[% ELSE %]Add items[% END %] &rsaquo; Course reserves &rsaquo; Koha</title>
Lines 79-87 Link Here
79
                            <option value=""></option>
80
                            <option value=""></option>
80
                            [% FOREACH it IN itypes %]
81
                            [% FOREACH it IN itypes %]
81
                                [% IF it.itemtype == course_item.itype %]
82
                                [% IF it.itemtype == course_item.itype %]
82
                                    <option value="[% it.itemtype | html %]" selected="selected">[% it.description | html %]</option>
83
                                    <option value="[% it.itemtype | html %]" selected="selected">[% ItemTypes.t(it.description) | html %]</option>
83
                                [% ELSE %]
84
                                [% ELSE %]
84
                                    <option value="[% it.itemtype | html %]">[% it.description | html %]</option>
85
                                    <option value="[% it.itemtype | html %]">[% ItemTypes.t(it.description) | html %]</option>
85
                                [% END %]
86
                                [% END %]
86
                            [% END %]
87
                            [% END %]
87
                        </select>
88
                        </select>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_add_items.tt (-1 / +1 lines)
Lines 56-62 Link Here
56
                                <option value=""></option>
56
                                <option value=""></option>
57
57
58
                                [% FOREACH it IN ItemTypes.Get() %]
58
                                [% FOREACH it IN ItemTypes.Get() %]
59
                                    <option value="[% it.itemtype | html %]">[% it.description | html %]</option>
59
                                    <option value="[% it.itemtype | html %]">[% ItemTypes.t(it.description) | html %]</option>
60
                                [% END %]
60
                                [% END %]
61
                            </select>
61
                            </select>
62
                        </li>
62
                        </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt (-1 / +2 lines)
Lines 1-3 Link Here
1
[% USE ItemTypes %]
1
[% SET footerjs = 1 %]
2
[% SET footerjs = 1 %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>[% IF ( do_it ) %]Acquisitions statistics &rsaquo; Results[% ELSE %]Acquisitions statistics[% END %] &rsaquo; Reports &rsaquo; Koha</title>
4
<title>[% IF ( do_it ) %]Acquisitions statistics &rsaquo; Results[% ELSE %]Acquisitions statistics[% END %] &rsaquo; Reports &rsaquo; Koha</title>
Lines 218-224 Link Here
218
                    <select name="Filter" id="itemtypes">
219
                    <select name="Filter" id="itemtypes">
219
                        <option value="">All item types</option>
220
                        <option value="">All item types</option>
220
                        [% FOREACH itemtype IN itemtypes %]
221
                        [% FOREACH itemtype IN itemtypes %]
221
                        <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
222
                        <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
222
                        [% END %]
223
                        [% END %]
223
                    </select>
224
                    </select>
224
                </td>
225
                </td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt (-1 / +1 lines)
Lines 144-150 Link Here
144
			<li> 
144
			<li> 
145
                <label for="documenttype">Item type: </label><select name="Filter" id="documenttype"><option value="" > Any item type</option>
145
                <label for="documenttype">Item type: </label><select name="Filter" id="documenttype"><option value="" > Any item type</option>
146
    [% FOREACH itemtype IN itemtypes %]
146
    [% FOREACH itemtype IN itemtypes %]
147
        <option value="[% itemtype.itemtype | html %]" >[% itemtype.translated_description | html %] </option>
147
        <option value="[% itemtype.itemtype | html %]" >[% ItemTypes.t(itemtype.description) | html %] </option>
148
     [% END %] 
148
     [% END %] 
149
    </select>
149
    </select>
150
			</li>
150
			</li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cat_issues_top.tt (-1 / +2 lines)
Lines 1-4 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% USE ItemTypes %]
2
[% SET footerjs = 1 %]
3
[% SET footerjs = 1 %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Most-circulated items[% IF ( do_it ) %] &rsaquo; Results[% END %] &rsaquo; Reports &rsaquo; Koha</title>
5
<title>Most-circulated items[% IF ( do_it ) %] &rsaquo; Results[% END %] &rsaquo; Reports &rsaquo; Koha</title>
Lines 120-126 Link Here
120
      <li> 
121
      <li> 
121
        <label for="documenttype">Item type: </label><select name="Filter" id="documenttype"><option value="" > Any item type</option>
122
        <label for="documenttype">Item type: </label><select name="Filter" id="documenttype"><option value="" > Any item type</option>
122
    [% FOREACH itemtype IN itemtypes %]
123
    [% FOREACH itemtype IN itemtypes %]
123
        <option value="[% itemtype.itemtype | html %]" >[% itemtype.translated_description | html %] </option>
124
        <option value="[% itemtype.itemtype | html %]" >[% ItemTypes.t(itemtype.description) | html %] </option>
124
     [% END %] 
125
     [% END %] 
125
    </select>
126
    </select>
126
      </li>
127
      </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_out.tt (-1 / +2 lines)
Lines 1-4 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% USE ItemTypes %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Items with no checkouts &rsaquo; Reports &rsaquo; Koha</title>
4
<title>Items with no checkouts &rsaquo; Reports &rsaquo; Koha</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
Lines 112-118 Link Here
112
        <label for="documenttype">Item type: </label><select name="Filter" id="documenttype">
113
        <label for="documenttype">Item type: </label><select name="Filter" id="documenttype">
113
        <option value="">Any item type</option>
114
        <option value="">Any item type</option>
114
    [% FOREACH itemtype IN itemtypes %]
115
    [% FOREACH itemtype IN itemtypes %]
115
        <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
116
        <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
116
     [% END %] 
117
     [% END %] 
117
    </select>
118
    </select>
118
    </li>
119
    </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_stats.tt (-1 / +2 lines)
Lines 1-4 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% USE ItemTypes %]
2
[% SET footerjs = 1 %]
3
[% SET footerjs = 1 %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>[% IF ( do_it ) %]Catalog statistics &rsaquo; Results[% ELSE %]Catalog statistics[% END %] &rsaquo; Reports &rsaquo; Koha</title>
5
<title>[% IF ( do_it ) %]Catalog statistics &rsaquo; Results[% ELSE %]Catalog statistics[% END %] &rsaquo; Reports &rsaquo; Koha</title>
Lines 134-140 Link Here
134
				<td><select name="Filter" id="[% item_itype | html %]">
135
				<td><select name="Filter" id="[% item_itype | html %]">
135
					<option value=""> </option>
136
					<option value=""> </option>
136
                    [% FOREACH itemtype IN itemtypes %]
137
                    [% FOREACH itemtype IN itemtypes %]
137
                        <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
138
                        <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
138
                    [% END %]
139
                    [% END %]
139
					</select>
140
					</select>
140
				</td>
141
				</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_avg_stats.tt (-1 / +2 lines)
Lines 1-4 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% USE ItemTypes %]
2
[% SET footerjs = 1 %]
3
[% SET footerjs = 1 %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Average loan time &rsaquo; Reports &rsaquo; Koha</title>
5
<title>Average loan time &rsaquo; Reports &rsaquo; Koha</title>
Lines 170-176 Link Here
170
                    <select name="Filter" id="itemtypes">
171
                    <select name="Filter" id="itemtypes">
171
                        <option value=""></option>
172
                        <option value=""></option>
172
                        [% FOREACH itemtype IN itemtypes %]
173
                        [% FOREACH itemtype IN itemtypes %]
173
                        <option value="[%- itemtype.itemtype | html -%]">[%- itemtype.translated_description | html -%]</option>
174
                        <option value="[%- itemtype.itemtype | html -%]">[%- ItemTypes.t(itemtype.description) | html -%]</option>
174
                        [% END %]
175
                        [% END %]
175
                    </select>
176
                    </select>
176
                </td>
177
                </td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt (-1 / +2 lines)
Lines 1-4 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% USE ItemTypes %]
2
[% SET footerjs = 1 %]
3
[% SET footerjs = 1 %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Circulation statistics[% IF ( do_it ) %] &rsaquo; Results[% END %] &rsaquo; Reports &rsaquo; Koha</title>
5
<title>Circulation statistics[% IF ( do_it ) %] &rsaquo; Results[% END %] &rsaquo; Reports &rsaquo; Koha</title>
Lines 196-202 Link Here
196
           <td><select name="Filter" id="itemtype">
197
           <td><select name="Filter" id="itemtype">
197
               <option value=""> </option>
198
               <option value=""> </option>
198
               [% FOREACH itemtype IN itemtypes %]
199
               [% FOREACH itemtype IN itemtypes %]
199
                 <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
200
                 <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
200
               [% END %]
201
               [% END %]
201
               </select>
202
               </select>
202
             </td> 
203
             </td> 
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt (-1 / +1 lines)
Lines 155-161 Link Here
155
    <li><label for="itemtypesfilter">Item type: </label><select name="itemtypesfilter" id="itemtypesfilter">
155
    <li><label for="itemtypesfilter">Item type: </label><select name="itemtypesfilter" id="itemtypesfilter">
156
                <option value="">All</option>
156
                <option value="">All</option>
157
                [% FOREACH itemtype IN itemtypes %]
157
                [% FOREACH itemtype IN itemtypes %]
158
                    <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
158
                    <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
159
                [% END %]
159
                [% END %]
160
            </select></li>
160
            </select></li>
161
161
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt (-1 / +2 lines)
Lines 1-4 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% USE ItemTypes %]
2
[% SET footerjs = 1 %]
3
[% SET footerjs = 1 %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Holds statistics[% IF ( do_it ) %] &rsaquo; Results[% END %] &rsaquo; Reports &rsaquo; Koha</title>
5
<title>Holds statistics[% IF ( do_it ) %] &rsaquo; Results[% END %] &rsaquo; Reports &rsaquo; Koha</title>
Lines 198-204 Link Here
198
           <td><select name="filter_items.itype" id="itype">
199
           <td><select name="filter_items.itype" id="itype">
199
               <option value=""> </option>
200
               <option value=""> </option>
200
               [% FOREACH itemtype IN itemtypes %]
201
               [% FOREACH itemtype IN itemtypes %]
201
                 <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
202
                 <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
202
               [% END %]
203
               [% END %]
203
               </select>
204
               </select>
204
             </td> 
205
             </td> 
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-4 / +5 lines)
Lines 1-6 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE To %]
2
[% USE To %]
3
[% USE Asset %]
3
[% USE Asset %]
4
[% USE ItemTypes %]
4
[% USE KohaDates %]
5
[% USE KohaDates %]
5
[% USE Branches %]
6
[% USE Branches %]
6
[% USE Koha %]
7
[% USE Koha %]
Lines 205-213 fieldset.rows table { clear: none; margin: 0; } Link Here
205
                                        <option value=""></option>
206
                                        <option value=""></option>
206
                                        [% FOREACH type IN typeloop %]
207
                                        [% FOREACH type IN typeloop %]
207
                                            [% IF ( type.selected ) %]
208
                                            [% IF ( type.selected ) %]
208
                                                <option value="[% type.code | html %]" selected="selected">[% type.value | html %]</option>
209
                                                <option value="[% type.code | html %]" selected="selected">[% ItemTypes.t(type.value) | html %]</option>
209
                                            [% ELSE %]
210
                                            [% ELSE %]
210
                                                <option value="[% type.code | html %]">[% type.value | html %]</option>
211
                                                <option value="[% type.code | html %]">[% ItemTypes.t(type.value) | html %]</option>
211
                                            [% END %]
212
                                            [% END %]
212
                                        [% END %]
213
                                        [% END %]
213
                                    </select>
214
                                    </select>
Lines 219-227 fieldset.rows table { clear: none; margin: 0; } Link Here
219
                                            <option value=""></option>
220
                                            <option value=""></option>
220
                                        [% FOREACH previous IN previoustypeloop %]
221
                                        [% FOREACH previous IN previoustypeloop %]
221
                                            [% IF ( previous.selected ) %]
222
                                            [% IF ( previous.selected ) %]
222
                                                <option value="[% previous.code | html %]" selected="selected">[% previous.value | html %]</option>
223
                                                <option value="[% previous.code | html %]" selected="selected">[% ItemTypes.t(previous.value) | html %]</option>
223
                                            [% ELSE %]
224
                                            [% ELSE %]
224
                                                <option value="[% previous.code | html %]">[% previous.value | html %]</option>
225
                                                <option value="[% previous.code | html %]">[% ItemTypes.t(previous.value) | html %]</option>
225
                                            [% END %]
226
                                            [% END %]
226
                                        [% END %]
227
                                        [% END %]
227
                                    </select>
228
                                    </select>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-batchedit.tt (-1 / +1 lines)
Lines 119-125 Link Here
119
                                    <select id="itemtype" name="itemtype">
119
                                    <select id="itemtype" name="itemtype">
120
                                        <option value="">No change</option>
120
                                        <option value="">No change</option>
121
                                        [% FOREACH itemtype IN ItemTypes.Get() %]
121
                                        [% FOREACH itemtype IN ItemTypes.Get() %]
122
                                            <option value="[% itemtype.itemtype | html %]">[% itemtype.description | html %]</option>
122
                                            <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
123
                                        [% END %]
123
                                        [% END %]
124
                                    </select>
124
                                    </select>
125
                                </li>
125
                                </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-bib-search.tt (-1 / +2 lines)
Lines 1-3 Link Here
1
[% USE ItemTypes %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Catalog search &rsaquo; Serials &rsaquo; Koha</title>
3
<title>Catalog search &rsaquo; Serials &rsaquo; Koha</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 25-31 Link Here
25
                <option value="">All</option>
26
                <option value="">All</option>
26
                [%- FOREACH itemtypeloo IN itemtypeloop %]
27
                [%- FOREACH itemtypeloo IN itemtypeloop %]
27
                <option value="[% itemtypeloo.code | html %]">
28
                <option value="[% itemtypeloo.code | html %]">
28
                    [% itemtypeloo.description | html %]
29
                    [% ItemTypes.t(itemtypeloo.description) | html %]
29
                </option>
30
                </option>
30
                [%- END %]
31
                [%- END %]
31
            </select>
32
            </select>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt (-1 / +2 lines)
Lines 1-6 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Branches %]
3
[% USE Branches %]
4
[% USE ItemTypes %]
4
[% SET footerjs = 1 %]
5
[% SET footerjs = 1 %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Export data &rsaquo; Tools &rsaquo; Koha</title>
7
<title>Export data &rsaquo; Tools &rsaquo; Koha</title>
Lines 80-86 Link Here
80
            <select name="itemtype" id="itemtype">
81
            <select name="itemtype" id="itemtype">
81
                <option value="">-- All --</option>
82
                <option value="">-- All --</option>
82
                [% FOREACH itemtype IN itemtypes %]
83
                [% FOREACH itemtype IN itemtypes %]
83
                    <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
84
                    <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
84
                [% END %]
85
                [% END %]
85
            </select>
86
            </select>
86
        </li>
87
        </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (-1 / +2 lines)
Lines 1-5 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE ItemTypes %]
3
[% USE Koha %]
4
[% USE Koha %]
4
[% USE KohaDates %]
5
[% USE KohaDates %]
5
[% SET footerjs = 1 %]
6
[% SET footerjs = 1 %]
Lines 259-265 Link Here
259
                </td>
260
                </td>
260
            [% END %]
261
            [% END %]
261
			[% UNLESS ( item_level_itypes ) %]<td>
262
			[% UNLESS ( item_level_itypes ) %]<td>
262
                [% UNLESS ( noItemTypeImages || !itemsloo.imageurl ) %]<img src="[% itemsloo.imageurl | html %]" alt="[% itemsloo.description | html %]" title="[% itemsloo.description | html %]" />[% END %][% itemsloo.description | html %]
263
                [% UNLESS ( noItemTypeImages || !itemsloo.imageurl ) %]<img src="[% itemsloo.imageurl | html %]" alt="[% ItemTypes.t(itemsloo.description) | html %]" title="[% ItemTypes.t(itemsloo.description) | html %]" />[% END %][% ItemTypes.t(itemsloo.description) | html %]
263
			</td>[% END %]
264
			</td>[% END %]
264
			<td>
265
			<td>
265
                [% IF ( itemsloo.XSLTBloc ) %]
266
                [% IF ( itemsloo.XSLTBloc ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-topissues.inc (-1 / +2 lines)
Lines 1-3 Link Here
1
[% USE ItemTypes %]
1
[% USE Koha %]
2
[% USE Koha %]
2
[% USE Branches %]
3
[% USE Branches %]
3
[% PROCESS 'html_helpers.inc' %]
4
[% PROCESS 'html_helpers.inc' %]
Lines 37-43 Link Here
37
                                [% ELSE %]
38
                                [% ELSE %]
38
                                    <option value="[% itemtype.itemtype | html %]">
39
                                    <option value="[% itemtype.itemtype | html %]">
39
                                [% END %]
40
                                [% END %]
40
                                    [% itemtype.translated_description | html %]
41
                                    [% ItemTypes.t(itemtype.description) | html %]
41
                                </option>
42
                                </option>
42
                            [% END %]
43
                            [% END %]
43
                        </select>
44
                        </select>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt (-1 / +2 lines)
Lines 1-4 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE ItemTypes %]
2
[% USE Koha %]
3
[% USE Koha %]
3
[% USE KohaDates %]
4
[% USE KohaDates %]
4
[% USE TablesSettings %]
5
[% USE TablesSettings %]
Lines 160-166 Link Here
160
                                                    [% END %]
161
                                                    [% END %]
161
                                                [% END %]
162
                                                [% END %]
162
                                                <span class="tdlabel">Item type:</span>
163
                                                <span class="tdlabel">Item type:</span>
163
                                                [% issue.translated_description | html %]</td>
164
                                                [% ItemTypes.t(issue.description) | html %]</td>
164
                                                <td>
165
                                                <td>
165
                                                <span class="tdlabel">Call number:</span>
166
                                                <span class="tdlabel">Call number:</span>
166
                                                [% issue.itemcallnumber | html %]
167
                                                [% issue.itemcallnumber | html %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-2 / +2 lines)
Lines 224-230 Link Here
224
                                                <li class="itype">
224
                                                <li class="itype">
225
                                                    <span class="label">Item type: </span>
225
                                                    <span class="label">Item type: </span>
226
                                                    [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl | html %]" alt="" />[% END %]
226
                                                    [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl | html %]" alt="" />[% END %]
227
                                                    [% bibitemloo.translated_description | html %]
227
                                                    [% ItemTypes.t(bibitemloo.description) | html %]
228
                                                </li>
228
                                                </li>
229
                                            [% END %]
229
                                            [% END %]
230
230
Lines 406-412 Link Here
406
                                                                            <img src="[% itemLoo.imageurl | html %]" alt="" />
406
                                                                            <img src="[% itemLoo.imageurl | html %]" alt="" />
407
                                                                        [% END %]
407
                                                                        [% END %]
408
                                                                    [% END %]
408
                                                                    [% END %]
409
                                                                    [% itemLoo.translated_description | html %]
409
                                                                    [% ItemTypes.t(itemLoo.description) | html %]
410
                                                                </td>
410
                                                                </td>
411
                                                            [% END %]
411
                                                            [% END %]
412
412
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt (-2 / +3 lines)
Lines 1-5 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE ItemTypes %]
3
[% USE Koha %]
4
[% USE Koha %]
4
[% USE AdditionalContents %]
5
[% USE AdditionalContents %]
5
[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
6
[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
Lines 383-391 Link Here
383
                                                    [% UNLESS ( item_level_itypes ) %]
384
                                                    [% UNLESS ( item_level_itypes ) %]
384
                                                        <td>
385
                                                        <td>
385
                                                            [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
386
                                                            [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
386
                                                                <img src="[% itemsloo.imageurl | html %]" alt="[% itemsloo.description | html %]" title="[% itemsloo.description | html %]" />
387
                                                                <img src="[% itemsloo.imageurl | html %]" alt="[% ItemTypes.t(itemsloo.description) | html %]" title="[% ItemTypes.t(itemsloo.description) | html %]" />
387
                                                            [% END %]
388
                                                            [% END %]
388
                                                            [% itemsloo.description | html %]
389
                                                            [% ItemTypes.t(itemsloo.description) | html %]
389
                                                        </td>
390
                                                        </td>
390
                                                    [% END %]
391
                                                    [% END %]
391
                                                    <td>
392
                                                    <td>
(-)a/labels/label-item-search.pl (-13 lines)
Lines 217-236 else { Link Here
217
            flagsrequired   => { catalogue => 1 },
217
            flagsrequired   => { catalogue => 1 },
218
        }
218
        }
219
    );
219
    );
220
    my $itemtypes = Koha::ItemTypes->search;
221
    my @itemtypeloop;
222
    while ( my $itemtype = $itemtypes->next ) {
223
        # FIXME This must be improved:
224
        # - pass the iterator to the template
225
        # - display the translated_description
226
        my %row = (
227
            value       => $itemtype->itemtype,
228
            description => $itemtype->description,
229
        );
230
        push @itemtypeloop, \%row;
231
    }
232
    $template->param(
220
    $template->param(
233
        itemtypeloop => \@itemtypeloop,
234
        batch_id     => $batch_id,
221
        batch_id     => $batch_id,
235
        type         => $type,
222
        type         => $type,
236
    );
223
    );
(-)a/opac/opac-detail.pl (-4 / +5 lines)
Lines 74-79 use Koha::Biblios; Link Here
74
use Koha::RecordProcessor;
74
use Koha::RecordProcessor;
75
use Koha::AuthorisedValues;
75
use Koha::AuthorisedValues;
76
use Koha::CirculationRules;
76
use Koha::CirculationRules;
77
use Koha::I18N;
77
use Koha::Items;
78
use Koha::Items;
78
use Koha::ItemTypes;
79
use Koha::ItemTypes;
79
use Koha::Acquisition::Orders;
80
use Koha::Acquisition::Orders;
Lines 236-242 if ($session->param('busc')) { Link Here
236
    {
237
    {
237
        my ($arrParamsBusc, $offset, $results_per_page, $patron) = @_;
238
        my ($arrParamsBusc, $offset, $results_per_page, $patron) = @_;
238
239
239
        my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
240
        my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
240
        my @servers;
241
        my @servers;
241
        @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
242
        @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
242
        @servers = ("biblioserver") unless (@servers);
243
        @servers = ("biblioserver") unless (@servers);
Lines 540-551 my $HideMARC = $record_processor->filters->[0]->should_hide_marc( Link Here
540
        interface     => 'opac',
541
        interface     => 'opac',
541
    } );
542
    } );
542
543
543
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
544
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
544
# imageurl:
545
# imageurl:
545
my $itemtype = $dat->{'itemtype'};
546
my $itemtype = $dat->{'itemtype'};
546
if ( $itemtype ) {
547
if ( $itemtype ) {
547
    $dat->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
548
    $dat->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
548
    $dat->{'description'} = $itemtypes->{$itemtype}->{translated_description};
549
    $dat->{'description'} = db_t('itemtype', $itemtypes->{$itemtype}->{description});
549
}
550
}
550
551
551
my $shelflocations =
552
my $shelflocations =
Lines 724-730 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
724
    }
725
    }
725
    if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
726
    if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
726
        $itm->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
727
        $itm->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
727
        $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{translated_description};
728
        $itm->{'description'} = db_t('itemtype', $itemtypes->{ $itm->{itype} }->{description});
728
    }
729
    }
729
    foreach (qw(ccode materials enumchron copynumber itemnotes location_description uri)) {
730
    foreach (qw(ccode materials enumchron copynumber itemnotes location_description uri)) {
730
        $itemfields{$_} = 1 if ($itm->{$_});
731
        $itemfields{$_} = 1 if ($itm->{$_});
(-)a/opac/opac-readingrecord.pl (-3 / +2 lines)
Lines 54-60 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
54
    }
54
    }
55
);
55
);
56
56
57
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
57
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
58
58
59
# get the record
59
# get the record
60
my $order = $query->param('order') || '';
60
my $order = $query->param('order') || '';
Lines 83-90 my $opac_summary_html = C4::Context->preference('OPACMySummaryHTML'); Link Here
83
foreach my $issue ( @{$issues} ) {
83
foreach my $issue ( @{$issues} ) {
84
    $issue->{normalized_isbn} = GetNormalizedISBN( $issue->{isbn} );
84
    $issue->{normalized_isbn} = GetNormalizedISBN( $issue->{isbn} );
85
    if ( $issue->{$itype_attribute} ) {
85
    if ( $issue->{$itype_attribute} ) {
86
        $issue->{translated_description} =
86
        $issue->{description} = $itemtypes->{ $issue->{$itype_attribute} }->{description};
87
          $itemtypes->{ $issue->{$itype_attribute} }->{translated_description};
88
        $issue->{imageurl} =
87
        $issue->{imageurl} =
89
          getitemtypeimagelocation( 'opac',
88
          getitemtypeimagelocation( 'opac',
90
            $itemtypes->{ $issue->{$itype_attribute} }->{imageurl} );
89
            $itemtypes->{ $issue->{$itype_attribute} }->{imageurl} );
(-)a/opac/opac-reserve.pl (-4 / +4 lines)
Lines 97-103 if ( $reservefee > 0){ Link Here
97
    $template->param( RESERVE_CHARGE => $reservefee);
97
    $template->param( RESERVE_CHARGE => $reservefee);
98
}
98
}
99
99
100
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
100
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
101
101
102
# There are two ways of calling this script, with a single biblio num
102
# There are two ways of calling this script, with a single biblio num
103
# or multiple biblio nums.
103
# or multiple biblio nums.
Lines 443-455 foreach my $biblioNum (@biblionumbers) { Link Here
443
    $biblioLoopIter{reqholdnotes}=0; #TODO: For future use
443
    $biblioLoopIter{reqholdnotes}=0; #TODO: For future use
444
444
445
    if (!$itemLevelTypes && $biblioData->{itemtype}) {
445
    if (!$itemLevelTypes && $biblioData->{itemtype}) {
446
        $biblioLoopIter{translated_description} = $itemtypes->{$biblioData->{itemtype}}{translated_description};
446
        $biblioLoopIter{description} = $itemtypes->{$biblioData->{itemtype}}{description};
447
        $biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$biblioData->{itemtype}}{imageurl};
447
        $biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$biblioData->{itemtype}}{imageurl};
448
    }
448
    }
449
449
450
    foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
450
    foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
451
        if ($itemLevelTypes && $itemInfo->{itype}) {
451
        if ($itemLevelTypes && $itemInfo->{itype}) {
452
            $itemInfo->{translated_description} = $itemtypes->{$itemInfo->{itype}}{translated_description};
452
            $itemInfo->{description} = $itemtypes->{$itemInfo->{itype}}{description};
453
            $itemInfo->{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$itemInfo->{itype}}{imageurl};
453
            $itemInfo->{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$itemInfo->{itype}}{imageurl};
454
        }
454
        }
455
455
Lines 490-496 foreach my $biblioNum (@biblionumbers) { Link Here
490
        $itemLoopIter->{copynumber} = $itemInfo->{copynumber};
490
        $itemLoopIter->{copynumber} = $itemInfo->{copynumber};
491
        $itemLoopIter->{itemnotes} = $itemInfo->{itemnotes};
491
        $itemLoopIter->{itemnotes} = $itemInfo->{itemnotes};
492
        if ($itemLevelTypes) {
492
        if ($itemLevelTypes) {
493
            $itemLoopIter->{translated_description} = $itemInfo->{translated_description};
493
            $itemLoopIter->{description} = $itemInfo->{description};
494
            $itemLoopIter->{itype} = $itemInfo->{itype};
494
            $itemLoopIter->{itype} = $itemInfo->{itype};
495
            $itemLoopIter->{imageurl} = $itemInfo->{imageurl};
495
            $itemLoopIter->{imageurl} = $itemInfo->{imageurl};
496
        }
496
        }
(-)a/opac/opac-search.pl (-7 / +7 lines)
Lines 57-62 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;
60
use Koha::ItemTypes;
61
use Koha::ItemTypes;
61
use Koha::Ratings;
62
use Koha::Ratings;
62
use Koha::Virtualshelves;
63
use Koha::Virtualshelves;
Lines 225-238 $template->param(search_languages_loop => $languages_limit_loop,); Link Here
225
226
226
# load the Type stuff
227
# load the Type stuff
227
my $itemtypes = GetItemTypesCategorized;
228
my $itemtypes = GetItemTypesCategorized;
228
# add translated_description to itemtypes
229
foreach my $itemtype ( keys %{$itemtypes} ) {
229
foreach my $itemtype ( keys %{$itemtypes} ) {
230
    # Itemtypes search categories don't have (yet) translated descriptions, they are auth values (and could still have no descriptions too BZ 18400)
230
    # Itemtypes search categories don't have (yet) translated descriptions, they are auth values (and could still have no descriptions too BZ 18400)
231
    # If 'iscat' (see ITEMTYPECAT) then there is no itemtype and the description is not translated
231
    # If 'iscat' (see ITEMTYPECAT) then there is no itemtype and the description is not translated
232
    my $translated_description = $itemtypes->{$itemtype}->{iscat}
232
    my $description = $itemtypes->{$itemtype}->{iscat}
233
      ? $itemtypes->{$itemtype}->{description}
233
      ? $itemtypes->{$itemtype}->{description}
234
      : Koha::ItemTypes->find($itemtype)->translated_description;
234
      : db_t('itemtype', Koha::ItemTypes->find($itemtype)->description);
235
    $itemtypes->{$itemtype}->{translated_description} = $translated_description || $itemtypes->{$itemtype}->{description} || q{};
235
    $itemtypes->{$itemtype}->{description} = $description || $itemtypes->{$itemtype}->{description} || q{};
236
}
236
}
237
237
238
# the index parameter is different for item-level itemtypes
238
# the index parameter is different for item-level itemtypes
Lines 244-250 my @advanced_search_types = split(/\|/, $advanced_search_types); Link Here
244
244
245
my $hidingrules = C4::Context->yaml_preference('OpacHiddenItems') // {};
245
my $hidingrules = C4::Context->yaml_preference('OpacHiddenItems') // {};
246
246
247
my @sorted_itemtypes = sort { $itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description} } keys %$itemtypes;
247
my @sorted_itemtypes = sort { $itemtypes->{$a}->{description} cmp $itemtypes->{$b}->{description} } keys %$itemtypes;
248
foreach my $advanced_srch_type (@advanced_search_types) {
248
foreach my $advanced_srch_type (@advanced_search_types) {
249
    $advanced_srch_type =~ s/^\s*//;
249
    $advanced_srch_type =~ s/^\s*//;
250
    $advanced_srch_type =~ s/\s*$//;
250
    $advanced_srch_type =~ s/\s*$//;
Lines 257-263 foreach my $advanced_srch_type (@advanced_search_types) { Link Here
257
	    my %row =(  number=>$cnt++,
257
	    my %row =(  number=>$cnt++,
258
		ccl => "$itype_or_itemtype,phr",
258
		ccl => "$itype_or_itemtype,phr",
259
                code => $thisitemtype,
259
                code => $thisitemtype,
260
                description => $itemtypes->{$thisitemtype}->{translated_description},
260
                description => $itemtypes->{$thisitemtype}->{description},
261
                imageurl=> getitemtypeimagelocation( 'opac', $itemtypes->{$thisitemtype}->{'imageurl'} ),
261
                imageurl=> getitemtypeimagelocation( 'opac', $itemtypes->{$thisitemtype}->{'imageurl'} ),
262
                cat => $itemtypes->{$thisitemtype}->{'iscat'},
262
                cat => $itemtypes->{$thisitemtype}->{'iscat'},
263
                hideinopac => $itemtypes->{$thisitemtype}->{'hideinopac'},
263
                hideinopac => $itemtypes->{$thisitemtype}->{'hideinopac'},
Lines 565-571 if ($tag) { Link Here
565
    $pasarParams .= '&amp;count=' . uri_escape_utf8($results_per_page);
565
    $pasarParams .= '&amp;count=' . uri_escape_utf8($results_per_page);
566
    $pasarParams .= '&amp;simple_query=' . uri_escape_utf8($simple_query);
566
    $pasarParams .= '&amp;simple_query=' . uri_escape_utf8($simple_query);
567
    $pasarParams .= '&amp;query_type=' . uri_escape_utf8($query_type) if ($query_type);
567
    $pasarParams .= '&amp;query_type=' . uri_escape_utf8($query_type) if ($query_type);
568
    my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
568
    my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
569
    eval {
569
    eval {
570
        ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes_nocategory,$query_type,$scan,1);
570
        ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes_nocategory,$query_type,$scan,1);
571
};
571
};
(-)a/opac/opac-shelves.pl (-1 / +1 lines)
Lines 328-334 if ( $op eq 'view' ) { Link Here
328
                $itemtype = Koha::ItemTypes->find( $itemtype );
328
                $itemtype = Koha::ItemTypes->find( $itemtype );
329
                if( $itemtype ) {
329
                if( $itemtype ) {
330
                    $this_item->{imageurl}          = C4::Koha::getitemtypeimagelocation( 'opac', $itemtype->imageurl );
330
                    $this_item->{imageurl}          = C4::Koha::getitemtypeimagelocation( 'opac', $itemtype->imageurl );
331
                    $this_item->{description}       = $itemtype->description; #FIXME Should not it be translated_description?
331
                    $this_item->{description}       = $itemtype->description;
332
                    $this_item->{notforloan}        = $itemtype->notforloan;
332
                    $this_item->{notforloan}        = $itemtype->notforloan;
333
                }
333
                }
334
                $this_item->{'coins'}           = $biblio->get_coins;
334
                $this_item->{'coins'}           = $biblio->get_coins;
(-)a/opac/opac-user.pl (-1 / +1 lines)
Lines 189-195 my $count = 0; Link Here
189
my $overdues_count = 0;
189
my $overdues_count = 0;
190
my @overdues;
190
my @overdues;
191
my @issuedat;
191
my @issuedat;
192
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
192
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
193
my $pending_checkouts = $patron->pending_checkouts->search({}, { order_by => [ { -desc => 'date_due' }, { -asc => 'issue_id' } ] });
193
my $pending_checkouts = $patron->pending_checkouts->search({}, { order_by => [ { -desc => 'date_due' }, { -asc => 'issue_id' } ] });
194
my $are_renewable_items = 0;
194
my $are_renewable_items = 0;
195
if ( $pending_checkouts->count ) { # Useless test
195
if ( $pending_checkouts->count ) { # Useless test
(-)a/reports/acquisitions_stats.pl (-1 / +1 lines)
Lines 191-197 else { Link Here
191
        $ccode_avlist = GetAuthorisedValues($ccode_subfield_structure->{authorised_value});
191
        $ccode_avlist = GetAuthorisedValues($ccode_subfield_structure->{authorised_value});
192
    }
192
    }
193
193
194
    my $itemtypes = Koha::ItemTypes->search_with_localization;
194
    my $itemtypes = Koha::ItemTypes->search;
195
    $template->param(
195
    $template->param(
196
        booksellers   => $booksellers,
196
        booksellers   => $booksellers,
197
        itemtypes     => $itemtypes, # FIXME Should use the TT plugin instead
197
        itemtypes     => $itemtypes, # FIXME Should use the TT plugin instead
(-)a/reports/bor_issues_top.pl (-1 / +1 lines)
Lines 102-108 my @mime = ( map { {type =>$_} } (split /[;:]/, 'CSV') ); # FIXME translation Link Here
102
my $delims = GetDelimiterChoices;
102
my $delims = GetDelimiterChoices;
103
103
104
my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['categorycode']});
104
my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['categorycode']});
105
my $itemtypes = Koha::ItemTypes->search_with_localization;
105
my $itemtypes = Koha::ItemTypes->search;
106
$template->param(
106
$template->param(
107
	    mimeloop => \@mime,
107
	    mimeloop => \@mime,
108
	  CGIseplist => $delims,
108
	  CGIseplist => $delims,
(-)a/reports/cat_issues_top.pl (-1 / +1 lines)
Lines 103-109 if ($do_it) { Link Here
103
    my $CGIsepChoice=GetDelimiterChoices;
103
    my $CGIsepChoice=GetDelimiterChoices;
104
104
105
    #doctype
105
    #doctype
106
    my $itemtypes = Koha::ItemTypes->search_with_localization;
106
    my $itemtypes = Koha::ItemTypes->search;
107
107
108
    #ccode
108
    #ccode
109
    my $ccodes = GetAuthorisedValues('CCODE');
109
    my $ccodes = GetAuthorisedValues('CCODE');
(-)a/reports/catalogue_out.pl (-1 / +1 lines)
Lines 54-60 if ($do_it) { Link Here
54
    exit;    # in either case, exit after do_it
54
    exit;    # in either case, exit after do_it
55
}
55
}
56
56
57
my $itemtypes = Koha::ItemTypes->search_with_localization;
57
my $itemtypes = Koha::ItemTypes->search;
58
$template->param(
58
$template->param(
59
    itemtypes => $itemtypes,
59
    itemtypes => $itemtypes,
60
);
60
);
(-)a/reports/catalogue_stats.pl (-1 / +1 lines)
Lines 113-119 if ($do_it) { Link Here
113
	my $dbh = C4::Context->dbh;
113
	my $dbh = C4::Context->dbh;
114
	my $count=0;
114
	my $count=0;
115
115
116
    my $itemtypes = Koha::ItemTypes->search_with_localization;
116
    my $itemtypes = Koha::ItemTypes->search;
117
117
118
    my @authvals = map { { code => $_->{authorised_value}, description => $_->{lib} } } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } );
118
    my @authvals = map { { code => $_->{authorised_value}, description => $_->{lib} } } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } );
119
    my @locations = map { { code => $_->{authorised_value}, description => $_->{lib} } } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } );
119
    my @locations = map { { code => $_->{authorised_value}, description => $_->{lib} } } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } );
(-)a/reports/issues_avg_stats.pl (-1 / +1 lines)
Lines 116-122 if ($do_it) { Link Here
116
} else {
116
} else {
117
    my $patron_categories = Koha::Patron::Categories->search({}, {order_by => ['description']});
117
    my $patron_categories = Koha::Patron::Categories->search({}, {order_by => ['description']});
118
118
119
    my $itemtypes = Koha::ItemTypes->search_with_localization;
119
    my $itemtypes = Koha::ItemTypes->search;
120
120
121
    my $dbh = C4::Context->dbh;
121
    my $dbh = C4::Context->dbh;
122
    my $req = $dbh->prepare("select distinctrow sort1 from borrowers where sort1 is not null order by sort1");
122
    my $req = $dbh->prepare("select distinctrow sort1 from borrowers where sort1 is not null order by sort1");
(-)a/reports/issues_stats.pl (-3 / +4 lines)
Lines 29-34 use C4::Reports qw( GetDelimiterChoices ); Link Here
29
29
30
use Koha::AuthorisedValues;
30
use Koha::AuthorisedValues;
31
use Koha::DateUtils qw( dt_from_string output_pref );
31
use Koha::DateUtils qw( dt_from_string output_pref );
32
use Koha::I18N;
32
use Koha::ItemTypes;
33
use Koha::ItemTypes;
33
use Koha::Patron::Attribute::Types;
34
use Koha::Patron::Attribute::Types;
34
35
Lines 80-86 $sep = "\t" if ($sep eq 'tabulation'); Link Here
80
$template->param(do_it => $do_it,
81
$template->param(do_it => $do_it,
81
);
82
);
82
83
83
our $itemtypes = Koha::ItemTypes->search_with_localization->unblessed;
84
our $itemtypes = Koha::ItemTypes->search->unblessed;
84
85
85
our @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']})->as_list;
86
our @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']})->as_list;
86
87
Lines 350-356 sub calculate { Link Here
350
        $cell{rowtitle_display} =
351
        $cell{rowtitle_display} =
351
            ( $line =~ /ccode/ )    ? $ccodes->{$celvalue}
352
            ( $line =~ /ccode/ )    ? $ccodes->{$celvalue}
352
          : ( $line =~ /location/ ) ? $locations->{$celvalue}
353
          : ( $line =~ /location/ ) ? $locations->{$celvalue}
353
          : ( $line =~ /itemtype/ ) ? $itemtypes_map->{$celvalue}->{translated_description}
354
          : ( $line =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{description})
354
          :                           $celvalue;                               # default fallback
355
          :                           $celvalue;                               # default fallback
355
        if ( $line =~ /sort1/ ) {
356
        if ( $line =~ /sort1/ ) {
356
            foreach (@$Bsort1) {
357
            foreach (@$Bsort1) {
Lines 439-445 sub calculate { Link Here
439
        $cell{coltitle_display} =
440
        $cell{coltitle_display} =
440
            ( $column =~ /ccode/ )    ? $ccodes->{$celvalue}
441
            ( $column =~ /ccode/ )    ? $ccodes->{$celvalue}
441
          : ( $column =~ /location/ ) ? $locations->{$celvalue}
442
          : ( $column =~ /location/ ) ? $locations->{$celvalue}
442
          : ( $column =~ /itemtype/ ) ? $itemtypes_map->{$celvalue}->{translated_description}
443
          : ( $column =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{description});
443
          :                             $celvalue;                               # default fallback
444
          :                             $celvalue;                               # default fallback
444
        if ( $column =~ /sort1/ ) {
445
        if ( $column =~ /sort1/ ) {
445
            foreach (@$Bsort1) {
446
            foreach (@$Bsort1) {
(-)a/reports/itemslost.pl (-1 / +1 lines)
Lines 145-151 if ( $op eq 'export' ) { Link Here
145
}
145
}
146
146
147
# getting all itemtypes
147
# getting all itemtypes
148
my $itemtypes = Koha::ItemTypes->search_with_localization;
148
my $itemtypes = Koha::ItemTypes->search;
149
149
150
my $csv_profiles = Koha::CsvProfiles->search({ type => 'sql', used_for => 'export_lost_items' });
150
my $csv_profiles = Koha::CsvProfiles->search({ type => 'sql', used_for => 'export_lost_items' });
151
151
(-)a/reports/reserves_stats.pl (-2 / +3 lines)
Lines 29-34 use C4::Reports qw( GetDelimiterChoices ); Link Here
29
use C4::Members;
29
use C4::Members;
30
use Koha::AuthorisedValues;
30
use Koha::AuthorisedValues;
31
use Koha::DateUtils qw( dt_from_string output_pref );
31
use Koha::DateUtils qw( dt_from_string output_pref );
32
use Koha::I18N;
32
use Koha::ItemTypes;
33
use Koha::ItemTypes;
33
use Koha::Libraries;
34
use Koha::Libraries;
34
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
Lines 122-128 if ($do_it) { Link Here
122
123
123
my $dbh = C4::Context->dbh;
124
my $dbh = C4::Context->dbh;
124
125
125
my $itemtypes = Koha::ItemTypes->search_with_localization;
126
my $itemtypes = Koha::ItemTypes->search;
126
127
127
    # location list
128
    # location list
128
my @locations;
129
my @locations;
Lines 308-314 sub display_value { Link Here
308
    my $display_value =
309
    my $display_value =
309
        ( $crit =~ /ccode/ )         ? $ccodes->{$value}
310
        ( $crit =~ /ccode/ )         ? $ccodes->{$value}
310
      : ( $crit =~ /location/ )      ? $locations->{$value}
311
      : ( $crit =~ /location/ )      ? $locations->{$value}
311
      : ( $crit =~ /itemtype/ )      ? Koha::ItemTypes->find( $value )->translated_description
312
      : ( $crit =~ /itemtype/ )      ? db_t('itemtype', Koha::ItemTypes->find( $value )->description)
312
      : ( $crit =~ /branch/ )        ? Koha::Libraries->find($value)->branchname
313
      : ( $crit =~ /branch/ )        ? Koha::Libraries->find($value)->branchname
313
      : ( $crit =~ /reservestatus/ ) ? reservestatushuman($value)
314
      : ( $crit =~ /reservestatus/ ) ? reservestatushuman($value)
314
      :                                $value;    # default fallback
315
      :                                $value;    # default fallback
(-)a/reserve/request.pl (-1 / +1 lines)
Lines 72-78 my $itemtypes = { Link Here
72
    map {
72
    map {
73
        $_->itemtype =>
73
        $_->itemtype =>
74
          { %{ $_->unblessed }, image_location => $_->image_location }
74
          { %{ $_->unblessed }, image_location => $_->image_location }
75
    } Koha::ItemTypes->search_with_localization->as_list
75
    } Koha::ItemTypes->search->as_list
76
};
76
};
77
77
78
# Select borrowers infos
78
# Select borrowers infos
(-)a/serials/subscription-add.pl (-2 / +1 lines)
Lines 144-152 $template->param( Link Here
144
    additional_field_values => \%additional_field_values,
144
    additional_field_values => \%additional_field_values,
145
);
145
);
146
146
147
my $typeloop = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
147
my $typeloop = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
148
148
149
# FIXME We should use the translated_description for item types
150
my @typearg =
149
my @typearg =
151
    map { { code => $_, value => $typeloop->{$_}{'description'}, selected => ( ( $subs->{itemtype} and $_ eq $subs->{itemtype} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$typeloop};
150
    map { { code => $_, value => $typeloop->{$_}{'description'}, selected => ( ( $subs->{itemtype} and $_ eq $subs->{itemtype} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$typeloop};
152
my @previoustypearg =
151
my @previoustypearg =
(-)a/serials/subscription-bib-search.pl (-2 / +1 lines)
Lines 193-202 else { Link Here
193
    );
193
    );
194
194
195
    # load the itemtypes
195
    # load the itemtypes
196
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
196
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
197
    my @itemtypesloop;
197
    my @itemtypesloop;
198
    # FIXME This is uselessly complex, the iterator should be send to the template
198
    # FIXME This is uselessly complex, the iterator should be send to the template
199
    # FIXME The translated_description should be used
200
    foreach my $thisitemtype (
199
    foreach my $thisitemtype (
201
        sort {
200
        sort {
202
            $itemtypes->{$a}->{'description'}
201
            $itemtypes->{$a}->{'description'}
(-)a/svc/bib_profile (-1 / +1 lines)
Lines 113-119 sub _get_bib_number_tag { Link Here
113
113
114
sub _get_biblioitem_itemtypes {
114
sub _get_biblioitem_itemtypes {
115
    my $result = shift;
115
    my $result = shift;
116
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
116
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
117
    my $sth = $dbh->prepare_cached("SELECT tagfield, tagsubfield
117
    my $sth = $dbh->prepare_cached("SELECT tagfield, tagsubfield
118
                                    FROM marc_subfield_structure 
118
                                    FROM marc_subfield_structure 
119
                                    WHERE frameworkcode = '' 
119
                                    WHERE frameworkcode = '' 
(-)a/svc/checkouts (-1 / +2 lines)
Lines 30-35 use C4::Context; Link Here
30
use Koha::AuthorisedValues;
30
use Koha::AuthorisedValues;
31
use Koha::DateUtils qw( dt_from_string output_pref );
31
use Koha::DateUtils qw( dt_from_string output_pref );
32
use Koha::Items;
32
use Koha::Items;
33
use Koha::I18N;
33
use Koha::ItemTypes;
34
use Koha::ItemTypes;
34
35
35
my $input = CGI->new;
36
my $input = CGI->new;
Lines 146-152 my $item_level_itypes = C4::Context->preference('item-level_itypes'); Link Here
146
my $claims_returned_lost_value = C4::Context->preference('ClaimReturnedLostValue');
147
my $claims_returned_lost_value = C4::Context->preference('ClaimReturnedLostValue');
147
my $confirm_parts_required = C4::Context->preference("CircConfirmItemParts");
148
my $confirm_parts_required = C4::Context->preference("CircConfirmItemParts");
148
149
149
my $itemtypes = { map { $_->{itemtype} => $_->{translated_description} } @{ Koha::ItemTypes->search_with_localization->unblessed } };
150
my $itemtypes = { map { $_->{itemtype} => db_t('itemtypes', $_->{itemtype}) } @{ Koha::ItemTypes->search->unblessed } };
150
151
151
my @checkouts_today;
152
my @checkouts_today;
152
my @checkouts_previous;
153
my @checkouts_previous;
(-)a/svc/holds (-1 / +2 lines)
Lines 29-34 use C4::Context; Link Here
29
29
30
use Koha::DateUtils qw( dt_from_string output_pref );
30
use Koha::DateUtils qw( dt_from_string output_pref );
31
use Koha::Holds;
31
use Koha::Holds;
32
use Koha::I18N;
32
use Koha::ItemTypes;
33
use Koha::ItemTypes;
33
use Koha::Libraries;
34
use Koha::Libraries;
34
35
Lines 81-87 while ( my $h = $holds_rs->next() ) { Link Here
81
    my $itemtype_limit;
82
    my $itemtype_limit;
82
    if ( $h->itemtype ) {
83
    if ( $h->itemtype ) {
83
        my $itemtype = Koha::ItemTypes->find( $h->itemtype );
84
        my $itemtype = Koha::ItemTypes->find( $h->itemtype );
84
        $itemtype_limit = $itemtype->translated_description;
85
        $itemtype_limit = db_t('itemtype', $itemtype->description);
85
    }
86
    }
86
87
87
    my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;
88
    my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;
(-)a/svc/localization (-74 / +55 lines)
Lines 4-104 use Modern::Perl; Link Here
4
use Encode qw( encode );
4
use Encode qw( encode );
5
5
6
use C4::Service;
6
use C4::Service;
7
use Koha::Localizations;
7
use Koha::Caches;
8
use Koha::Database;
8
9
9
our ( $query, $response ) = C4::Service->init( parameters => 'manage_itemtypes' );
10
our ( $query, $response ) = C4::Service->init( parameters => 'parameters_remaining_permissions' );
10
11
11
sub get_translations {
12
sub get_translations {
12
    my $rs = Koha::Localizations->search({ entity => $query->param('entity'), code => $query->param('code') });
13
    my $draw = $query->param('draw');
13
    my @translations;
14
    my $start = $query->param('start');
14
    while ( my $s = $rs->next ) {
15
    my $length = $query->param('length');
15
        push @translations, {
16
    my $search = $query->param('search[value]');
16
              id          => $s->localization_id,
17
              entity      => $s->entity,
18
              code        => $s->code,
19
              lang        => $s->lang,
20
              translation => $s->translation,
21
        }
22
    }
23
    $response->param( translations => \@translations );
24
    C4::Service->return_success( $response );
25
}
26
17
27
sub update_translation {
18
    my $schema = Koha::Database->new->schema;
28
    my $id = $query->param('id');
19
    my $rs = $schema->resultset('L10nSource');
29
    my $translation = $query->param('translation');
20
    my $recordsTotal = $rs->count;
30
    my $lang = $query->param('lang');
31
21
32
    my $localization = Koha::Localizations->find( $id );
22
    my $cond = {};
33
    if ( defined $lang and $localization->lang ne $lang ) {
23
    if ($search) {
34
        $localization->lang( $lang )
24
        my @and;
35
    }
25
        my @words = split /\s+/, $search;
36
    if ( defined $translation and $localization->translation ne $translation ) {
26
        foreach my $word (@words) {
37
        $localization->translation( $translation )
27
            push @and, \['source LIKE ? COLLATE utf8mb4_unicode_ci', "%$word%"];
38
    }
39
    my %params;
40
    my $is_changed;
41
    if ( $localization->is_changed ) {
42
        $is_changed = 1;
43
        unless ( Koha::Localizations->search( { entity => $localization->entity, code => $localization->code, lang => $lang, localization_id => { '!=' => $localization->localization_id }, } )->count ) {
44
            $localization->store;
45
        } else {
46
            $params{error} = 1;
47
            $params{error_code} = 'already_exists';
48
        }
28
        }
29
        $cond->{-and} = \@and;
49
    }
30
    }
31
32
    $rs = $rs->search($cond);
33
    my $recordsFiltered = $rs->count;
34
35
    my @sources = $rs->search({}, {
36
        prefetch => 'l10n_targets',
37
        result_class => 'DBIx::Class::ResultClass::HashRefInflator',
38
        rows => $length,
39
        offset => $start,
40
        order_by => { -asc => ['context', 'source'] },
41
    });
42
50
    $response->param(
43
    $response->param(
51
        %params,
44
        draw => $draw,
52
        id          => $localization->localization_id,
45
        recordsTotal => $recordsTotal,
53
        entity      => $localization->entity,
46
        recordsFiltered => $recordsFiltered,
54
        code        => $localization->code,
47
        data => \@sources,
55
        lang        => $localization->lang,
56
        translation => $localization->translation,
57
        is_changed  => $is_changed,
58
    );
48
    );
59
    C4::Service->return_success( $response );
49
    C4::Service->return_success( $response );
60
}
50
}
61
51
62
sub add_translation {
52
sub update_translation {
63
    my $entity = $query->param('entity');
53
    my $id = $query->param('id');
64
    my $code = $query->param('code');
65
    my $lang = $query->param('lang');
66
    my $translation = $query->param('translation');
54
    my $translation = $query->param('translation');
55
    my $lang = $query->param('lang');
67
56
68
    unless ( Koha::Localizations->search({entity => $entity, code => $code, lang => $lang, })->count ) {
57
    my $schema = Koha::Database->new->schema;
69
        my $localization = Koha::Localization->new(
58
    my $rs = $schema->resultset('L10nTarget');
70
            {
71
                entity => $entity,
72
                code => $code,
73
                lang => $lang,
74
                translation => $translation,
75
            }
76
        );
77
        $localization->store;
78
        $response->param(
79
            id          => $localization->localization_id,
80
            entity      => $localization->entity,
81
            code        => $localization->code,
82
            lang        => $localization->lang,
83
            translation => $localization->translation,
84
        );
85
59
60
    if (defined $translation && $translation ne '') {
61
        $rs->update_or_create({
62
            l10n_source_id => $id,
63
            language => $lang,
64
            translation => $translation,
65
        }, {
66
            key => 'l10n_source_language',
67
        });
86
    } else {
68
    } else {
87
        $response->param( error => 1, error_code => 'already_exists', );
69
        $rs->search({
70
            l10n_source_id => $id,
71
            language => $lang,
72
        })->delete;
88
    }
73
    }
89
    C4::Service->return_success( $response );
90
}
91
74
92
sub delete_translation {
75
    my $source = $schema->resultset('L10nSource')->find($id);
93
    my $id = $query->param('id');
76
    my $cache_key = sprintf('%s:%s', $source->context, $lang);
94
    Koha::Localizations->find($id)->delete;
77
    Koha::Caches->get_instance()->clear_from_cache($cache_key);
95
    $response->param( id => $id );
78
96
    C4::Service->return_success( $response );
79
    C4::Service->return_success( $response );
97
}
80
}
98
81
99
C4::Service->dispatch(
82
C4::Service->dispatch(
100
    [ 'GET /', [ 'id' ], \&get_translations ],
83
    [ 'GET /', [], \&get_translations ],
101
    [ 'PUT /', [ 'id' ], \&update_translation ],
84
    [ 'PUT /', [ 'id' ], \&update_translation ],
102
    [ 'POST /', [ 'entity', 'code', 'lang', 'translation' ], \&add_translation ],
103
    [ 'DELETE /', ['id'],  \&delete_translation ],
104
);
85
);
(-)a/t/db_dependent/Koha/ItemTypes.t (-40 / +4 lines)
Lines 67-97 my $child3 = $builder->build_object({ Link Here
67
        }
67
        }
68
    });
68
    });
69
69
70
Koha::Localization->new(
71
    {
72
        entity      => 'itemtypes',
73
        code        => $child1->itemtype,
74
        lang        => 'en',
75
        translation => 'b translated itemtype desc'
76
    }
77
)->store;
78
Koha::Localization->new(
79
    {
80
        entity      => 'itemtypes',
81
        code        => $child2->itemtype,
82
        lang        => 'en',
83
        translation => 'a translated itemtype desc'
84
    }
85
)->store;
86
Koha::Localization->new(
87
    {
88
        entity      => 'something_else',
89
        code        => $child2->itemtype,
90
        lang        => 'en',
91
        translation => 'another thing'
92
    }
93
)->store;
94
95
my $type = Koha::ItemTypes->find($child1->itemtype);
70
my $type = Koha::ItemTypes->find($child1->itemtype);
96
ok( defined($type), 'first result' );
71
ok( defined($type), 'first result' );
97
is_deeply( $type->unblessed, $child1->unblessed, "We got back the same object" );
72
is_deeply( $type->unblessed, $child1->unblessed, "We got back the same object" );
Lines 103-124 is_deeply( $type->unblessed, $child2->unblessed, "We got back the same object" ) Link Here
103
78
104
t::lib::Mocks::mock_preference('language', 'en');
79
t::lib::Mocks::mock_preference('language', 'en');
105
t::lib::Mocks::mock_preference('OPACLanguages', 'en');
80
t::lib::Mocks::mock_preference('OPACLanguages', 'en');
106
my $itemtypes = Koha::ItemTypes->search_with_localization;
81
my $itemtypes = Koha::ItemTypes->search;
107
is( $itemtypes->count, $initial_count + 4, 'We added 4 item types' );
82
is( $itemtypes->count, $initial_count + 4, 'We added 4 item types' );
108
my $first_itemtype = $itemtypes->next;
83
109
is(
84
my $children = $parent1->children;
110
    $first_itemtype->translated_description,
85
is ($children->count, 3, 'parent type has 3 children');
111
    'a translated itemtype desc',
112
    'item types should be sorted by translated description'
113
);
114
115
my $children = $parent1->children_with_localization;
116
my $first_child = $children->next;
117
is(
118
    $first_child->translated_description,
119
    'a translated itemtype desc',
120
    'item types should be sorted by translated description'
121
);
122
86
123
my $item_type = $builder->build_object({ class => 'Koha::ItemTypes' });
87
my $item_type = $builder->build_object({ class => 'Koha::ItemTypes' });
124
88
(-)a/tools/batchMod.pl (+1 lines)
Lines 32-37 use Encode qw( encode_utf8 ); Link Here
32
32
33
use Koha::Database;
33
use Koha::Database;
34
use Koha::DateUtils qw( dt_from_string );
34
use Koha::DateUtils qw( dt_from_string );
35
use Koha::I18N;
35
use Koha::Exception;
36
use Koha::Exception;
36
use Koha::Biblios;
37
use Koha::Biblios;
37
use Koha::Items;
38
use Koha::Items;
(-)a/tools/export.pl (-1 / +1 lines)
Lines 267-273 if ( $op eq "export" ) { Link Here
267
267
268
else {
268
else {
269
269
270
    my $itemtypes = Koha::ItemTypes->search_with_localization;
270
    my $itemtypes = Koha::ItemTypes->search;
271
271
272
    my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
272
    my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
273
273
(-)a/virtualshelves/shelves.pl (-2 / +1 lines)
Lines 285-291 if ( $op eq 'view' ) { Link Here
285
                $this_item->{author}            = $biblio->author;
285
                $this_item->{author}            = $biblio->author;
286
                $this_item->{dateadded}         = $content->dateadded;
286
                $this_item->{dateadded}         = $content->dateadded;
287
                $this_item->{imageurl}          = $itemtype ? C4::Koha::getitemtypeimagelocation( 'intranet', $itemtype->imageurl ) : q{};
287
                $this_item->{imageurl}          = $itemtype ? C4::Koha::getitemtypeimagelocation( 'intranet', $itemtype->imageurl ) : q{};
288
                $this_item->{description}       = $itemtype ? $itemtype->description : q{}; #FIXME Should this be translated_description ?
288
                $this_item->{description}       = $itemtype ? $itemtype->description : q{};
289
                $this_item->{notforloan}        = $itemtype->notforloan if $itemtype;
289
                $this_item->{notforloan}        = $itemtype->notforloan if $itemtype;
290
                $this_item->{'coins'}           = $biblio->get_coins;
290
                $this_item->{'coins'}           = $biblio->get_coins;
291
                $this_item->{'normalized_upc'}  = GetNormalizedUPC( $record, $marcflavour );
291
                $this_item->{'normalized_upc'}  = GetNormalizedUPC( $record, $marcflavour );
292
- 

Return to bug 24975