Fix: Werktagsberechnung robust, Checkbox-Auswertung verbessert, Tests angepasst

This commit is contained in:
2025-07-24 15:31:55 +02:00
parent b71bca3bb4
commit 0674849b6c
3 changed files with 44 additions and 51 deletions

View File

@@ -55,7 +55,7 @@
<!-- Kalender mit Doppelpfeil -->
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="3" y="5" width="18" height="16" rx="4" fill="#fff" stroke="#2563eb" stroke-width="2"/><rect x="3" y="5" width="18" height="4" rx="2" fill="#2563eb"/><rect x="6" y="2" width="2" height="4" rx="1" fill="#2563eb"/><rect x="16" y="2" width="2" height="4" rx="1" fill="#2563eb"/><path d="M8 15h8M8 15l2-2M8 15l2 2M16 15l-2-2M16 15l-2 2" stroke="#2563eb" stroke-width="1.5" stroke-linecap="round"/></svg>
</span>
Anzahl der Tage zwischen zwei Daten
Anzahl der Tage/Werktage zwischen zwei Daten
</button>
<div class="accordion-content">
<form method="post">
@@ -71,39 +71,20 @@
<button type="button" class="today-btn" onclick="setToday('end1')">Heute</button>
</span>
</label>
<button name="action" value="tage" type="submit">Berechnen</button>
<label style="display:flex;align-items:center;gap:0.5em;margin-top:0.7em;">
<input type="checkbox" name="werktage" id="werktage" {% if request.form.get('werktage') %}checked{% endif %}>
Nur Werktage
</label>
<button name="action" value="tage_werktage" type="submit">Berechnen</button>
</form>
{% if tage is not none %}
<div class="result">Anzahl der Tage zwischen <b>{{ format_date(request.form.get('start1', '')) }}</b> und <b>{{ format_date(request.form.get('end1', '')) }}</b>: {{ tage }}</div>
{% endif %}
</div>
</div>
<div class="accordion-item">
<button type="button" class="accordion-header header-werktage" onclick="openAccordion(1)">
<span style="vertical-align:middle;display:inline-block;width:1.5em;">
<!-- Kalender mit Mo-Fr Symbol -->
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="3" y="5" width="18" height="16" rx="4" fill="#fff" stroke="#2563eb" stroke-width="2"/><rect x="3" y="5" width="18" height="4" rx="2" fill="#2563eb"/><rect x="6" y="2" width="2" height="4" rx="1" fill="#2563eb"/><rect x="16" y="2" width="2" height="4" rx="1" fill="#2563eb"/><text x="12" y="17" text-anchor="middle" font-size="8" font-family="Segoe UI, Arial, sans-serif" fill="#2563eb" font-weight="bold">Mo-Fr</text></svg>
</span>
Anzahl der Werktage zwischen zwei Daten
</button>
<div class="accordion-content">
<form method="post">
<label>Startdatum:<br>
<span class="date-row">
<input type="date" name="start2" id="start2">
<button type="button" class="today-btn" onclick="setToday('start2')">Heute</button>
</span>
</label>
<label>Enddatum:<br>
<span class="date-row">
<input type="date" name="end2" id="end2">
<button type="button" class="today-btn" onclick="setToday('end2')">Heute</button>
</span>
</label>
<button name="action" value="werktage" type="submit">Berechnen</button>
</form>
{% if werktage is not none %}
<div class="result">Anzahl der Werktage zwischen <b>{{ format_date(request.form.get('start2', '')) }}</b> und <b>{{ format_date(request.form.get('end2', '')) }}</b>: {{ werktage }}</div>
<div class="result">
{% if request.form.get('werktage') %}
Anzahl der Werktage zwischen <b>{{ format_date(request.form.get('start1', '')) }}</b> und <b>{{ format_date(request.form.get('end1', '')) }}</b>: {{ tage }}
{% else %}
Anzahl der Tage zwischen <b>{{ format_date(request.form.get('start1', '')) }}</b> und <b>{{ format_date(request.form.get('end1', '')) }}</b>: {{ tage }}
{% endif %}
</div>
{% endif %}
</div>
</div>