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