diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 81594bbd76..13492b780f 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -47,6 +47,7 @@ use Storable qw( freeze thaw ); use URI::Escape qw( uri_escape_utf8 ); use C4::Members; use Koha::UI::Form::Builder::Item; +use Koha::Result::Boolean; use MARC::File::XML; use URI::Escape qw( uri_escape_utf8 ); @@ -380,7 +381,12 @@ if ($op eq "additem") { #------------------------------------------------------------------------------- # check that there is no issue on this item before deletion. my $item = Koha::Items->find($itemnumber); - my $deleted = $item->safe_delete; + my $deleted; + if( $item ) { + $deleted = $item->safe_delete; + } else { + $deleted = Koha::Result::Boolean->new(0)->add_message({ message => 'item_not_found' }); + } if ( $deleted ) { print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode&searchid=$searchid"); exit; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index aa02320f52..42acc93f5c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -62,6 +62,7 @@ [% IF ( not_same_branch ) %]
Cannot delete: The items do not belong to your library.
[% END %] [% IF ( linked_analytics ) %]
Cannot delete: item has linked analytics..
[% END %] [% IF last_item_for_hold %]
Cannot delete: Last item for bibliographic record with biblio-level hold on it.
[% END %] +[% IF item_not_found %]
Cannot delete: Item not found.
[% END %]
[% IF items %]