Files
stiftung-management-system/app/templates/stiftung/destinataer_list.html
SysAdmin Agent cf127b043d Bug fixes + archive feature for Destinatäre
- Make Destinatär names clickable in list view (link to detail page)
- Nachweis-Board: auto-create missing VierteljahresNachweis records
  for active Destinatäre when viewing a year (fixes missing Q1 2026)
- Add archive/deactivate toggle for Destinatäre (button on detail page)
  with AuditLog entry and confirmation dialog
- Default Destinatär list to show active only (filter preset to "Aktiv")

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 20:07:30 +00:00

266 lines
20 KiB
HTML

{% extends 'base.html' %}
{% load static %}
{% block title %}Destinatäre - Stiftungsverwaltung{% endblock %}
{% block content %}
<div class="row">
<div class="col-12">
<!-- Header -->
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="h3">
<i class="fas fa-users text-primary me-2"></i>
Destinatäre
</h1>
<div class="d-flex gap-2">
<a href="{% url 'stiftung:unterstuetzungen_list' %}" class="btn btn-outline-primary">
<i class="fas fa-hand-holding-usd me-2"></i>Unterstützungen
</a>
<a href="{% url 'stiftung:destinataer_create' %}" class="btn btn-success">
<i class="fas fa-plus me-2"></i>Neuen Destinatär erstellen
</a>
</div>
</div>
<!-- Search and Filters -->
<div class="card shadow mb-4">
<div class="card-body">
<form method="get" class="row g-3">
<div class="col-md-4">
<label for="search" class="form-label">Suche</label>
<input type="text" class="form-control" id="search" name="search"
value="{{ search_query }}" placeholder="Name, E-Mail oder Institution...">
</div>
<div class="col-md-2">
<label for="familienzweig" class="form-label">Familienzweig</label>
<select class="form-control" id="familienzweig" name="familienzweig">
<option value="">Alle</option>
{% for choice in familienzweig_choices %}
<option value="{{ choice.0 }}" {% if choice.0 == familienzweig_filter %}selected{% endif %}>
{{ choice.1 }}
</option>
{% endfor %}
</select>
</div>
<div class="col-md-2">
<label for="berufsgruppe" class="form-label">Berufsgruppe</label>
<select class="form-control" id="berufsgruppe" name="berufsgruppe">
<option value="">Alle</option>
{% for choice in berufsgruppe_choices %}
<option value="{{ choice.0 }}" {% if choice.0 == berufsgruppe_filter %}selected{% endif %}>
{{ choice.1 }}
</option>
{% endfor %}
</select>
</div>
<div class="col-md-2">
<label for="aktiv" class="form-label">Status</label>
<select class="form-control" id="aktiv" name="aktiv">
<option value="">Alle</option>
<option value="true" {% if aktiv_filter == 'true' %}selected{% endif %}>Aktiv</option>
<option value="false" {% if aktiv_filter == 'false' %}selected{% endif %}>Inaktiv</option>
</select>
</div>
<div class="col-md-2 d-flex align-items-end">
<button type="submit" class="btn btn-primary me-2">
<i class="fas fa-search me-1"></i>Suchen
</button>
<a href="{% url 'stiftung:destinataer_list' %}" class="btn btn-outline-secondary">
<i class="fas fa-times me-1"></i>Zurücksetzen
</a>
</div>
</form>
</div>
</div>
<!-- Results -->
<div class="card shadow">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">
<i class="fas fa-list me-2"></i>Destinatäre ({{ page_obj.paginator.count }})
</h6>
</div>
<div class="card-body">
{% if page_obj %}
<div class="table-responsive">
<table class="table table-hover">
<thead class="table-light">
<tr>
<th>
<a href="?sort=vorname&dir={% if sort == 'vorname' and dir != 'desc' %}desc{% else %}asc{% endif %}{% if search_query %}&search={{ search_query }}{% endif %}{% if familienzweig_filter %}&familienzweig={{ familienzweig_filter }}{% endif %}{% if berufsgruppe_filter %}&berufsgruppe={{ berufsgruppe_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}">
Vorname
{% if sort == 'vorname' %}
{% if dir == 'desc' %}
<i class="fas fa-sort-down"></i>
{% else %}
<i class="fas fa-sort-up"></i>
{% endif %}
{% endif %}
</a>
</th>
<th>
<a href="?sort=nachname&dir={% if sort == 'nachname' and dir != 'desc' %}desc{% else %}asc{% endif %}{% if search_query %}&search={{ search_query }}{% endif %}{% if familienzweig_filter %}&familienzweig={{ familienzweig_filter }}{% endif %}{% if berufsgruppe_filter %}&berufsgruppe={{ berufsgruppe_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}">
Nachname
{% if sort == 'nachname' %}
{% if dir == 'desc' %}
<i class="fas fa-sort-down"></i>
{% else %}
<i class="fas fa-sort-up"></i>
{% endif %}
{% endif %}
</a>
</th>
<th>
<a href="?sort=email&dir={% if sort == 'email' and dir != 'desc' %}desc{% else %}asc{% endif %}{% if search_query %}&search={{ search_query }}{% endif %}{% if familienzweig_filter %}&familienzweig={{ familienzweig_filter }}{% endif %}{% if berufsgruppe_filter %}&berufsgruppe={{ berufsgruppe_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}">E-Mail</a>
</th>
<th>
<a href="?sort=vierteljaehrlicher_betrag&dir={% if sort == 'vierteljaehrlicher_betrag' and dir != 'desc' %}desc{% else %}asc{% endif %}{% if search_query %}&search={{ search_query }}{% endif %}{% if familienzweig_filter %}&familienzweig={{ familienzweig_filter }}{% endif %}{% if berufsgruppe_filter %}&berufsgruppe={{ berufsgruppe_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}">Vierteljährlicher Betrag</a>
</th>
<th>
<a href="?sort=aktiv&dir={% if sort == 'aktiv' and dir != 'desc' %}desc{% else %}asc{% endif %}{% if search_query %}&search={{ search_query }}{% endif %}{% if familienzweig_filter %}&familienzweig={{ familienzweig_filter }}{% endif %}{% if berufsgruppe_filter %}&berufsgruppe={{ berufsgruppe_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}">Status</a>
</th>
<th>
<a href="?sort=unterstuetzung_bestaetigt&dir={% if sort == 'unterstuetzung_bestaetigt' and dir != 'desc' %}desc{% else %}asc{% endif %}{% if search_query %}&search={{ search_query }}{% endif %}{% if familienzweig_filter %}&familienzweig={{ familienzweig_filter }}{% endif %}{% if berufsgruppe_filter %}&berufsgruppe={{ berufsgruppe_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}">Unterstützung bestätigt</a>
</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
{% for destinataer in page_obj %}
<tr>
<td>
<a href="{% url 'stiftung:destinataer_detail' pk=destinataer.pk %}" class="text-decoration-none fw-bold">{{ destinataer.vorname|default:"-" }}</a>
</td>
<td>
<a href="{% url 'stiftung:destinataer_detail' pk=destinataer.pk %}" class="text-decoration-none fw-bold">{{ destinataer.nachname }}</a>
{% if destinataer.geburtsdatum %}
<br><small class="text-muted">{{ destinataer.geburtsdatum|date:"d.m.Y" }}</small>
{% endif %}
</td>
<td>
{% if destinataer.email %}
<a href="mailto:{{ destinataer.email }}">{{ destinataer.email }}</a>
{% else %}
<span class="text-muted">-</span>
{% endif %}
</td>
<td>
{% if destinataer.vierteljaehrlicher_betrag %}
<span class="text-success fw-bold">€{{ destinataer.vierteljaehrlicher_betrag|floatformat:2 }}</span>
{% else %}
<span class="text-muted">-</span>
{% endif %}
</td>
<td>
{% if destinataer.aktiv %}
<span class="badge bg-success"><i class="fas fa-check-circle me-1"></i>Aktiv</span>
{% else %}
<span class="badge bg-secondary"><i class="fas fa-pause-circle me-1"></i>Inaktiv</span>
{% endif %}
</td>
<td>
{% if destinataer.unterstuetzung_bestaetigt %}
<span class="badge bg-success"><i class="fas fa-check me-1"></i>Bestätigt</span>
{% else %}
<span class="badge bg-warning"><i class="fas fa-clock me-1"></i>Ausstehend</span>
{% endif %}
</td>
<td>
<div class="btn-group" role="group">
<a href="{% url 'stiftung:destinataer_detail' pk=destinataer.pk %}"
class="btn btn-sm btn-outline-primary">
<i class="fas fa-eye"></i>
</a>
<a href="{% url 'stiftung:destinataer_update' pk=destinataer.pk %}"
class="btn btn-sm btn-outline-warning">
<i class="fas fa-edit"></i>
</a>
<a href="{% url 'stiftung:destinataer_delete' pk=destinataer.pk %}"
class="btn btn-sm btn-outline-danger">
<i class="fas fa-trash"></i>
</a>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Results info -->
<div class="mt-3 mb-3 text-muted text-center">
<small>
Zeige {{ page_obj.start_index }} - {{ page_obj.end_index }} von {{ page_obj.paginator.count }} Destinatären
(50 Einträge pro Seite{% if sort %}, sortiert nach
{% if sort == 'nachname' %}Nachname{% elif sort == 'vorname' %}Vorname{% elif sort == 'email' %}E-Mail{% elif sort == 'vierteljaehrlicher_betrag' %}Vierteljährlicher Betrag{% elif sort == 'aktiv' %}Status{% elif sort == 'unterstuetzung_bestaetigt' %}Unterstützung bestätigt{% endif %}
{% if dir == 'desc' %} (absteigend){% else %} (aufsteigend){% endif %}{% endif %})
</small>
</div>
<!-- Pagination -->
{% if page_obj.has_other_pages %}
<nav aria-label="Destinatäre Pagination" class="mt-4">
<ul class="pagination justify-content-center">
{% if page_obj.has_previous %}
<li class="page-item">
<a class="page-link" href="?page=1{% if search_query %}&search={{ search_query }}{% endif %}{% if familienzweig_filter %}&familienzweig={{ familienzweig_filter }}{% endif %}{% if berufsgruppe_filter %}&berufsgruppe={{ berufsgruppe_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}{% if sort %}&sort={{ sort }}&dir={{ dir }}{% endif %}">
<i class="fas fa-angle-double-left"></i>
</a>
</li>
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.previous_page_number }}{% if search_query %}&search={{ search_query }}{% endif %}{% if familienzweig_filter %}&familienzweig={{ familienzweig_filter }}{% endif %}{% if berufsgruppe_filter %}&berufsgruppe={{ berufsgruppe_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}{% if sort %}&sort={{ sort }}&dir={{ dir }}{% endif %}">
<i class="fas fa-angle-left"></i>
</a>
</li>
{% endif %}
{% for num in page_obj.paginator.page_range %}
{% if page_obj.number == num %}
<li class="page-item active">
<span class="page-link">{{ num }}</span>
</li>
{% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}
<li class="page-item">
<a class="page-link" href="?page={{ num }}{% if search_query %}&search={{ search_query }}{% endif %}{% if familienzweig_filter %}&familienzweig={{ familienzweig_filter }}{% endif %}{% if berufsgruppe_filter %}&berufsgruppe={{ berufsgruppe_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}{% if sort %}&sort={{ sort }}&dir={{ dir }}{% endif %}">{{ num }}</a>
</li>
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.next_page_number }}{% if search_query %}&search={{ search_query }}{% endif %}{% if familienzweig_filter %}&familienzweig={{ familienzweig_filter }}{% endif %}{% if berufsgruppe_filter %}&berufsgruppe={{ berufsgruppe_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}{% if sort %}&sort={{ sort }}&dir={{ dir }}{% endif %}">
<i class="fas fa-angle-right"></i>
</a>
</li>
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}{% if search_query %}&search={{ search_query }}{% endif %}{% if familienzweig_filter %}&familienzweig={{ familienzweig_filter }}{% endif %}{% if berufsgruppe_filter %}&berufsgruppe={{ berufsgruppe_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}{% if sort %}&sort={{ sort }}&dir={{ dir }}{% endif %}">
<i class="fas fa-angle-double-right"></i>
</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
{% else %}
<div class="text-center py-5">
<i class="fas fa-users fa-3x text-muted mb-3"></i>
<h5 class="text-muted">Keine Destinatäre gefunden</h5>
<p class="text-muted">
{% if search_query or familienzweig_filter or berufsgruppe_filter or aktiv_filter %}
Versuchen Sie andere Suchkriterien oder
<a href="{% url 'stiftung:destinataer_list' %}">setzen Sie die Filter zurück</a>.
{% else %}
Erstellen Sie den ersten Destinatär mit dem Button oben.
{% endif %}
</p>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}