Bug 10910: Add a warning when deleting a patron with pending suggestions
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Sun, 5 May 2019 14:42:45 +0000 (09:42 -0500)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 15 Jun 2020 09:53:36 +0000 (11:53 +0200)
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 <victor@tuxayo.net>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

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

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

index 776de69..e27af52 100644 (file)
@@ -48,7 +48,9 @@
                 <ul>
             [% END %]
             <h3>Are you sure you want to delete the patron [% patron.firstname | html %] [% patron.surname | html %]? This cannot be undone.</h3>
-
+            [% IF pending_suggestions > 0 %]
+                <h3>Note that this patron has [% pending_suggestions %] pending suggestions.</h3>
+            [% END %]
             <form action="/cgi-bin/koha/members/deletemem.pl">
                 <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
                 <input type="hidden" name="member" value="[% patron.borrowernumber | html %]"/>
index 12eac49..bd8a043 100755 (executable)
@@ -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( {