Bug 9302: Add error message if keeper patron is invalid
authorKyle M Hall <kyle@bywatersolutions.com>
Fri, 20 Apr 2018 15:47:51 +0000 (15:47 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 20 Apr 2018 16:34:41 +0000 (13:34 -0300)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

koha-tmpl/intranet-tmpl/prog/en/modules/members/merge-patrons.tt
members/merge-patrons.pl

index a8cd953..264d1c6 100644 (file)
             [% ELSIF action == 'merge' %]
                 <h4>Results</h4>
                 [% IF error %]
-                    <div class="dialog alert">Merge failed! The following error was reported: [% error %].</div>
+                    [% IF error == 'INVALID_KEEPER' %]
+                        <div class="dialog alert">Merge failed! The patron to keep was invalid.</div>
+                    [% ELSE %]
+                        <div class="dialog alert">Merge failed! The following error was reported: [% error %].</div>
+                    [% END %]
                 [% ELSIF !results.merged.keys.size %]
                     <div class="dialog alert">No valid patrons to merge were found.</div>
                 [% ELSE %]
                     [% END %]
                 [% END %]
 
-                <a class="btn btn-default btn-sm" href="moremember.pl?borrowernumber=[% keeper.id %]">View patron record</a>
+                [% UNLESS error %]
+                    <a class="btn btn-default btn-sm" href="moremember.pl?borrowernumber=[% keeper.id %]">View patron record</a>
+                [% END %]
             [% END %]
         </div>
     </div>
index b55db88..b4ea721 100755 (executable)
@@ -48,16 +48,21 @@ if ( $action eq 'show' ) {
     my $keeper_id = $cgi->param('keeper');
     my $results;
 
-    try {
-        my $keeper = Koha::Patrons->find( $keeper_id );
-        $results = $keeper->merge_with( \@ids );
-        $template->param(
-            keeper  => $keeper,
-            results => $results
-        );
-    }
-    catch {
-        $template->param( error => $_ );
+    my $keeper = Koha::Patrons->find( $keeper_id );
+
+    if ( $keeper ) {
+        try {
+            $results = $keeper->merge_with( \@ids );
+            $template->param(
+                keeper  => $keeper,
+                results => $results
+            );
+        }
+        catch {
+            $template->param( error => $_ );
+        }
+    } else {
+        $template->param( error => 'INVALID_KEEPER' );
     }
 }