Collabsable automations

This commit is contained in:
Carsten Graf
2026-01-26 10:48:39 +01:00
parent bbb176dbe3
commit 00669be250
3 changed files with 108 additions and 26 deletions

View File

@@ -113,6 +113,10 @@
<div style="display: inline-block; margin-right: 20px;">
<strong>Kalenderwochen:</strong> <span><%= employee.weeks.length %></span>
</div>
<div style="display: inline-block; margin-right: 20px;">
<strong>Krankheitstage (<span class="sick-days-year"><%= new Date().getFullYear() %></span>):</strong>
<span class="sick-days-count" data-user-id="<%= employee.user.id %>" style="color: #e74c3c;">-</span>
</div>
</div>
</div>
<button class="btn btn-secondary btn-sm toggle-employee-btn" data-employee-index="<%= employeeIndex %>">
@@ -330,6 +334,36 @@
// Statistiken für alle Wochen initial laden
document.querySelectorAll('.group-stats').forEach(statsDiv => loadStatsForDiv(statsDiv));
// Krankheitstage für alle Mitarbeiter laden
async function loadSickDays() {
const sickDaysElements = document.querySelectorAll('.sick-days-count');
const userIds = Array.from(sickDaysElements).map(el => el.dataset.userId);
const uniqueUserIds = [...new Set(userIds)];
for (const userId of uniqueUserIds) {
try {
const response = await fetch(`/api/verwaltung/user/${userId}/sick-days`);
if (!response.ok) {
throw new Error('Fehler beim Laden der Krankheitstage');
}
const data = await response.json();
// Alle Elemente für diesen User aktualisieren
document.querySelectorAll(`.sick-days-count[data-user-id="${userId}"]`).forEach(el => {
el.textContent = data.sickDays || 0;
});
} catch (error) {
console.error('Fehler beim Laden der Krankheitstage für User', userId, ':', error);
document.querySelectorAll(`.sick-days-count[data-user-id="${userId}"]`).forEach(el => {
el.textContent = '-';
});
}
}
}
// Krankheitstage beim Laden der Seite abrufen
loadSickDays();
// Überstunden-Offset speichern
document.querySelectorAll('.save-overtime-offset-btn').forEach(btn => {
btn.addEventListener('click', async function() {