From b698493e1a1918f4f0f44aa74ce1b925c4b41ef6 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 23 Feb 2026 09:48:48 +0530 Subject: [PATCH] Changed logic in calender blade file --- resources/views/forms/calendar.blade.php | 82 ++++++++++++------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/resources/views/forms/calendar.blade.php b/resources/views/forms/calendar.blade.php index 1e22410..bf4c87f 100644 --- a/resources/views/forms/calendar.blade.php +++ b/resources/views/forms/calendar.blade.php @@ -64,57 +64,57 @@ document.addEventListener('DOMContentLoaded', function () { }); - // function updateWorkingDays(date) { - // let totalDays = new Date( - // date.getFullYear(), - // date.getMonth()+1, - // 0 - // ).getDate(); - - // let workingDays = totalDays - selectedDates.length; - // // document.querySelector('input[name="working_days"]').value = workingDays; - - // const input = document.querySelector('#working_days'); - - // input.value = workingDays; - - // input.dispatchEvent(new Event('input')); - - // const monthInput = document.querySelector('#month'); - // monthInput.value = date.getMonth() + 1; // 1–12 month number - // monthInput.dispatchEvent(new Event('input')); - - // const yearInput = document.querySelector('#year'); - // yearInput.value = date.getFullYear(); - // yearInput.dispatchEvent(new Event('input')); - - // const selectedDatesInput = document.querySelector('#selected_dates'); - // selectedDatesInput.value = selectedDates.join(','); - // selectedDatesInput.dispatchEvent(new Event('input')); - - // } - - function updateWorkingDays(date) { + function updateWorkingDays(date) { let totalDays = new Date( date.getFullYear(), - date.getMonth() + 1, + date.getMonth()+1, 0 ).getDate(); let workingDays = totalDays - selectedDates.length; + // document.querySelector('input[name="working_days"]').value = workingDays; - // Set values only - document.querySelector('#working_days').value = workingDays; - document.querySelector('#month').value = date.getMonth() + 1; - document.querySelector('#year').value = date.getFullYear(); - document.querySelector('#selected_dates').value = selectedDates.join(','); + const input = document.querySelector('#working_days'); + + input.value = workingDays; + + input.dispatchEvent(new Event('input')); + + const monthInput = document.querySelector('#month'); + monthInput.value = date.getMonth() + 1; // 1–12 month number + monthInput.dispatchEvent(new Event('input')); + + const yearInput = document.querySelector('#year'); + yearInput.value = date.getFullYear(); + yearInput.dispatchEvent(new Event('input')); + + const selectedDatesInput = document.querySelector('#selected_dates'); + selectedDatesInput.value = selectedDates.join(','); + selectedDatesInput.dispatchEvent(new Event('input')); - // Trigger only ONE update (important) - document - .querySelector('#selected_dates') - .dispatchEvent(new Event('input')); } + // function updateWorkingDays(date) { + // let totalDays = new Date( + // date.getFullYear(), + // date.getMonth() + 1, + // 0 + // ).getDate(); + + // let workingDays = totalDays - selectedDates.length; + + // // Set values only + // document.querySelector('#working_days').value = workingDays; + // document.querySelector('#month').value = date.getMonth() + 1; + // document.querySelector('#year').value = date.getFullYear(); + // document.querySelector('#selected_dates').value = selectedDates.join(','); + + // // Trigger only ONE update (important) + // document + // .querySelector('#selected_dates') + // .dispatchEvent(new Event('input')); + // } + calendar.render(); });