Changed logic in calender blade file #370
@@ -64,57 +64,57 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// function updateWorkingDays(date) {
|
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) {
|
|
||||||
let totalDays = new Date(
|
let totalDays = new Date(
|
||||||
date.getFullYear(),
|
date.getFullYear(),
|
||||||
date.getMonth() + 1,
|
date.getMonth()+1,
|
||||||
0
|
0
|
||||||
).getDate();
|
).getDate();
|
||||||
|
|
||||||
let workingDays = totalDays - selectedDates.length;
|
let workingDays = totalDays - selectedDates.length;
|
||||||
|
// document.querySelector('input[name="working_days"]').value = workingDays;
|
||||||
|
|
||||||
// Set values only
|
const input = document.querySelector('#working_days');
|
||||||
document.querySelector('#working_days').value = workingDays;
|
|
||||||
document.querySelector('#month').value = date.getMonth() + 1;
|
input.value = workingDays;
|
||||||
document.querySelector('#year').value = date.getFullYear();
|
|
||||||
document.querySelector('#selected_dates').value = selectedDates.join(',');
|
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();
|
calendar.render();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user