diff --git a/Koha/ItemTypes.pm b/Koha/ItemTypes.pm index daa808b046..a3786cbab3 100644 --- a/Koha/ItemTypes.pm +++ b/Koha/ItemTypes.pm @@ -46,11 +46,15 @@ sub search_with_localization { my ( $self, $params, $attributes ) = @_; my $language = C4::Languages::getlanguage(); - $params->{'-or'} = { 'localization.lang' => [ $language, undef ] }; - $attributes->{order_by} = 'localization.translation' unless exists $attributes->{order_by}; + $Koha::Schema::Result::Itemtype::LANGUAGE = $language; + $attributes->{order_by} = 'translated_description' unless exists $attributes->{order_by}; $attributes->{join} = 'localization'; - $attributes->{'+select'} = [ { coalesce => [qw( localization.translation me.description )] } ]; - $attributes->{'+as'} = ['translated_description']; + $attributes->{'+select'} = [ + { + coalesce => [qw( localization.translation me.description )], + -as => 'translated_description' + } + ]; $self->SUPER::search( $params, $attributes ); } diff --git a/Koha/Schema/Result/Itemtype.pm b/Koha/Schema/Result/Itemtype.pm index 5af2466e1c..959f8a3956 100644 --- a/Koha/Schema/Result/Itemtype.pm +++ b/Koha/Schema/Result/Itemtype.pm @@ -199,11 +199,20 @@ __PACKAGE__->has_many( # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1GiikODklVISOurHX37qjA # Use the ItemtypeLocalization view to create the join on localization +our $LANGUAGE; __PACKAGE__->has_many( - "localization", - "Koha::Schema::Result::ItemtypeLocalization", - { "foreign.code" => "self.itemtype" }, - { cascade_copy => 0, cascade_delete => 0 }, + "localization" => "Koha::Schema::Result::ItemtypeLocalization", + sub { + my $args = shift; + + die "no lang specified!" unless $LANGUAGE; + + return ({ + "$args->{self_alias}.itemtype" => { -ident => "$args->{foreign_alias}.code" }, + "$args->{foreign_alias}.lang" => $LANGUAGE, + }); + + } ); 1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt index ec9fda9b5d..9b6c77d04f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt @@ -223,8 +223,8 @@