3 Commits
Author SHA1 Message Date
mike 2c24b4d71d Release v0.41.1 Versionsanzeige als Footer 2026-06-19 15:19:15 +02:00
mike 9308d8cf93 Release v0.40.0 Feiertagslogik 2026-06-19 14:56:50 +02:00
mike faa91e4425 README ergänzen 2026-06-18 15:24:10 +02:00
5 changed files with 497 additions and 299 deletions
+20
View File
@@ -0,0 +1,20 @@
# Changelog
## v0.41.1
- Versionsanzeige in einen dezenten Footer rechts unten verschoben
- Repository-Link ergänzt
- Version zentral über `APP_VERSION` gesetzt
## v0.41.0
- Versionsanzeige im Tool ergänzt
- CSV-Export enthält Tool-Version
- Exportdateiname enthält Tool-Version
## v0.40.0
- Feiertagslogik für Nordrhein-Westfalen, Bayern, Niedersachsen und Hamburg ergänzt
- Zusatzoption Bayern inkl. Mariä Himmelfahrt
- Feiertage werden mit 0:00 Sollzeit bewertet
- Tagesdetails und Export um Feiertagsinformationen ergänzt
+28
View File
@@ -0,0 +1,28 @@
# qplanner-arbeitszeit-auswertung
Browserbasierte Auswertung von qPlanner CSV-Exporten zur Berechnung von Plus- und Minusstunden.
## Version
Aktueller Stand: v0.41.1
## Funktionen
- CSV-Upload im Browser
- Auswertung der Netto-Arbeitszeit
- Sollzeit Montag bis Freitag: 8:00 Stunden
- Sollzeit Samstag und Sonntag: 0:00 Stunden
- Gesetzliche Feiertage je Bundesland: 0:00 Stunden
- Unterstützte Bundesländer: Bayern, Niedersachsen, Hamburg, Nordrhein-Westfalen
- Zusatzoption: Bayern inkl. Mariä Himmelfahrt
- Monatsübersicht
- Tagesdetails inklusive Wochentag und Feiertag
- CSV-Export inklusive Tool-Version
## Datenschutz
Die CSV-Datei wird ausschließlich lokal im Browser verarbeitet. Es findet kein Upload auf einen Server statt.
## Repository
https://git.mike-lindner.net/mike/qplanner-arbeitszeit-auswertung
+305 -234
View File
@@ -1,6 +1,9 @@
const APP_VERSION = 'v0.41.1';
const fileInput = document.getElementById('csvFile'); const fileInput = document.getElementById('csvFile');
const dropZone = document.getElementById('dropZone'); const dropZone = document.getElementById('dropZone');
const targetTimeInput = document.getElementById('targetTime'); const targetTimeInput = document.getElementById('targetTime');
const federalStateInput = document.getElementById('federalState');
const errorBox = document.getElementById('errorBox'); const errorBox = document.getElementById('errorBox');
const summary = document.getElementById('summary'); const summary = document.getElementById('summary');
const results = document.getElementById('results'); const results = document.getElementById('results');
@@ -8,6 +11,9 @@ const monthTable = document.getElementById('monthTable');
const dayTable = document.getElementById('dayTable'); const dayTable = document.getElementById('dayTable');
const exportButton = document.getElementById('exportCsv'); const exportButton = document.getElementById('exportCsv');
const formatHint = document.getElementById('formatHint'); const formatHint = document.getElementById('formatHint');
const appVersion = document.getElementById('appVersion');
if (appVersion) appVersion.textContent = APP_VERSION;
let lastResult = null; let lastResult = null;
let lastFileText = null; let lastFileText = null;
@@ -17,9 +23,8 @@ fileInput.addEventListener('change', event => {
if (file) readFile(file); if (file) readFile(file);
}); });
targetTimeInput.addEventListener('change', () => { targetTimeInput.addEventListener('change', rerunAnalysis);
if (lastFileText) analyseCsv(lastFileText); federalStateInput.addEventListener('change', rerunAnalysis);
});
exportButton.addEventListener('click', () => { exportButton.addEventListener('click', () => {
if (lastResult) exportResultCsv(lastResult); if (lastResult) exportResultCsv(lastResult);
@@ -44,6 +49,10 @@ dropZone.addEventListener('drop', event => {
if (file) readFile(file); if (file) readFile(file);
}); });
function rerunAnalysis() {
if (lastFileText) analyseCsv(lastFileText);
}
function readFile(file) { function readFile(file) {
hideError(); hideError();
@@ -62,158 +71,193 @@ function readFile(file) {
} }
function analyseCsv(text) { function analyseCsv(text) {
try { hideError();
const rows = parseCsv(text);
if (rows.length < 2) throw new Error('Die CSV enthält keine auswertbaren Daten.');
const headers = rows[0].map(h => h.trim().replace(/^\uFEFF/, '')); const rows = parseCsv(text);
const dataRows = rows.slice(1).filter(row => row.some(cell => String(cell).trim() !== '')); if (rows.length < 2) {
showError('Die CSV-Datei enthält keine auswertbaren Daten.');
const targetMinutes = timeToMinutes(targetTimeInput.value || '08:00'); return;
const detectedFormat = detectFormat(headers);
let days;
if (detectedFormat === 'daily') {
days = analyseDailyFormat(headers, dataRows, targetMinutes);
formatHint.textContent = 'Format erkannt: Tagesauswertung. Montag bis Freitag haben Sollzeit, Samstag und Sonntag werden mit 0:00 Sollzeit berechnet. Zeilen ohne Arbeitszeit werden ignoriert.';
} else if (detectedFormat === 'monthly') {
days = analyseMonthlyFormat(headers, dataRows, targetMinutes);
formatHint.textContent = 'Format erkannt: Monatsauswertung. Arbeitszeiten werden aus dem Monatsblock gelesen.';
} else {
throw new Error('Das CSV-Format wurde nicht erkannt. Benötigt wird entweder die Spalte "Tag" oder "Monat" plus "Dauer Arbeitstag".');
}
if (!days.length) throw new Error('Es wurden keine Arbeitszeiten in "Dauer Arbeitstag" gefunden.');
const months = groupByMonth(days);
const totals = {
days: days.length,
workMinutes: days.reduce((sum, day) => sum + day.workMinutes, 0),
targetMinutes: days.reduce((sum, day) => sum + day.targetMinutes, 0),
saldoMinutes: days.reduce((sum, day) => sum + day.saldoMinutes, 0)
};
lastResult = { months, days, totals };
render(lastResult);
} catch (error) {
showError(error.message);
} }
const headers = rows[0].map(normalizeHeader);
const dataRows = rows.slice(1).filter(row => row.some(cell => String(cell || '').trim() !== ''));
const targetMinutes = timeToMinutes(targetTimeInput.value || '08:00');
const state = federalStateInput.value || 'NW';
const dailyRows = analyseDailyRows(headers, dataRows, targetMinutes, state);
if (!dailyRows.length) {
showError('Es wurden keine Arbeitstage mit auswertbarer Dauer gefunden.');
return;
}
const monthlyRows = groupByMonth(dailyRows);
const totals = dailyRows.reduce((acc, row) => {
acc.days += row.workMinutes > 0 ? 1 : 0;
acc.work += row.workMinutes;
acc.target += row.targetMinutes;
acc.saldo += row.saldoMinutes;
acc.holidays += row.isHoliday ? 1 : 0;
return acc;
}, { days: 0, work: 0, target: 0, saldo: 0, holidays: 0 });
lastResult = { dailyRows, monthlyRows, totals, state, version: APP_VERSION };
renderResult(lastResult);
} }
function detectFormat(headers) { function analyseDailyRows(headers, dataRows, targetMinutes, state) {
const hasDuration = headers.includes('Dauer Arbeitstag'); const tagIndex = headers.indexOf('tag');
if (!hasDuration) return 'unknown'; const beginnIndex = headers.indexOf('arbeitstag beginn');
if (headers.includes('Tag')) return 'daily'; const endeIndex = headers.indexOf('arbeitstag ende');
if (headers.includes('Monat')) return 'monthly'; const dauerIndex = headers.indexOf('dauer arbeitstag');
return 'unknown'; const pauseIndex = headers.indexOf('ruhepause eingehalten');
} const warningIndex = headers.indexOf('warnungen');
function analyseDailyFormat(headers, dataRows, targetMinutes) { if (tagIndex === -1 || dauerIndex === -1) {
const dateIndex = headers.indexOf('Tag'); throwCsvError('Das Tagesformat wurde nicht erkannt. Erwartet werden mindestens die Spalten "Tag" und "Dauer Arbeitstag".');
const startIndex = headers.indexOf('Arbeitstag Beginn'); }
const endIndex = headers.indexOf('Arbeitstag Ende');
const durationIndex = headers.indexOf('Dauer Arbeitstag');
const breakIndex = headers.indexOf('Ruhepause eingehalten');
const warningIndex = headers.indexOf('Warnungen');
const days = []; formatHint.textContent = `Erkanntes Format: Tagesauswertung | Feiertagsregel: ${stateLabel(state)} | Tool-Version: ${APP_VERSION}`;
for (const row of dataRows) {
const date = (row[dateIndex] || '').trim();
const durationText = row[durationIndex] || '';
const workMinutes = extractSingleDuration(durationText);
// Wochenenden, Feiertage und nicht gearbeitete Tage stehen meist als "-" in Dauer Arbeitstag. return dataRows.map(row => {
if (workMinutes === null) continue; const dateText = cleanCell(row[tagIndex]);
const date = parseGermanDate(dateText);
if (!date) return null;
days.push({ const durationText = cleanCell(row[dauerIndex]);
const workMinutes = extractDurationMinutes(durationText);
if (workMinutes === null) return null;
const weekdayNumber = date.getDay();
const isWeekend = weekdayNumber === 0 || weekdayNumber === 6;
const holidayName = getHolidayName(date, state);
const isHoliday = Boolean(holidayName);
const dayTargetMinutes = isWeekend || isHoliday ? 0 : targetMinutes;
const saldoMinutes = workMinutes - dayTargetMinutes;
return {
date, date,
month: monthNameFromDate(date), dateText,
start: cleanCell(row[startIndex]), monthKey: `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}`,
end: cleanCell(row[endIndex]), monthLabel: date.toLocaleDateString('de-DE', { month: 'long', year: 'numeric' }),
weekday: weekdayLabel(date),
begin: cleanCell(row[beginnIndex]) || '-',
end: cleanCell(row[endeIndex]) || '-',
workMinutes, workMinutes,
weekday: weekdayNameFromDate(date), targetMinutes: dayTargetMinutes,
targetMinutes: targetMinutesForDate(date, targetMinutes), saldoMinutes,
saldoMinutes: workMinutes - targetMinutesForDate(date, targetMinutes), holidayName: holidayName || '-',
breakOk: cleanCell(row[breakIndex]), isHoliday,
warnings: cleanCell(row[warningIndex]) isWeekend,
}); pause: cleanCell(row[pauseIndex]) || '-',
} warnings: cleanCell(row[warningIndex]) || '-'
return days; };
}).filter(Boolean);
} }
function analyseMonthlyFormat(headers, dataRows, targetMinutes) { function groupByMonth(dailyRows) {
const monthIndex = headers.indexOf('Monat'); const months = new Map();
const durationIndex = headers.indexOf('Dauer Arbeitstag');
const stampIndex = headers.indexOf('Stempelzeit');
const days = []; dailyRows.forEach(row => {
for (const row of dataRows) { if (!months.has(row.monthKey)) {
const month = row[monthIndex] || 'Unbekannter Monat'; months.set(row.monthKey, {
const durations = extractDurations(row[durationIndex] || ''); key: row.monthKey,
const dates = stampIndex >= 0 ? extractDates(row[stampIndex] || '') : []; label: row.monthLabel,
days: 0,
durations.forEach((workMinutes, index) => { holidays: 0,
const date = dates[index] || `Tag ${index + 1}`; work: 0,
days.push({ target: 0,
date, saldo: 0
month,
start: '',
end: '',
workMinutes,
weekday: weekdayNameFromDate(date),
targetMinutes: targetMinutesForDate(date, targetMinutes),
saldoMinutes: workMinutes - targetMinutesForDate(date, targetMinutes),
breakOk: '',
warnings: ''
}); });
});
}
return days;
}
function targetMinutesForDate(date, weekdayTargetMinutes) {
const weekday = getWeekdayIndex(date);
// 0 = Sonntag, 6 = Samstag. Rufbereitschafts-/Wochenendarbeit zählt komplett als Pluszeit.
if (weekday === 0 || weekday === 6) return 0;
return weekdayTargetMinutes;
}
function getWeekdayIndex(date) {
const match = String(date).match(/^(\d{2})\.(\d{2})\.(\d{4})$/);
if (!match) return null;
const day = Number(match[1]);
const month = Number(match[2]) - 1;
const year = Number(match[3]);
return new Date(year, month, day).getDay();
}
function weekdayNameFromDate(date) {
const names = ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'];
const index = getWeekdayIndex(date);
return index === null ? '' : names[index];
}
function groupByMonth(days) {
const map = new Map();
for (const day of days) {
const key = day.month || 'Unbekannt';
if (!map.has(key)) {
map.set(key, { month: key, days: 0, workMinutes: 0, targetMinutes: 0, saldoMinutes: 0 });
} }
const month = map.get(key);
month.days += 1; const month = months.get(row.monthKey);
month.workMinutes += day.workMinutes; month.days += row.workMinutes > 0 ? 1 : 0;
month.targetMinutes += day.targetMinutes; month.holidays += row.isHoliday ? 1 : 0;
month.saldoMinutes += day.saldoMinutes; month.work += row.workMinutes;
} month.target += row.targetMinutes;
return [...map.values()]; month.saldo += row.saldoMinutes;
});
return [...months.values()].sort((a, b) => a.key.localeCompare(b.key));
}
function renderResult(result) {
summary.classList.remove('hidden');
results.classList.remove('hidden');
document.getElementById('totalDays').textContent = String(result.totals.days);
document.getElementById('totalWork').textContent = minutesToHours(result.totals.work);
document.getElementById('totalTarget').textContent = minutesToHours(result.totals.target);
const saldoElement = document.getElementById('totalSaldo');
saldoElement.textContent = minutesToSignedHours(result.totals.saldo);
saldoElement.className = saldoClass(result.totals.saldo);
monthTable.innerHTML = result.monthlyRows.map(month => `
<tr>
<td>${escapeHtml(month.label)}</td>
<td>${month.days}</td>
<td>${month.holidays}</td>
<td>${minutesToHours(month.work)}</td>
<td>${minutesToHours(month.target)}</td>
<td class="${saldoClass(month.saldo)}">${minutesToSignedHours(month.saldo)}</td>
</tr>
`).join('');
dayTable.innerHTML = result.dailyRows.map(row => `
<tr class="${row.isHoliday ? 'holiday-row' : row.isWeekend ? 'weekend-row' : ''}">
<td>${escapeHtml(row.dateText)}</td>
<td>${escapeHtml(row.weekday)}</td>
<td>${escapeHtml(row.begin)}</td>
<td>${escapeHtml(row.end)}</td>
<td>${minutesToHours(row.workMinutes)}</td>
<td>${minutesToHours(row.targetMinutes)}</td>
<td class="${saldoClass(row.saldoMinutes)}">${minutesToSignedHours(row.saldoMinutes)}</td>
<td>${escapeHtml(row.holidayName)}</td>
<td>${escapeHtml(row.pause)}</td>
<td>${escapeHtml(row.warnings)}</td>
</tr>
`).join('');
}
function exportResultCsv(result) {
const lines = [
['Tool-Version', APP_VERSION],
['Bundesland', stateLabel(result.state)],
[],
['Datum', 'Wochentag', 'Beginn', 'Ende', 'Arbeitszeit', 'Sollzeit', 'Saldo', 'Feiertag', 'Ruhepause', 'Warnungen']
];
result.dailyRows.forEach(row => {
lines.push([
row.dateText,
row.weekday,
row.begin,
row.end,
minutesToHours(row.workMinutes),
minutesToHours(row.targetMinutes),
minutesToSignedHours(row.saldoMinutes),
row.holidayName,
row.pause,
row.warnings
]);
});
const csv = lines.map(line => line.map(csvEscape).join(';')).join('\n');
const blob = new Blob([`\ufeff${csv}`], { type: 'text/csv;charset=utf-8' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `qplanner-arbeitszeit-auswertung-${APP_VERSION}.csv`;
a.click();
URL.revokeObjectURL(url);
} }
function parseCsv(text) { function parseCsv(text) {
const rows = []; const rows = [];
let row = []; let row = [];
let value = ''; let cell = '';
let inQuotes = false; let inQuotes = false;
for (let i = 0; i < text.length; i++) { for (let i = 0; i < text.length; i++) {
@@ -222,7 +266,7 @@ function parseCsv(text) {
if (char === '"') { if (char === '"') {
if (inQuotes && next === '"') { if (inQuotes && next === '"') {
value += '"'; cell += '"';
i++; i++;
} else { } else {
inQuotes = !inQuotes; inQuotes = !inQuotes;
@@ -231,70 +275,64 @@ function parseCsv(text) {
} }
if (char === ',' && !inQuotes) { if (char === ',' && !inQuotes) {
row.push(value); row.push(cell);
value = ''; cell = '';
continue; continue;
} }
if ((char === '\n' || char === '\r') && !inQuotes) { if ((char === '\n' || char === '\r') && !inQuotes) {
if (char === '\r' && next === '\n') i++; if (char === '\r' && next === '\n') i++;
row.push(value); row.push(cell);
rows.push(row); rows.push(row);
row = []; row = [];
value = ''; cell = '';
continue; continue;
} }
value += char; cell += char;
} }
if (value.length || row.length) { if (cell.length || row.length) {
row.push(value); row.push(cell);
rows.push(row); rows.push(row);
} }
return rows; return rows;
} }
function extractDurations(text) { function extractDurationMinutes(text) {
const matches = [...text.matchAll(/=(\d{1,3}):(\d{2})/g)]; if (!text || text === '-') return null;
return matches.map(match => Number(match[1]) * 60 + Number(match[2])); const match = text.match(/(?:=|^)(\d{1,3}):(\d{2})/);
}
function extractSingleDuration(text) {
const match = String(text).match(/=(\d{1,3}):(\d{2})/);
if (!match) return null; if (!match) return null;
return Number(match[1]) * 60 + Number(match[2]); return Number(match[1]) * 60 + Number(match[2]);
} }
function extractDates(text) { function parseGermanDate(value) {
return [...text.matchAll(/(\d{2}\.\d{2}\.\d{4})\s+\d{2}:\d{2}\s+-/g)].map(match => match[1]); const match = String(value || '').trim().match(/^(\d{2})\.(\d{2})\.(\d{4})$/);
} if (!match) return null;
const day = Number(match[1]);
function monthNameFromDate(date) { const month = Number(match[2]) - 1;
const match = String(date).match(/^(\d{2})\.(\d{2})\.(\d{4})$/); const year = Number(match[3]);
if (!match) return 'Unbekannt'; const date = new Date(year, month, day);
const names = ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember']; if (date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day) return null;
const monthIndex = Number(match[2]) - 1; return date;
return `${names[monthIndex] || 'Unbekannt'} ${match[3]}`;
}
function cleanCell(value) {
const text = String(value ?? '').trim();
return text === '-' ? '' : text;
} }
function timeToMinutes(time) { function timeToMinutes(time) {
const [hours, minutes] = time.split(':').map(Number); const [hours, minutes] = String(time || '08:00').split(':').map(Number);
return hours * 60 + minutes; return (hours || 0) * 60 + (minutes || 0);
} }
function formatDuration(minutes, signed = false) { function minutesToHours(minutes) {
const sign = minutes < 0 ? '-' : signed && minutes > 0 ? '+' : signed ? '±' : '';
const abs = Math.abs(minutes); const abs = Math.abs(minutes);
const hours = Math.floor(abs / 60); const hours = Math.floor(abs / 60);
const mins = abs % 60; const mins = abs % 60;
return `${sign}${hours}:${String(mins).padStart(2, '0')}`; return `${hours}:${String(mins).padStart(2, '0')}`;
}
function minutesToSignedHours(minutes) {
if (minutes === 0) return '±0:00';
return `${minutes > 0 ? '+' : '-'}${minutesToHours(minutes)}`;
} }
function saldoClass(minutes) { function saldoClass(minutes) {
@@ -303,70 +341,107 @@ function saldoClass(minutes) {
return 'neutral'; return 'neutral';
} }
function render(result) { function cleanCell(value) {
hideError(); const text = String(value ?? '').trim();
summary.classList.remove('hidden'); return text === '' ? '-' : text;
results.classList.remove('hidden');
document.getElementById('totalDays').textContent = result.totals.days;
document.getElementById('totalWork').textContent = formatDuration(result.totals.workMinutes);
document.getElementById('totalTarget').textContent = formatDuration(result.totals.targetMinutes);
const totalSaldo = document.getElementById('totalSaldo');
totalSaldo.textContent = formatDuration(result.totals.saldoMinutes, true);
totalSaldo.className = saldoClass(result.totals.saldoMinutes);
monthTable.innerHTML = result.months.map(month => `
<tr>
<td>${escapeHtml(month.month)}</td>
<td>${month.days}</td>
<td>${formatDuration(month.workMinutes)}</td>
<td>${formatDuration(month.targetMinutes)}</td>
<td class="${saldoClass(month.saldoMinutes)}">${formatDuration(month.saldoMinutes, true)}</td>
</tr>
`).join('');
dayTable.innerHTML = result.days.map(day => `
<tr>
<td>${escapeHtml(day.date)}</td>
<td>${escapeHtml(day.weekday || '')}</td>
<td>${escapeHtml(day.start || '')}</td>
<td>${escapeHtml(day.end || '')}</td>
<td>${formatDuration(day.workMinutes)}</td>
<td>${formatDuration(day.targetMinutes)}</td>
<td class="${saldoClass(day.saldoMinutes)}">${formatDuration(day.saldoMinutes, true)}</td>
<td>${escapeHtml(day.breakOk || '')}</td>
<td>${escapeHtml(day.warnings || '')}</td>
</tr>
`).join('');
} }
function exportResultCsv(result) { function normalizeHeader(value) {
const rows = [ return String(value || '').trim().toLowerCase();
['Bereich', 'Monat/Datum', 'Arbeitstage', 'Arbeitszeit', 'Sollzeit', 'Saldo'], }
['Gesamt', '', result.totals.days, formatDuration(result.totals.workMinutes), formatDuration(result.totals.targetMinutes), formatDuration(result.totals.saldoMinutes, true)],
[],
['Monat', 'Monat/Datum', 'Arbeitstage', 'Arbeitszeit', 'Sollzeit', 'Saldo'],
...result.months.map(m => ['Monat', m.month, m.days, formatDuration(m.workMinutes), formatDuration(m.targetMinutes), formatDuration(m.saldoMinutes, true)]),
[],
['Tag', 'Datum', 'Wochentag', 'Beginn', 'Ende', 'Arbeitszeit', 'Sollzeit', 'Saldo', 'Ruhepause', 'Warnungen'],
...result.days.map(d => ['Tag', d.date, d.weekday || '', d.start, d.end, formatDuration(d.workMinutes), formatDuration(d.targetMinutes), formatDuration(d.saldoMinutes, true), d.breakOk, d.warnings])
];
const csv = rows.map(row => row.map(csvEscape).join(';')).join('\n'); function weekdayLabel(date) {
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8' }); return date.toLocaleDateString('de-DE', { weekday: 'long' });
const url = URL.createObjectURL(blob); }
const link = document.createElement('a');
link.href = url; function stateLabel(state) {
link.download = 'arbeitszeit-auswertung.csv'; const labels = {
link.click(); NW: 'Nordrhein-Westfalen',
URL.revokeObjectURL(url); BY: 'Bayern',
BY_MARIA: 'Bayern inkl. Mariä Himmelfahrt',
NI: 'Niedersachsen',
HH: 'Hamburg'
};
return labels[state] || state;
}
function getHolidayName(date, state) {
const year = date.getFullYear();
const key = dateKey(date);
const easter = easterSunday(year);
const holidays = new Map([
[`${year}-01-01`, 'Neujahr'],
[`${year}-05-01`, 'Tag der Arbeit'],
[`${year}-10-03`, 'Tag der Deutschen Einheit'],
[`${year}-12-25`, '1. Weihnachtstag'],
[`${year}-12-26`, '2. Weihnachtstag'],
[dateKey(addDays(easter, -2)), 'Karfreitag'],
[dateKey(addDays(easter, 1)), 'Ostermontag'],
[dateKey(addDays(easter, 39)), 'Christi Himmelfahrt'],
[dateKey(addDays(easter, 50)), 'Pfingstmontag']
]);
if (state === 'BY' || state === 'BY_MARIA') {
holidays.set(`${year}-01-06`, 'Heilige Drei Könige');
holidays.set(dateKey(addDays(easter, 60)), 'Fronleichnam');
holidays.set(`${year}-11-01`, 'Allerheiligen');
if (state === 'BY_MARIA') holidays.set(`${year}-08-15`, 'Mariä Himmelfahrt');
}
if (state === 'NW') {
holidays.set(dateKey(addDays(easter, 60)), 'Fronleichnam');
holidays.set(`${year}-11-01`, 'Allerheiligen');
}
if (state === 'NI' || state === 'HH') {
holidays.set(`${year}-10-31`, 'Reformationstag');
}
return holidays.get(key) || null;
}
function easterSunday(year) {
const a = year % 19;
const b = Math.floor(year / 100);
const c = year % 100;
const d = Math.floor(b / 4);
const e = b % 4;
const f = Math.floor((b + 8) / 25);
const g = Math.floor((b - f + 1) / 3);
const h = (19 * a + b - d - g + 15) % 30;
const i = Math.floor(c / 4);
const k = c % 4;
const l = (32 + 2 * e + 2 * i - h - k) % 7;
const m = Math.floor((a + 11 * h + 22 * l) / 451);
const month = Math.floor((h + l - 7 * m + 114) / 31) - 1;
const day = ((h + l - 7 * m + 114) % 31) + 1;
return new Date(year, month, day);
}
function addDays(date, days) {
const result = new Date(date);
result.setDate(result.getDate() + days);
return result;
}
function dateKey(date) {
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
} }
function csvEscape(value) { function csvEscape(value) {
const text = String(value ?? ''); const text = String(value ?? '');
if (/[;"\n\r]/.test(text)) return `"${text.replace(/"/g, '""')}"`; return `"${text.replaceAll('"', '""')}"`;
return text; }
function escapeHtml(value) {
return String(value ?? '').replace(/[&<>'"]/g, char => ({
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
"'": '&#39;',
'"': '&quot;'
}[char]));
} }
function showError(message) { function showError(message) {
@@ -381,11 +456,7 @@ function hideError() {
errorBox.classList.add('hidden'); errorBox.classList.add('hidden');
} }
function escapeHtml(value) { function throwCsvError(message) {
return String(value) showError(message);
.replace(/&/g, '&amp;') throw new Error(message);
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
} }
+31 -12
View File
@@ -3,26 +3,36 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Arbeitszeit-Auswertung</title> <title>qPlanner Arbeitszeit-Auswertung</title>
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
</head> </head>
<body> <body>
<main class="app"> <main class="app">
<section class="hero"> <section class="hero">
<div> <div>
<p class="eyebrow">CSV-Auswertung</p> <p class="eyebrow">qPlanner CSV-Auswertung</p>
<h1>Arbeitszeit-Saldo berechnen</h1> <h1>Arbeitszeit-Saldo berechnen</h1>
<p class="intro">CSV-Datei hochladen, Netto-Arbeitszeiten auslesen und Plus-/Minusstunden berechnen: Montag bis Freitag mit 8:00 Stunden Sollzeit, Samstag/Sonntag mit 0:00 Sollzeit.</p> <p class="intro">CSV-Datei hochladen, Netto-Arbeitszeiten auslesen und Plus-/Minusstunden berechnen. Samstage, Sonntage und gesetzliche Feiertage im gewählten Bundesland werden mit 0:00 Stunden Sollzeit bewertet.</p>
</div>
<div class="settings" aria-label="Einstellungen">
<label>
Sollzeit pro Arbeitstag
<input id="targetTime" type="time" value="08:00" step="60">
<small>Gilt für Montag bis Freitag. Samstag/Sonntag = 0:00.</small>
</label>
</div> </div>
</section> </section>
<section class="settings" aria-label="Einstellungen">
<label>
Sollzeit pro Arbeitstag Montag bis Freitag
<input id="targetTime" type="time" value="08:00" step="60">
</label>
<label>
Bundesland / Feiertagsregel
<select id="federalState">
<option value="NW">Nordrhein-Westfalen</option>
<option value="BY">Bayern</option>
<option value="BY_MARIA">Bayern inkl. Mariä Himmelfahrt</option>
<option value="NI">Niedersachsen</option>
<option value="HH">Hamburg</option>
</select>
</label>
</section>
<section id="dropZone" class="drop-zone"> <section id="dropZone" class="drop-zone">
<input id="csvFile" type="file" accept=".csv,text/csv"> <input id="csvFile" type="file" accept=".csv,text/csv">
<div class="drop-content"> <div class="drop-content">
@@ -31,10 +41,10 @@
</div> </div>
</section> </section>
<section id="formatHint" class="hint"></section>
<section id="errorBox" class="error hidden"></section> <section id="errorBox" class="error hidden"></section>
<p id="formatHint" class="format-hint"></p>
<section id="summary" class="summary hidden" aria-live="polite"> <section id="summary" class="summary hidden" aria-live="polite">
<article class="card"> <article class="card">
<span>Arbeitstage</span> <span>Arbeitstage</span>
@@ -65,6 +75,7 @@
<tr> <tr>
<th>Monat</th> <th>Monat</th>
<th>Arbeitstage</th> <th>Arbeitstage</th>
<th>Feiertage</th>
<th>Arbeitszeit</th> <th>Arbeitszeit</th>
<th>Sollzeit</th> <th>Sollzeit</th>
<th>Saldo</th> <th>Saldo</th>
@@ -87,6 +98,7 @@
<th>Arbeitszeit</th> <th>Arbeitszeit</th>
<th>Sollzeit</th> <th>Sollzeit</th>
<th>Saldo</th> <th>Saldo</th>
<th>Feiertag</th>
<th>Ruhepause</th> <th>Ruhepause</th>
<th>Warnungen</th> <th>Warnungen</th>
</tr> </tr>
@@ -98,6 +110,13 @@
</section> </section>
</main> </main>
<footer class="app-footer" aria-label="Projektinformationen">
<span id="appVersion">v0.41.1</span>
<span aria-hidden="true"></span>
<a href="https://git.mike-lindner.net/mike/qplanner-arbeitszeit-auswertung" target="_blank" rel="noopener noreferrer">Repository</a>
</footer>
<script src="app.js"></script> <script src="app.js"></script>
</body> </body>
</html> </html>
+113 -53
View File
@@ -12,7 +12,7 @@ body {
} }
.app { .app {
width: min(1120px, calc(100% - 32px)); width: min(1180px, calc(100% - 32px));
margin: 0 auto; margin: 0 auto;
padding: 40px 0; padding: 40px 0;
} }
@@ -40,17 +40,45 @@ h1 {
} }
.intro { .intro {
max-width: 700px; max-width: 760px;
color: #566277; color: #566277;
line-height: 1.6; line-height: 1.6;
} }
.settings { .settings,
.card,
.results {
background: white; background: white;
border: 1px solid #dde5f2; border: 1px solid #dde5f2;
box-shadow: 0 12px 30px rgba(29, 45, 68, .08);
}
.version-card {
border-radius: 18px;
padding: 14px 18px;
min-width: 130px;
text-align: center;
}
.version-card span {
display: block;
color: #566277;
font-size: .82rem;
}
.version-card strong {
display: block;
margin-top: 4px;
font-size: 1.25rem;
}
.settings {
display: grid;
grid-template-columns: repeat(2, minmax(220px, 1fr));
gap: 16px;
border-radius: 18px; border-radius: 18px;
padding: 16px; padding: 16px;
box-shadow: 0 12px 30px rgba(29, 45, 68, .08); margin-bottom: 24px;
} }
.settings label { .settings label {
@@ -60,17 +88,14 @@ h1 {
color: #566277; color: #566277;
} }
.settings input { .settings input,
.settings select {
border: 1px solid #cbd5e1; border: 1px solid #cbd5e1;
border-radius: 10px; border-radius: 10px;
padding: 10px 12px; padding: 10px 12px;
font: inherit; font: inherit;
color: #172033; color: #172033;
} background: white;
.settings small {
color: #566277;
line-height: 1.4;
} }
.drop-zone { .drop-zone {
@@ -86,8 +111,8 @@ h1 {
} }
.drop-zone.dragover { .drop-zone.dragover {
border-color: #2f6fed; border-color: #2f6feb;
background: #eef4ff; background: #edf4ff;
} }
.drop-zone input { .drop-zone input {
@@ -109,6 +134,22 @@ h1 {
font-size: 1.25rem; font-size: 1.25rem;
} }
.error {
margin-top: 18px;
padding: 14px 16px;
border-radius: 14px;
background: #fff1f2;
color: #be123c;
border: 1px solid #fecdd3;
}
.hidden { display: none !important; }
.format-hint {
color: #566277;
min-height: 22px;
}
.summary { .summary {
display: grid; display: grid;
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);
@@ -117,35 +158,26 @@ h1 {
} }
.card { .card {
background: white; border-radius: 18px;
border: 1px solid #dde5f2; padding: 18px;
border-radius: 20px;
padding: 20px;
box-shadow: 0 12px 30px rgba(29, 45, 68, .08);
} }
.card span { .card span {
display: block; display: block;
color: #566277; color: #566277;
font-size: .9rem;
margin-bottom: 8px; margin-bottom: 8px;
} }
.card strong { .card strong {
display: block;
font-size: 1.8rem; font-size: 1.8rem;
} }
.positive { color: #137333; } .saldo-card strong.positive { color: #15803d; }
.negative { color: #b3261e; } .saldo-card strong.negative { color: #b91c1c; }
.neutral { color: #172033; }
.results { .results {
background: white;
border: 1px solid #dde5f2;
border-radius: 24px; border-radius: 24px;
padding: 24px; padding: 22px;
box-shadow: 0 12px 30px rgba(29, 45, 68, .08);
} }
.table-header { .table-header {
@@ -156,18 +188,22 @@ h1 {
margin-bottom: 16px; margin-bottom: 16px;
} }
.table-header h2 { margin: 0; } .table-header h2 {
margin: 0;
}
button { button {
border: 0; border: none;
border-radius: 12px; border-radius: 12px;
padding: 10px 14px;
background: #172033; background: #172033;
color: white; color: white;
padding: 10px 14px;
font: inherit; font: inherit;
cursor: pointer; cursor: pointer;
} }
button:hover { opacity: .9; }
.table-wrap { .table-wrap {
overflow-x: auto; overflow-x: auto;
} }
@@ -175,55 +211,79 @@ button {
table { table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
min-width: 680px; font-size: .95rem;
} }
th, td { th,
td {
padding: 12px 10px; padding: 12px 10px;
border-bottom: 1px solid #e6edf7; border-bottom: 1px solid #e5eaf3;
text-align: left; text-align: left;
white-space: nowrap; white-space: nowrap;
} }
th { th {
color: #566277; color: #566277;
font-size: .85rem; font-weight: 700;
text-transform: uppercase; background: #f8fafc;
letter-spacing: .04em;
} }
tr.holiday-row td {
background: #fff7ed;
}
tr.weekend-row td {
background: #f8fafc;
}
.positive { color: #15803d; font-weight: 700; }
.negative { color: #b91c1c; font-weight: 700; }
.neutral { color: #566277; font-weight: 700; }
.details { .details {
margin-top: 24px; margin-top: 20px;
} }
.details summary { .details summary {
cursor: pointer; cursor: pointer;
font-weight: 700; font-weight: 700;
margin-bottom: 16px; margin-bottom: 14px;
} }
.error {
margin-top: 16px; .app-footer {
padding: 14px 16px; position: fixed;
border-radius: 14px; right: 16px;
background: #fff1f0; bottom: 10px;
border: 1px solid #ffccc7; display: inline-flex;
color: #8a1f11; gap: 6px;
align-items: center;
font-size: 12px;
color: #6b7280;
background: rgba(255, 255, 255, .85);
border: 1px solid #e5eaf3;
border-radius: 999px;
padding: 5px 10px;
box-shadow: 0 6px 18px rgba(29, 45, 68, .08);
backdrop-filter: blur(6px);
} }
.hidden { display: none; } .app-footer a {
color: inherit;
text-decoration: none;
}
.app-footer a:hover {
text-decoration: underline;
}
@media (max-width: 820px) { @media (max-width: 820px) {
.hero { display: grid; align-items: start; } .hero { align-items: start; flex-direction: column; }
.settings { grid-template-columns: 1fr; }
.summary { grid-template-columns: 1fr 1fr; } .summary { grid-template-columns: 1fr 1fr; }
} }
@media (max-width: 520px) { @media (max-width: 540px) {
.summary { grid-template-columns: 1fr; } .summary { grid-template-columns: 1fr; }
} .app-footer { right: 8px; bottom: 8px; font-size: 11px; }
.hint {
color: #566277;
margin: 16px 0 0;
font-size: .95rem;
} }