further changes to also reflekt all relevant changes

This commit is contained in:
2026-06-26 17:32:24 +02:00
parent 480bd00a54
commit 7d13dc264c
2 changed files with 38 additions and 49 deletions
+2 -1
View File
@@ -136,7 +136,8 @@ def client(appointment_id):
current_user=session.get('username', ''), current_user=session.get('username', ''),
tenant_id=_current_tenant_id(), tenant_id=_current_tenant_id(),
can_view_booking_names=can_view_booking_names, can_view_booking_names=can_view_booking_names,
custom_fields=custom_fields custom_fields=custom_fields,
appointment_item=appointment_item
) )
+19 -31
View File
@@ -126,6 +126,7 @@
<tr> <tr>
<th scope="col" class="py-3">Zeitpunkt</th> <th scope="col" class="py-3">Zeitpunkt</th>
<th scope="col" class="py-3">Name</th> <th scope="col" class="py-3">Name</th>
<!-- Spaltenüberschriften für Custom Fields -->
{% for field_label in custom_fields %} {% for field_label in custom_fields %}
<th scope="col" class="py-3">{{ field_label }}</th> <th scope="col" class="py-3">{{ field_label }}</th>
{% endfor %} {% endfor %}
@@ -133,51 +134,38 @@
</tr> </tr>
</thead> </thead>
<tbody id="booking-table-body"> <tbody id="booking-table-body">
{% for booking in available.slots_booked %} {# Wir loopen jetzt über die rohen DB-Daten statt über die beschnittene Service-Funktion #}
{% for booking in appointment_item.get('slots_booked', []) %}
<tr> <tr>
<!-- 1. ZEITPUNKT -->
<td class="fw-semibold text-primary py-3 text-nowrap"> <td class="fw-semibold text-primary py-3 text-nowrap">
{% if booking is mapping %}
{{ booking.start }}
{% else %}
{{ booking[0] }} {{ booking[0] }}
{% endif %}
</td> </td>
<!-- 2. CLIENT NAME -->
<td> <td>
<span class="fw-bold text-dark"> <span class="fw-bold text-dark">{{ booking[1] }}</span>
{% if booking is mapping %}
{{ booking.name }}
{% else %}
{{ booking[1] }}
{% endif %}
</span>
</td> </td>
{% set answers = none %} <!-- 3. CUSTOM FIELDS (Präziser Index-Abgleich gegen Spaltenkopf) -->
{% if booking is mapping %}
{# Versucht alle gängigen Bezeichnungen für das Antwort-Array zu treffen #}
{% set answers = booking.custom or booking.custom_fields or booking.custom_answers %}
{% elif booking|length > 2 %}
{% set answers = booking[2] %}
{% endif %}
{% if answers %}
{% for answer in answers %}
<td>{{ answer if answer else '<span class="text-muted small">-</span>'|safe }}</td>
{% endfor %}
{% else %}
{# Fallback: Zeige Striche, wenn keine Antworten da sind #}
{% for field in custom_fields %} {% for field in custom_fields %}
<td><span class="text-muted small">-</span></td> <td>
{% endfor %} {# Prüft ob für dieses Feld eine Antwort am exakt gleichen Index existiert #}
{% if booking|length > 2 and booking[2] and booking[2]|length > loop.index0 %}
{% set answer = booking[2][loop.index0] %}
{{ answer if answer else '<span class="text-muted small">-</span>'|safe }}
{% else %}
<span class="text-muted small">-</span>
{% endif %} {% endif %}
</td>
{% endfor %}
<!-- 4. AKTION (LÖSCHEN) -->
<td class="text-end"> <td class="text-end">
<form method="post" action="{{ url_for('terminplaner.client', appointment_id=appointment_id, tenant=tenant_id) }}" onsubmit="return confirm('Möchten Sie diesen Termin wirklich löschen?');" class="d-inline"> <form method="post" action="{{ url_for('terminplaner.client', appointment_id=appointment_id, tenant=tenant_id) }}" onsubmit="return confirm('Möchten Sie diesen Termin wirklich löschen?');" class="d-inline">
<input type="hidden" name="action" value="delete"> <input type="hidden" name="action" value="delete">
<input type="hidden" name="slot_time" value="{{ booking[0] }}">
<input type="hidden" name="slot_time" value="{% if booking is mapping %}{{ booking.start }}{% else %}{{ booking[0] }}{% endif %}"> <input type="hidden" name="target_client_name" value="{{ booking[1] }}">
<input type="hidden" name="target_client_name" value="{% if booking is mapping %}{{ booking.name }}{% else %}{{ booking[1] }}{% endif %}">
<button type="submit" class="btn btn-sm btn-outline-danger px-3 rounded-3"> <button type="submit" class="btn btn-sm btn-outline-danger px-3 rounded-3">
Löschen Löschen