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 );
}
# 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;
<td><input type="radio" name="Column" value="items.itype" /></td>
<td><select name="filter_items.itype" id="itype">
<option value=""> </option>
- [% FOREACH itypeloo IN itemtypeloop %]
- [% IF ( itypeloo.selected ) %]<option value="[% itypeloo.code %]" selected="selected">[% itypeloo.description %]</option>[% ELSE %]<option value="[% itypeloo.code %]">[% itypeloo.description %]</option>[% END %]
+ [% FOREACH itemtype IN itemtypes %]
+ <option value="[% itemtype.itemtype %]">[% itemtype.translated_description %]</option>
[% END %]
</select>
</td>
use C4::Auth; # get_template_and_user
use C4::Output;
use C4::Suggestions;
+use C4::Koha;
use C4::Budgets;
use C4::Search;
use C4::Members;
}
)->store;
+Koha::ItemType->new(
+ {
+ itemtype => 'type3',
+ description => 'description',
+ rentalcharge => '0.00',
+ imageurl => 'imageurl',
+ summary => 'summary',
+ checkinmsg => 'checkinmsg',
+ checkinmsgtype => 'checkinmsgtype',
+ }
+)->store;
+
Koha::Localization->new(
{
entity => 'itemtypes',
is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' );
my $itemtypes = Koha::ItemTypes->search_with_localization;
-is( $itemtypes->count, 2, 'There are 2 item types' );
+is( $itemtypes->count, 3, 'There are 3 item types' );
my $first_itemtype = $itemtypes->next;
is(
$first_itemtype->translated_description,