Bug 23987: "return to cataloguing" if the record is deleted from bachMod-del
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 20 Nov 2019 09:56:24 +0000 (10:56 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 9 Dec 2019 14:31:13 +0000 (14:31 +0000)
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 <george@nekls.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt
tools/batchMod.pl

index b938a16..3d11faf 100644 (file)
             <p>[% deleted_items | html %] item(s) deleted.</p>
             [% IF delete_records %] <p>[% deleted_records | html %] record(s) deleted.</p> [% END %]
             [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Delete items in a batch%]
-                <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">Return to the record</a>
+                [% IF biblio_deleted %]
+                    <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Return to the cataloging module</a>
+                [% ELSE %]
+                    <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">Return to the record</a>
+                [% END %]
             [% ELSIF src %]
                 <a href="[% src | url %]">Return to where you were</a>
             [% ELSE %]
 
     <p>
         [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Delete items in a batch%]
-           <a class="btn btn-default" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | html %]"><i class="fa fa-check-square-o"></i> Return to the record</a>
+            [% IF biblio_deleted %]
+                <a class="btn btn-default" href="/cgi-bin/koha/cataloguing/addbooks.pl"><i class="fa fa-check-square-o"></i> Return to the cataloging module</a>
+            [% ELSE %]
+               <a class="btn btn-default" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]"><i class="fa fa-check-square-o"></i> Return to the record</a>
+            [% END %]
         [% ELSIF src %]
            <a class="btn btn-default" href="[% src | url %]"><i class="fa fa-check-square-o"></i> Return to where you were</a>
         [% ELSE %]
index 2e64737..ce7be79 100755 (executable)
@@ -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);