diff --git a/Koha/Item.pm b/Koha/Item.pm index 52f8e44a3d..ed175d3ced 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -345,6 +345,8 @@ returns 1 if the item is safe to delete, "book_reserved" if the there are holds aganst the item, or +"item_has_holds" if the item has holds, + "linked_analytics" if the item has linked analytic records. "last_item_for_hold" if the item is the last one on a record on which a biblio-level hold is placed @@ -367,6 +369,9 @@ sub safe_to_delete { $error //= "book_reserved" if $self->holds->filter_by_found->count; + $error //= "item_has_holds" + if $self->holds->count; + $error //= "linked_analytics" if C4::Items::GetAnalyticsCount( $self->itemnumber ) > 0; diff --git a/Koha/REST/V1/Items.pm b/Koha/REST/V1/Items.pm index 5e8175a61f..07a8a4f03e 100644 --- a/Koha/REST/V1/Items.pm +++ b/Koha/REST/V1/Items.pm @@ -140,6 +140,7 @@ sub delete { { code => 'linked_analytics', description => 'The item has linked analytic records' }, not_same_branch => { code => 'not_same_branch', description => 'The item is blocked by independent branches' }, + item_has_holds => { code => 'item_has_holds', description => 'The item has item level holds' }, }; if ( any { $error->message eq $_ } keys %{$errors} ) { diff --git a/api/v1/swagger/paths/items.yaml b/api/v1/swagger/paths/items.yaml index 5acc18ad28..e99a6e0e55 100644 --- a/api/v1/swagger/paths/items.yaml +++ b/api/v1/swagger/paths/items.yaml @@ -158,6 +158,7 @@ * last_item_for_hold: The item is the last one on a record on which a biblio-level hold is placed * linked_analytics: The item has linked analytic records * not_same_branch: The item is blocked by independent branches + * item_has_holds: The item has holds schema: $ref: "../swagger.yaml#/definitions/error" "500": diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/batch_item_record_deletion.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/batch_item_record_deletion.inc index d549de90b2..5dbd3460b0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/batch_item_record_deletion.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/batch_item_record_deletion.inc @@ -49,6 +49,8 @@ Item does not belong to your library [% CASE "book_reserved" %] Item has a waiting hold + [% CASE "item_has_holds" %] + Item has item level holds [% CASE "linked_analytics" %] Item has linked analytics [% CASE "last_item_for_hold" %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc index f392453454..9e69dbf96a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc @@ -378,6 +378,8 @@ [% SET cannot_delete_reason = t("Item does not belong to your library") %] [% CASE "book_reserved" %] [% SET cannot_delete_reason = t("Item has a waiting hold") %] + [% CASE "item_has_holds" %] + [% SET cannot_delete_reason = t("Item has item level holds") %] [% CASE "linked_analytics" %] [% SET cannot_delete_reason = t("Item has linked analytics") %] [% CASE "last_item_for_hold" %] 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 76758d3deb..0e6c6a6c81 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -95,6 +95,7 @@ [% IF ( no_next_barcode ) %]