diff --git a/resources/views/hr/attendances/index.blade.php b/resources/views/hr/attendances/index.blade.php index 7abcf889..22488698 100644 --- a/resources/views/hr/attendances/index.blade.php +++ b/resources/views/hr/attendances/index.blade.php @@ -277,6 +277,27 @@ function loadTabData(tab) { document.getElementById('statsMonth').addEventListener('change', onPeriodChange); function onPeriodChange() { + const year = parseInt(document.getElementById('statsYear').value); + const month = parseInt(document.getElementById('statsMonth').value); + + // 해당 월의 시작일 + const startDate = `${year}-${String(month).padStart(2, '0')}-01`; + + // 해당 월의 마지막 날 계산 (현재 월이면 오늘 날짜) + const now = new Date(); + const isCurrentMonth = (year === now.getFullYear() && month === (now.getMonth() + 1)); + let endDate; + if (isCurrentMonth) { + endDate = now.toISOString().split('T')[0]; + } else { + const lastDay = new Date(year, month, 0).getDate(); + endDate = `${year}-${String(month).padStart(2, '0')}-${String(lastDay).padStart(2, '0')}`; + } + + // 시작일/종료일 입력 필드 업데이트 + document.querySelector('input[name="date_from"]').value = startDate; + document.querySelector('input[name="date_to"]').value = endDate; + refreshStats(); if (tabLoaded.calendar) { tabLoaded.calendar = false;