Files
stiftung-management-system/app/templates/stiftung/paechter_list.html
2025-09-06 18:31:54 +02:00

240 lines
17 KiB
HTML

{% extends 'base.html' %}
{% load static %}
{% block title %}Pächter - 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-user-tie text-primary me-2"></i>
Pächter
</h1>
<div>
<a href="{% url 'stiftung:paechter_create' %}" class="btn btn-success">
<i class="fas fa-plus me-2"></i>Neuen Pächter 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-3">
<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 Pachtnummer...">
</div>
<div class="col-md-2">
<label for="ausbildung" class="form-label">Ausbildung</label>
<select class="form-control" id="ausbildung" name="ausbildung">
<option value="">Alle</option>
<option value="true" {% if ausbildung_filter == 'true' %}selected{% endif %}>Mit Ausbildung</option>
<option value="false" {% if ausbildung_filter == 'false' %}selected{% endif %}>Ohne Ausbildung</option>
</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-3 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:paechter_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>Pächter ({{ 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=name&dir={% if sort == 'name' and dir != 'desc' %}desc{% else %}asc{% endif %}{% if search_query %}&search={{ search_query }}{% endif %}{% if ausbildung_filter %}&ausbildung={{ ausbildung_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}">Name</a>
</th>
<th>
<a href="?sort=pachtnummer&dir={% if sort == 'pachtnummer' and dir != 'desc' %}desc{% else %}asc{% endif %}{% if search_query %}&search={{ search_query }}{% endif %}{% if ausbildung_filter %}&ausbildung={{ ausbildung_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}">Pachtnummer</a>
</th>
<th>
<a href="?sort=ausbildung&dir={% if sort == 'ausbildung' and dir != 'desc' %}desc{% else %}asc{% endif %}{% if search_query %}&search={{ search_query }}{% endif %}{% if ausbildung_filter %}&ausbildung={{ ausbildung_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}">Ausbildung</a>
</th>
<th>
<a href="?sort=spezialisierung&dir={% if sort == 'spezialisierung' and dir != 'desc' %}desc{% else %}asc{% endif %}{% if search_query %}&search={{ search_query }}{% endif %}{% if ausbildung_filter %}&ausbildung={{ ausbildung_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}">Spezialisierung</a>
</th>
<th>
<a href="?sort=flaeche&dir={% if sort == 'flaeche' and dir != 'desc' %}desc{% else %}asc{% endif %}{% if search_query %}&search={{ search_query }}{% endif %}{% if ausbildung_filter %}&ausbildung={{ ausbildung_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}">Verpachtete Fläche</a>
</th>
<th>
<a href="?sort=pachtzins&dir={% if sort == 'pachtzins' and dir != 'desc' %}desc{% else %}asc{% endif %}{% if search_query %}&search={{ search_query }}{% endif %}{% if ausbildung_filter %}&ausbildung={{ ausbildung_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}">Pachtzins</a>
</th>
<th>
<a href="?sort=status&dir={% if sort == 'status' and dir != 'desc' %}desc{% else %}asc{% endif %}{% if search_query %}&search={{ search_query }}{% endif %}{% if ausbildung_filter %}&ausbildung={{ ausbildung_filter }}{% endif %}{% if aktiv_filter %}&aktiv={{ aktiv_filter }}{% endif %}">Status</a>
</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
{% for paechter in page_obj %}
<tr>
<td>
<strong>{{ paechter.nachname }}, {{ paechter.vorname }}</strong>
{% if paechter.geburtsdatum %}
<br><small class="text-muted">{{ paechter.geburtsdatum|date:"d.m.Y" }}</small>
{% endif %}
</td>
<td>
{% if paechter.pachtnummer %}
<span class="badge bg-secondary">{{ paechter.pachtnummer }}</span>
{% else %}
<span class="text-muted">-</span>
{% endif %}
</td>
<td>
{% if paechter.landwirtschaftliche_ausbildung %}
<span class="badge bg-success">
<i class="fas fa-graduation-cap me-1"></i>Ja
</span>
{% else %}
<span class="badge bg-warning">
<i class="fas fa-times me-1"></i>Nein
</span>
{% endif %}
</td>
<td>
{% if paechter.spezialisierung %}
{{ paechter.spezialisierung }}
{% else %}
<span class="text-muted">-</span>
{% endif %}
</td>
<td>
{% if paechter.gesamt_flaeche %}
<span class="text-success fw-bold">{{ paechter.gesamt_flaeche|floatformat:2 }} qm</span>
{% else %}
<span class="text-muted">0.00 qm</span>
{% endif %}
</td>
<td>
{% if paechter.gesamt_pachtzins %}
<span class="text-primary fw-bold">€{{ paechter.gesamt_pachtzins|floatformat:2 }}/Jahr</span>
{% else %}
<span class="text-muted">€0.00/Jahr</span>
{% endif %}
</td>
<td>
{% if paechter.aktiv %}
<span class="badge bg-success">Aktiv</span>
{% else %}
<span class="badge bg-secondary">Inaktiv</span>
{% endif %}
</td>
<td>
<div class="btn-group" role="group">
<a href="{% url 'stiftung:paechter_detail' pk=paechter.pk %}"
class="btn btn-sm btn-outline-primary">
<i class="fas fa-eye"></i>
</a>
<a href="{% url 'stiftung:paechter_update' pk=paechter.pk %}"
class="btn btn-sm btn-outline-warning">
<i class="fas fa-edit"></i>
</a>
<a href="{% url 'stiftung:paechter_delete' pk=paechter.pk %}"
class="btn btn-sm btn-outline-danger">
<i class="fas fa-trash"></i>
</a>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Pagination -->
{% if page_obj.has_other_pages %}
<nav aria-label="Pächter 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 ausbildung_filter %}&ausbildung={{ ausbildung_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 ausbildung_filter %}&ausbildung={{ ausbildung_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 ausbildung_filter %}&ausbildung={{ ausbildung_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 ausbildung_filter %}&ausbildung={{ ausbildung_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 ausbildung_filter %}&ausbildung={{ ausbildung_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-user-tie fa-3x text-muted mb-3"></i>
<h5 class="text-muted">Keine Pächter gefunden</h5>
<p class="text-muted">
{% if search_query or familienzweig_filter or ausbildung_filter or aktiv_filter %}
Versuchen Sie andere Suchkriterien oder
<a href="{% url 'stiftung:paechter_list' %}">setzen Sie die Filter zurück</a>.
{% else %}
Erstellen Sie den ersten Pächter mit dem Button oben.
{% endif %}
</p>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}