Verwaltung Überstunden anzeige, Buttons am unteren ende der Seite

This commit is contained in:
2026-02-09 17:37:06 +01:00
parent c396fe7d0e
commit cf1ca107f5
4 changed files with 326 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ const { requireVerwaltung } = require('../middleware/auth');
const { getWeekDatesFromCalendarWeek } = require('../helpers/utils');
const { generatePDFToBuffer } = require('../services/pdf-service');
const { getHolidaysForDateRange } = require('../services/feiertage-service');
const { getCurrentOvertimeForUser } = require('../services/overtime-service');
// Routes registrieren
function registerVerwaltungRoutes(app) {
@@ -190,6 +191,35 @@ function registerVerwaltungRoutes(app) {
);
});
// API: Aktuelle Überstunden für mehrere Mitarbeiter (Batch für Verwaltungs-Übersicht)
app.get('/api/verwaltung/employees/current-overtime', requireVerwaltung, (req, res) => {
const userIdsParam = req.query.userIds;
if (!userIdsParam || typeof userIdsParam !== 'string') {
return res.status(400).json({ error: 'userIds (kommagetrennt) erforderlich' });
}
const userIds = userIdsParam.split(',').map((id) => parseInt(id.trim(), 10)).filter((id) => !isNaN(id));
if (userIds.length === 0) {
return res.json({});
}
const result = {};
let pending = userIds.length;
userIds.forEach((userId) => {
getCurrentOvertimeForUser(userId, db, (err, currentOvertime) => {
if (err) {
result[String(userId)] = null;
} else {
result[String(userId)] = currentOvertime != null ? currentOvertime : 0;
}
pending--;
if (pending === 0) {
res.json(result);
}
});
});
});
// API: Überstunden- und Urlaubsstatistiken für einen User abrufen
app.get('/api/verwaltung/user/:id/stats', requireVerwaltung, (req, res) => {
const userId = req.params.id;