Bug 10910: Add a warning when deleting a patron with pending suggestions
[koha.git] / members / deletemem.pl
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( {