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 <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>
This commit is contained in:
Jonathan Druart 2019-05-05 09:42:45 -05:00
parent 9681b8a1ca
commit 85c1537bd7
2 changed files with 13 additions and 1 deletions

View file

@ -48,7 +48,9 @@
<ul> <ul>
[% END %] [% END %]
<h3>Are you sure you want to delete the patron [% patron.firstname | html %] [% patron.surname | html %]? This cannot be undone.</h3> <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"> <form action="/cgi-bin/koha/members/deletemem.pl">
<input type="hidden" name="csrf_token" value="[% csrf_token | html %]" /> <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
<input type="hidden" name="member" value="[% patron.borrowernumber | html %]"/> <input type="hidden" name="member" value="[% patron.borrowernumber | html %]"/>

View file

@ -28,6 +28,7 @@ use C4::Context;
use C4::Output; use C4::Output;
use C4::Auth; use C4::Auth;
use C4::Members; use C4::Members;
use C4::Suggestions qw( SearchSuggestion );
use Koha::Patrons; use Koha::Patrons;
use Koha::Token; use Koha::Token;
use Koha::Patron::Categories; use Koha::Patron::Categories;
@ -102,6 +103,15 @@ if ( $op eq 'delete_confirm' or $countissues > 0 or $debits or $is_guarantor ) {
op => 'delete_confirm', op => 'delete_confirm',
csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }), 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' ) { } elsif ( $op eq 'delete_confirmed' ) {
output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' ) output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' )
unless Koha::Token->new->check_csrf( { unless Koha::Token->new->check_csrf( {