Umstellung auf anzeige x h y min

This commit is contained in:
2026-02-13 12:21:43 +01:00
parent 23c255438b
commit af1f6efb40
8 changed files with 117 additions and 94 deletions

View File

@@ -51,7 +51,7 @@ async function loadUserStats() {
const currentOvertimeEl = document.getElementById('currentOvertime');
if (currentOvertimeEl) {
const overtime = stats.currentOvertime || 0;
currentOvertimeEl.textContent = overtime >= 0 ? `+${overtime.toFixed(2)}` : overtime.toFixed(2);
currentOvertimeEl.textContent = (overtime >= 0 ? '+' : '') + formatHoursMin(overtime);
currentOvertimeEl.style.color = overtime >= 0 ? '#27ae60' : '#e74c3c';
// Auch die Border-Farbe des Cards anpassen
const overtimeCard = currentOvertimeEl.closest('.stat-card');
@@ -548,27 +548,27 @@ function renderWeek() {
// Stunden-Anzeige für halben Tag Urlaub berechnen
let hoursDisplay = '';
if (isFullDayVacation) {
hoursDisplay = fullDayHours.toFixed(2) + ' h (Urlaub)';
hoursDisplay = formatHoursMin(fullDayHours) + ' (Urlaub)';
} else if (isHalfDayVacation) {
const halfHours = fullDayHours / 2;
const workHours = hours || 0; // Das sind die gearbeiteten Stunden (ohne Urlaub)
const totalHours = halfHours + workHours;
if (workHours > 0.01) {
hoursDisplay = totalHours.toFixed(2) + ' h (' + halfHours.toFixed(2) + ' h Urlaub + ' + workHours.toFixed(2) + ' h)';
hoursDisplay = formatHoursMin(totalHours) + ' (' + formatHoursMin(halfHours) + ' Urlaub + ' + formatHoursMin(workHours) + ')';
} else {
hoursDisplay = halfHours.toFixed(2) + ' h (Urlaub)';
hoursDisplay = formatHoursMin(halfHours) + ' (Urlaub)';
}
} else if (isSick) {
hoursDisplay = fullDayHours.toFixed(2) + ' h (Krank)';
hoursDisplay = formatHoursMin(fullDayHours) + ' (Krank)';
} else if (isHoliday && isWeekend) {
// Feiertag am Wochenende: keine Tagesarbeitsstunden
hoursDisplay = (hours ? hours.toFixed(2) : '0') + ' h (Feiertag)';
hoursDisplay = formatHoursMin(hours || 0) + ' (Feiertag)';
} else if (isHoliday && !hours) {
hoursDisplay = fullDayHours.toFixed(2) + ' h (Feiertag)';
hoursDisplay = formatHoursMin(fullDayHours) + ' (Feiertag)';
} else if (isHoliday && hours) {
hoursDisplay = fullDayHours.toFixed(2) + ' + ' + hours.toFixed(2) + ' h (Überst.)';
hoursDisplay = formatHoursMin(fullDayHours) + ' + ' + formatHoursMin(hours) + ' (Überst.)';
} else {
hoursDisplay = hours.toFixed(2) + ' h';
hoursDisplay = formatHoursMin(hours);
}
const requiredBreak = (startTime && endTime) ? calculateRequiredBreakMinutes(startTime, endTime) : null;
@@ -741,7 +741,7 @@ function renderWeek() {
`;
document.getElementById('timesheetTable').innerHTML = html;
document.getElementById('totalHours').textContent = totalHours.toFixed(2) + ' h';
document.getElementById('totalHours').textContent = formatHoursMin(totalHours);
// Überstunden-Berechnung (startDate und endDate sind bereits oben deklariert)
@@ -1017,14 +1017,14 @@ function updateOvertimeDisplay() {
if (overtimeSummaryItem && overtimeHoursSpan) {
overtimeSummaryItem.style.display = 'block';
const sign = overtimeHours >= 0 ? '+' : '';
overtimeHoursSpan.textContent = `${sign}${overtimeHours.toFixed(2)} h`;
overtimeHoursSpan.textContent = (sign === '+' ? '+' : '') + formatHoursMin(overtimeHours);
overtimeHoursSpan.style.color = overtimeHours >= 0 ? '#27ae60' : '#e74c3c';
}
// Gesamtstunden-Anzeige aktualisieren
const totalHoursElement = document.getElementById('totalHours');
if (totalHoursElement) {
totalHoursElement.textContent = totalHoursWithVacation.toFixed(2) + ' h';
totalHoursElement.textContent = formatHoursMin(totalHoursWithVacation);
}
}
@@ -1272,7 +1272,7 @@ async function saveEntry(input) {
if (hoursElement) {
if (isFullDayVacation) {
// Ganzer Tag Urlaub: Zeige fullDayHours mit "(Urlaub)" Label
hoursElement.textContent = fullDayHours.toFixed(2) + ' h (Urlaub)';
hoursElement.textContent = formatHoursMin(fullDayHours) + ' (Urlaub)';
currentEntries[date].total_hours = fullDayHours;
} else if (isHalfDayVacation) {
// Halber Tag Urlaub: Berechne Stunden aus Start/Ende falls vorhanden
@@ -1293,9 +1293,9 @@ async function saveEntry(input) {
const totalHours = halfHours + workHours;
if (workHours > 0) {
hoursElement.textContent = totalHours.toFixed(2) + ' h (' + halfHours.toFixed(2) + ' h Urlaub + ' + workHours.toFixed(2) + ' h)';
hoursElement.textContent = formatHoursMin(totalHours) + ' (' + formatHoursMin(halfHours) + ' Urlaub + ' + formatHoursMin(workHours) + ')';
} else {
hoursElement.textContent = halfHours.toFixed(2) + ' h (Urlaub)';
hoursElement.textContent = formatHoursMin(halfHours) + ' (Urlaub)';
}
currentEntries[date].total_hours = totalHours;
} else {
@@ -1303,15 +1303,15 @@ async function saveEntry(input) {
const d = new Date(date);
const isWeekendHoliday = isHoliday && (d.getDay() === 6 || d.getDay() === 0);
if (isSick) {
hoursElement.textContent = fullDayHours.toFixed(2) + ' h (Krank)';
hoursElement.textContent = formatHoursMin(fullDayHours) + ' (Krank)';
} else if (isWeekendHoliday) {
hoursElement.textContent = (hours ? hours.toFixed(2) : '0') + ' h (Feiertag)';
hoursElement.textContent = formatHoursMin(hours || 0) + ' (Feiertag)';
} else if (isHoliday && !hours) {
hoursElement.textContent = fullDayHours.toFixed(2) + ' h (Feiertag)';
hoursElement.textContent = formatHoursMin(fullDayHours) + ' (Feiertag)';
} else if (isHoliday && hours) {
hoursElement.textContent = fullDayHours.toFixed(2) + ' + ' + hours.toFixed(2) + ' h (Überst.)';
hoursElement.textContent = formatHoursMin(fullDayHours) + ' + ' + formatHoursMin(hours) + ' (Überst.)';
} else {
hoursElement.textContent = hours.toFixed(2) + ' h';
hoursElement.textContent = formatHoursMin(hours);
}
}
}
@@ -1446,10 +1446,10 @@ async function saveEntry(input) {
const isHalfDayVacation = vacationType === 'half';
const fullDayHours = getFullDayHours();
let hoursText = result.total_hours.toFixed(2) + ' h';
let hoursText = formatHoursMin(result.total_hours);
if (isFullDayVacation) {
hoursText = fullDayHours.toFixed(2) + ' h (Urlaub)';
hoursText = formatHoursMin(fullDayHours) + ' (Urlaub)';
} else if (isHalfDayVacation) {
// Bei halbem Tag Urlaub: result.total_hours enthält nur die gearbeiteten Stunden
// Die Urlaubsstunden müssen addiert werden
@@ -1458,25 +1458,25 @@ async function saveEntry(input) {
const totalHours = halfHours + workHours; // Gesamt = Urlaub + gearbeitet
if (workHours > 0.01) {
hoursText = totalHours.toFixed(2) + ' h (' + halfHours.toFixed(2) + ' h Urlaub + ' + workHours.toFixed(2) + ' h)';
hoursText = formatHoursMin(totalHours) + ' (' + formatHoursMin(halfHours) + ' Urlaub + ' + formatHoursMin(workHours) + ')';
} else {
hoursText = halfHours.toFixed(2) + ' h (Urlaub)';
hoursText = formatHoursMin(halfHours) + ' (Urlaub)';
}
// Aktualisiere currentEntries mit den Gesamtstunden
currentEntries[date].total_hours = totalHours;
} else if (isSick) {
hoursText = fullDayHours.toFixed(2) + ' h (Krank)';
hoursText = formatHoursMin(fullDayHours) + ' (Krank)';
} else if (isHoliday) {
const d = new Date(date);
const isWeekendHoliday = (d.getDay() === 6 || d.getDay() === 0);
if (isWeekendHoliday) {
hoursText = (result.total_hours || 0).toFixed(2) + ' h (Feiertag)';
hoursText = formatHoursMin(result.total_hours || 0) + ' (Feiertag)';
} else if (result.total_hours <= fullDayHours) {
hoursText = fullDayHours.toFixed(2) + ' h (Feiertag)';
hoursText = formatHoursMin(fullDayHours) + ' (Feiertag)';
} else {
const overtime = result.total_hours - fullDayHours;
hoursText = fullDayHours.toFixed(2) + ' + ' + overtime.toFixed(2) + ' h (Überst.)';
hoursText = formatHoursMin(fullDayHours) + ' + ' + formatHoursMin(overtime) + ' (Überst.)';
}
}
@@ -1492,7 +1492,7 @@ async function saveEntry(input) {
Object.values(currentEntries).forEach(e => {
totalHours += e.total_hours || 0;
});
document.getElementById('totalHours').textContent = totalHours.toFixed(2) + ' h';
document.getElementById('totalHours').textContent = formatHoursMin(totalHours);
// Überstunden-Anzeige aktualisieren (bei jeder Änderung)
updateOvertimeDisplay();
@@ -1591,7 +1591,7 @@ function checkWeekComplete() {
if (overtimeValue > fullDayHours) {
if (!startTime || !endTime || startTime === '' || endTime === '') {
allWeekdaysFilled = false;
missingFields.push(formatDateDE(dateStr) + ' (bei Überstunden > ' + fullDayHours.toFixed(2) + 'h müssen Start/Ende vorhanden sein)');
missingFields.push(formatDateDE(dateStr) + ' (bei Überstunden > ' + formatHoursMin(fullDayHours) + ' müssen Start/Ende vorhanden sein)');
continue; // Weiter zum nächsten Tag
}
}
@@ -2077,22 +2077,22 @@ function toggleSickStatus(dateStr) {
if (newStatus) {
// Krank: Zeige fullDayHours mit "(Krank)" Label
hoursElement.textContent = fullDayHours.toFixed(2) + ' h (Krank)';
hoursElement.textContent = formatHoursMin(fullDayHours) + ' (Krank)';
currentEntries[dateStr].total_hours = fullDayHours;
} else {
// Zurück zu normaler Anzeige basierend auf anderen Status
const d = new Date(dateStr);
const isWeekendHoliday = isHoliday && (d.getDay() === 6 || d.getDay() === 0);
if (isFullDayVacation) {
hoursElement.textContent = fullDayHours.toFixed(2) + ' h (Urlaub)';
hoursElement.textContent = formatHoursMin(fullDayHours) + ' (Urlaub)';
} else if (isWeekendHoliday) {
hoursElement.textContent = (hours ? hours.toFixed(2) : '0') + ' h (Feiertag)';
hoursElement.textContent = formatHoursMin(hours || 0) + ' (Feiertag)';
} else if (isHoliday && !hours) {
hoursElement.textContent = fullDayHours.toFixed(2) + ' h (Feiertag)';
hoursElement.textContent = formatHoursMin(fullDayHours) + ' (Feiertag)';
} else if (isHoliday && hours) {
hoursElement.textContent = fullDayHours.toFixed(2) + ' + ' + hours.toFixed(2) + ' h (Überst.)';
hoursElement.textContent = formatHoursMin(fullDayHours) + ' + ' + formatHoursMin(hours) + ' (Überst.)';
} else {
hoursElement.textContent = hours.toFixed(2) + ' h';
hoursElement.textContent = formatHoursMin(hours);
}
}
}