From 6485ce2c7e476766eded0e4f5b18d99b3c50577a Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Fri, 15 Nov 2024 17:15:57 +0000 Subject: [PATCH] Bug 38254: Treat NULL dateexpity as not expired in patron autocomplete To test: 1. Add some NULL patron dateexpiry dates. 2. Make sure PatronAutoComplete is on. 3. Try searching for some patrons with NULL patron dateexpiry dates. 4. Search doesn't complete, see JS error in console. 5. APPLY PATCH and try again 6. Now NULL dateexpiry patrons should be returned in the autocomplete. 7. Make sure patrons with dateexpiry in past still show the 'Expired' badge. 8. Patrons with a dateexpiry in the future or a NULL dateexpiry should not shhow the 'Expired' badge. --- koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index e993f8fe01..d6e6ece3cf 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -697,10 +697,12 @@ function patron_autocomplete(node, options) { } let new_date = new Date(); let today = Date.parse($date_to_rfc3339($date(new_date.toString()))); - let expiration = Date.parse( - $date_to_rfc3339($date(item.expiry_date.toString())) - ); - let expired = today > expiration; + if ( item.expiry_date ) { + let expiration = Date.parse($date_to_rfc3339($date(item.expiry_date.toString()))); + } else { + expiration = 0; + } + let expired = item.expiry_date ? today > Date.parse($date_to_rfc3339($date(item.expiry_date.toString()))) : false; return $("
  • ") .addClass(loggedInClass) .data("ui-autocomplete-item", item) -- 2.39.2