Bug 16204: Show friendly error message if trying to edit record which no longer exists
authorAleisha Amohia <aleishaamohia@hotmail.com>
Wed, 30 Aug 2017 04:36:50 +0000 (04:36 +0000)
committerKatrin Fischer <katrin.fischer.83@web.de>
Sun, 29 Oct 2017 18:05:28 +0000 (19:05 +0100)
To test:
1) Create a record
2) Click Edit -> Edit record. open this in another tab
3) Delete the record in the original tab
4) Refresh the edit form in the other tab. Notice the software error
5) Apply patch and refresh page
6) There should be a nice error message with the form fields and buttons
hidden. Confirm links work as expected.

Sponsored-by: Catalyst IT
Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 17c5b76597b9a356bc215a3682d7293e307fcc46)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 1766d21389a104948aba639921d987674cba3d6b)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

cataloguing/addbiblio.pl
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt

index 4b118f5..30e5751 100755 (executable)
@@ -729,6 +729,14 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
+if ($biblionumber){
+    my $does_bib_exist = Koha::Biblios->find($biblionumber);
+    if (!defined $does_bib_exist){
+        $biblionumber = undef;
+        $template->param( bib_doesnt_exist => 1 );
+    }
+}
+
 if ($frameworkcode eq 'FA'){
     # We need to grab and set some variables in the template for use on the additems screen
     $template->param(
@@ -797,7 +805,7 @@ if ($parentbiblio) {
 }
 
 $is_a_modif = 0;
-    
+
 if ($biblionumber) {
     $is_a_modif = 1;
     my $title = C4::Context->preference('marcflavour') eq "UNIMARC" ? $record->subfield('200', 'a') : $record->title;
index 1aa98ed..9a4bff3 100644 (file)
         $("#loading").hide();
     });
         $(document).ready(function() {
+
+        [% IF bib_doesnt_exist %]
+            $("#addbibliotabs").hide();
+            $("#toolbar").hide();
+        [% END %]
+
         $('#addbibliotabs').tabs().bind('show.ui-tabs', function(e, ui) {
                        $("#"+ui.panel.id+" input:eq(0)").focus();
                });
@@ -540,6 +546,13 @@ function Changefwk() {
     [% END %]
 </div>
 
+[% IF bib_doesnt_exist %]
+    <div class="dialog alert">
+        The record you are trying to edit doesn't exist.<br>
+        <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=">Add a new record</a> or <a href="/cgi-bin/koha/catalogue/search.pl">do a catalog search</a>.
+    </div>
+[% END %]
+
 [% IF ( popup ) %]
         <input type="hidden" name="mode" value="popup" />
 [% END %]