use Koha::Database;
use Koha::ItemType;
-use base qw(Koha::Objects);
+use base qw(Koha::Objects Koha::Objects::Limit::Library);
=head1 NAME
=head1 API
-=head2 Class Methods
+=head2 Class methods
=cut
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'];
- $self->SUPER::search( $params, $attributes );
+ $attributes->{'+select'} = [
+ {
+ coalesce => [qw( localization.translation me.description )],
+ -as => 'translated_description'
+ }
+ ];
+ if(defined $params->{branchcode}) {
+ my $branchcode = delete $params->{branchcode};
+ $self->search_with_library_limits( $params, $attributes, $branchcode );
+ } else {
+ $self->SUPER::search( $params, $attributes );
+ }
}
+=head2 Internal methods
+
=head3 type
=cut
return 'Itemtype';
}
+=head3 object_class
+
+=cut
+
sub object_class {
return 'Koha::ItemType';
}