From c30fdae57407403a7bfab7ef61917e91d2221ba0 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sun, 5 May 2019 09:42:45 -0500 Subject: [PATCH] Bug 10910: Add a warning when deleting a patron with pending suggestions Test plan: From the OPAC, add a suggestion From the staff interface, try to delete the patron who created the suggestion => You get a warning message Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Katrin Fischer Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart (cherry picked from commit 85c1537bd7e4002a59c3c3eba6d2180911d8b7c3) Signed-off-by: Lucas Gass --- .../intranet-tmpl/prog/en/modules/members/deletemem.tt | 4 +++- members/deletemem.pl | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt index 776de69ba4..e27af5288a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt @@ -48,7 +48,9 @@
    [% END %]

    Are you sure you want to delete the patron [% patron.firstname | html %] [% patron.surname | html %]? This cannot be undone.

    - + [% IF pending_suggestions > 0 %] +

    Note that this patron has [% pending_suggestions %] pending suggestions.

    + [% END %]
    diff --git a/members/deletemem.pl b/members/deletemem.pl index 12eac49339..bd8a043bd6 100755 --- a/members/deletemem.pl +++ b/members/deletemem.pl @@ -28,6 +28,7 @@ use C4::Context; use C4::Output; use C4::Auth; use C4::Members; +use C4::Suggestions qw( SearchSuggestion ); use Koha::Patrons; use Koha::Token; use Koha::Patron::Categories; @@ -102,6 +103,15 @@ if ( $op eq 'delete_confirm' or $countissues > 0 or $debits or $is_guarantor ) { op => 'delete_confirm', csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }), ); + + # Add warning if patron has pending suggestions + $template->param( + pending_suggestions => scalar @{ + C4::Suggestions::SearchSuggestion( + { suggestedby => $member, STATUS => 'ASKED' } + ) + } + ); } elsif ( $op eq 'delete_confirmed' ) { output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' ) unless Koha::Token->new->check_csrf( { -- 2.39.5