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

(-)a/C4/Biblio.pm (-1 / +2 lines)
Lines 101-106 use Koha::Authority::Types; Link Here
101
use Koha::Acquisition::Currencies;
101
use Koha::Acquisition::Currencies;
102
use Koha::Biblio::Metadatas;
102
use Koha::Biblio::Metadatas;
103
use Koha::Holds;
103
use Koha::Holds;
104
use Koha::I18N;
104
use Koha::ItemTypes;
105
use Koha::ItemTypes;
105
use Koha::Plugins;
106
use Koha::Plugins;
106
use Koha::SearchEngine;
107
use Koha::SearchEngine;
Lines 1383-1389 sub GetAuthorisedValueDesc { Link Here
1383
        #---- itemtypes
1384
        #---- itemtypes
1384
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
1385
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
1385
            my $itemtype = Koha::ItemTypes->find( $value );
1386
            my $itemtype = Koha::ItemTypes->find( $value );
1386
            return $itemtype ? $itemtype->translated_description : q||;
1387
            return $itemtype ? db_t('itemtype', $itemtype->description) : q||;
1387
        }
1388
        }
1388
1389
1389
        #---- "true" authorized value
1390
        #---- "true" authorized value
(-)a/C4/Items.pm (-7 / +4 lines)
Lines 67-72 use Koha::DateUtils qw(dt_from_string); Link Here
67
use Koha::Database;
67
use Koha::Database;
68
68
69
use Koha::Biblioitems;
69
use Koha::Biblioitems;
70
use Koha::I18N;
70
use Koha::Items;
71
use Koha::Items;
71
use Koha::ItemTypes;
72
use Koha::ItemTypes;
72
use Koha::SearchEngine;
73
use Koha::SearchEngine;
Lines 668-674 sub GetItemsInfo { Link Here
668
           serial.serialseq,
669
           serial.serialseq,
669
           serial.publisheddate,
670
           serial.publisheddate,
670
           itemtypes.description,
671
           itemtypes.description,
671
           COALESCE( localization.translation, itemtypes.description ) AS translated_description,
672
           itemtypes.notforloan as notforloan_per_itemtype,
672
           itemtypes.notforloan as notforloan_per_itemtype,
673
           holding.branchurl,
673
           holding.branchurl,
674
           holding.branchcode,
674
           holding.branchcode,
Lines 689-702 sub GetItemsInfo { Link Here
689
     . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype');
689
     . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype');
690
    $query .= q|
690
    $query .= q|
691
    LEFT JOIN tmp_holdsqueue USING (itemnumber)
691
    LEFT JOIN tmp_holdsqueue USING (itemnumber)
692
    LEFT JOIN localization ON itemtypes.itemtype = localization.code
693
        AND localization.entity = 'itemtypes'
694
        AND localization.lang = ?
695
    |;
692
    |;
696
693
697
    $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
694
    $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
698
    my $sth = $dbh->prepare($query);
695
    my $sth = $dbh->prepare($query);
699
    $sth->execute($language, $biblionumber);
696
    $sth->execute($biblionumber);
700
    my $i = 0;
697
    my $i = 0;
701
    my @results;
698
    my @results;
702
    my $serial;
699
    my $serial;
Lines 1667-1678 sub PrepareItemrecordDisplay { Link Here
1667
1664
1668
                        #----- itemtypes
1665
                        #----- itemtypes
1669
                    } elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
1666
                    } elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
1670
                        my $itemtypes = Koha::ItemTypes->search_with_localization;
1667
                        my $itemtypes = Koha::ItemTypes->search;
1671
                        push @authorised_values, ""
1668
                        push @authorised_values, ""
1672
                          unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
1669
                          unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
1673
                        while ( my $itemtype = $itemtypes->next ) {
1670
                        while ( my $itemtype = $itemtypes->next ) {
1674
                            push @authorised_values, $itemtype->itemtype;
1671
                            push @authorised_values, $itemtype->itemtype;
1675
                            $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
1672
                            $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->description);
1676
                        }
1673
                        }
1677
                        if ($defaultvalues && $defaultvalues->{'itemtype'}) {
1674
                        if ($defaultvalues && $defaultvalues->{'itemtype'}) {
1678
                            $defaultvalue = $defaultvalues->{'itemtype'};
1675
                            $defaultvalue = $defaultvalues->{'itemtype'};
(-)a/C4/Search.pm (-6 / +5 lines)
Lines 30-35 use C4::Reserves; # GetReserveStatus Link Here
30
use C4::Debug;
30
use C4::Debug;
31
use C4::Charset;
31
use C4::Charset;
32
use Koha::AuthorisedValues;
32
use Koha::AuthorisedValues;
33
use Koha::I18N;
33
use Koha::ItemTypes;
34
use Koha::ItemTypes;
34
use Koha::Libraries;
35
use Koha::Libraries;
35
use Koha::Patrons;
36
use Koha::Patrons;
Lines 539-547 sub getRecords { Link Here
539
                                    && ref( $itemtypes->{$one_facet} ) eq
540
                                    && ref( $itemtypes->{$one_facet} ) eq
540
                                    "HASH" )
541
                                    "HASH" )
541
                                {
542
                                {
542
                                    $facet_label_value =
543
                                    $facet_label_value = db_t('itemtype', $itemtypes->{$one_facet}->{description});
543
                                      $itemtypes->{$one_facet}
544
                                      ->{translated_description};
545
                                }
544
                                }
546
                            }
545
                            }
547
546
Lines 1704-1710 sub searchResults { Link Here
1704
    my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef;
1703
    my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef;
1705
1704
1706
    #Get itemtype hash
1705
    #Get itemtype hash
1707
    my $itemtypes = Koha::ItemTypes->search_with_localization;
1706
    my $itemtypes = Koha::ItemTypes->search;
1708
    my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes->unblessed };
1707
    my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes->unblessed };
1709
1708
1710
    #search item field code
1709
    #search item field code
