From 2e49c2040e4cffd68a4b93333b4ef17c39e8aae5 Mon Sep 17 00:00:00 2001 From: Sam Lau Date: Wed, 3 Jul 2024 20:09:37 +0000 Subject: [PATCH] Bug 32581: Automatically update patron expiration date when changing their category To test: 1) In Administration-> Patron categories, set the enrollment period for the 'School' category to 12 months. 2) Find a patron that is from another category, edit their info and change their category from patron to school. 3) Note that the expiry date automatically changes to 12 months from today. 4) Save your changes and ensure on the patron's detail page that their expiration date was successfully changed. Signed-off-by: Roman Dolny Signed-off-by: Jan Kissig --- .../prog/en/modules/members/memberentrygen.tt | 2 ++ koha-tmpl/intranet-tmpl/prog/js/members.js | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index 361a178107..ec7c493421 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -942,6 +942,7 @@ data-pwd-length="[% category.effective_min_password_length | html %]" data-pwd-strong="[% category.effective_require_strong_password | html %]" data-typename="[% category_type | html %]" + data-expiry-date="[% category.get_expiry_date | html %]" >[% category.description | html %] [% ELSE %] @@ -950,6 +951,7 @@ data-pwd-length="[% category.effective_min_password_length | html %]" data-pwd-strong="[% category.effective_require_strong_password | html %]" data-typename="[% category_type | html %]" + data-expiry-date="[% category.get_expiry_date | html %]" >[% category.description | html %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index a20561cfe0..55cffbc504 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -88,6 +88,17 @@ function update_category_code(category_code) { ); var hint_string = __("Minimum password length: %s").format(min_length); hint.html(hint_string); + + // Change patron's expiration date + $('#categorycode_entry').change(function() { + var fp = $("#to").flatpickr(); + var expiryDate = $('select'+category_selector+' option:selected').data('expiryDate'); + // Check if expiryDate is available and format it to YYYY-MM-DD + if (expiryDate) { + var formattedDate = expiryDate.split('T')[0]; + fp.setDate(formattedDate); + } + }); } function select_user(borrowernumber, borrower, relationship) { -- 2.39.5