From 262cbe360cd7385aad7c6866d635cc038ea06146 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Tue, 5 Dec 2023 16:06:04 +0000 Subject: [PATCH] Bug 35341: Fix circulation rule dates being overwritten This patch correctly sets the values of the date fields so that they are not overwritten when only one is amended. It also amends the collumn indexes being used in the click event as new columns have been added without these being updated Test plan: 1) Navigate to Administration > Circulation and fine rules 2) Add a new circulation rule for a category of your choice 3) For the "All" rule, add the date 31/12/2023 to both the Hard due date and No automatic renewal after (hard limit) (NARAHL) columns and save 4) Now edit the rule that you created. 5) Change the two columns above to 01/12/2023 and click save 6) Edit the rule again and change the Hard due date to 15/12/2023. Click save 7) Note that the date for your rule in the NARAHL has changed to 31/12/2023 despite not being edited 8) Click edit again, and change the NARAHL date to 15/12/2023 and save. 9) This time the date in Hard due date will have changed to 31/12/2023 10) Apply patch 11) Edit the dates individually a few times and this time your rule should update correctly --- .../prog/en/modules/admin/smart-rules.tt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt index 74c962503b..c3d8446cbd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -475,7 +475,7 @@ - +
[% INCLUDE 'date-format.inc' %]
@@ -1504,9 +1504,20 @@ $(current_column).find("input[type='text']").val(note); } else if ( i == 9 || i == 26 ) { // specific processing for Hard due date and No automatic renewal after (hard limit) + var dateCheck = /\d{1,2}\/\d{1,2}\/\d{2,4}/ if (itm_text) { - input_values = itm_text.split(' '); - $(current_column).find("input[type='text']").val( input_values[1] ); + if(i == 9) { + var input_values = itm_text.split(' '); + var date = input_values[1]; + itm_text = dateCheck.test(date) ? date : '' + } + var formatted_date = flatpickr.formatDate(new Date(itm_text), "Y-m-d") + $(current_column).find("input[type='hidden']").val(formatted_date); + $(current_column).find("input[type='text']").val(itm_text); + $(current_column).find("select").val(itm_code); + } else { + $(current_column).find("input[type='hidden']").val(''); + $(current_column).find("input[type='text']").val(''); $(current_column).find("select").val(itm_code); } } else if ( i == 16 ) { -- 2.37.1 (Apple Git-137.1)