|
|
|
@@ -202,7 +202,7 @@
|
|
|
|
|
if (slotsAmountsInput) slotsAmountsInput.value = totalSlots;
|
|
|
|
|
if (slotsAmountsDisplay) slotsAmountsDisplay.innerText = totalSlots + " Slots gesamt";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Helper utility in case your timeToMinutes handler doesn't catch empty strings safely
|
|
|
|
|
function safeTimeToMinutes(timeString) {
|
|
|
|
|
if (!timeString || typeof timeString !== 'string' || !timeString.includes(':')) {
|
|
|
|
@@ -214,45 +214,45 @@
|
|
|
|
|
if (isNaN(hours) || isNaN(minutes)) return 0;
|
|
|
|
|
return (hours * 60) + minutes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Berechnet die Slots basierend auf den konfigurierten Zeiten & Pausen
|
|
|
|
|
function calculateSlots() {
|
|
|
|
|
if (!slotLengthInput || !slotsAmountsInput || !clientsperslot) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const slotLength = parseInt(slotLengthInput.value, 10);
|
|
|
|
|
if (isNaN(slotLength) || slotLength <= 0) {
|
|
|
|
|
updateSlotsDisplay(0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIX 1: Make sure we parse the input VALUE, defaulting to 1 if empty or invalid
|
|
|
|
|
const multiplier = parseInt(clientsperslot.value, 10) || 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let totalSlots = 0;
|
|
|
|
|
const rows = Array.from(daysContainer.querySelectorAll('[data-day-row]'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rows.forEach(row => {
|
|
|
|
|
const startTime = row.querySelector('[data-time-start]')?.value;
|
|
|
|
|
const endTime = row.querySelector('[data-time-end]')?.value;
|
|
|
|
|
const pauseStart = row.querySelector('[data-time-pause-start]')?.value;
|
|
|
|
|
const pauseEnd = row.querySelector('[data-time-pause-end]')?.value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!startTime || !endTime) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Using safety parsing to prevent missing values from generating NaN
|
|
|
|
|
const startMins = safeTimeToMinutes(startTime);
|
|
|
|
|
const endMins = safeTimeToMinutes(endTime);
|
|
|
|
|
const pauseStartMins = safeTimeToMinutes(pauseStart);
|
|
|
|
|
const pauseEndMins = safeTimeToMinutes(pauseEnd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isNaN(startMins) || isNaN(endMins) || endMins <= startMins) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Wenn eine gültige Pause innerhalb der Start/Endzeit existiert
|
|
|
|
|
if (pauseStartMins > 0 && pauseEndMins > 0 && pauseStartMins < pauseEndMins && pauseStartMins > startMins && pauseStartMins < endMins) {
|
|
|
|
|
// Segment 1 (Vor der Pause)
|
|
|
|
|
const segment1 = pauseStartMins - startMins;
|
|
|
|
|
totalSlots += Math.floor(segment1 / slotLength);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Segment 2 (Nach der Pause)
|
|
|
|
|
const effectivePauseEnd = Math.min(pauseEndMins, endMins);
|
|
|
|
|
const segment2 = endMins - effectivePauseEnd;
|
|
|
|
@@ -264,10 +264,10 @@
|
|
|
|
|
totalSlots += Math.floor((endMins - startMins) / slotLength);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIX 2: Multiply by our safely parsed input value scalar
|
|
|
|
|
const totalSlotscomplete = totalSlots * multiplier;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Safety check: if anything went wrong anyway, fallback to 0 instead of displaying NaN
|
|
|
|
|
updateSlotsDisplay(isNaN(totalSlotscomplete) ? 0 : totalSlotscomplete);
|
|
|
|
|
}
|
|
|
|
@@ -434,6 +434,10 @@
|
|
|
|
|
slotLengthInput.addEventListener('input', calculateSlots);
|
|
|
|
|
slotLengthInput.addEventListener('change', calculateSlots);
|
|
|
|
|
}
|
|
|
|
|
if (clientsperslot) {
|
|
|
|
|
slotLengthInput.addEventListener('input', calculateSlots);
|
|
|
|
|
slotLengthInput.addEventListener('change', calculateSlots);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (startDateInput.value && endDateInput.value) {
|
|
|
|
|
renderRows();
|
|
|
|
|