From 46678dc3a50464631d555199605d4c9d979fd09e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 5 Jan 2022 10:27:30 +0100 Subject: [PATCH] Bug 29788: Fix batch delete item Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall --- Koha/Acquisition/Order.pm | 2 +- Koha/BackgroundJob/BatchDeleteBiblio.pm | 2 +- Koha/BackgroundJob/BatchDeleteItem.pm | 2 +- Koha/UI/Table/Builder/Items.pm | 8 +++++++- koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc | 6 +++--- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm index 517c88af186..214d7fe69c8 100644 --- a/Koha/Acquisition/Order.pm +++ b/Koha/Acquisition/Order.pm @@ -131,7 +131,7 @@ sub cancel { $self->add_message( { message => 'error_delitem', - payload => { item => $item, reason => @{$deleted->messages}[0]->messages } + payload => { item => $item, reason => @{$deleted->messages}[0]->message } } ); } diff --git a/Koha/BackgroundJob/BatchDeleteBiblio.pm b/Koha/BackgroundJob/BatchDeleteBiblio.pm index 63e12935af0..8c94720ac19 100644 --- a/Koha/BackgroundJob/BatchDeleteBiblio.pm +++ b/Koha/BackgroundJob/BatchDeleteBiblio.pm @@ -119,7 +119,7 @@ sub process { code => 'item_not_deleted', biblionumber => $biblionumber, itemnumber => $item->itemnumber, - error => @{$deleted->messages}[0]->messages, + error => @{$deleted->messages}[0]->message, }; $schema->storage->txn_rollback; $job->progress( ++$job_progress )->store; diff --git a/Koha/BackgroundJob/BatchDeleteItem.pm b/Koha/BackgroundJob/BatchDeleteItem.pm index 66f0044624d..b5147e78292 100644 --- a/Koha/BackgroundJob/BatchDeleteItem.pm +++ b/Koha/BackgroundJob/BatchDeleteItem.pm @@ -126,7 +126,7 @@ sub process { biblionumber => $item->biblionumber, barcode => $item->barcode, title => $item->biblio->title, - reason => $return, + reason => @{$return->messages}[0]->message, }; next; diff --git a/Koha/UI/Table/Builder/Items.pm b/Koha/UI/Table/Builder/Items.pm index 516414d2648..b573f2a3b3f 100644 --- a/Koha/UI/Table/Builder/Items.pm +++ b/Koha/UI/Table/Builder/Items.pm @@ -108,7 +108,13 @@ sub _build_headers { my @witness_attributes = uniq map { my $item = $_; - map { defined $item->{$_} && $item->{$_} ne "" ? $_ : () } keys %$item + map { + defined $item->{$_} + && !ref( $item->{$_} ) # biblio and safe_to_delete are objects + && $item->{$_} ne "" + ? $_ + : () + } keys %$item } @$items; my ( $itemtag, $itemsubfield ) = 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 56707256be0..802e6621ce5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc @@ -261,18 +261,18 @@ [% UNLESS can_be_edited %] Cannot delete [% ELSE %] - [% IF item.safe_to_delete == 1 %] + [% IF item.safe_to_delete %] [% ELSE %] [% SET messages = item.safe_to_delete.messages %] [% FOR m IN messages %] - [% SWITCH m %] + [% SWITCH m.message %] [% 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") _ '(' _ item.safe_to_delete _ ')' %] + [% CASE %][% SET cannot_delete_reason = t("Unknown reason") _ '(' _ m.message _ ')' %] [% END %] [% END %] -- 2.30.2