From f562be51a8c4a15c34e8248968096bbc5a2994e6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 18 May 2021 09:41:40 +0200 Subject: [PATCH] Bug 28353: Display a list of items that cannot be deleted We used to display a list of items that cannot be deleted (checked out or on hold) on the Batch item deletion tool. With bug 8132 we improve the error handling, but the info is spread in the table. This patch adds, at the top of the page, the list of items (barcode) that cannot be removed. Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit 7de5d06abd8c3d6d1e5fc13e51ee3ce8074efe1d) Signed-off-by: Fridolin Somers --- .../prog/en/modules/tools/batchMod-del.tt | 35 +++++++++++-------- tools/batchMod.pl | 10 +++++- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt index 5a97941b25..e36a90089a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt @@ -43,11 +43,6 @@ [% END %] - [% UNLESS ( too_many_items_display ) %] - [% IF ( item_loop ) %] -

The following barcodes were found:

- [% END %] - [% END %] [% END %] [% IF ( notfounditemnumbers.size ) %]
@@ -63,14 +58,27 @@ [% END %] - [% UNLESS ( too_many_items_display ) %] - [% IF ( item_loop ) %] -

The following itemnumbers were found:

- [% END %] - [% END %] [% END %] + [% IF cannot_be_deleted.size %] +
+

Warning, the following items cannot be deleted:

+
+ + + + + + [% FOREACH barcode IN cannot_be_deleted %] + + [% END %] + +
Cannot be deleted
[% barcode | html %]
+ [% END %] + [% IF ( notfoundbarcodes.size || notfounditemnumbers.size || cannot_be_deleted.size ) && !too_many_items_display && item_loop %] +

The following barcodes were found:

+ [% END %]
@@ -112,17 +120,16 @@ [% IF item_loo.nomod %] Cannot delete [% ELSE %] - [% SET can_be_deleted = item_loo.item.safe_to_delete %] - [% IF can_be_deleted == 1 %] + [% IF item_loo.safe_to_delete == 1 %] [% ELSE %] - [% SWITCH can_be_deleted %] + [% SWITCH item_loo.safe_to_delete%] [% CASE "book_on_loan" %][% SET cannot_delete_reason = t("Item is checked out") %] [% CASE "not_same_branch" %][% 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 "linked_analytics" %][% SET cannot_delete_reason = t("Item has linked analytics") %] [% CASE "last_item_for_hold" %][% SET cannot_delete_reason = t("Last item for bibliographic record with biblio-level hold on it") %] - [% CASE %][% SET cannot_delete_reason = t("Unknown reason") _ '(' _ can_be_deleted _ ')' %] + [% CASE %][% SET cannot_delete_reason = t("Unknown reason") _ '(' _ item_loo.safe_to_delete _ ')' %] [% END %] diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 53181f5b6e..aeb5afd21e 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -734,13 +734,21 @@ sub BuildItemsData{ $row_data{holds} = $row->{holds}; $row_data{item_holds} = $row->{item_holds}; $row_data{item} = $row->{item}; + $row_data{safe_to_delete} = $row->{item}->safe_to_delete; my $is_on_loan = C4::Circulation::IsItemIssued( $row->{itemnumber} ); $row_data{onloan} = $is_on_loan ? 1 : 0; push(@item_value_loop,\%row_data); } my @header_loop=map { { header_value=> $witness{$_}} } @witnesscodessorted; - return { item_loop => \@item_value_loop, item_header_loop => \@header_loop }; + my @cannot_be_deleted = map { + $_->{safe_to_delete} == 1 ? () : $_->{item}->barcode + } @item_value_loop; + return { + item_loop => \@item_value_loop, + cannot_be_deleted => \@cannot_be_deleted, + item_header_loop => \@header_loop + }; } #BE WARN : it is not the general case -- 2.39.5