From 5d94cbefdc0f06c9cc9b57a9e3016f52fdf2d71a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Nov 2019 10:56:24 +0100 Subject: [PATCH] Bug 23987: "return to cataloguing" if the record is deleted from bachMod-del If a bibliographic record is deleted after having deleted all their items in a batch, we should not display a "return to the record" button but "return to cataloguing" instead Test plan: 1 - Have/make a bib with items 2 - On details page select Edit->Delete items in a batch 3 - Select all items and check "Delete record if no items remain" 4 - Delete the things 5 - On confirmation screen you have a count of items/bibs deleted => Without the patch there is a 'Return to record' button that leads to nowhere => With this patch there is a "Return to cataloging module" button 6 - Repeat using the "Delete selected items" link on top of the items table => Without the patch there is a 'Return to where you were' button that leads to nowhere => With this patch there is a "Return to cataloging module" button Note that there is a link AND a button, coming from commit 928c0af2b6a2c7aa6ed54019c5bd7dbddbccf4ee Bug 15824 - 'Done' button is unclear on batch item modification and deletion I do not think it makes sense to have both. Signed-off-by: George Williams Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- .../prog/en/modules/tools/batchMod-del.tt | 12 ++++++++++-- tools/batchMod.pl | 18 ++++++++++++------ 2 files changed, 22 insertions(+), 8 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 b938a16c87..3d11fafd52 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 @@ -200,7 +200,11 @@

[% deleted_items | html %] item(s) deleted.

[% IF delete_records %]

[% deleted_records | html %] record(s) deleted.

[% END %] [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Delete items in a batch%] - Return to the record + [% IF biblio_deleted %] + Return to the cataloging module + [% ELSE %] + Return to the record + [% END %] [% ELSIF src %] Return to where you were [% ELSE %] @@ -235,7 +239,11 @@

[% IF src == 'CATALOGUING' # from catalogue/detail.pl > Delete items in a batch%] - Return to the record + [% IF biblio_deleted %] + Return to the cataloging module + [% ELSE %] + Return to the record + [% END %] [% ELSIF src %] Return to where you were [% ELSE %] diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 2e6473784c..ce7be79e76 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -200,14 +200,20 @@ if ($op eq "action") { }; } - # If there are no items left, delete the biblio - if ( $del_records ) { - my $itemscount = Koha::Biblios->find( $itemdata->{'biblionumber'} )->items->count; - if ( $itemscount == 0 ) { - my $error = DelBiblio($itemdata->{'biblionumber'}); - $deleted_records++ unless ( $error ); + # If there are no items left, delete the biblio + if ($del_records) { + my $itemscount = Koha::Biblios->find( $itemdata->{'biblionumber'} )->items->count; + if ( $itemscount == 0 ) { + my $error = DelBiblio( $itemdata->{'biblionumber'} ); + unless ($error) { + $deleted_records++; + if ( $src eq 'CATALOGUING' ) { + # We are coming catalogue/detail.pl, there were items from a single bib record + $template->param( biblio_deleted => 1 ); } } + } + } } else { if ($values_to_modify || $values_to_blank) { my $localmarcitem = Item2Marc($itemdata); -- 2.39.5