Gehe zu button, Verwaltung Urlaubsberechnung
This commit is contained in:
@@ -383,9 +383,11 @@ body {
|
||||
|
||||
.week-selector {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.week-selector h2 {
|
||||
@@ -394,6 +396,30 @@ body {
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
.week-selector-goto {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.week-selector-goto .form-control {
|
||||
width: 200px;
|
||||
max-width: 100%;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.go-to-week-error {
|
||||
color: #dc3545;
|
||||
font-size: 13px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Timesheet Table */
|
||||
.timesheet-grid {
|
||||
overflow-x: auto;
|
||||
|
||||
@@ -171,6 +171,56 @@ document.addEventListener('DOMContentLoaded', async function() {
|
||||
saveLastWeek();
|
||||
loadWeek();
|
||||
});
|
||||
|
||||
function showGoToWeekError(msg) {
|
||||
const el = document.getElementById('goToWeekError');
|
||||
if (el) { el.textContent = msg; el.style.display = 'inline'; }
|
||||
}
|
||||
function clearGoToWeekError() {
|
||||
const el = document.getElementById('goToWeekError');
|
||||
if (el) { el.textContent = ''; el.style.display = 'none'; }
|
||||
}
|
||||
function goToWeek() {
|
||||
clearGoToWeekError();
|
||||
const input = document.getElementById('goToWeekInput');
|
||||
if (!input) return;
|
||||
const raw = (input.value || '').trim();
|
||||
if (!raw) {
|
||||
showGoToWeekError('Bitte KW eingeben (z. B. 12 oder 2025 12).');
|
||||
return;
|
||||
}
|
||||
let year = null;
|
||||
let week = null;
|
||||
const parts = raw.split(/[\s\/]+/).filter(Boolean).map(p => parseInt(p, 10));
|
||||
if (parts.length === 1 && !isNaN(parts[0])) {
|
||||
week = parts[0];
|
||||
year = currentWeekStart ? parseInt(currentWeekStart.split('-')[0], 10) : new Date().getFullYear();
|
||||
} else if (parts.length === 2 && !isNaN(parts[0]) && !isNaN(parts[1])) {
|
||||
if (parts[0] >= 1000) {
|
||||
year = parts[0];
|
||||
week = parts[1];
|
||||
} else {
|
||||
week = parts[0];
|
||||
year = parts[1];
|
||||
}
|
||||
}
|
||||
if (year == null || week == null || week < 1 || week > 53 || year < 2000 || year > 2100) {
|
||||
showGoToWeekError('Ungültige Eingabe. KW 1–53, Jahr 2000–2100 (z. B. 12 oder 2025 12).');
|
||||
return;
|
||||
}
|
||||
currentWeekStart = getWeekStartFromYearAndWeek(year, week);
|
||||
saveLastWeek();
|
||||
loadWeek();
|
||||
}
|
||||
|
||||
const goToWeekBtn = document.getElementById('goToWeekBtn');
|
||||
if (goToWeekBtn) goToWeekBtn.addEventListener('click', goToWeek);
|
||||
const goToWeekInput = document.getElementById('goToWeekInput');
|
||||
if (goToWeekInput) {
|
||||
goToWeekInput.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Enter') { e.preventDefault(); goToWeek(); }
|
||||
});
|
||||
}
|
||||
|
||||
// Event-Listener für Submit-Button - mit Event-Delegation für bessere Zuverlässigkeit
|
||||
document.addEventListener('click', function(e) {
|
||||
@@ -285,6 +335,20 @@ function getCalendarWeek(dateStr) {
|
||||
return weekNo;
|
||||
}
|
||||
|
||||
// Montag (week_start) aus Jahr und Kalenderwoche (ISO 8601)
|
||||
function getWeekStartFromYearAndWeek(year, weekNumber) {
|
||||
const jan4 = new Date(Date.UTC(year, 0, 4));
|
||||
const jan4Day = jan4.getUTCDay() || 7;
|
||||
const daysToMonday = jan4Day === 1 ? 0 : 1 - jan4Day;
|
||||
const firstMonday = new Date(Date.UTC(year, 0, 4 + daysToMonday));
|
||||
const weekMonday = new Date(firstMonday);
|
||||
weekMonday.setUTCDate(firstMonday.getUTCDate() + (weekNumber - 1) * 7);
|
||||
const y = weekMonday.getUTCFullYear();
|
||||
const m = String(weekMonday.getUTCMonth() + 1).padStart(2, '0');
|
||||
const d = String(weekMonday.getUTCDate()).padStart(2, '0');
|
||||
return `${y}-${m}-${d}`;
|
||||
}
|
||||
|
||||
// Datum formatieren (YYYY-MM-DD)
|
||||
function formatDate(date) {
|
||||
const d = new Date(date);
|
||||
|
||||
Reference in New Issue
Block a user