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 <roman.dolny@jezuici.pl>
Signed-off-by: Jan Kissig <jkissig@th-wildau.de>
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
This commit is contained in:
Sam Lau 2024-07-03 20:09:37 +00:00 committed by Laura Escamilla
parent 29c404f63e
commit 8b1d39d58f
No known key found for this signature in database
GPG Key ID: B5DEB5FD2FCDA5D8
2 changed files with 13 additions and 0 deletions

View File

@ -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 %]</option
>
[% 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 %]</option
>
[% END %]

View File

@ -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) {