Bug 35906: (QA follow-up) Refactor (slightly) to reduce complexity in Koha/Item(s).pm, catalogue/updateitem
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
6380c89ab9
commit
f6f28e2265
|
|
@ -1928,7 +1928,7 @@ Returns the effective bookability of the current item, be that item or itemtype
|
|||
sub effective_bookable {
|
||||
my ($self) = @_;
|
||||
|
||||
return defined( $self->bookable ) ? $self->bookable : $self->itemtype->bookable;
|
||||
return $self->bookable // $self->itemtype->bookable;
|
||||
}
|
||||
|
||||
=head3 orders
|
||||
|
|
|
|||
|
|
@ -197,17 +197,29 @@ Returns a new resultset, containing only those items that are allowed to be book
|
|||
sub filter_by_bookable {
|
||||
my ($self) = @_;
|
||||
|
||||
my @bookable_itemtypes = Koha::ItemTypes->search( { bookable => 1 } )->get_column('itemtype');
|
||||
|
||||
my ( $where, $attr );
|
||||
if ( C4::Context->preference("item-level_itypes") ) {
|
||||
$where = [ { bookable => 1 }, { bookable => undef, itype => { -in => \@bookable_itemtypes } } ];
|
||||
} else {
|
||||
$where = [ { bookable => 1 }, { bookable => undef, 'biblioitem.itemtype' => { -in => \@bookable_itemtypes } } ];
|
||||
$attr = { join => 'biblioitem' };
|
||||
if ( !C4::Context->preference('item-level_itypes') ) {
|
||||
return $self->search(
|
||||
[
|
||||
{ bookable => 1 },
|
||||
{
|
||||
bookable => undef,
|
||||
'biblioitem.itemtype' =>
|
||||
{ -in => [ Koha::ItemTypes->search( { bookable => 1 } )->get_column('itemtype') ] }
|
||||
},
|
||||
],
|
||||
{ join => 'biblioitem' }
|
||||
);
|
||||
}
|
||||
|
||||
return $self->search( $where, $attr );
|
||||
return $self->search(
|
||||
[
|
||||
{ bookable => 1 },
|
||||
{
|
||||
bookable => undef,
|
||||
itype => { -in => [ Koha::ItemTypes->search( { bookable => 1 } )->get_column('itemtype') ] }
|
||||
},
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
=head3 move_to_biblio
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ elsif ( $op eq "cud-set_public_note" ) { # i.e., itemnotes parameter passed from
|
|||
$item->exclude_from_local_holds_priority($exclude_from_local_holds_priority);
|
||||
$messages = "updated_exclude_from_local_holds_priority=$exclude_from_local_holds_priority&";
|
||||
} elsif ( $op eq "cud-set_bookable" && $bookable ne $item_data_hashref->{'bookable'} ) {
|
||||
undef($bookable) if $bookable eq "";
|
||||
undef $bookable if $bookable eq q{};
|
||||
$item->bookable($bookable);
|
||||
} elsif ( $op eq "cud-set_damaged" && $damaged ne $item_data_hashref->{'damaged'}) {
|
||||
$item->damaged($damaged);
|
||||
|
|
|
|||
Loading…
Reference in New Issue