diff --git a/public/js/main.js b/public/js/main.js index 03fdc83..bedf6cb 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -1086,20 +1086,19 @@ async function loadMonthlyView() { updateStatistics(entries); updateBridgeDaysDisplay(); - // Show/hide PDF export button based on whether last day has complete times + // Show/hide PDF export button based on whether the month is complete (in the past) const pdfButton = document.getElementById('btnExportPDF'); const pdfButtonMobile = document.getElementById('btnExportPDFMobile'); - // Check if last day of month has start and end time (and they're different) - const lastDayDate = `${displayYear}-${String(displayMonth + 1).padStart(2, '0')}-${String(lastDay).padStart(2, '0')}`; - const lastDayEntry = entries.find(e => e.date === lastDayDate); + // Check if the displayed month is in the past (not current month or future) + const today = new Date(); + const currentYear = today.getFullYear(); + const currentMonth = today.getMonth(); - const isLastDayComplete = lastDayEntry && - lastDayEntry.startTime && - lastDayEntry.endTime && - lastDayEntry.startTime !== lastDayEntry.endTime; + const isMonthComplete = (displayYear < currentYear) || + (displayYear === currentYear && displayMonth < currentMonth); - if (isLastDayComplete) { + if (isMonthComplete) { pdfButton.style.display = ''; if (pdfButtonMobile) pdfButtonMobile.style.display = ''; } else {