Lines 289-310
returns 1 if the item is safe to delete,
Link Here
|
289 |
sub safe_to_delete { |
289 |
sub safe_to_delete { |
290 |
my ($self) = @_; |
290 |
my ($self) = @_; |
291 |
|
291 |
|
292 |
return Koha::Result::Boolean->new(0)->add_message({ message => "book_on_loan" }) |
292 |
my $error; |
293 |
if $self->checkout; |
|
|
294 |
|
293 |
|
295 |
return Koha::Result::Boolean->new(0)->add_message({ message => "not_same_branch" }) |
294 |
$error = "book_on_loan" if $self->checkout; |
|
|
295 |
|
296 |
$error //= "not_same_branch" |
296 |
if defined C4::Context->userenv |
297 |
if defined C4::Context->userenv |
297 |
and !C4::Context->IsSuperLibrarian() |
298 |
&& !C4::Context->IsSuperLibrarian() |
298 |
and C4::Context->preference("IndependentBranches") |
299 |
&& C4::Context->preference("IndependentBranches") |
299 |
and ( C4::Context->userenv->{branch} ne $self->homebranch ); |
300 |
&& ( C4::Context->userenv->{branch} ne $self->homebranch ); |
300 |
|
301 |
|
301 |
return Koha::Result::Boolean->new(0)->add_message({ message => "book_reserved" }) |
302 |
# check it doesn't have a waiting reserve |
|
|
303 |
$error //= "book_reserved" |
302 |
if $self->holds->filter_by_found->count; |
304 |
if $self->holds->filter_by_found->count; |
303 |
|
305 |
|
304 |
return Koha::Result::Boolean->new(0)->add_message({ message => "linked_analytics" }) |
306 |
$error //= "linked_analytics" |
305 |
if C4::Items::GetAnalyticsCount( $self->itemnumber ) > 0; |
307 |
if C4::Items::GetAnalyticsCount( $self->itemnumber ) > 0; |
306 |
|
308 |
|
307 |
return Koha::Result::Boolean->new(0)->add_message({ message => "last_item_for_hold" }) |
309 |
$error //= "last_item_for_hold" |
308 |
if $self->biblio->items->count == 1 |
310 |
if $self->biblio->items->count == 1 |
309 |
&& $self->biblio->holds->search( |
311 |
&& $self->biblio->holds->search( |
310 |
{ |
312 |
{ |
Lines 312-317
sub safe_to_delete {
Link Here
|
312 |
} |
314 |
} |
313 |
)->count; |
315 |
)->count; |
314 |
|
316 |
|
|
|
317 |
if ( $error ) { |
318 |
return Koha::Result::Boolean->new(0)->add_message({ message => $error }); |
319 |
} |
320 |
|
315 |
return Koha::Result::Boolean->new(1); |
321 |
return Koha::Result::Boolean->new(1); |
316 |
} |
322 |
} |
317 |
|
323 |
|
318 |
- |
|
|