From 4e9eeadc4eb5390e405f78dd21214aad806cb329 Mon Sep 17 00:00:00 2001 From: PhilipOrr Date: Tue, 1 Apr 2025 09:59:39 +0000 Subject: [PATCH] Bug 39498: correct patron restrictions displays This patch updates the way patron restrictions are displayed in the OPAC and staff interface, with the intention of making the details of each restriction more clear. In the OPAC, a new include file is created to be reused on the holds page and the user summary page. opac-user.pl is updated to allow a parameter to be passed to automatically open the "Overdues" tab. Test plan (copied from the original patch): 1. Before applying the patch, check how the display is currently. First set syspref PatronRestrictionTypes to "Allow" 2. Add two different new restriction types, fill out both "Code" and "Label" 3. Go to a patron's checkout page and add one of each of these restrictions, but do not fill out the comment field when adding them! 4. Observe that in the checkouts page and details page of the patron, it just says "Restricted since..." and does not show the restriction types. 5. Add another restriction, this time fill out the comment field 6. Observe that now in checkout and detail pages, the labels from the restriction types are listed and the comment shown. 7. Apply patch 8. Go to patron's details and checkout pages and check the restrictions are now displayed correctly, that is the text "with the explanation" is only shown for the restrictions that actually have a comment 8b. Log in to the OPAC with that patron and check they are displayed correctly in their summary page and when the patron is trying to place a hold. 9. Go to a different patron's account and add a restriction without a comment 10. Check it is now displayed correctly 11. Add more restrictions and check they are displayed correctly. Also add an OVERDUES restriction: 11a. Find a patron with an overdue item checked out (or create an overdue checkout on a patron's account) 11b. Go to Tools -> Overdue notice/status triggers 11c. Set up a rule for that patron's category, e.g. "First" -> Delay: 1, make sure to mark the check box for "Restrict" and "Print" 11d. Run misc/cronjobs/overdue_notices.pl 11e. That patron should now also have an OVERDUES restriction 12. Turn PatronRestrictionTypes off again and check the patrons if everything is still displayed correctly 13. Go to another different patron and add a restriction with no comment, check if it is displayed correctly 14. Add another restriction with a comment and check it is displayed correctly 15. Log in to the OPAC with the patron that had OVERDUES restriction and check they are displayed correctly in their summary page and when the patron is trying to place a hold. 16. Same thing for the other patron without the OVERDUES restriction. --- .../prog/en/includes/patron_messages.inc | 46 +++++++++---------- .../en/includes/patron-restrictions.inc | 27 +++++++++++ .../bootstrap/en/modules/opac-reserve.tt | 46 +++---------------- .../bootstrap/en/modules/opac-user.tt | 36 ++------------- opac/opac-user.pl | 1 + 5 files changed, 59 insertions(+), 97 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/patron-restrictions.inc diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc index 5d71adf30d7..942993dde70 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc @@ -92,32 +92,28 @@ [% IF ( userdebarred ) %]
  • - Restricted since [% debarredsince | $KohaDates %]: Patron's account is restricted - [% IF ( userdebarreddate ) %] - until [% userdebarreddate | $KohaDates %] - [% END %] - - [% IF ( debarredcomment ) %] - with the explanation:
    - - [% IF debarredcomment.search('OVERDUES_PROCESS') %] - Restriction added by overdues process [% debarredcomment.remove('OVERDUES_PROCESS ') | $raw | html_line_break %] - [% ELSE %] - [% FOREACH restriction IN patron.restrictions %] -
    - - [% IF restriction.expiration %] - [% restriction.expiration | $KohaDates %] - [% ELSE %] - Indefinite - [% END %] - - [%- restriction.type.display_text | html -%][%- IF restriction.comment -%]: [%- restriction.comment | html_line_break -%][%- END -%] -
    + Account restricted since [% debarredsince | $KohaDates %] +
    View restrictions
  • diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/patron-restrictions.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/patron-restrictions.inc new file mode 100644 index 00000000000..7b2453b7b37 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/patron-restrictions.inc @@ -0,0 +1,27 @@ +
  • + Your account has been frozen + +
  • diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index 59e57049507..ffc97ff6fe0 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -30,8 +30,8 @@

    Placing a hold

    [% IF ( message ) %] -
    -

    Sorry, you cannot place holds.

    +
    +

    Sorry, you cannot place holds.

      [% IF ( GNA ) %]
    • @@ -49,41 +49,7 @@ [% END %] [% IF ( debarred ) %] -
    • - Your account has been frozen. - [% IF debarred_comment %] - Comment:
      - - - [% IF debarred_comment.search('OVERDUES_PROCESS') %] - Restriction added by overdues process [% debarred_comment.remove('OVERDUES_PROCESS ') | html_line_break %] - [% ELSE %] - [% FOR restriction IN logged_in_user.restrictions %] -
      - [%- restriction.type.display_text | html -%][%- IF restriction.comment -%] - : [% restriction.comment | html_line_break %], frozen until: - - [%- IF restriction.expiration -%] - [%- restriction.expiration | $KohaDates -%] - [%- ELSE -%] - Indefinite - [%- END -%] - - [% END %] -
      - [% END %] - [% END %] -
      -
      - [% END %] - - [% IF debarred_date && debarred_date != '9999-12-31' %] - End date: - [% debarred_date | $KohaDates %] - [% END %] -
      Usually the reason for freezing an account is old overdues or damage fees. If shows your account to be clear, please contact the library. - Go to your charges page -
    • + [% INCLUDE "patron-restrictions.inc" %] [% END %] [% IF ( too_much_oweing ) %] @@ -273,9 +239,9 @@ [% END %] [% IF at_least_one_library_not_available_for_pickup %] -
      Note: Library policy does not allow hold/pickup of an item available locally. Please come to the library to retrieve these items
      +
      + Note: Library policy does not allow hold/pickup of an item available locally. Please come to the library to retrieve these items +
      [% END %] [% END # / UNLESS bibitemloo.holdable %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index c0777a8bab7..9b1f5685ab5 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -167,36 +167,7 @@ [% IF ( discharge_available ) %]
    • Please note: Your account is frozen because it has been discharged. Get your discharge
    • [% ELSE %] -
    • - Please note: Your account has been frozen. - [% IF ( borrower.debarredcomment ) %] - Comment:
      -
        - [% FOREACH restriction IN logged_in_user.restrictions %] -
      • - [%- restriction.type.display_text | html -%]: - [% IF restriction.comment.search('OVERDUES_PROCESS') %] - Restriction added by overdues process [% restriction.comment.remove('OVERDUES_PROCESS ') | html_line_break %] - [% ELSE %] - [%- IF restriction.comment -%] - [% restriction.comment | html_line_break %]. - [%- END -%] - [% END %] - [%- IF restriction.expiration -%] - Account frozen until [%- restriction.expiration | $KohaDates -%] - [%- ELSE -%] - Account frozen indefinitely - [%- END -%] -
      • - [% END %] -
      - [% END %] - -

      Usually the reason for freezing an account is old overdues or damage fees. If your account shows to be clear, please contact the library. - Go to your charges page

      -
    • + [% INCLUDE "patron-restrictions.inc" %] [% END %] [% END %] [% IF ( borrower.gonenoaddress ) %] @@ -1094,8 +1065,9 @@ $(document).ready(function(){ [% IF ( opac_user_holds ) %] $("#opac-user-views a[href='#opac-user-holds_panel']").tab("show"); - [% END %] - [% IF ( opac_user_article_requests ) %] + [% ELSIF ( opac_user_overdues ) %] + $("#opac-user-views a[href='#opac-user-overdues_panel']").tab("show"); + [% ELSIF ( opac_user_article_requests ) %] $("#opac-user-views a[href='#opac-user-article-requests_panel']").tab("show"); [% END %] $('#article-requests-table caption .count').html(AR_CAPTION_COUNT.format('[% current_article_requests.size | html %]')); diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 9d7109bcac7..be5f63896b2 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -430,6 +430,7 @@ $template->param( OpacHoldNotes => C4::Context->preference('OpacHoldNotes'), failed_holds => scalar $query->param('failed_holds'), opac_user_holds => scalar $query->param('opac-user-holds') || 0, + opac_user_overdues => scalar $query->param('opac-user-overdues') || 0, opac_user_article_requests => scalar $query->param('opac-user-article-requests') || 0, ); -- 2.39.5