Lines 1797-1803 sub searchResults { Link Here
1797
        # add imageurl to itemtype if there is one
1796
        # add imageurl to itemtype if there is one
1798
        $oldbiblio->{imageurl} = $itemtype ? getitemtypeimagelocation( $search_context->{'interface'}, $itemtype->{imageurl} ) : q{};
1797
        $oldbiblio->{imageurl} = $itemtype ? getitemtypeimagelocation( $search_context->{'interface'}, $itemtype->{imageurl} ) : q{};
1799
        # Build summary if there is one (the summary is defined in the itemtypes table)
1798
        # Build summary if there is one (the summary is defined in the itemtypes table)
1800
        $oldbiblio->{description} = $itemtype ? $itemtype->{translated_description} : q{};
1799
        $oldbiblio->{description} = $itemtype ? db_t('itemtype', $itemtype->{description}) : q{};
1801
1800
1802
        # FIXME: this is only used in the deprecated non-XLST opac results
1801
        # FIXME: this is only used in the deprecated non-XLST opac results
1803
        if ( !$xslfile && $is_opac && $itemtype && $itemtype->{summary} ) {
1802
        if ( !$xslfile && $is_opac && $itemtype && $itemtype->{summary} ) {
Lines 1906-1912 sub searchResults { Link Here
1906
            foreach my $code ( keys %subfieldstosearch ) {
1905
            foreach my $code ( keys %subfieldstosearch ) {
1907
                $item->{$code} = $field->subfield( $subfieldstosearch{$code} );
1906
                $item->{$code} = $field->subfield( $subfieldstosearch{$code} );
1908
            }
1907
            }
1909
            $item->{description} = $itemtypes{ $item->{itype} }{translated_description} if $item->{itype};
1908
            $item->{description} = db_t('itemtype', $itemtypes{ $item->{itype} }{description}) if $item->{itype};
1910
1909
1911
	        # OPAC hidden items
1910
	        # OPAC hidden items
1912
            if ($is_opac) {
1911
            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 27-32 use Encode; Link Here
27
use Locale::Messages qw(:locale_h LC_MESSAGES);
27
use Locale::Messages qw(:locale_h LC_MESSAGES);
28
use POSIX qw( setlocale );
28
use POSIX qw( setlocale );
29
use Koha::Cache::Memory::Lite;
29
use Koha::Cache::Memory::Lite;
30
use Koha::Caches;
31
use Koha::Database;
30
32
31
use parent 'Exporter';
33
use parent 'Exporter';
32
our @EXPORT = qw(
34
our @EXPORT = qw(
Lines 43-48 our @EXPORT = qw( Link Here
43
    N__n
45
    N__n
44
    N__p
46
    N__p
45
    N__np
47
    N__np
48
49
    db_t
46
);
50
);
47
51
48
our $textdomain = 'Koha';
52
our $textdomain = 'Koha';
Lines 201-204 sub _expand { Link Here
201
    return $text;
205
    return $text;
202
}
206
}
203
207
208
=head2 db_t
209
210
    db_t($context, $source)
211
    db_t('itemtype', $itemtype->description)
212
213
Search for a translation in l10n_target table and return it if found
214
Return source string otherwise
215
216
=cut
217
218
sub db_t {
219
    my ($context, $source) = @_;
220
221
    my $cache = Koha::Caches->get_instance();
222
    my $language = C4::Languages::getlanguage();
223
    my $cache_key = sprintf('%s:%s', $context, $language);
224
225
    my $translations = $cache->get_from_cache($cache_key);
226
    unless ($translations) {
227
        my $schema = Koha::Database->new->schema;
228
        my $rs = $schema->resultset('L10nTarget');
229
230
        my @targets = $rs->search(
231
            {
232
                'l10n_source.context' => $context,
233
                language => $language,
234
            },
235
            {
236
                join => 'l10n_source',
237
                prefetch => 'l10n_source',
238
                result_class => 'DBIx::Class::ResultClass::HashRefInflator',
239
            },
240
        );
241
        $translations = { map { $_->{l10n_source}->{source} => $_->{translation} } @targets };
242
243
        $cache->set_in_cache($cache_key, $translations);
244
    }
245
246
    if (exists $translations->{$source}) {
247
        return $translations->{$source};
248
    }
249
250
    return $source;
251
}
252
204
1;
253
1;
(-)a/Koha/ItemType.pm (-45 lines)
Lines 23-29 use C4::Koha; Link Here
23
use C4::Languages;
23
use C4::Languages;
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::CirculationRules;
25
use Koha::CirculationRules;
26
use Koha::Localizations;
27
26
28
use base qw(Koha::Object Koha::Object::Limit::Library);
27
use base qw(Koha::Object Koha::Object::Limit::Library);
29
28
Lines 46-95 sub image_location { Link Here
46
    return C4::Koha::getitemtypeimagelocation( $interface, $self->SUPER::imageurl );
45
    return C4::Koha::getitemtypeimagelocation( $interface, $self->SUPER::imageurl );
47
}
46
}
48
47
49
=head3 translated_description
50
51
=cut
52
53
sub translated_description {
54
    my ( $self, $lang ) = @_;
55
    if ( my $translated_description = eval { $self->get_column('translated_description') } ) {
56
        # If the value has already been fetched (eg. from sarch_with_localization),
57
        # do not search for it again
58
        # Note: This is a bit hacky but should be fast
59
        return $translated_description
60
             ? $translated_description
61
             : $self->description;
62
    }
63
    $lang ||= C4::Languages::getlanguage;
64
    my $translated_description = Koha::Localizations->search({
65
        code => $self->itemtype,
66
        entity => 'itemtypes',
67
        lang => $lang
68
    })->next;
69
    return $translated_description
70
         ? $translated_description->translation
71
         : $self->description;
72
}
73
74
=head3 translated_descriptions
75
76
=cut
77
78
sub translated_descriptions {
79
    my ( $self ) = @_;
80
    my @translated_descriptions = Koha::Localizations->search(
81
        {   entity => 'itemtypes',
82
            code   => $self->itemtype,
83
        }
84
    );
85
    return [ map {
86
        {
87
            lang => $_->lang,
88
            translation => $_->translation,
89
        }
90
    } @translated_descriptions ];
91
}
92
93
=head3 can_be_deleted
48
=head3 can_be_deleted
94
49
95
my $can_be_deleted = Koha::ItemType->can_be_deleted();
50
my $can_be_deleted = Koha::ItemType->can_be_deleted();
(-)a/Koha/ItemTypes.pm (-31 lines)
Lines 32-68 Koha::ItemTypes - Koha ItemType Object set class Link Here
32
32
33
=head1 API
33
=head1 API
34
34
35
=head2 Class methods
36
37
=cut
38
39
=head3 search_with_localization
40
41
my $itemtypes = Koha::ItemTypes->search_with_localization
42
43
=cut
44
45
sub search_with_localization {
46
    my ( $self, $params, $attributes ) = @_;
47
48
    my $language = C4::Languages::getlanguage();
49
    $Koha::Schema::Result::Itemtype::LANGUAGE = $language;
50
    $attributes->{order_by} = 'translated_description' unless exists $attributes->{order_by};
51
    $attributes->{join} = 'localization';
52
    $attributes->{'+select'} = [
53
        {
54
            coalesce => [qw( localization.translation me.description )],
55
            -as      => 'translated_description'
56
        }
57
    ];
58
    if(defined $params->{branchcode}) {
59
        my $branchcode = delete $params->{branchcode};
60
        $self->search_with_library_limits( $params, $attributes, $branchcode );
61
    } else {
62
        $self->SUPER::search( $params, $attributes );
63
    }
64
}
65
66
=head2 Internal methods
35
=head2 Internal methods
67
36
68
=head3 type
37
=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 230-251 __PACKAGE__->has_many( Link Here
230
# Created by DBIx::Class::Schema::Loader v0.07048 @ 2019-07-04 04:56:48
230
# Created by DBIx::Class::Schema::Loader v0.07048 @ 2019-07-04 04:56:48
231
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Qo6jabJSQGeYJ542ebSJfg
231
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Qo6jabJSQGeYJ542ebSJfg
232
232
233
# Use the ItemtypeLocalization view to create the join on localization
233
__PACKAGE__->load_components('+Koha::DBIx::Component::L10nSource');
234
our $LANGUAGE;
235
__PACKAGE__->has_many(
236
  "localization" => "Koha::Schema::Result::ItemtypeLocalization",
237
    sub {
238
        my $args = shift;
239
240
        die "no lang specified!" unless $LANGUAGE;
241
242
        return ({
243
            "$args->{self_alias}.itemtype" => { -ident => "$args->{foreign_alias}.code" },
244
            "$args->{foreign_alias}.lang" => $LANGUAGE,
245
        });
246
247
    }
248
);
249
234
250
sub koha_object_class {
235
sub koha_object_class {
251
    'Koha::ItemType';
236
    'Koha::ItemType';
Lines 254-257 sub koha_objects_class { Link Here
254
    'Koha::ItemTypes';
239
    'Koha::ItemTypes';
255
}
240
}
256
241
242
sub insert {
243
    my $self = shift;
244
245
    my $result = $self->next::method(@_);
246
247
    my @sources = $self->result_source->resultset->get_column('description')->all;
248
    $self->update_l10n_source('itemtype', @sources);
249
250
    return $result;
251
}
252
253
sub update {
254
    my $self = shift;
255
256
    my $is_description_changed = $self->is_column_changed('description');
257
258
    my $result = $self->next::method(@_);
259
260
    if ($is_description_changed) {
261
        my @sources = $self->result_source->resultset->get_column('description')->all;
262
        $self->update_l10n_source('itemtype', @sources);
263
    }
264
265
    return $result;
266
}
267
268
sub delete {
269
    my $self = shift;
270
271
    my $result = $self->next::method(@_);
272
273
    my @sources = $self->result_source->resultset->get_column('description')->all;
274
    $self->update_l10n_source('itemtype', @sources);
275
276
    return $result;
277
}
278
257
1;
279
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/Schema/Result/Localization.pm (-106 lines)
Lines 1-106 Link Here
1
use utf8;
2
package Koha::Schema::Result::Localization;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::Localization
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<localization>
19
20
=cut
21
22
__PACKAGE__->table("localization");
23
24
=head1 ACCESSORS
25
26
=head2 localization_id
27
28
  data_type: 'integer'
29
  is_auto_increment: 1
30
  is_nullable: 0
31
32
=head2 entity
33
34
  data_type: 'varchar'
35
  is_nullable: 0
36
  size: 16
37
38
=head2 code
39
40
  data_type: 'varchar'
41
  is_nullable: 0
42
  size: 64
43
44
=head2 lang
45
46
  data_type: 'varchar'
47
  is_nullable: 0
48
  size: 25
49
50
=head2 translation
51
52
  data_type: 'mediumtext'
53
  is_nullable: 1
54
55
=cut
56
57
__PACKAGE__->add_columns(
58
  "localization_id",
59
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
60
  "entity",
61
  { data_type => "varchar", is_nullable => 0, size => 16 },
62
  "code",
63
  { data_type => "varchar", is_nullable => 0, size => 64 },
64
  "lang",
65
  { data_type => "varchar", is_nullable => 0, size => 25 },
66
  "translation",
67
  { data_type => "mediumtext", is_nullable => 1 },
68
);
69
70
=head1 PRIMARY KEY
71
72
=over 4
73
74
=item * L</localization_id>
75
76
=back
77
78
=cut
79
80
__PACKAGE__->set_primary_key("localization_id");
81
82
=head1 UNIQUE CONSTRAINTS
83
84
=head2 C<entity_code_lang>
85
86
=over 4
87
88
=item * L</entity>
89
90
=item * L</code>
91
92
=item * L</lang>
93
94
=back
95
96
=cut
97
98
__PACKAGE__->add_unique_constraint("entity_code_lang", ["entity", "code", "lang"]);
99
100
101
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:54
102
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4642LmshpGd3JW7YxM5pIA
103
104
105
# You can replace this text with custom code or comments, and it will be preserved on regeneration
106
1;
(-)a/Koha/Template/Plugin/ItemTypes.pm (-2 / +9 lines)
Lines 22-37 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 {
28
    my ( $self, $itemtypecode ) = @_;
29
    my ( $self, $itemtypecode ) = @_;
29
    my $itemtype = Koha::ItemTypes->find( $itemtypecode );
30
    my $itemtype = Koha::ItemTypes->find( $itemtypecode );
30
    return $itemtype ? $itemtype->translated_description : q{};
31
    return $itemtype ? $self->t($itemtype->description) : q{};
31
}
32
}
32
33
33
sub Get {
34
sub Get {
34
    return Koha::ItemTypes->search_with_localization->unblessed;
35
    return Koha::ItemTypes->search->unblessed;
36
}
37
38
sub t {
39
    my ($self, $description) = @_;
40
41
    return db_t('itemtype', $description);
35
}
42
}
36
43
37
1;
44
1;
(-)a/acqui/orderreceive.pl (-1 / +2 lines)
Lines 76-81 use Koha::Acquisition::Booksellers; Link Here
76
use Koha::Acquisition::Currencies;
76
use Koha::Acquisition::Currencies;
77
use Koha::Acquisition::Orders;
77
use Koha::Acquisition::Orders;
78
use Koha::DateUtils qw( dt_from_string );
78
use Koha::DateUtils qw( dt_from_string );
79
use Koha::I18N;
79
use Koha::ItemTypes;
80
use Koha::ItemTypes;
80
use Koha::Patrons;
81
use Koha::Patrons;
81
82
Lines 153-159 if ($AcqCreateItem eq 'receiving') { Link Here
153
        my $itemtype = Koha::ItemTypes->find($i->effective_itemtype);
154
        my $itemtype = Koha::ItemTypes->find($i->effective_itemtype);
154
        if (defined $itemtype) {
155
        if (defined $itemtype) {
155
            # We should not do that here, but call ->itemtype->description when needed instead
156
            # We should not do that here, but call ->itemtype->description when needed instead
156
            $item->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description?
157
            $item->{itemtype} = db_t('itemtype', $itemtype->description);
157
        }
158
        }
158
        push @items, $item;
159
        push @items, $item;
159
    }
160
    }
(-)a/admin/itemtypes.pl (-3 lines)
Lines 33-39 use C4::Auth; Link Here
33
use C4::Output;
33
use C4::Output;
34
use Koha::ItemTypes;
34
use Koha::ItemTypes;
35
use Koha::ItemType;
35
use Koha::ItemType;
36
use Koha::Localizations;
37
36
38
my $input         = new CGI;
37
my $input         = new CGI;
39
my $searchfield   = $input->param('description');
38
my $searchfield   = $input->param('description');
Lines 73-84 if ( $op eq 'add_form' ) { Link Here
73
72
74
    my $imagesets = C4::Koha::getImageSets( checked => ( $itemtype ? $itemtype->imageurl : undef ) );
73
    my $imagesets = C4::Koha::getImageSets( checked => ( $itemtype ? $itemtype->imageurl : undef ) );
75
    my $searchcategory = GetAuthorisedValues("ITEMTYPECAT");
74
    my $searchcategory = GetAuthorisedValues("ITEMTYPECAT");
76
    my $translated_languages = C4::Languages::getTranslatedLanguages( undef , C4::Context->preference('template') );
77
    $template->param(
75
    $template->param(
78
        itemtype  => $itemtype,
76
        itemtype  => $itemtype,
79
        imagesets => $imagesets,
77
        imagesets => $imagesets,
80
        searchcategory => $searchcategory,
78
        searchcategory => $searchcategory,
81
        can_be_translated => ( scalar(@$translated_languages) > 1 ? 1 : 0 ),
82
        branches_loop    => \@branches_loop,
79
        branches_loop    => \@branches_loop,
83
    );
80
    );
84
} elsif ( $op eq 'add_validate' ) {
81
} elsif ( $op eq 'add_validate' ) {
(-)a/admin/localization.pl (-20 lines)
Lines 21-29 use Modern::Perl; Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Output;
22
use C4::Output;
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 = new CGI;
26
my $query = new CGI;
Lines 38-64 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
38
    }
35
    }
39
);
36
);
40
37
41
my $entity = $query->param('entity');
42
my $code   = $query->param('code');
43
my $rs     = Koha::Localizations->search( { entity => $entity, code => $code } );
44
my @translations;
45
while ( my $s = $rs->next ) {
46
    push @translations,
47
      { id          => $s->localization_id,
48
        entity      => $s->entity,
49
        code        => $s->code,
50
        lang        => $s->lang,
51
        translation => $s->translation,
52
      };
53
}
54
55
my $translated_languages = C4::Languages::getTranslatedLanguages( 'intranet', C4::Context->preference('template') );
38
my $translated_languages = C4::Languages::getTranslatedLanguages( 'intranet', C4::Context->preference('template') );
56
39
57
$template->param(
40
$template->param(
58
    translations => \@translations,
59
    languages    => $translated_languages,
41
    languages    => $translated_languages,
60
    entity       => $entity,
61
    code         => $code,
62
);
42
);
63
43
64
output_html_with_http_headers $query, $cookie, $template->output;
44
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/admin/smart-rules.pl (-31 / +1 lines)
Lines 556-562 $template->param( Link Here
556
556
557
my $patron_categories = Koha::Patron::Categories->search({}, { order_by => ['description'] });
557
my $patron_categories = Koha::Patron::Categories->search({}, { order_by => ['description'] });
558
558
559
my $itemtypes = Koha::ItemTypes->search_with_localization;
559
my $itemtypes = Koha::ItemTypes->search;
560
560
561
my $humanbranch = ( $branch ne '*' ? $branch : undef );
561
my $humanbranch = ( $branch ne '*' ? $branch : undef );
562
562
Lines 583-618 output_html_with_http_headers $input, $cookie, $template->output; Link Here
583
583
584
exit 0;
584
exit 0;
585
585
586
# sort by patron category, then item type, putting
587
# default entries at the bottom
588
sub by_category_and_itemtype {
589
    unless (by_category($a, $b)) {
590
        return by_itemtype($a, $b);
591
    }
592
}
593
594
sub by_category {
595
    my ($a, $b) = @_;
596
    if ($a->{'default_humancategorycode'}) {
597
        return ($b->{'default_humancategorycode'} ? 0 : 1);
598
    } elsif ($b->{'default_humancategorycode'}) {
599
        return -1;
600
    } else {
601
        return $a->{'humancategorycode'} cmp $b->{'humancategorycode'};
602
    }
603
}
604
605
sub by_itemtype {
606
    my ($a, $b) = @_;
607
    if ($a->{default_translated_description}) {
608
        return ($b->{'default_translated_description'} ? 0 : 1);
609
    } elsif ($b->{'default_translated_description'}) {
610
        return -1;
611
    } else {
612
        return lc $a->{'translated_description'} cmp lc $b->{'translated_description'};
613
    }
614
}
615
616
sub strip_non_numeric {
586
sub strip_non_numeric {
617
    my $string = shift;
587
    my $string = shift;
618
    $string =~ s/\s//g;
588
    $string =~ s/\s//g;
(-)a/authorities/authorities.pl (-2 / +3 lines)
Lines 33-38 use MARC::File::XML; Link Here
33
use C4::Biblio;
33
use C4::Biblio;
34
use Koha::Authority::Types;
34
use Koha::Authority::Types;
35
use Koha::ItemTypes;
35
use Koha::ItemTypes;
36
use Koha::I18N;
36
use vars qw( $tagslib);
37
use vars qw( $tagslib);
37
use vars qw( $authorised_values_sth);
38
use vars qw( $authorised_values_sth);
38
use vars qw( $is_a_modif );
39
use vars qw( $is_a_modif );
Lines 92-101 sub build_authorized_values_list { Link Here
92
            && ( $value || $tagslib->{$tag}->{$subfield}->{defaultvalue} ) );
93
            && ( $value || $tagslib->{$tag}->{$subfield}->{defaultvalue} ) );
93
94
94
        my $itemtype;
95
        my $itemtype;
95
        my $itemtypes = Koha::ItemTypes->search_with_localization;
96
        my $itemtypes = Koha::ItemTypes->search;
96
        while ( $itemtype = $itemtypes->next ) {
97
        while ( $itemtype = $itemtypes->next ) {
97
            push @authorised_values, $itemtype->itemtype;
98
            push @authorised_values, $itemtype->itemtype;
98
            $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
99
            $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->description);
99
        }
100
        }
100
        $value = $itemtype unless ($value);
101
        $value = $itemtype unless ($value);
101
102
(-)a/catalogue/getitem-ajax.pl (-1 / +2 lines)
Lines 29-34 use C4::Output; Link Here
29
use Koha::Libraries;
29
use Koha::Libraries;
30
30
31
use Koha::AuthorisedValues;
31
use Koha::AuthorisedValues;
32
use Koha::I18N;
32
use Koha::Items;
33
use Koha::Items;
33
use Koha::ItemTypes;
34
use Koha::ItemTypes;
34
35
Lines 77-83 if($itemnumber) { Link Here
77
78
78
    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
79
    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
79
    # We should not do that here, but call ->itemtype->description when needed instea
80
    # We should not do that here, but call ->itemtype->description when needed instea
80
    $item_unblessed->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description?
81
    $item_unblessed->{itemtype} = db_t('itemtype', $itemtype->description);
81
}
82
}
82
83
83
my $json_text = to_json( $item_unblessed, { utf8 => 1 } );
84
my $json_text = to_json( $item_unblessed, { utf8 => 1 } );
(-)a/catalogue/itemsearch.pl (-1 / +2 lines)
Lines 29-34 use C4::Koha; Link Here
29
29
30
use Koha::AuthorisedValues;
30
use Koha::AuthorisedValues;
31
use Koha::Biblios;
31
use Koha::Biblios;
32
use Koha::I18N;
32
use Koha::Item::Search::Field qw(GetItemSearchFields);
33
use Koha::Item::Search::Field qw(GetItemSearchFields);
33
use Koha::ItemTypes;
34
use Koha::ItemTypes;
34
use Koha::Libraries;
35
use Koha::Libraries;
Lines 259-265 my @itemtypes; Link Here
259
foreach my $itemtype ( Koha::ItemTypes->search ) {
260
foreach my $itemtype ( Koha::ItemTypes->search ) {
260
    push @itemtypes, {
261
    push @itemtypes, {
261
        value => $itemtype->itemtype,
262
        value => $itemtype->itemtype,
262
        label => $itemtype->translated_description,
263
        label => db_t('itemtype', $itemtype->description),
263
    };
264
    };
264
}
265
}
265
266
(-)a/catalogue/moredetail.pl (-3 / +4 lines)
Lines 37-42 use Koha::Biblios; Link Here
37
use Koha::DateUtils;
37
use Koha::DateUtils;
38
use Koha::Items;
38
use Koha::Items;
39
use Koha::Patrons;
39
use Koha::Patrons;
40
use Koha::I18N;
40
41
41
my $query=new CGI;
42
my $query=new CGI;
42
43
Lines 132-140 my $ccodes = Link Here
132
my $copynumbers =
133
my $copynumbers =
133
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
134
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
134
135
135
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
136
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
136
137
137
$data->{'itemtypename'} = $itemtypes->{ $data->{'itemtype'} }->{'translated_description'}
138
$data->{'itemtypename'} = db_t('itemtype', $itemtypes->{ $data->{'itemtype'} }->{description});
138
  if $data->{itemtype} && exists $itemtypes->{ $data->{itemtype} };
139
  if $data->{itemtype} && exists $itemtypes->{ $data->{itemtype} };
139
foreach ( keys %{$data} ) {
140
foreach ( keys %{$data} ) {
140
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
141
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
Lines 144-150 foreach ( keys %{$data} ) { Link Here
144
foreach my $item (@items){
145
foreach my $item (@items){
145
    $item->{object} = Koha::Items->find( $item->{itemnumber} );
146
    $item->{object} = Koha::Items->find( $item->{itemnumber} );
146
    $item->{'collection'}              = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} };
147
    $item->{'collection'}              = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} };
147
    $item->{'itype'}                   = $itemtypes->{ $item->{'itype'} }->{'translated_description'} if exists $itemtypes->{ $item->{'itype'} };
148
    $item->{'itype'}                   = db_t('itemtype', $itemtypes->{ $item->{'itype'} }->{description}) if exists $itemtypes->{ $item->{'itype'} };
148
    $item->{'replacementprice'}        = $item->{'replacementprice'};
149
    $item->{'replacementprice'}        = $item->{'replacementprice'};
149
    if ( defined $item->{'copynumber'} ) {
150
    if ( defined $item->{'copynumber'} ) {
150
        $item->{'displaycopy'} = 1;
151
        $item->{'displaycopy'} = 1;
(-)a/catalogue/search.pl (-8 / +23 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 237-243 $template->param( Link Here
237
);
238
);
238
239
239
# load the Type stuff
240
# load the Type stuff
240
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
241
my $itemtypes = {
242
    map {
243
        $_->{itemtype} => {
244
            %$_,
245
            description => db_t( 'itemtype', $_->{description} ),
246
          }
247
    } @{ Koha::ItemTypes->search->unblessed }
248
};
241
# the index parameter is different for item-level itemtypes
249
# the index parameter is different for item-level itemtypes
242
my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'itemtype';
250
my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'itemtype';
243
my @advancedsearchesloop;
251
my @advancedsearchesloop;
Lines 251-261 foreach my $advanced_srch_type (@advanced_search_types) { Link Here
251
   if ($advanced_srch_type eq 'itemtypes') {
259
   if ($advanced_srch_type eq 'itemtypes') {
252
   # itemtype is a special case, since it's not defined in authorized values
260
   # itemtype is a special case, since it's not defined in authorized values
253
        my @itypesloop;
261
        my @itypesloop;
254
        foreach my $thisitemtype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description} } keys %$itemtypes ) {
262
        foreach my $thisitemtype ( sort {$itemtypes->{$a}->{description} cmp $itemtypes->{$b}->{description} } keys %$itemtypes ) {
255
	    my %row =(  number=>$cnt++,
263
	    my %row =(  number=>$cnt++,
256
		ccl => "$itype_or_itemtype,phr",
264
		ccl => "$itype_or_itemtype,phr",
257
                code => $thisitemtype,
265
                code => $thisitemtype,
258
                description => $itemtypes->{$thisitemtype}->{translated_description},
266
                description => $itemtypes->{$thisitemtype}->{description},
259
                imageurl=> getitemtypeimagelocation( 'intranet', $itemtypes->{$thisitemtype}->{'imageurl'} ),
267
                imageurl=> getitemtypeimagelocation( 'intranet', $itemtypes->{$thisitemtype}->{'imageurl'} ),
260
            );
268
            );
261
	    push @itypesloop, \%row;
269
	    push @itypesloop, \%row;
Lines 546-552 my $facets; # this object stores the faceted results that display on the left-ha Link Here
546
my $results_hashref;
554
my $results_hashref;
547
555
548
eval {
556
eval {
549
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
557
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
550
    ( $error, $results_hashref, $facets ) = $searcher->search_compat(
558
    ( $error, $results_hashref, $facets ) = $searcher->search_compat(
551
        $query,            $simple_query, \@sort_by,       \@servers,
559
        $query,            $simple_query, \@sort_by,       \@servers,
552
        $results_per_page, $offset,       undef,           $itemtypes,
560
        $results_per_page, $offset,       undef,           $itemtypes,
Lines 818-824 sub prepare_adv_search_types { Link Here
818
    # the index parameter is different for item-level itemtypes
826
    # the index parameter is different for item-level itemtypes
819
    my $itype_or_itemtype =
827
    my $itype_or_itemtype =
820
      ( C4::Context->preference("item-level_itypes") ) ? 'itype' : 'itemtype';
828
      ( C4::Context->preference("item-level_itypes") ) ? 'itype' : 'itemtype';
821
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
829
    my $itemtypes = {
830
        map {
831
            $_->{itemtype} => {
832
                %$_,
833
                description => db_t( 'itemtype', $_->{description} ),
834
              }
835
        } @{ Koha::ItemTypes->search->unblessed }
836
    };
822
837
823
    my ( $cnt, @result );
838
    my ( $cnt, @result );
824
    foreach my $advanced_srch_type (@advanced_search_types) {
839
    foreach my $advanced_srch_type (@advanced_search_types) {
Lines 830-837 sub prepare_adv_search_types { Link Here
830
            my @itypesloop;
845
            my @itypesloop;
831
            foreach my $thisitemtype (
846
            foreach my $thisitemtype (
832
                sort {
847
                sort {
833
                    $itemtypes->{$a}->{'translated_description'}
848
                    $itemtypes->{$a}->{'description'}
834
                      cmp $itemtypes->{$b}->{'translated_description'}
849
                      cmp $itemtypes->{$b}->{'description'}
835
                } keys %$itemtypes
850
                } keys %$itemtypes
836
              )
851
              )
837
            {
852
            {
Lines 839-845 sub prepare_adv_search_types { Link Here
839
                    number      => $cnt++,
854
                    number      => $cnt++,
840
                    ccl         => "$itype_or_itemtype,phr",
855
                    ccl         => "$itype_or_itemtype,phr",
841
                    code        => $thisitemtype,
856
                    code        => $thisitemtype,
842
                    description => $itemtypes->{$thisitemtype}->{'translated_description'},
857
                    description => $itemtypes->{$thisitemtype}->{'description'},
843
                    imageurl    => getitemtypeimagelocation(
858
                    imageurl    => getitemtypeimagelocation(
844
                        'intranet', $itemtypes->{$thisitemtype}->{'imageurl'}
859
                        'intranet', $itemtypes->{$thisitemtype}->{'imageurl'}
845
                    ),
860
                    ),
(-)a/cataloguing/addbiblio.pl (-2 / +3 lines)
Lines 46-51 use Date::Calc qw(Today); Link Here
46
use MARC::File::USMARC;
46
use MARC::File::USMARC;
47
use MARC::File::XML;
47
use MARC::File::XML;
48
use URI::Escape;
48
use URI::Escape;
49
use Koha::I18N;
49
50
50
if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
51
if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
51
    MARC::File::XML->default_record_format('UNIMARC');
52
    MARC::File::XML->default_record_format('UNIMARC');
Lines 181-190 sub build_authorized_values_list { Link Here
181
        push @authorised_values, "";
182
        push @authorised_values, "";
182
183
183
        my $itemtype;
184
        my $itemtype;
184
        my $itemtypes = Koha::ItemTypes->search_with_localization;
185
        my $itemtypes = Koha::ItemTypes->search;
185
        while ( $itemtype = $itemtypes->next ) {
186
        while ( $itemtype = $itemtypes->next ) {
186
            push @authorised_values, $itemtype->itemtype;
187
            push @authorised_values, $itemtype->itemtype;
187
            $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
188
            $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->description);
188
        }
189
        }
189
        $value = $itemtype unless ($value);
190
        $value = $itemtype unless ($value);
190
    }
191
    }
(-)a/cataloguing/additem.pl (-3 / +4 lines)
Lines 31-36 use C4::Circulation; Link Here
31
use C4::Koha;
31
use C4::Koha;
32
use C4::ClassSource;
32
use C4::ClassSource;
33
use Koha::DateUtils;
33
use Koha::DateUtils;
34
use Koha::I18N;
34
use Koha::Items;
35
use Koha::Items;
35
use Koha::ItemTypes;
36
use Koha::ItemTypes;
36
use Koha::Libraries;
37
use Koha::Libraries;
Lines 182-194 sub generate_subfield_form { Link Here
182
                  my $branch_limit = C4::Context->userenv && C4::Context->userenv->{"branch"};
183
                  my $branch_limit = C4::Context->userenv && C4::Context->userenv->{"branch"};
183
                  my $itemtypes;
184
                  my $itemtypes;
184
                  if($branch_limit) {
185
                  if($branch_limit) {
185
                      $itemtypes = Koha::ItemTypes->search_with_localization({branchcode => $branch_limit});
186
                      $itemtypes = Koha::ItemTypes->search({branchcode => $branch_limit});
186
                  } else {
187
                  } else {
187
                      $itemtypes = Koha::ItemTypes->search_with_localization;
188
                      $itemtypes = Koha::ItemTypes->search;
188
                  }
189
                  }
189
                  while ( my $itemtype = $itemtypes->next ) {
190
                  while ( my $itemtype = $itemtypes->next ) {
190
                      push @authorised_values, $itemtype->itemtype;
191
                      push @authorised_values, $itemtype->itemtype;
191
                      $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
192
                      $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->description);
192
                  }
193
                  }
193
194
194
                  unless ( $value ) {
195
                  unless ( $value ) {
(-)a/circ/transferstoreceive.pl (-1 / +2 lines)
Lines 34-39 use Date::Calc qw( Link Here
34
34
35
use C4::Koha;
35
use C4::Koha;
36
use C4::Reserves;
36
use C4::Reserves;
37
use Koha::I18N;
37
use Koha::Items;
38
use Koha::Items;
38
use Koha::ItemTypes;
39
use Koha::ItemTypes;
39
use Koha::Libraries;
40
use Koha::Libraries;
Lines 95-101 while ( my $library = $libraries->next ) { Link Here
95
            my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
96
            my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
96
97
97
            $getransf{'datetransfer'} = $num->{'datesent'};
98
            $getransf{'datetransfer'} = $num->{'datesent'};
98
            $getransf{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description?
99
            $getransf{'itemtype'} = db_t('itemtype', $itemtype->description);
99
            %getransf = (
100
            %getransf = (
100
                %getransf,
101
                %getransf,
101
                title          => $biblio->title,
102
                title          => $biblio->title,
(-)a/course_reserves/add_items.pl (-1 / +1 lines)
Lines 84-90 if ( $action eq 'lookup' and $item ) { Link Here
84
84
85
        ccodes    => GetAuthorisedValues('CCODE'),
85
        ccodes    => GetAuthorisedValues('CCODE'),
86
        locations => GetAuthorisedValues('LOC'),
86
        locations => GetAuthorisedValues('LOC'),
87
        itypes    => $itemtypes, # FIXME We certainly want to display the translated_description in the template
87
        itypes    => $itemtypes,
88
        return    => $return,
88
        return    => $return,
89
    );
89
    );
90
90
(-)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 (-13 / +20 lines)
Lines 3695-3714 CREATE TABLE `additional_field_values` ( Link Here
3695
  CONSTRAINT `afv_fk` FOREIGN KEY (`field_id`) REFERENCES `additional_fields` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
3695
  CONSTRAINT `afv_fk` FOREIGN KEY (`field_id`) REFERENCES `additional_fields` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
3696
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3696
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3697
3697
3698
--
3699
-- Table structure for table 'localization'
3700
--
3701
3698
3702
DROP TABLE IF EXISTS localization;
3699
DROP TABLE IF EXISTS l10n_source;
3703
CREATE TABLE `localization` (
3700
CREATE TABLE l10n_source (
3704
      localization_id int(11) NOT NULL AUTO_INCREMENT,
3701
    l10n_source_id INT(11) NOT NULL AUTO_INCREMENT,
3705
      entity varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL,
3702
    context VARCHAR(100) NULL DEFAULT NULL,
3706
      code varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
3703
    source TEXT NOT NULL,
3707
      lang varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL, -- could be a foreign key
3704
    PRIMARY KEY (l10n_source_id),
3708
      translation MEDIUMTEXT COLLATE utf8mb4_unicode_ci,
3705
    KEY context_source (context, source(60))
3709
      PRIMARY KEY (localization_id),
3706
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
3710
      UNIQUE KEY `entity_code_lang` (`entity`,`code`,`lang`)
3707
3711
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3708
DROP TABLE IF EXISTS l10n_target;
3709
CREATE TABLE l10n_target (
3710
    l10n_target_id INT(11) NOT NULL AUTO_INCREMENT,
3711
    l10n_source_id INT(11) NOT NULL,
3712
    language VARCHAR(10) NOT NULL,
3713
    translation TEXT NOT NULL,
3714
    PRIMARY KEY (l10n_target_id),
3715
    UNIQUE KEY l10n_source_language (l10n_source_id, language),
3716
    FOREIGN KEY l10n_source (l10n_source_id) REFERENCES l10n_source (l10n_source_id)
3717
        ON DELETE CASCADE ON UPDATE CASCADE
3718
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
3712
3719
3713
--
3720
--
3714
-- Table structure for table 'audio_alerts'
3721
-- Table structure for table 'audio_alerts'
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc (+1 lines)
Lines 150-155 Link Here
150
            [% IF ( Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts ) %]
150
            [% IF ( Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts ) %]
151
                <li><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></li>
151
                <li><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></li>
152
            [% END %]
152
            [% END %]
153
            <li><a href="/cgi-bin/koha/admin/localization.pl">Localization</a></li>
153
        </ul>
154
        </ul>
154
    [% END %]
155
    [% END %]
155
</div>
156
</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 25-31 Link Here
25
        [% ELSE %]
26
        [% ELSE %]
26
            <option value="[% itemtype.itemtype | html %]">
27
            <option value="[% itemtype.itemtype | html %]">
27
        [% END %]
28
        [% END %]
28
            [% itemtype.translated_description | html %]
29
            [% ItemTypes.t(itemtype.description) | html %]
29
        </option>
30
        </option>
30
    [% END %]
31
    [% END %]
31
[% END %]
32
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt (+2 lines)
Lines 236-241 Link Here
236
                        <dt><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></dt>
236
                        <dt><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></dt>
237
                        <dd>Define which keys trigger actions in the advanced cataloging editor</dd>
237
                        <dd>Define which keys trigger actions in the advanced cataloging editor</dd>
238
                    [% END %]
238
                    [% END %]
239
                    <dt><a href="/cgi-bin/koha/admin/localization.pl">Localization</a></dt>
240
                    <dd>Translate user-defined strings</dd>
239
                </dl>
241
                </dl>
240
            [% END %]
242
            [% END %]
241
            </div>
243
            </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (-17 / +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 AuthorisedValues %]
5
[% USE AuthorisedValues %]
5
[% USE Price %]
6
[% USE Price %]
Lines 118-126 Item types administration Link Here
118
                <li>
119
                <li>
119
                    <label for="description" class="required">Description: </label>
120
                    <label for="description" class="required">Description: </label>
120
                    <input type="text" id="description" name="description" size="48" value="[% itemtype.description | html %]" required="required" /> <span class="required">Required</span>
121
                    <input type="text" id="description" name="description" size="48" value="[% itemtype.description | html %]" required="required" /> <span class="required">Required</span>
121
                    [% IF can_be_translated %]
122
                        <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>
123
                    [% END %]
124
                </li>
122
                </li>
125
                <li>
123
                <li>
126
                    <span class="label">Search category</span>
124
                    <span class="label">Search category</span>
Lines 323-329 Item types administration Link Here
323
                <th scope="row">Item type</th>
321
                <th scope="row">Item type</th>
324
                <td>[% itemtype.itemtype | html %]</td>
322
                <td>[% itemtype.itemtype | html %]</td>
325
            </tr>
323
            </tr>
326
            <tr><th scope="row">Description</th><td>[% itemtype.translated_description | html %]</td></tr>
324
            <tr><th scope="row">Description</th><td>[% ItemTypes.t(itemtype.description) | html %]</td></tr>
327
            [% UNLESS Koha.Preference('noItemTypeImages') %]
325
            [% UNLESS Koha.Preference('noItemTypeImages') %]
328
                <tr>
326
                <tr>
329
                    <th scope="row">Image</th>
327
                    <th scope="row">Image</th>
Lines 379-397 Item types administration Link Here
379
              </a>
377
              </a>
380
            </td>
378
            </td>
381
            <td>
379
            <td>
382
                [% IF itemtype.translated_descriptions.size %]
380
                [% itemtype.description | html %]
383
                    [% itemtype.description | html %] (default)<br/>
384
                    [% FOR description IN itemtype.translated_descriptions %]
385
                        [% IF description.translation == itemtype.translated_description %]
386
                            <b>[% description.translation | html %]</b>
387
                        [% ELSE %]
388
                            [% description.translation | html %] ([% description.lang | html %])
389
                        [% END %]
390
                        <br/>
391
                    [% END %]
392
                [% ELSE %]
393
                    [% itemtype.description | html %]
394
                [% END %]
395
            </td>
381
            </td>
396
            <td>[% itemtype.searchcategory | html %]</td>
382
            <td>[% itemtype.searchcategory | html %]</td>
397
            <td>[% IF ( itemtype.notforloan ) %]Yes[% ELSE %]&nbsp;[% END %]</td>
383
            <td>[% IF ( itemtype.notforloan ) %]Yes[% ELSE %]&nbsp;[% END %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/localization.tt (-243 / +126 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>Koha &rsaquo; Localization</title>
4
<title>Koha &rsaquo; Localization</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
    .add-translation-block {
8
        margin-bottom: 5px;
9
    }
10
11
    .add-translation-block form {
12
        display: inline-flex;
13
        align-items: center;
14
    }
15
    code {
16
        background-color: lightgrey;
17
        font-weight: bold;
18
        display: inline-block;
19
        padding: 2px 4px;
20
    }
21
</style>
8
</head>
22
</head>
9
23
10
<body id="admin_localization" class="admin">
24
<body id="admin_localization" class="admin">
11
    <div class="container-fluid">
25
    [% INCLUDE 'header.inc' %]
12
        <div class="row">
26
    [% 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
27
52
        <div class="row">
28
    <div id="breadcrumbs">
53
            <div class="col-sm-12">
29
        <a href="/cgi-bin/koha/mainpage.pl">Home</a>
54
<div id="messages"></div>
30
        &rsaquo;
55
            </div> <!-- /.col-sm-12 -->
31
        <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
56
        </div> <!-- /.row -->
32
        &rsaquo;
33
        Localization
34
    </div>
35
36
    <div class="main container-fluid">
57
37
58
        <div class="row">
38
        <div class="row">
59
            <div class="col-sm-12">
39
            <div class="col-sm-10 col-sm-push-2">
60
<table id="localization">
40
                <main>
61
    <thead>
41
                    <h2>Localization</h2>
62
        <tr>
42
63
            <th>Id</th>
43
                    <table id="localization">
64
            <th>Entity</th>
44
                        <thead>
65
            <th>Code</th>
45
                            <tr>
66
            <th>Language</th>
46
                                <th>Context</th>
67
            <th>Translation</th>
47
                                <th>Source</th>
68
            <th class="NoSort">&nbsp;</th>
48
                                <th>Translations</th>
69
        </tr>
49
                            </tr>
70
    </thead>
50
                        </thead>
71
    <tbody>
51
                        <tbody>
72
        [% FOR t IN translations %]
52
                        </tbody>
73
        <tr id="row_id_[% t.id | html %]" data-id="[% t.id | html %]">
53
                    </table>
74
            <td>[% t.id | html %]</td>
54
                </main>
75
            <td>[% t.entity | html %]</td>
55
            </div>
76
            <td>[% t.code | html %]</td>
56
77
            <td class="lang">[% t.lang | html %]</td>
57
            <div class="col-sm-2 col-sm-pull-10">
78
            <td class="translation" contenteditable="true">[% t.translation | html %]</td>
58
                <aside>
79
            <td class="actions"><a href="#" class="delete"><i class="fa fa-trash"></i> Delete</a></td>
59
                    [% INCLUDE 'admin-menu.inc' %]
80
        </tr>
60
                </aside>
81
        [% END %]
61
            </div>
82
    </tbody>
62
        </div>
83
</table>
63
    </div>
84
            </div> <!-- /.col-sm-12 -->
85
        </div> <!-- /.row -->
86
    </div> <!-- /.container-fluid -->
87
64
88
[% MACRO jsinclude BLOCK %]
65
[% MACRO jsinclude BLOCK %]
89
    [% INCLUDE 'datatables.inc' %]
66
    [% INCLUDE 'datatables.inc' %]
90
    <script>
67
    <script>
91
68
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 ) {
69
        function send_update_request( data, cell ) {
133
            $.ajax({
70
            $.ajax({
134
                data: data,
71
                data: data,
135
                type: 'PUT',
72
                type: 'PUT',
136
                url: '/cgi-bin/koha/svc/localization',
73
                url: '/cgi-bin/koha/svc/localization',
137
                success: function (data) {
74
                success: function (data) {
138
                    if ( data.error ) {
75
                    $("#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
                },
76
                },
176
            });
77
            });
177
        }
78
        }
178
79
179
        $(document).ready(function() {
80
        $(document).ready(function() {
180
            $(".dialog").hide();
181
182
            var table = $("#localization").DataTable($.extend(true, {}, dataTablesDefaults, {
81
            var table = $("#localization").DataTable($.extend(true, {}, dataTablesDefaults, {
183
                "dom": 't',
82
                autoWidth: true,
184
                "columnDefs": [
83
                serverSide: true,
185
                    { 'sortable': false, 'targets': [ 'NoSort' ] }
84
                ordering: false,
186
                ],
85
                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',
86
                    url: '/cgi-bin/koha/svc/localization',
259
                    success: function (data) {
87
                },
260
                        if ( data.error ) {
88
                columns: [
261
                            show_message({ type: 'error_on_insert', data: data });
89
                    {
262
                        } else {
90
                        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();
91
                        data: 'context',
264
                            $( new_row ).attr("id", "row_id_" + data.id ).data("id", data.id );
92
                    },
265
                            show_message({ type: 'success_on_insert', data: data });
93
                    {
266
                        }
94
                        name: 'source',
95
                        data: 'source',
267
                    },
96
                    },
268
                    error: function (data) {
97
                    {
269
                        show_message({ type: 'error_on_insert', data: data });
98
                        name: 'targets',
99
                        data: 'l10n_targets',
100
                        render: function (data, type, row, meta) {
101
                            const languages = [% languages.json %];
102
                            const translations = Object.fromEntries(data.map(translation => [translation.language, translation]));
103
                            let output = '';
104
                            for (const language of languages) {
105
                                const div = $('<div>');
106
                                div.addClass('add-translation-block');
107
                                const languageCode = $('<code>').text(language.rfc4646_subtag);
108
                                const translationSpan = $('<span>');
109
                                if (translations[language.rfc4646_subtag]) {
110
                                    const translation = translations[language.rfc4646_subtag].translation;
111
                                    translationSpan.text(translation);
112
                                } else {
113
                                    languageCode.html('<del>' + languageCode.text() + '</del>');
114
                                }
115
                                const translateLink = $('<a>');
116
                                translateLink.text('Translate');
117
                                translateLink.addClass('add-translation');
118
                                translateLink.attr('href', '#');
119
                                translateLink.attr('data-l10n-source-id', row.l10n_source_id);
120
                                translateLink.attr('data-language', language.rfc4646_subtag);
121
                                translateLink.attr('data-source', row.source);
122
                                if (translations[language.rfc4646_subtag]) {
123
                                    translateLink.attr('data-translation', translations[language.rfc4646_subtag].translation);
124
                                }
125
126
                                div.append(languageCode, ' ', translationSpan, ' ', translateLink);
127
128
                                output += ' ' + div[0].outerHTML;
129
                            }
130
131
                            return output;
132
                        },
270
                    },
133
                    },
134
                ],
135
            }));
136
137
            $('#localization').on('click', '.add-translation', function (ev) {
138
                ev.preventDefault();
139
                const form = $('<form>');
140
                const textarea = $('<textarea>').attr('rows', '1');
141
                textarea.text(ev.target.getAttribute('data-translation'));
142
                form.append(textarea);
143
                form.append('<button type="submit">Save</button>');
144
                const l10n_source_id = ev.target.getAttribute('data-l10n-source-id');
145
                const language = ev.target.getAttribute('data-language');
146
                form.on('submit', function (ev) {
147
                    ev.preventDefault();
148
                    send_update_request({
149
                        id: l10n_source_id,
150
                        lang: language,
151
                        translation: textarea.val(),
152
                    });
271
                });
153
                });
154
                $(ev.target).hide();
155
                $(ev.target).after(form);
272
            });
156
            });
273
274
         });
157
         });
275
    </script>
158
    </script>
276
[% END %]
159
[% END %]
277
[% INCLUDE 'popup-bottom.inc' %]
160
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-3 / +3 lines)
Lines 322-328 Link Here
322
                        <select name="itemtype" id="matrixitemtype" style="width:13em;">
322
                        <select name="itemtype" id="matrixitemtype" style="width:13em;">
323
                            <option value="*">All</option>
323
                            <option value="*">All</option>
324
                        [% FOREACH itemtypeloo IN itemtypeloop %]
324
                        [% FOREACH itemtypeloo IN itemtypeloop %]
325
                            <option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %]</option>
325
                            <option value="[% itemtypeloo.itemtype | html %]">[% ItemTypes.t(itemtypeloo.description) | html %]</option>
326
                        [% END %]
326
                        [% END %]
327
                        </select>
327
                        </select>
328
                    </td>
328
                    </td>
Lines 818-824 Link Here
818
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
818
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
819
                        <tr>
819
                        <tr>
820
                            <td>
820
                            <td>
821
                                [% i.translated_description | html %]
821
                                [% ItemTypes.t(i.description) | html %]
822
                            </td>
822
                            </td>
823
                            <td>
823
                            <td>
824
                                [% IF holdallowed == 2 %]
824
                                [% IF holdallowed == 2 %]
Lines 863-869 Link Here
863
                    <td>
863
                    <td>
864
                        <select name="itemtype">
864
                        <select name="itemtype">
865
                        [% FOREACH itemtypeloo IN itemtypeloop %]
865
                        [% FOREACH itemtypeloo IN itemtypeloop %]
866
                            <option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %]</option>
866
                            <option value="[% itemtypeloo.itemtype | html %]">[% ItemTypes.t(itemtypeloo.description) | html %]</option>
867
                        [% END %]
867
                        [% END %]
868
                        </select>
868
                        </select>
869
                    </td>
869
                    </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 143-149 Link Here
143
        <tr>
144
        <tr>
144
    [% FOREACH itemtypeloo IN advsearchloo.code_loop %]
145
    [% FOREACH itemtypeloo IN advsearchloo.code_loop %]
145
        <td><input type="checkbox" id="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]" name="limit" value="mc-[% itemtypeloo.ccl | html %]:[% itemtypeloo.code | html %]"/><label for="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]">[% UNLESS ( noItemTypeImages ) %][% IF ( itemtypeloo.imageurl ) %]<img src="[% itemtypeloo.imageurl | html %]" alt="[% itemtypeloo.description | html %]" />[% END %]&nbsp;[% END %]
146
        <td><input type="checkbox" id="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]" name="limit" value="mc-[% itemtypeloo.ccl | html %]:[% itemtypeloo.code | html %]"/><label for="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]">[% UNLESS ( noItemTypeImages ) %][% IF ( itemtypeloo.imageurl ) %]<img src="[% itemtypeloo.imageurl | html %]" alt="[% itemtypeloo.description | html %]" />[% END %]&nbsp;[% END %]
146
        [% itemtypeloo.description | html %]</label></td>
147
        [% ItemTypes.t(itemtypeloo.description) | html %]</label></td>
147
        [% IF ( loop.last ) %]</tr>[% ELSE %][% UNLESS ( loop.count % 5 ) %]</tr><tr>[% END %][% END %]
148
        [% IF ( loop.last ) %]</tr>[% ELSE %][% UNLESS ( loop.count % 5 ) %]</tr><tr>[% END %][% END %]
148
    [% END %]
149
    [% END %]
149
    </table>
150
    </table>
(-)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 AuthorisedValues %]
6
[% USE AuthorisedValues %]
Lines 264-272 Link Here
264
                    [% IF ( item_level_itypes ) %]
265
                    [% IF ( item_level_itypes ) %]
265
                        <td class="itype">
266
                        <td class="itype">
266
                            [% IF !noItemTypeImages && item.imageurl %]
267
                            [% IF !noItemTypeImages && item.imageurl %]
267
                                <img src="[% item.imageurl | html %]" alt="[% item.translated_description | html %]" title="[% item.translated_description | html %]" />
268
                                <img src="[% item.imageurl | html %]" alt="[% ItemTypes.t(item.description) | html %]" title="[% ItemTypes.t(item.description) | html %]" />
268
                            [% END %]
269
                            [% END %]
269
                            [% item.translated_description | html %]
270
                            [% ItemTypes.t(item.description) | html %]
270
                        </td>
271
                        </td>
271
                    [% END %]
272
                    [% END %]
272
                    <td class="location">[% UNLESS ( singlebranchmode ) %][% Branches.GetName( item.branchcode ) | html %] [% END %]</td>
273
                    <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
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Course reserves &rsaquo;[% IF is_edit || course_reserve %] Edit item[% ELSE %] Add items[% END %]</title>
4
<title>Koha &rsaquo; Course reserves &rsaquo;[% IF is_edit || course_reserve %] Edit item[% ELSE %] Add items[% END %]</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
Lines 44-52 Link Here
44
45
45
                            [% FOREACH it IN itypes %]
46
                            [% FOREACH it IN itypes %]
46
                                [% IF course_item.itype.defined && ( ( course.enabled == 'yes' && it.itemtype == item.itype ) || ( course.enabled == 'no' && it.itemtype == course_item.itype ) ) %]
47
                                [% IF course_item.itype.defined && ( ( course.enabled == 'yes' && it.itemtype == item.itype ) || ( course.enabled == 'no' && it.itemtype == course_item.itype ) ) %]
47
                                    <option value="[% it.itemtype | html %]" selected="selected">[% it.description | html %]</option>
48
                                    <option value="[% it.itemtype | html %]" selected="selected">[% ItemTypes.t(it.description) | html %]</option>
48
                                [% ELSE %]
49
                                [% ELSE %]
49
                                    <option value="[% it.itemtype | html %]">[% it.description | html %]</option>
50
                                    <option value="[% it.itemtype | html %]">[% ItemTypes.t(it.description) | html %]</option>
50
                                [% END %]
51
                                [% END %]
51
                            [% END %]
52
                            [% END %]
52
                        </select>
53
                        </select>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_add_items.tt (-1 / +1 lines)
Lines 39-45 Link Here
39
                                <option value="">LEAVE UNCHANGED</option>
39
                                <option value="">LEAVE UNCHANGED</option>
40
40
41
                                [% FOREACH it IN ItemTypes.Get() %]
41
                                [% FOREACH it IN ItemTypes.Get() %]
42
                                    <option value="[% it.itemtype | html %]">[% it.description | html %]</option>
42
                                    <option value="[% it.itemtype | html %]">[% ItemTypes.t(it.description) | html %]</option>
43
                                [% END %]
43
                                [% END %]
44
                            </select>
44
                            </select>
45
                        </li>
45
                        </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>Koha &rsaquo; Reports [% IF ( do_it ) %]&rsaquo; Acquisitions statistics &rsaquo; Results[% ELSE %]&rsaquo; Acquisitions statistics[% END %]</title>
4
<title>Koha &rsaquo; Reports [% IF ( do_it ) %]&rsaquo; Acquisitions statistics &rsaquo; Results[% ELSE %]&rsaquo; Acquisitions statistics[% END %]</title>
Lines 191-197 Link Here
191
                    <select name="Filter" size="1" id="itemtypes">
192
                    <select name="Filter" size="1" id="itemtypes">
192
                        <option value="">All item types</option>
193
                        <option value="">All item types</option>
193
                        [% FOREACH itemtype IN itemtypes %]
194
                        [% FOREACH itemtype IN itemtypes %]
194
                        <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
195
                        <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
195
                        [% END %]
196
                        [% END %]
196
                    </select>
197
                    </select>
197
                </td>
198
                </td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt (-1 / +1 lines)
Lines 108-114 Link Here
108
			<li> 
108
			<li> 
109
                <label for="documenttype">Item type: </label><select name="Filter" id="documenttype"><option value="" > Any item type</option>
109
                <label for="documenttype">Item type: </label><select name="Filter" id="documenttype"><option value="" > Any item type</option>
110
    [% FOREACH itemtype IN itemtypes %]
110
    [% FOREACH itemtype IN itemtypes %]
111
        <option value="[% itemtype.itemtype | html %]" >[% itemtype.translated_description | html %] </option>
111
        <option value="[% itemtype.itemtype | html %]" >[% ItemTypes.t(itemtype.description) | html %] </option>
112
     [% END %] 
112
     [% END %] 
113
    </select>
113
    </select>
114
			</li>
114
			</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>Koha &rsaquo; Reports &rsaquo; Most-circulated items[% IF ( do_it ) %] &rsaquo; Results[% END %]</title>
5
<title>Koha &rsaquo; Reports &rsaquo; Most-circulated items[% IF ( do_it ) %] &rsaquo; Results[% END %]</title>
Lines 85-91 Link Here
85
      <li> 
86
      <li> 
86
        <label for="documenttype">Item type: </label><select name="Filter" id="documenttype"><option value="" > Any item type</option>
87
        <label for="documenttype">Item type: </label><select name="Filter" id="documenttype"><option value="" > Any item type</option>
87
    [% FOREACH itemtype IN itemtypes %]
88
    [% FOREACH itemtype IN itemtypes %]
88
        <option value="[% itemtype.itemtype | html %]" >[% itemtype.translated_description | html %] </option>
89
        <option value="[% itemtype.itemtype | html %]" >[% ItemTypes.t(itemtype.description) | html %] </option>
89
     [% END %] 
90
     [% END %] 
90
    </select>
91
    </select>
91
      </li>
92
      </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>Koha &rsaquo; Reports &rsaquo; Items with no checkouts</title>
4
<title>Koha &rsaquo; Reports &rsaquo; Items with no checkouts</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
Lines 98-104 Link Here
98
        <label for="documenttype">Item type: </label><select name="Filter" id="documenttype">
99
        <label for="documenttype">Item type: </label><select name="Filter" id="documenttype">
99
        <option value="">Any item type</option>
100
        <option value="">Any item type</option>
100
    [% FOREACH itemtype IN itemtypes %]
101
    [% FOREACH itemtype IN itemtypes %]
101
        <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
102
        <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
102
     [% END %] 
103
     [% END %] 
103
    </select>
104
    </select>
104
    </li>
105
    </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>Koha &rsaquo; Reports [% IF ( do_it ) %]&rsaquo; Catalog statistics &rsaquo; Results[% ELSE %]&rsaquo; Catalog statistics[% END %]</title>
5
<title>Koha &rsaquo; Reports [% IF ( do_it ) %]&rsaquo; Catalog statistics &rsaquo; Results[% ELSE %]&rsaquo; Catalog statistics[% END %]</title>
Lines 103-109 Link Here
103
				<td><select name="Filter" id="[% item_itype | html %]">
104
				<td><select name="Filter" id="[% item_itype | html %]">
104
					<option value=""> </option>
105
					<option value=""> </option>
105
                    [% FOREACH itemtype IN itemtypes %]
106
                    [% FOREACH itemtype IN itemtypes %]
106
                        <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
107
                        <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
107
                    [% END %]
108
                    [% END %]
108
					</select>
109
					</select>
109
				</td>
110
				</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>Koha &rsaquo; Reports &rsaquo; Average loan time</title>
5
<title>Koha &rsaquo; Reports &rsaquo; Average loan time</title>
Lines 137-143 Link Here
137
                    <select name="Filter" size="1" id="itemtypes">
138
                    <select name="Filter" size="1" id="itemtypes">
138
                        <option value=""></option>
139
                        <option value=""></option>
139
                        [% FOREACH itemtype IN itemtypes %]
140
                        [% FOREACH itemtype IN itemtypes %]
140
                        <option value="[%- itemtype.itemtype | html -%]">[%- itemtype.translated_description | html -%]</option>
141
                        <option value="[%- itemtype.itemtype | html -%]">[%- ItemTypes.t(itemtype.description) | html -%]</option>
141
                        [% END %]
142
                        [% END %]
142
                    </select>
143
                    </select>
143
                </td>
144
                </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>Koha &rsaquo; Reports &rsaquo; Circulation statistics [% IF ( do_it ) %]&rsaquo; Results[% END %]</title>
5
<title>Koha &rsaquo; Reports &rsaquo; Circulation statistics [% IF ( do_it ) %]&rsaquo; Results[% END %]</title>
Lines 168-174 Link Here
168
           <td><select name="Filter" id="itemtype">
169
           <td><select name="Filter" id="itemtype">
169
               <option value=""> </option>
170
               <option value=""> </option>
170
               [% FOREACH itemtype IN itemtypes %]
171
               [% FOREACH itemtype IN itemtypes %]
171
                 <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
172
                 <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
172
               [% END %]
173
               [% END %]
173
               </select>
174
               </select>
174
             </td> 
175
             </td> 
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt (-1 / +1 lines)
Lines 137-143 Link Here
137
    <li><label for="itemtypesfilter">Item type: </label><select name="itemtypesfilter" id="itemtypesfilter">
137
    <li><label for="itemtypesfilter">Item type: </label><select name="itemtypesfilter" id="itemtypesfilter">
138
                <option value="">All</option>
138
                <option value="">All</option>
139
                [% FOREACH itemtype IN itemtypes %]
139
                [% FOREACH itemtype IN itemtypes %]
140
                    <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
140
                    <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
141
                [% END %]
141
                [% END %]
142
            </select></li>
142
            </select></li>
143
143
(-)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>Koha &rsaquo; Reports &rsaquo; Holds statistics [% IF ( do_it ) %]&rsaquo; Results[% END %]</title>
5
<title>Koha &rsaquo; Reports &rsaquo; Holds statistics [% IF ( do_it ) %]&rsaquo; Results[% END %]</title>
Lines 153-159 Link Here
153
           <td><select name="filter_items.itype" id="itype">
154
           <td><select name="filter_items.itype" id="itype">
154
               <option value=""> </option>
155
               <option value=""> </option>
155
               [% FOREACH itemtype IN itemtypes %]
156
               [% FOREACH itemtype IN itemtypes %]
156
                 <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
157
                 <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
157
               [% END %]
158
               [% END %]
158
               </select>
159
               </select>
159
             </td> 
160
             </td> 
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-4 / +5 lines)
Lines 1-5 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE ItemTypes %]
3
[% USE KohaDates %]
4
[% USE KohaDates %]
4
[% USE Branches %]
5
[% USE Branches %]
5
[% USE Koha %]
6
[% USE Koha %]
Lines 175-183 fieldset.rows table { clear: none; margin: 0; } Link Here
175
                                        <option value=""></option>
176
                                        <option value=""></option>
176
                                        [% FOREACH type IN typeloop %]
177
                                        [% FOREACH type IN typeloop %]
177
                                            [% IF ( type.selected ) %]
178
                                            [% IF ( type.selected ) %]
178
                                                <option value="[% type.code | html %]" selected="selected">[% type.value | html %]</option>
179
                                                <option value="[% type.code | html %]" selected="selected">[% ItemTypes.t(type.value) | html %]</option>
179
                                            [% ELSE %]
180
                                            [% ELSE %]
180
                                                <option value="[% type.code | html %]">[% type.value | html %]</option>
181
                                                <option value="[% type.code | html %]">[% ItemTypes.t(type.value) | html %]</option>
181
                                            [% END %]
182
                                            [% END %]
182
                                        [% END %]
183
                                        [% END %]
183
                                    </select>
184
                                    </select>
Lines 189-197 fieldset.rows table { clear: none; margin: 0; } Link Here
189
                                            <option value=""></option>
190
                                            <option value=""></option>
190
                                        [% FOREACH previous IN previoustypeloop %]
191
                                        [% FOREACH previous IN previoustypeloop %]
191
                                            [% IF ( previous.selected ) %]
192
                                            [% IF ( previous.selected ) %]
192
                                                <option value="[% previous.code | html %]" selected="selected">[% previous.value | html %]</option>
193
                                                <option value="[% previous.code | html %]" selected="selected">[% ItemTypes.t(previous.value) | html %]</option>
193
                                            [% ELSE %]
194
                                            [% ELSE %]
194
                                                <option value="[% previous.code | html %]">[% previous.value | html %]</option>
195
                                                <option value="[% previous.code | html %]">[% ItemTypes.t(previous.value) | html %]</option>
195
                                            [% END %]
196
                                            [% END %]
196
                                        [% END %]
197
                                        [% END %]
197
                                    </select>
198
                                    </select>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-batchedit.tt (-1 / +1 lines)
Lines 111-117 Link Here
111
                                    <select id="itemtype" name="itemtype">
111
                                    <select id="itemtype" name="itemtype">
112
                                        <option value="">No change</option>
112
                                        <option value="">No change</option>
113
                                        [% FOREACH itemtype IN ItemTypes.Get() %]
113
                                        [% FOREACH itemtype IN ItemTypes.Get() %]
114
                                            <option value="[% itemtype.itemtype | html %]">[% itemtype.description | html %]</option>
114
                                            <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
115
                                        [% END %]
115
                                        [% END %]
116
                                    </select>
116
                                    </select>
117
                                </li>
117
                                </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>Koha &rsaquo; Serials &rsaquo; Catalog search</title>
3
<title>Koha &rsaquo; Serials &rsaquo; Catalog search</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>Koha &rsaquo; Tools &rsaquo; Export data</title>
7
<title>Koha &rsaquo; Tools &rsaquo; Export data</title>
Lines 66-72 Link Here
66
            <select name="itemtype" id="itemtype">
67
            <select name="itemtype" id="itemtype">
67
                <option value="">-- All --</option>
68
                <option value="">-- All --</option>
68
                [% FOREACH itemtype IN itemtypes %]
69
                [% FOREACH itemtype IN itemtypes %]
69
                    <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
70
                    <option value="[% itemtype.itemtype | html %]">[% ItemTypes.t(itemtype.description) | html %]</option>
70
                [% END %]
71
                [% END %]
71
            </select>
72
            </select>
72
        </li>
73
        </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 PRIVATE = 1 %]
6
[% SET PRIVATE = 1 %]
Lines 203-209 Link Here
203
                </td>
204
                </td>
204
            [% END %]
205
            [% END %]
205
			[% UNLESS ( item_level_itypes ) %]<td>
206
			[% UNLESS ( item_level_itypes ) %]<td>
206
                [% UNLESS ( noItemTypeImages || !itemsloo.imageurl ) %]<img src="[% itemsloo.imageurl | html %]" alt="[% itemsloo.description | html %]" title="[% itemsloo.description | html %]" />[% END %][% itemsloo.description | html %]
207
                [% 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 %]
207
			</td>[% END %]
208
			</td>[% END %]
208
			<td>
209
			<td>
209
                [% IF ( itemsloo.XSLTBloc ) %]
210
                [% 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
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
Lines 172-178 Link Here
172
                                                    [% END %]
173
                                                    [% END %]
173
                                                [% END %]
174
                                                [% END %]
174
                                                <span class="tdlabel">Item type:</span>
175
                                                <span class="tdlabel">Item type:</span>
175
                                                [% issue.translated_description | html %]</td>
176
                                                [% ItemTypes.t(issue.description) | html %]</td>
176
                                                <td>
177
                                                <td>
177
                                                <span class="tdlabel">Call number:</span>
178
                                                <span class="tdlabel">Call number:</span>
178
                                                [% issue.itemcallnumber | html %]
179
                                                [% issue.itemcallnumber | html %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-2 / +2 lines)
Lines 214-220 Link Here
214
                                                <li class="itype">
214
                                                <li class="itype">
215
                                                    <span class="label">Item type: </span>
215
                                                    <span class="label">Item type: </span>
216
                                                    [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl | html %]" alt="" />[% END %]
216
                                                    [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl | html %]" alt="" />[% END %]
217
                                                    [% bibitemloo.translated_description | html %]
217
                                                    [% ItemTypes.t(bibitemloo.description) | html %]
218
                                                </li>
218
                                                </li>
219
                                            [% END %]
219
                                            [% END %]
220
220
Lines 380-386 Link Here
380
                                                                            <img src="[% itemLoo.imageurl | html %]" alt="" />
380
                                                                            <img src="[% itemLoo.imageurl | html %]" alt="" />
381
                                                                        [% END %]
381
                                                                        [% END %]
382
                                                                    [% END %]
382
                                                                    [% END %]
383
                                                                    [% itemLoo.translated_description | html %]
383
                                                                    [% ItemTypes.t(itemLoo.description) | html %]
384
                                                                </td>
384
                                                                </td>
385
                                                            [% END %]
385
                                                            [% END %]
386
386
(-)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
[% SET PRIVATE = 1 %]
5
[% SET PRIVATE = 1 %]
5
[% SET PUBLIC = 2 %]
6
[% SET PUBLIC = 2 %]
Lines 315-323 Link Here
315
                                                [% UNLESS ( item_level_itypes ) %]
316
                                                [% UNLESS ( item_level_itypes ) %]
316
                                                    <td>
317
                                                    <td>
317
                                                        [% UNLESS ( noItemTypeImages ) %]
318
                                                        [% UNLESS ( noItemTypeImages ) %]
318
                                                            <img src="[% itemsloo.imageurl | html %]" alt="[% itemsloo.description | html %]" title="[% itemsloo.description | html %]" />
319
                                                            <img src="[% itemsloo.imageurl | html %]" alt="[% ItemTypes.t(itemsloo.description) | html %]" title="[% ItemTypes.t(itemsloo.description) | html %]" />
319
                                                        [% END %]
320
                                                        [% END %]
320
                                                        [% itemsloo.description | html %]
321
                                                        [% ItemTypes.t(itemsloo.description) | html %]
321
                                                    </td>
322
                                                    </td>
322
                                                [% END %]
323
                                                [% END %]
323
                                                <td>
324
                                                <td>
(-)a/labels/label-item-search.pl (-13 lines)
Lines 231-250 else { Link Here
231
            debug           => 1,
231
            debug           => 1,
232
        }
232
        }
233
    );
233
    );
234
    my $itemtypes = Koha::ItemTypes->search;
235
    my @itemtypeloop;
236
    while ( my $itemtype = $itemtypes->next ) {
237
        # FIXME This must be improved:
238
        # - pass the iterator to the template
239
        # - display the translated_description
240
        my %row = (
241
            value       => $itemtype->itemtype,
242
            description => $itemtype->description,
243
        );
244
        push @itemtypeloop, \%row;
245
    }
246
    $template->param(
234
    $template->param(
247
        itemtypeloop => \@itemtypeloop,
248
        batch_id     => $batch_id,
235
        batch_id     => $batch_id,
249
        type         => $type,
236
        type         => $type,
250
    );
237
    );
(-)a/opac/opac-detail.pl (-4 / +5 lines)
Lines 54-59 use Koha::Biblios; Link Here
54
use Koha::RecordProcessor;
54
use Koha::RecordProcessor;
55
use Koha::AuthorisedValues;
55
use Koha::AuthorisedValues;
56
use Koha::CirculationRules;
56
use Koha::CirculationRules;
57
use Koha::I18N;
57
use Koha::Items;
58
use Koha::Items;
58
use Koha::ItemTypes;
59
use Koha::ItemTypes;
59
use Koha::Acquisition::Orders;
60
use Koha::Acquisition::Orders;
Lines 220-226 if ($session->param('busc')) { Link Here
220
    {
221
    {
221
        my ($arrParamsBusc, $offset, $results_per_page) = @_;
222
        my ($arrParamsBusc, $offset, $results_per_page) = @_;
222
223
223
        my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
224
        my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
224
        my @servers;
225
        my @servers;
225
        @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
226
        @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
226
        @servers = ("biblioserver") unless (@servers);
227
        @servers = ("biblioserver") unless (@servers);
Lines 557-568 my $HideMARC = $record_processor->filters->[0]->should_hide_marc( Link Here
557
        interface     => 'opac',
558
        interface     => 'opac',
558
    } );
559
    } );
559
560
560
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
561
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
561
# imageurl:
562
# imageurl:
562
my $itemtype = $dat->{'itemtype'};
563
my $itemtype = $dat->{'itemtype'};
563
if ( $itemtype ) {
564
if ( $itemtype ) {
564
    $dat->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
565
    $dat->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
565
    $dat->{'description'} = $itemtypes->{$itemtype}->{translated_description};
566
    $dat->{'description'} = db_t('itemtype', $itemtypes->{$itemtype}->{description});
566
}
567
}
567
568
568
my $shelflocations =
569
my $shelflocations =
Lines 696-702 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
696
    }
697
    }
697
    if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
698
    if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
698
        $itm->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
699
        $itm->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
699
        $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{translated_description};
700
        $itm->{'description'} = db_t('itemtype', $itemtypes->{ $itm->{itype} }->{description});
700
    }
701
    }
701
    foreach (qw(ccode enumchron copynumber itemnotes location_description uri)) {
702
    foreach (qw(ccode enumchron copynumber itemnotes location_description uri)) {
702
        $itemfields{$_} = 1 if ($itm->{$_});
703
        $itemfields{$_} = 1 if ($itm->{$_});
(-)a/opac/opac-readingrecord.pl (-3 / +2 lines)
Lines 58-64 my $borr = Koha::Patrons->find( $borrowernumber )->unblessed; Link Here
58
58
59
$template->param(%{$borr});
59
$template->param(%{$borr});
60
60
61
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
61
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
62
62
63
# get the record
63
# get the record
64
my $order = $query->param('order') || '';
64
my $order = $query->param('order') || '';
Lines 87-94 my $opac_summary_html = C4::Context->preference('OPACMySummaryHTML'); Link Here
87
foreach my $issue ( @{$issues} ) {
87
foreach my $issue ( @{$issues} ) {
88
    $issue->{normalized_isbn} = GetNormalizedISBN( $issue->{isbn} );
88
    $issue->{normalized_isbn} = GetNormalizedISBN( $issue->{isbn} );
89
    if ( $issue->{$itype_attribute} ) {
89
    if ( $issue->{$itype_attribute} ) {
90
        $issue->{translated_description} =
90
        $issue->{description} = $itemtypes->{ $issue->{$itype_attribute} }->{description};
91
          $itemtypes->{ $issue->{$itype_attribute} }->{translated_description};
92
        $issue->{imageurl} =
91
        $issue->{imageurl} =
93
          getitemtypeimagelocation( 'opac',
92
          getitemtypeimagelocation( 'opac',
94
            $itemtypes->{ $issue->{$itype_attribute} }->{imageurl} );
93
            $itemtypes->{ $issue->{$itype_attribute} }->{imageurl} );
(-)a/opac/opac-reserve.pl (-4 / +4 lines)
Lines 100-106 if ( $reservefee > 0){ Link Here
100
    $template->param( RESERVE_CHARGE => $reservefee);
100
    $template->param( RESERVE_CHARGE => $reservefee);
101
}
101
}
102
102
103
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
103
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
104
104
105
# There are two ways of calling this script, with a single biblio num
105
# There are two ways of calling this script, with a single biblio num
106
# or multiple biblio nums.
106
# or multiple biblio nums.
Lines 444-456 foreach my $biblioNum (@biblionumbers) { Link Here
444
    $biblioLoopIter{reqholdnotes}=0; #TODO: For future use
444
    $biblioLoopIter{reqholdnotes}=0; #TODO: For future use
445
445
446
    if (!$itemLevelTypes && $biblioData->{itemtype}) {
446
    if (!$itemLevelTypes && $biblioData->{itemtype}) {
447
        $biblioLoopIter{translated_description} = $itemtypes->{$biblioData->{itemtype}}{translated_description};
447
        $biblioLoopIter{description} = $itemtypes->{$biblioData->{itemtype}}{description};
448
        $biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$biblioData->{itemtype}}{imageurl};
448
        $biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$biblioData->{itemtype}}{imageurl};
449
    }
449
    }
450
450
451
    foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
451
    foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
452
        if ($itemLevelTypes && $itemInfo->{itype}) {
452
        if ($itemLevelTypes && $itemInfo->{itype}) {
453
            $itemInfo->{translated_description} = $itemtypes->{$itemInfo->{itype}}{translated_description};
453
            $itemInfo->{description} = $itemtypes->{$itemInfo->{itype}}{description};
454
            $itemInfo->{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$itemInfo->{itype}}{imageurl};
454
            $itemInfo->{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$itemInfo->{itype}}{imageurl};
455
        }
455
        }
456
456
Lines 478-484 foreach my $biblioNum (@biblionumbers) { Link Here
478
        $itemLoopIter->{ccode} = $itemInfo->{ccode};
478
        $itemLoopIter->{ccode} = $itemInfo->{ccode};
479
        $itemLoopIter->{copynumber} = $itemInfo->{copynumber};
479
        $itemLoopIter->{copynumber} = $itemInfo->{copynumber};
480
        if ($itemLevelTypes) {
480
        if ($itemLevelTypes) {
481
            $itemLoopIter->{translated_description} = $itemInfo->{translated_description};
481
            $itemLoopIter->{description} = $itemInfo->{description};
482
            $itemLoopIter->{itype} = $itemInfo->{itype};
482
            $itemLoopIter->{itype} = $itemInfo->{itype};
483
            $itemLoopIter->{imageurl} = $itemInfo->{imageurl};
483
            $itemLoopIter->{imageurl} = $itemInfo->{imageurl};
484
        }
484
        }
(-)a/opac/opac-search.pl (-7 / +7 lines)
Lines 55-60 use C4::External::BakerTaylor qw( image_url link_url ); Link Here
55
55
56
use Koha::CirculationRules;
56
use Koha::CirculationRules;
57
use Koha::Libraries;
57
use Koha::Libraries;
58
use Koha::I18N;
58
use Koha::ItemTypes;
59
use Koha::ItemTypes;
59
use Koha::Ratings;
60
use Koha::Ratings;
60
use Koha::Virtualshelves;
61
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 254-260 if ( $yaml =~ /\S/ ) { Link Here
254
    }
254
    }
255
}
255
}
256
256
257
my @sorted_itemtypes = sort { $itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description} } keys %$itemtypes;
257
my @sorted_itemtypes = sort { $itemtypes->{$a}->{description} cmp $itemtypes->{$b}->{description} } keys %$itemtypes;
258
foreach my $advanced_srch_type (@advanced_search_types) {
258
foreach my $advanced_srch_type (@advanced_search_types) {
259
    $advanced_srch_type =~ s/^\s*//;
259
    $advanced_srch_type =~ s/^\s*//;
260
    $advanced_srch_type =~ s/\s*$//;
260
    $advanced_srch_type =~ s/\s*$//;
Lines 267-273 foreach my $advanced_srch_type (@advanced_search_types) { Link Here
267
	    my %row =(  number=>$cnt++,
267
	    my %row =(  number=>$cnt++,
268
		ccl => "$itype_or_itemtype,phr",
268
		ccl => "$itype_or_itemtype,phr",
269
                code => $thisitemtype,
269
                code => $thisitemtype,
270
                description => $itemtypes->{$thisitemtype}->{translated_description},
270
                description => $itemtypes->{$thisitemtype}->{description},
271
                imageurl=> getitemtypeimagelocation( 'opac', $itemtypes->{$thisitemtype}->{'imageurl'} ),
271
                imageurl=> getitemtypeimagelocation( 'opac', $itemtypes->{$thisitemtype}->{'imageurl'} ),
272
                cat => $itemtypes->{$thisitemtype}->{'iscat'},
272
                cat => $itemtypes->{$thisitemtype}->{'iscat'},
273
                hideinopac => $itemtypes->{$thisitemtype}->{'hideinopac'},
273
                hideinopac => $itemtypes->{$thisitemtype}->{'hideinopac'},
Lines 628-634 if ($tag) { Link Here
628
    $pasarParams .= '&amp;count=' . uri_escape_utf8($results_per_page);
628
    $pasarParams .= '&amp;count=' . uri_escape_utf8($results_per_page);
629
    $pasarParams .= '&amp;simple_query=' . uri_escape_utf8($simple_query);
629
    $pasarParams .= '&amp;simple_query=' . uri_escape_utf8($simple_query);
630
    $pasarParams .= '&amp;query_type=' . uri_escape_utf8($query_type) if ($query_type);
630
    $pasarParams .= '&amp;query_type=' . uri_escape_utf8($query_type) if ($query_type);
631
    my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
631
    my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
632
    eval {
632
    eval {
633
        ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes_nocategory,$query_type,$scan,1);
633
        ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes_nocategory,$query_type,$scan,1);
634
};
634
};
(-)a/opac/opac-shelves.pl (-1 / +1 lines)
Lines 326-332 if ( $op eq 'view' ) { Link Here
326
                $itemtype = Koha::ItemTypes->find( $itemtype );
326
                $itemtype = Koha::ItemTypes->find( $itemtype );
327
                if( $itemtype ) {
327
                if( $itemtype ) {
328
                    $this_item->{imageurl}          = C4::Koha::getitemtypeimagelocation( 'opac', $itemtype->imageurl );
328
                    $this_item->{imageurl}          = C4::Koha::getitemtypeimagelocation( 'opac', $itemtype->imageurl );
329
                    $this_item->{description}       = $itemtype->description; #FIXME Should not it be translated_description?
329
                    $this_item->{description}       = $itemtype->description;
330
                    $this_item->{notforloan}        = $itemtype->notforloan;
330
                    $this_item->{notforloan}        = $itemtype->notforloan;
331
                }
331
                }
332
                $this_item->{'coins'}           = $biblio->get_coins;
332
                $this_item->{'coins'}           = $biblio->get_coins;
(-)a/opac/opac-user.pl (-1 / +1 lines)
Lines 172-178 my $count = 0; Link Here
172
my $overdues_count = 0;
172
my $overdues_count = 0;
173
my @overdues;
173
my @overdues;
174
my @issuedat;
174
my @issuedat;
175
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
175
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
176
my $pending_checkouts = $patron->pending_checkouts->search({}, { order_by => [ { -desc => 'date_due' }, { -asc => 'issue_id' } ] });
176
my $pending_checkouts = $patron->pending_checkouts->search({}, { order_by => [ { -desc => 'date_due' }, { -asc => 'issue_id' } ] });
177
if ( $pending_checkouts->count ) { # Useless test
177
if ( $pending_checkouts->count ) { # Useless test
178
    while ( my $c = $pending_checkouts->next ) {
178
    while ( my $c = $pending_checkouts->next ) {
(-)a/reports/acquisitions_stats.pl (-1 / +1 lines)
Lines 194-200 else { Link Here
194
        $ccode_avlist = GetAuthorisedValues($ccode_subfield_structure->{authorised_value});
194
        $ccode_avlist = GetAuthorisedValues($ccode_subfield_structure->{authorised_value});
195
    }
195
    }
196
196
197
    my $itemtypes = Koha::ItemTypes->search_with_localization;
197
    my $itemtypes = Koha::ItemTypes->search;
198
    $template->param(
198
    $template->param(
199
        booksellers   => $booksellers,
199
        booksellers   => $booksellers,
200
        itemtypes     => $itemtypes, # FIXME Should use the TT plugin instead
200
        itemtypes     => $itemtypes, # FIXME Should use the TT plugin instead
(-)a/reports/bor_issues_top.pl (-1 / +1 lines)
Lines 111-117 my @mime = ( map { {type =>$_} } (split /[;:]/, 'CSV') ); # FIXME translation Link Here
111
my $delims = GetDelimiterChoices;
111
my $delims = GetDelimiterChoices;
112
112
113
my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['categorycode']});
113
my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['categorycode']});
114
my $itemtypes = Koha::ItemTypes->search_with_localization;
114
my $itemtypes = Koha::ItemTypes->search;
115
$template->param(
115
$template->param(
116
	    mimeloop => \@mime,
116
	    mimeloop => \@mime,
117
	  CGIseplist => $delims,
117
	  CGIseplist => $delims,
(-)a/reports/cat_issues_top.pl (-1 / +1 lines)
Lines 107-113 if ($do_it) { Link Here
107
    my $CGIsepChoice=GetDelimiterChoices;
107
    my $CGIsepChoice=GetDelimiterChoices;
108
108
109
    #doctype
109
    #doctype
110
    my $itemtypes = Koha::ItemTypes->search_with_localization;
110
    my $itemtypes = Koha::ItemTypes->search;
111
111
112
    #ccode
112
    #ccode
113
    my $ccodes = GetAuthorisedValues('CCODE');
113
    my $ccodes = GetAuthorisedValues('CCODE');
(-)a/reports/catalogue_out.pl (-1 / +1 lines)
Lines 58-64 if ($do_it) { Link Here
58
    exit;    # in either case, exit after do_it
58
    exit;    # in either case, exit after do_it
59
}
59
}
60
60
61
my $itemtypes = Koha::ItemTypes->search_with_localization;
61
my $itemtypes = Koha::ItemTypes->search;
62
$template->param(
62
$template->param(
63
    itemtypes => $itemtypes,
63
    itemtypes => $itemtypes,
64
);
64
);
(-)a/reports/catalogue_stats.pl (-1 / +1 lines)
Lines 120-126 if ($do_it) { Link Here
120
	my $req;
120
	my $req;
121
	my @select;
121
	my @select;
122
122
123
    my $itemtypes = Koha::ItemTypes->search_with_localization;
123
    my $itemtypes = Koha::ItemTypes->search;
124
124
125
    my @authvals = map { { code => $_->{authorised_value}, description => $_->{lib} } } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } );
125
    my @authvals = map { { code => $_->{authorised_value}, description => $_->{lib} } } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } );
126
    my @locations = map { { code => $_->{authorised_value}, description => $_->{lib} } } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } );
126
    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 120-126 if ($do_it) { Link Here
120
} else {
120
} else {
121
    my $patron_categories = Koha::Patron::Categories->search({}, {order_by => ['description']});
121
    my $patron_categories = Koha::Patron::Categories->search({}, {order_by => ['description']});
122
122
123
    my $itemtypes = Koha::ItemTypes->search_with_localization;
123
    my $itemtypes = Koha::ItemTypes->search;
124
124
125
    my $dbh = C4::Context->dbh;
125
    my $dbh = C4::Context->dbh;
126
    my $req = $dbh->prepare("select distinctrow sort1 from borrowers where sort1 is not null order by sort1");
126
    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 33-38 use C4::Members; Link Here
33
33
34
use Koha::AuthorisedValues;
34
use Koha::AuthorisedValues;
35
use Koha::DateUtils;
35
use Koha::DateUtils;
36
use Koha::I18N;
36
use Koha::ItemTypes;
37
use Koha::ItemTypes;
37
use Koha::Patron::Attribute::Types;
38
use Koha::Patron::Attribute::Types;
38
39
Lines 87-93 $sep = "\t" if ($sep eq 'tabulation'); Link Here
87
$template->param(do_it => $do_it,
88
$template->param(do_it => $do_it,
88
);
89
);
89
90
90
our $itemtypes = Koha::ItemTypes->search_with_localization->unblessed;
91
our $itemtypes = Koha::ItemTypes->search->unblessed;
91
92
92
our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
93
our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
93
94
Lines 361-367 sub calculate { Link Here
361
        $cell{rowtitle_display} =
362
        $cell{rowtitle_display} =
362
            ( $line =~ /ccode/ )    ? $ccodes->{$celvalue}
363
            ( $line =~ /ccode/ )    ? $ccodes->{$celvalue}
363
          : ( $line =~ /location/ ) ? $locations->{$celvalue}
364
          : ( $line =~ /location/ ) ? $locations->{$celvalue}
364
          : ( $line =~ /itemtype/ ) ? $itemtypes_map->{$celvalue}->{translated_description}
365
          : ( $line =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{description})
365
          :                           $celvalue;                               # default fallback
366
          :                           $celvalue;                               # default fallback
366
        if ( $line =~ /sort1/ ) {
367
        if ( $line =~ /sort1/ ) {
367
            foreach (@$Bsort1) {
368
            foreach (@$Bsort1) {
Lines 450-456 sub calculate { Link Here
450
        $cell{coltitle_display} =
451
        $cell{coltitle_display} =
451
            ( $column =~ /ccode/ )    ? $ccodes->{$celvalue}
452
            ( $column =~ /ccode/ )    ? $ccodes->{$celvalue}
452
          : ( $column =~ /location/ ) ? $locations->{$celvalue}
453
          : ( $column =~ /location/ ) ? $locations->{$celvalue}
453
          : ( $column =~ /itemtype/ ) ? $itemtypes_map->{$celvalue}->{translated_description}
454
          : ( $column =~ /itemtype/ ) ? db_t('itemtype', $itemtypes_map->{$celvalue}->{description});
454
          :                             $celvalue;                               # default fallback
455
          :                             $celvalue;                               # default fallback
455
        if ( $column =~ /sort1/ ) {
456
        if ( $column =~ /sort1/ ) {
456
            foreach (@$Bsort1) {
457
            foreach (@$Bsort1) {
(-)a/reports/itemslost.pl (-1 / +1 lines)
Lines 150-156 if ( $op eq 'export' ) { Link Here
150
}
150
}
151
151
152
# getting all itemtypes
152
# getting all itemtypes
153
my $itemtypes = Koha::ItemTypes->search_with_localization;
153
my $itemtypes = Koha::ItemTypes->search;
154
154
155
my $csv_profiles = Koha::CsvProfiles->search({ type => 'sql', used_for => 'export_lost_items' });
155
my $csv_profiles = Koha::CsvProfiles->search({ type => 'sql', used_for => 'export_lost_items' });
156
156
(-)a/reports/reserves_stats.pl (-2 / +3 lines)
Lines 30-35 use C4::Reports; Link Here
30
use C4::Members;
30
use C4::Members;
31
use Koha::AuthorisedValues;
31
use Koha::AuthorisedValues;
32
use Koha::DateUtils;
32
use Koha::DateUtils;
33
use Koha::I18N;
33
use Koha::ItemTypes;
34
use Koha::ItemTypes;
34
use Koha::Libraries;
35
use Koha::Libraries;
35
use Koha::Patron::Categories;
36
use Koha::Patron::Categories;
Lines 130-136 my @values; Link Here
130
my %labels;
131
my %labels;
131
my %select;
132
my %select;
132
133
133
my $itemtypes = Koha::ItemTypes->search_with_localization;
134
my $itemtypes = Koha::ItemTypes->search;
134
135
135
    # location list
136
    # location list
136
my @locations;
137
my @locations;
Lines 320-326 sub display_value { Link Here
320
    my $display_value =
321
    my $display_value =
321
        ( $crit =~ /ccode/ )         ? $ccodes->{$value}
322
        ( $crit =~ /ccode/ )         ? $ccodes->{$value}
322
      : ( $crit =~ /location/ )      ? $locations->{$value}
323
      : ( $crit =~ /location/ )      ? $locations->{$value}
323
      : ( $crit =~ /itemtype/ )      ? Koha::ItemTypes->find( $value )->translated_description
324
      : ( $crit =~ /itemtype/ )      ? db_t('itemtype', Koha::ItemTypes->find( $value )->description)
324
      : ( $crit =~ /branch/ )        ? Koha::Libraries->find($value)->branchname
325
      : ( $crit =~ /branch/ )        ? Koha::Libraries->find($value)->branchname
325
      : ( $crit =~ /reservestatus/ ) ? reservestatushuman($value)
326
      : ( $crit =~ /reservestatus/ ) ? reservestatushuman($value)
326
      :                                $value;    # default fallback
327
      :                                $value;    # default fallback
(-)a/reserve/request.pl (-1 / +1 lines)
Lines 70-76 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( Link Here
70
my $showallitems = $input->param('showallitems');
70
my $showallitems = $input->param('showallitems');
71
my $pickup = $input->param('pickup') || C4::Context->userenv->{'branch'};
71
my $pickup = $input->param('pickup') || C4::Context->userenv->{'branch'};
72
72
73
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
73
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
74
74
75
# Select borrowers infos
75
# Select borrowers infos
76
my $findborrower = $input->param('findborrower');
76
my $findborrower = $input->param('findborrower');
(-)a/serials/subscription-add.pl (-2 / +1 lines)
Lines 158-166 $template->param( Link Here
158
    additional_field_values => \%additional_field_values,
158
    additional_field_values => \%additional_field_values,
159
);
159
);
160
160
161
my $typeloop = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
161
my $typeloop = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
162
162
163
# FIXME We should use the translated_description for item types
164
my @typearg =
163
my @typearg =
165
    map { { code => $_, value => $typeloop->{$_}{'description'}, selected => ( ( $subs->{itemtype} and $_ eq $subs->{itemtype} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$typeloop};
164
    map { { code => $_, value => $typeloop->{$_}{'description'}, selected => ( ( $subs->{itemtype} and $_ eq $subs->{itemtype} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$typeloop};
166
my @previoustypearg =
165
my @previoustypearg =
(-)a/serials/subscription-bib-search.pl (-2 / +1 lines)
Lines 199-208 else { Link Here
199
    );
199
    );
200
200
201
    # load the itemtypes
201
    # load the itemtypes
202
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
202
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
203
    my @itemtypesloop;
203
    my @itemtypesloop;
204
    # FIXME This is uselessly complex, the iterator should be send to the template
204
    # FIXME This is uselessly complex, the iterator should be send to the template
205
    # FIXME The translated_description should be used
206
    foreach my $thisitemtype (
205
    foreach my $thisitemtype (
207
        sort {
206
        sort {
208
            $itemtypes->{$a}->{'description'}
207
            $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 (-3 / +4 lines)
Lines 29-34 use C4::Context; Link Here
29
29
30
use Koha::AuthorisedValues;
30
use Koha::AuthorisedValues;
31
use Koha::DateUtils;
31
use Koha::DateUtils;
32
use Koha::I18N;
32
use Koha::ItemTypes;
33
use Koha::ItemTypes;
33
34
34
my $input = new CGI;
35
my $input = new CGI;
Lines 196-204 while ( my $c = $sth->fetchrow_hashref() ) { Link Here
196
        part_name            => $c->{part_name} // '',
197
        part_name            => $c->{part_name} // '',
197
        author               => $c->{author},
198
        author               => $c->{author},
198
        barcode              => $c->{barcode},
199
        barcode              => $c->{barcode},
199
        type_for_stat        => $type_for_stat ? $type_for_stat->translated_description : q{},
200
        type_for_stat        => $type_for_stat ? db_t('itemtype', $type_for_stat->description) : q{},
200
        itemtype_description => $itemtype ? $itemtype->translated_description : q{},
201
        itemtype_description => $itemtype ? db_t('itemtype', $itemtype->description) : q{},
201
        recordtype_description => $recordtype ? $recordtype->translated_description : q{},
202
        recordtype_description => $recordtype ? db_t('itemtype', $recordtype->description) : q{},
202
        collection           => $collection,
203
        collection           => $collection,
203
        location             => $location,
204
        location             => $location,
204
        homebranch           => $c->{homebranch},
205
        homebranch           => $c->{homebranch},
(-)a/svc/holds (-1 / +2 lines)
Lines 29-34 use C4::Context; Link Here
29
29
30
use Koha::DateUtils;
30
use Koha::DateUtils;
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 76-82 while ( my $h = $holds_rs->next() ) { Link Here
76
    my $itemtype_limit;
77
    my $itemtype_limit;
77
    if ( $h->itemtype ) {
78
    if ( $h->itemtype ) {
78
        my $itemtype = Koha::ItemTypes->find( $h->itemtype );
79
        my $itemtype = Koha::ItemTypes->find( $h->itemtype );
79
        $itemtype_limit = $itemtype->translated_description;
80
        $itemtype_limit = db_t('itemtype', $itemtype->description);
80
    }
81
    }
81
82
82
    my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;
83
    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/svc/split_callnumbers (-72 lines)
Lines 20-97 sub get_split_callnumbers { Link Here
20
    C4::Service->return_success( $response );
20
    C4::Service->return_success( $response );
21
}
21
}
22
22
23
sub update_translation {
24
    my $id = $query->param('id');
25
    my $translation = $query->param('translation');
26
    my $lang = $query->param('lang');
27
28
    my $localization = Koha::Localizations->find( $id );
29
    if ( defined $lang and $localization->lang ne $lang ) {
30
        $localization->lang( $lang )
31
    }
32
    if ( defined $translation and $localization->translation ne $translation ) {
33
        $localization->translation( $translation )
34
    }
35
    my %params;
36
    my $is_changed;
37
    if ( $localization->is_changed ) {
38
        $is_changed = 1;
39
        unless ( Koha::Localizations->search( { entity => $localization->entity, code => $localization->code, lang => $lang, localization_id => { '!=' => $localization->localization_id }, } )->count ) {
40
            $localization->store;
41
        } else {
42
            $params{error} = 1;
43
            $params{error_code} = 'already_exists';
44
        }
45
    }
46
    $response->param(
47
        %params,
48
        id          => $localization->localization_id,
49
        entity      => $localization->entity,
50
        code        => $localization->code,
51
        lang        => $localization->lang,
52
        translation => $localization->translation,
53
        is_changed  => $is_changed,
54
    );
55
    C4::Service->return_success( $response );
56
}
57
58
sub add_translation {
59
    my $entity = $query->param('entity');
60
    my $code = $query->param('code');
61
    my $lang = $query->param('lang');
62
    my $translation = $query->param('translation');
63
64
    unless ( Koha::Localizations->search({entity => $entity, code => $code, lang => $lang, })->count ) {
65
        my $localization = Koha::Localization->new(
66
            {
67
                entity => $entity,
68
                code => $code,
69
                lang => $lang,
70
                translation => $translation,
71
            }
72
        );
73
        $localization->store;
74
        $response->param(
75
            id          => $localization->localization_id,
76
            entity      => $localization->entity,
77
            code        => $localization->code,
78
            lang        => $localization->lang,
79
            translation => $localization->translation,
80
        );
81
82
    } else {
83
        $response->param( error => 1, error_code => 'already_exists', );
84
    }
85
    C4::Service->return_success( $response );
86
}
87
88
sub delete_translation {
89
    my $id = $query->param('id');
90
    Koha::Localizations->find($id)->delete;
91
    $response->param( id => $id );
92
    C4::Service->return_success( $response );
93
}
94
95
C4::Service->dispatch(
23
C4::Service->dispatch(
96
    [ 'GET /', [ 'callnumbers', 'regexs' ], \&get_split_callnumbers ],
24
    [ 'GET /', [ 'callnumbers', 'regexs' ], \&get_split_callnumbers ],
97
);
25
);
(-)a/t/db_dependent/Koha/ItemTypes.t (-34 / +1 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Data::Dumper;
22
use Data::Dumper;
23
use Test::More tests => 24;
23
use Test::More tests => 22;
24
24
25
use t::lib::Mocks;
25
use t::lib::Mocks;
26
use t::lib::TestBuilder;
26
use t::lib::TestBuilder;
Lines 84-114 Koha::ItemType->new( Link Here
84
    }
84
    }
85
)->store;
85
)->store;
86
86
87
Koha::Localization->new(
88
    {
89
        entity      => 'itemtypes',
90
        code        => 'type1',
91
        lang        => 'en',
92
        translation => 'b translated itemtype desc'
93
    }
94
)->store;
95
Koha::Localization->new(
96
    {
97
        entity      => 'itemtypes',
98
        code        => 'type2',
99
        lang        => 'en',
100
        translation => 'a translated itemtype desc'
101
    }
102
)->store;
103
Koha::Localization->new(
104
    {
105
        entity      => 'something_else',
106
        code        => 'type2',
107
        lang        => 'en',
108
        translation => 'another thing'
109
    }
110
)->store;
111
112
my $type = Koha::ItemTypes->find('type1');
87
my $type = Koha::ItemTypes->find('type1');
113
ok( defined($type), 'first result' );
88
ok( defined($type), 'first result' );
114
is( $type->itemtype,       'type1',          'itemtype/code' );
89
is( $type->itemtype,       'type1',          'itemtype/code' );
Lines 131-144 is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' ); Link Here
131
106
132
t::lib::Mocks::mock_preference('language', 'en');
107
t::lib::Mocks::mock_preference('language', 'en');
133
t::lib::Mocks::mock_preference('opaclanguages', 'en');
108
t::lib::Mocks::mock_preference('opaclanguages', 'en');
134
my $itemtypes = Koha::ItemTypes->search_with_localization;
135
is( $itemtypes->count, 3, 'There are 3 item types' );
136
my $first_itemtype = $itemtypes->next;
137
is(
138
    $first_itemtype->translated_description,
139
    'a translated itemtype desc',
140
    'item types should be sorted by translated description'
141
);
142
109
143
my $builder = t::lib::TestBuilder->new;
110
my $builder = t::lib::TestBuilder->new;
144
my $item_type = $builder->build_object({ class => 'Koha::ItemTypes' });
111
my $item_type = $builder->build_object({ class => 'Koha::ItemTypes' });
(-)a/tools/batchMod.pl (-2 / +3 lines)
Lines 37-42 use List::MoreUtils qw/uniq/; Link Here
37
use Koha::AuthorisedValues;
37
use Koha::AuthorisedValues;
38
use Koha::Biblios;
38
use Koha::Biblios;
39
use Koha::DateUtils;
39
use Koha::DateUtils;
40
use Koha::I18N;
40
use Koha::Items;
41
use Koha::Items;
41
use Koha::ItemTypes;
42
use Koha::ItemTypes;
42
use Koha::Patrons;
43
use Koha::Patrons;
Lines 420-429 foreach my $tag (sort keys %{$tagslib}) { Link Here
420
    }
421
    }
421
    elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
422
    elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
422
        push @authorised_values, "";
423
        push @authorised_values, "";
423
        my $itemtypes = Koha::ItemTypes->search_with_localization;
424
        my $itemtypes = Koha::ItemTypes->search;
424
        while ( my $itemtype = $itemtypes->next ) {
425
        while ( my $itemtype = $itemtypes->next ) {
425
            push @authorised_values, $itemtype->itemtype;
426
            push @authorised_values, $itemtype->itemtype;
426
            $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
427
            $authorised_lib{$itemtype->itemtype} = db_t('itemtype', $itemtype->description);
427
        }
428
        }
428
        $value = "";
429
        $value = "";
429
430
(-)a/tools/export.pl (-1 / +1 lines)
Lines 271-277 if ( $op eq "export" ) { Link Here
271
271
272
else {
272
else {
273
273
274
    my $itemtypes = Koha::ItemTypes->search_with_localization;
274
    my $itemtypes = Koha::ItemTypes->search;
275
275
276
    my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
276
    my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
277
277
(-)a/virtualshelves/shelves.pl (-2 / +1 lines)
Lines 281-287 if ( $op eq 'view' ) { Link Here
281
                $this_item->{author}            = $biblio->author;
281
                $this_item->{author}            = $biblio->author;
282
                $this_item->{dateadded}         = $content->dateadded;
282
                $this_item->{dateadded}         = $content->dateadded;
283
                $this_item->{imageurl}          = $itemtype ? C4::Koha::getitemtypeimagelocation( 'intranet', $itemtype->imageurl ) : q{};
283
                $this_item->{imageurl}          = $itemtype ? C4::Koha::getitemtypeimagelocation( 'intranet', $itemtype->imageurl ) : q{};
284
                $this_item->{description}       = $itemtype ? $itemtype->description : q{}; #FIXME Should this be translated_description ?
284
                $this_item->{description}       = $itemtype ? $itemtype->description : q{};
285
                $this_item->{notforloan}        = $itemtype->notforloan if $itemtype;
285
                $this_item->{notforloan}        = $itemtype->notforloan if $itemtype;
286
                $this_item->{'coins'}           = $biblio->get_coins;
286
                $this_item->{'coins'}           = $biblio->get_coins;
287
                $this_item->{'normalized_upc'}  = GetNormalizedUPC( $record, $marcflavour );
287
                $this_item->{'normalized_upc'}  = GetNormalizedUPC( $record, $marcflavour );
288
- 

Return to bug 24975