From 7f62627e8e14a89759436b0e3435d1c931b25928 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 24 Aug 2022 16:11:43 +0100 Subject: [PATCH] Bug 31095: Remove GetDebarments from circ/circulation.pl This patch remove the use of GetDebarments from circ/circulation.pl, replacing it with a reference to patron.restrictions in the template and includes. Test plan 1. Confirm that the 'Restrictions (x)' tab still appears on the checkout page for a user. 2. Confirm that the 'Restrictions (x)' tab count is correct 3. Confirm that the 'Restrictions (x)' tab table functions 4. Confirm that the 'Restrictions (x)' tab 'Add manual restriction' form works as expected Signed-off-by: Nick Clemens --- circ/circulation.pl | 6 +- .../en/includes/patron-restrictions-tab.inc | 81 +++++++++++++++++++ .../prog/en/includes/restriction-types.inc | 10 +++ .../prog/en/modules/circ/circulation.tt | 4 +- 4 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/patron-restrictions-tab.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/restriction-types.inc diff --git a/circ/circulation.pl b/circ/circulation.pl index b7270bfe56..e5735ad7c1 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -44,7 +44,6 @@ use CGI::Session; use Koha::AuthorisedValues; use Koha::CsvProfiles; use Koha::Patrons; -use Koha::Patron::Debarments qw( GetDebarments ); use Koha::DateUtils qw( dt_from_string ); use Koha::Patron::Restriction::Types; use Koha::Plugins; @@ -625,10 +624,9 @@ my $has_modifications = Koha::Patron::Modifications->search( { borrowernumber => $template->param( debt_confirmed => $debt_confirmed, SpecifyDueDate => $duedatespec_allow, - PatronAutoComplete => C4::Context->preference("PatronAutoComplete"), - debarments => scalar GetDebarments({ borrowernumber => $borrowernumber }), + PatronAutoComplete => C4::Context->preference("PatronAutoComplete"), todaysdate => dt_from_string()->set(hour => 23)->set(minute => 59), - restriction_types => scalar Koha::Patron::Restriction::Types->keyed_on_code(), + restriction_types => scalar Koha::Patron::Restriction::Types->search(), has_modifications => $has_modifications, override_high_holds => $override_high_holds, nopermission => scalar $query->param('nopermission'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-restrictions-tab.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-restrictions-tab.inc new file mode 100644 index 0000000000..4bedce39d1 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-restrictions-tab.inc @@ -0,0 +1,81 @@ +[% USE raw %] +[% USE Koha %] +[% PROCESS 'restriction-types.inc' %] +
+ [% IF ( patron.restrictions.count == 0 ) %] +

Patron is currently unrestricted.

+ [% ELSE %] + + + + + + + + [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %] + + [% END %] + + + + [% FOREACH restriction IN patron.restrictions %] + + + + + + [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %] + + [% END %] + + [% END %] + +
TypeCommentExpirationCreated 
+ [% PROCESS restriction_type_description restriction_type=restriction.type %] + + [% IF restriction.comment.search('OVERDUES_PROCESS') %] + Restriction added by overdues process [% restriction.comment.remove('OVERDUES_PROCESS ') | $raw %] + [% ELSE %] + [% restriction.comment | $raw %] + [% END %] + [% IF restriction.expiration %] [% restriction.expiration | $KohaDates %] [% ELSE %] Indefinite [% END %][% restriction.created | $KohaDates %] + + Remove + +
+ [% END %] + [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %] +

Add manual restriction

+
+ + +
+ Add manual restriction +
    + [% IF Koha.Preference('PatronRestrictionTypes') %] +
  1. + + +
  2. + [% END %] +
  3. +
  4. + + +
  5. +
+
Cancel
+
+
+ [% END %] +
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/restriction-types.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/restriction-types.inc new file mode 100644 index 0000000000..321bde9116 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/restriction-types.inc @@ -0,0 +1,10 @@ +[%- BLOCK restriction_type_description -%] + [%- ddisplay = restriction_type.display_text -%] + [%- SWITCH ddisplay -%] + [%- CASE 'Manual' -%]Manual + [%- CASE 'Overdues' -%]Overdues + [%- CASE 'Suspension' -%]Suspension + [%- CASE 'Discharge' -%]Discharge + [%- CASE -%][% ddisplay | html %] + [%- END -%] +[%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 50614e7b23..0ee53c6523 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -870,7 +870,7 @@ [% END %]
  • - Restrictions ([% debarments.size || 0 | html %]) + Restrictions ([% patron.restrictions.count || 0 | html %])
  • [% SET enrollments = patron.get_club_enrollments %] @@ -897,7 +897,7 @@ [% END %] - [% INCLUDE borrower_debarments.inc %] + [% INCLUDE "patron-restrictions-tab.inc" %]
    [% IF ( holds_count ) %] -- 2.20.1