From 51b774dc61d7ab49af843628333c26be4b57e1ac Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 20 Apr 2018 15:47:51 +0000 Subject: [PATCH] Bug 9302: Add error message if keeper patron is invalid Signed-off-by: Jonathan Druart --- .../prog/en/modules/members/merge-patrons.tt | 10 ++++++-- members/merge-patrons.pl | 25 +++++++++++-------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/merge-patrons.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/merge-patrons.tt index a8cd953978..264d1c6728 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/merge-patrons.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/merge-patrons.tt @@ -95,7 +95,11 @@ [% ELSIF action == 'merge' %]

Results

[% IF error %] -
Merge failed! The following error was reported: [% error %].
+ [% IF error == 'INVALID_KEEPER' %] +
Merge failed! The patron to keep was invalid.
+ [% ELSE %] +
Merge failed! The following error was reported: [% error %].
+ [% END %] [% ELSIF !results.merged.keys.size %]
No valid patrons to merge were found.
[% ELSE %] @@ -123,7 +127,9 @@ [% END %] [% END %] - View patron record + [% UNLESS error %] + View patron record + [% END %] [% END %] diff --git a/members/merge-patrons.pl b/members/merge-patrons.pl index b55db88bb6..b4ea721a10 100755 --- a/members/merge-patrons.pl +++ b/members/merge-patrons.pl @@ -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' ); } } -- 2.39.5