diff --git a/app/static/app/js/dbcontrol.js b/app/static/app/js/dbcontrol.js index a3e1df7..51794dc 100644 --- a/app/static/app/js/dbcontrol.js +++ b/app/static/app/js/dbcontrol.js @@ -240,9 +240,15 @@ function filterEntriesByMonthYear(month, year) { // Filter nach Monat und Jahr const filteredEntries = allEntries.filter(entry => { const entryDate = new Date(entry.date); // Konvertiere das date-Feld in ein Date-Objekt + var actualYear = year; const matchesMonth = month ? entryDate.getMonth() + 1 === month : true; // +1 da getMonth() 0-basiert ist - const matchesYear = year ? entryDate.getFullYear() === year : true; + if (entryDate.getMonth() + 1 >= 9){ + actualYear = actualYear - 1; + } else { + actualYear = actualYear; + }; + const matchesYear = actualYear ? entryDate.getFullYear() === actualYear : true; return matchesMonth && matchesYear; }); diff --git a/app/static/app/js/home.js b/app/static/app/js/home.js index 513ffde..da52656 100644 --- a/app/static/app/js/home.js +++ b/app/static/app/js/home.js @@ -207,7 +207,11 @@ async function getActualDataAndFillView(monat = currentDate.getMonth() + 1, jahr document.getElementById('monthHourOther').innerText = formatDuration(sumDurations(filteredEntries,3,true), true) // Jahres Ansicht füllen - var yearData = await filterEntriesByMonthYear(null, currentDate.getFullYear()); + var requestYear = currentDate.getFullYear() + if (currentDate.getMonth() +1 >= 9) { + requestYear += 1; + } + var yearData = await filterEntriesByMonthYear(null, requestYear) yearData = formatDuration(sumDurations(yearData, null, true), true) document.getElementById('yearHours').innerText = yearData document.getElementById('yearRest').innerText = 600 - parseInt(yearData) @@ -382,15 +386,25 @@ document.getElementById('dashbord_month_area').addEventListener('click', () =>{ }) document.getElementById('btn-month-before').addEventListener('click', () =>{ - diffMonth = ((monate[new Date().getMonth() + diffMonth]) != 'September') ? diffMonth - 1 : diffMonth; - // document.getElementById('actualMonthName').innerHTML = monate[new Date().getMonth() + diffMonth]; - getActualDataAndFillView(new Date().getMonth() + diffMonth + 1) + if (diffMonth === 0) { + diffMonth = 11; + getActualDataAndFillView(new Date().getMonth() + diffMonth + 1) + } else { + diffMonth = ((monate[new Date().getMonth() + diffMonth]) != 'September') ? diffMonth - 1 : diffMonth; + // document.getElementById('actualMonthName').innerHTML = monate[new Date().getMonth() + diffMonth]; + getActualDataAndFillView(new Date().getMonth() + diffMonth + 1) + }; }); document.getElementById('btn-month-next').addEventListener('click', () =>{ - diffMonth = ((monate[new Date().getMonth() + diffMonth]) != 'August') ? diffMonth + 1 : diffMonth; - // document.getElementById('actualMonthName').innerHTML = monate[new Date().getMonth() + diffMonth]; - getActualDataAndFillView(new Date().getMonth() + diffMonth + 1) + if (diffMonth === 11) { + diffMonth = 0; + getActualDataAndFillView(new Date().getMonth() + diffMonth + 1) + } else { + diffMonth = ((monate[new Date().getMonth() + diffMonth]) != 'August') ? diffMonth + 1 : diffMonth; + // document.getElementById('actualMonthName').innerHTML = monate[new Date().getMonth() + diffMonth]; + getActualDataAndFillView(new Date().getMonth() + diffMonth + 1) + }; }) function setNewCalsOfMonth(TheMonth) {