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,29 @@ function registerVerwaltungRoutes(app) {
});
});
// API: Krankheitstage für einen User im aktuellen Jahr abrufen
app.get('/api/verwaltung/user/:id/sick-days', requireVerwaltung, (req, res) => {
const userId = req.params.id;
const currentYear = new Date().getFullYear();
const yearStart = `${currentYear}-01-01`;
const yearEnd = `${currentYear}-12-31`;
db.all(`SELECT DISTINCT date
FROM timesheet_entries
WHERE user_id = ? AND date >= ? AND date <= ? AND sick_status = 1
ORDER BY date`,
[userId, yearStart, yearEnd],
(err, entries) => {
if (err) {
return res.status(500).json({ error: 'Fehler beim Abrufen der Krankheitstage' });
}
const sickDays = entries ? entries.length : 0;
res.json({ sickDays: sickDays, year: currentYear });
}
);
});
// API: Überstunden- und Urlaubsstatistiken für einen User abrufen
app.get('/api/verwaltung/user/:id/stats', requireVerwaltung, (req, res) => {
const userId = req.params.id;