Browse Source

Bug 31095: Remove GetDebarments from members/memberentry.pl

This patch removes the use of GetDebarments from members/memberentry.pl
and replaces the references in the templates with patron.restrictions.

Test plan
1. Add a new user and confirm that the patron restrictions section does
   not appear on the form
2. Edit the user and confirm the patron restrictions section now appears
3. Add a manual restriction using the patron edit form
4. Confirm the restriction appears on the patron edit form
5. Confirm you can remove the restriction usine the patron edit form

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
23.05.x
Martin Renvoize 2 years ago
committed by Tomas Cohen Arazi
parent
commit
4017946876
Signed by: tomascohen GPG Key ID: 0A272EA1B2F3C15F
  1. 37
      koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
  2. 5
      members/memberentry.pl

37
koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt

@ -8,7 +8,7 @@
[% PROCESS 'member-main-address-style.inc' %] [% PROCESS 'member-main-address-style.inc' %]
[% PROCESS 'member-alt-address-style.inc' %] [% PROCESS 'member-alt-address-style.inc' %]
[% PROCESS 'member-alt-contact-style.inc' %] [% PROCESS 'member-alt-contact-style.inc' %]
[% PROCESS 'patron_restrictions.inc' %] [% PROCESS 'restriction-types.inc' %]
[% SET footerjs = 1 %] [% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %] [% INCLUDE 'doc-head-open.inc' %]
<title> <title>
@ -1409,7 +1409,7 @@ legend:hover {
<fieldset class="rows" id="memberentry_restrictions"> <fieldset class="rows" id="memberentry_restrictions">
<legend id="restrictions_lgd">Patron restrictions</legend> <legend id="restrictions_lgd">Patron restrictions</legend>
[% IF ( debarments ) %] [% IF ( patron.restrictions.count ) %]
<table> <table>
<thead> <thead>
<tr> <tr>
@ -1423,28 +1423,27 @@ legend:hover {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
[% FOREACH d IN debarments %] [% FOREACH restriction IN patron.restrictions %]
[% dtype = d.type %]
<tr> <tr>
<td>[% restriction_types.$dtype.display_text | html %]</td> <td>[% PROCESS restriction_type_description restriction_type=restriction.type %]</td>
<td> <td>
[% IF d.comment.search('OVERDUES_PROCESS') %] [% IF restriction.comment.search('OVERDUES_PROCESS') %]
Restriction added by overdues process [% d.comment.remove('OVERDUES_PROCESS ') | $raw %] Restriction added by overdues process [% restriction.comment.remove('OVERDUES_PROCESS ') | $raw %]
[% ELSE %] [% ELSE %]
[% d.comment | $raw %] [% restriction.comment | $raw %]
[% END %] [% END %]
</td> </td>
<td> <td>
[% IF d.expiration %] [% IF restriction.expiration %]
[% d.expiration | $KohaDates %] [% restriction.expiration | $KohaDates %]
[% ELSE %] [% ELSE %]
<em>Indefinite</em> <em>Indefinite</em>
[% END %] [% END %]
</td> </td>
<td>[% d.created | $KohaDates %]</td> <td>[% restriction.created | $KohaDates %]</td>
[% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %] [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %]
<td> <td>
<input type="checkbox" id="debarment_[% d.borrower_debarment_id | html %]" name="remove_debarment" value="[% d.borrower_debarment_id | html %]" /> <input type="checkbox" id="debarment_[% restriction.borrower_debarment_id | html %]" name="remove_debarment" value="[% restriction.borrower_debarment_id | html %]" />
</td> </td>
[% END %] [% END %]
</tr> </tr>
@ -1453,10 +1452,10 @@ legend:hover {
</table> </table>
[% ELSE %] [% ELSE %]
<p>Patron is currently unrestricted.</p> <p>Patron is currently unrestricted.</p>
[% END # /IF ( debarments ) %] [% END # /IF ( patron.restrictions.count ) %]
[% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %] [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %]
<p><a href="#" id="add_manual_restriction">Add manual restriction</a></p> <p><a href="#" id="add_manual_restriction"><i class="fa fa-plus"></i> Add manual restriction</a></p>
<fieldset id="manual_restriction_form"> <fieldset id="manual_restriction_form">
<input type="hidden" id="add_debarment" name="add_debarment" value="0" /> <input type="hidden" id="add_debarment" name="add_debarment" value="0" />
<legend id="manual_restriction_lgd">Add manual restriction</legend> <legend id="manual_restriction_lgd">Add manual restriction</legend>
@ -1465,12 +1464,12 @@ legend:hover {
<li> <li>
<label for="debarred_type">Type:</label> <label for="debarred_type">Type:</label>
<select name="debarred_type"> <select name="debarred_type">
[% FOREACH code IN restriction_types.keys %] [% FOREACH restriction_type IN restriction_types %]
[% IF !restriction_types.$code.is_system %] [% IF !restriction_type.is_system %]
[% IF restriction_types.$code.is_default %] [% IF restriction_type.is_default %]
<option value="[% code | html %]" selected>[% PROCESS restriction_type_description restriction=restriction_types.$code %]</option> <option value="[% code | html %]" selected>[% PROCESS restriction_type_description %]</option>
[% ELSE %] [% ELSE %]
<option value="[% code | html %]">[% PROCESS restriction_type_description restriction=restriction_types.$code %]</option> <option value="[% code | html %]">[% PROCESS restriction_type_description %]</option>
[% END %] [% END %]
[% END %] [% END %]
[% END %] [% END %]

5
members/memberentry.pl

@ -35,7 +35,7 @@ use C4::Form::MessagingPreferences;
use Koha::AuthUtils; use Koha::AuthUtils;
use Koha::AuthorisedValues; use Koha::AuthorisedValues;
use Koha::Email; use Koha::Email;
use Koha::Patron::Debarments qw( AddDebarment DelDebarment GetDebarments ); use Koha::Patron::Debarments qw( AddDebarment DelDebarment );
use Koha::Patron::Restriction::Types; use Koha::Patron::Restriction::Types;
use Koha::Cities; use Koha::Cities;
use Koha::DateUtils qw( dt_from_string ); use Koha::DateUtils qw( dt_from_string );
@ -118,8 +118,7 @@ foreach my $id ( @delete_guarantor ) {
## Deal with debarments ## Deal with debarments
$template->param( $template->param(
debarments => scalar GetDebarments( { borrowernumber => $borrowernumber } ), restriction_types => scalar Koha::Patron::Restriction::Types->search()
restriction_types => scalar Koha::Patron::Restriction::Types->keyed_on_code()
); );
my @debarments_to_remove = $input->multi_param('remove_debarment'); my @debarments_to_remove = $input->multi_param('remove_debarment');
foreach my $d ( @debarments_to_remove ) { foreach my $d ( @debarments_to_remove ) {

Loading…
Cancel
Save