{% extends 'base.html' %}
{% load static %}
{% load help_tags %}

{% block title %}{{ title }} - Stiftungsverwaltung{% endblock %}

{% block content %}

    <div class="row">
        <div class="col-12">
            <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>
                    {{ title }}
                </h1>
                <div>
                    <a href="{% url 'stiftung:destinataer_list' %}" class="btn btn-outline-secondary">
                        <i class="fas fa-arrow-left me-2"></i>Zurück zur Liste
                    </a>
                </div>
            </div>

            <div class="row">
                <div class="col-lg-8">
                    <div class="card shadow">
                        <div class="card-header bg-primary text-white">
                            <h5 class="card-title mb-0">
                                <i class="fas fa-edit me-2"></i>Destinatär-Daten
                            </h5>
                        </div>
                        <div class="card-body">
                            <form method="post" novalidate>
                                {% csrf_token %}
                                
                                <!-- Persönliche Informationen -->
                                <div class="row mb-4">
                                    <div class="col-12">
                                        <h6 class="text-primary border-bottom pb-2 mb-3">
                                            <i class="fas fa-user me-2"></i>Persönliche Informationen
                                        </h6>
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.vorname.id_for_label }}" class="form-label">
                                            {{ form.vorname.label }} *
                                        </label>
                                        {{ form.vorname }}
                                        {% if form.vorname.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.vorname.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.vorname.help_text %}
                                            <div class="form-text">{{ form.vorname.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.nachname.id_for_label }}" class="form-label">
                                            {{ form.nachname.label }} *
                                        </label>
                                        {{ form.nachname }}
                                        {% if form.nachname.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.nachname.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.nachname.help_text %}
                                            <div class="form-text">{{ form.nachname.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.geburtsdatum.id_for_label }}" class="form-label">
                                            {{ form.geburtsdatum.label }}
                                        </label>
                                        {{ form.geburtsdatum }}
                                        {% if form.geburtsdatum.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.geburtsdatum.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.geburtsdatum.help_text %}
                                            <div class="form-text">{{ form.geburtsdatum.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.familienzweig.id_for_label }}" class="form-label">
                                            {{ form.familienzweig.label }}
                                        </label>
                                        {{ form.familienzweig }}
                                        {% if form.familienzweig.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.familienzweig.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.familienzweig.help_text %}
                                            <div class="form-text">{{ form.familienzweig.help_text }}</div>
                                        {% endif %}
                                    </div>
                                </div>

                                <!-- Kontaktinformationen -->
                                <div class="row mb-4">
                                    <div class="col-12">
                                        <h6 class="text-primary border-bottom pb-2 mb-3">
                                            <i class="fas fa-address-book me-2"></i>Kontaktinformationen
                                        </h6>
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.email.id_for_label }}" class="form-label">
                                            {{ form.email.label }}
                                        </label>
                                        {{ form.email }}
                                        {% if form.email.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.email.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.email.help_text %}
                                            <div class="form-text">{{ form.email.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.telefon.id_for_label }}" class="form-label">
                                            {{ form.telefon.label }}
                                        </label>
                                        {{ form.telefon }}
                                        {% if form.telefon.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.telefon.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.telefon.help_text %}
                                            <div class="form-text">{{ form.telefon.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.iban.id_for_label }}" class="form-label">
                                            {{ form.iban.label }}
                                        </label>
                                        {{ form.iban }}
                                        {% if form.iban.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.iban.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.iban.help_text %}
                                            <div class="form-text">{{ form.iban.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.adresse.id_for_label }}" class="form-label">
                                            {{ form.adresse.label }}
                                        </label>
                                        {{ form.adresse }}
                                        {% if form.adresse.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.adresse.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.adresse.help_text %}
                                            <div class="form-text">{{ form.adresse.help_text }}</div>
                                        {% endif %}
                                    </div>
                                </div>

                                <!-- Berufliche Informationen -->
                                <div class="row mb-4">
                                    <div class="col-12">
                                        <h6 class="text-primary border-bottom pb-2 mb-3">
                                            <i class="fas fa-briefcase me-2"></i>Berufliche Informationen
                                        </h6>
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.berufsgruppe.id_for_label }}" class="form-label">
                                            {{ form.berufsgruppe.label }}
                                        </label>
                                        {{ form.berufsgruppe }}
                                        {% if form.berufsgruppe.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.berufsgruppe.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.berufsgruppe.help_text %}
                                            <div class="form-text">{{ form.berufsgruppe.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.ausbildungsstand.id_for_label }}" class="form-label">
                                            {{ form.ausbildungsstand.label }}
                                        </label>
                                        {{ form.ausbildungsstand }}
                                        {% if form.ausbildungsstand.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.ausbildungsstand.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.ausbildungsstand.help_text %}
                                            <div class="form-text">{{ form.ausbildungsstand.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-12 mb-3">
                                        <label for="{{ form.institution.id_for_label }}" class="form-label">
                                            {{ form.institution.label }}
                                        </label>
                                        {{ form.institution }}
                                        {% if form.institution.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.institution.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.institution.help_text %}
                                            <div class="form-text">{{ form.institution.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-12 mb-3">
                                        <label for="{{ form.projekt_beschreibung.id_for_label }}" class="form-label">
                                            {{ form.projekt_beschreibung.label }}
                                        </label>
                                        {{ form.projekt_beschreibung }}
                                        {% if form.projekt_beschreibung.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.projekt_beschreibung.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.projekt_beschreibung.help_text %}
                                            <div class="form-text">{{ form.projekt_beschreibung.help_text }}</div>
                                        {% endif %}
                                    </div>
                                </div>

                                <!-- Finanzielle Informationen -->
                                <div class="row mb-4">
                                    <div class="col-12">
                                        <h6 class="text-primary border-bottom pb-2 mb-3">
                                            <i class="fas fa-euro-sign me-2"></i>Finanzielle Informationen
                                        </h6>
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.jaehrliches_einkommen.id_for_label }}" class="form-label">
                                            {{ form.jaehrliches_einkommen.label }}
                                        </label>
                                        {{ form.jaehrliches_einkommen }}
                                        {% if form.jaehrliches_einkommen.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.jaehrliches_einkommen.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.jaehrliches_einkommen.help_text %}
                                            <div class="form-text">{{ form.jaehrliches_einkommen.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <div class="form-check">
                                            {{ form.finanzielle_notlage }}
                                            <label class="form-check-label" for="{{ form.finanzielle_notlage.id_for_label }}">
                                                {{ form.finanzielle_notlage.label }}
                                            </label>
                                        </div>
                                        {% if form.finanzielle_notlage.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.finanzielle_notlage.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.finanzielle_notlage.help_text %}
                                            <div class="form-text">{{ form.finanzielle_notlage.help_text }}</div>
                                        {% endif %}
                                    </div>
                                </div>

                                <!-- Unterstützungsprüfung & Auszahlung -->
                                <div class="row mb-4">
                                    <div class="col-12">
                                        <h6 class="text-primary border-bottom pb-2 mb-3">
                                            <i class="fas fa-check-circle me-2"></i>Unterstützung & Auszahlung
                                        </h6>
                                    </div>
                                    <div class="col-md-6 mb-3">
                                        <div class="form-check mb-2">
                                            {{ form.ist_abkoemmling }}
                                            <label class="form-check-label" for="{{ form.ist_abkoemmling.id_for_label }}">{{ form.ist_abkoemmling.label }}</label>
                                        </div>
                                        <div class="form-check mb-3">
                                            {{ form.unterstuetzung_bestaetigt }}
                                            <label class="form-check-label" for="{{ form.unterstuetzung_bestaetigt.id_for_label }}">{{ form.unterstuetzung_bestaetigt.label }}</label>
                                        </div>
                                        <label for="{{ form.haushaltsgroesse.id_for_label }}" class="form-label">{{ form.haushaltsgroesse.label }}</label>
                                        {{ form.haushaltsgroesse }}
                                        <div class="mt-2">
                                            <label for="{{ form.vierteljaehrlicher_betrag.id_for_label }}" class="form-label">Vierteljährliche Bezüge (€)</label>
                                            {{ form.vierteljaehrlicher_betrag }}
                                        </div>
                                        <div class="mt-2">
                                            <label for="{{ form.vermoegen.id_for_label }}" class="form-label">{{ form.vermoegen.label }}</label>
                                            {{ form.vermoegen }}
                                        </div>
                                    </div>
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.standard_konto.id_for_label }}" class="form-label">{{ form.standard_konto.label }}</label>
                                        {{ form.standard_konto }}
                                        <div class="form-text">Standardkonto für vierteljährliche Vorauszahlungen</div>
                                    </div>
                                </div>

                                <!-- Studiennachweis -->
                                <div class="row mb-4">
                                    <div class="col-12">
                                        <h6 class="text-primary border-bottom pb-2 mb-3">
                                            <i class="fas fa-graduation-cap me-2"></i>Studiennachweis
                                        </h6>
                                    </div>
                                    <div class="col-md-6 mb-3">
                                        <div class="form-check">
                                            {{ form.studiennachweis_erforderlich }}
                                            <label class="form-check-label" for="{{ form.studiennachweis_erforderlich.id_for_label }}">{{ form.studiennachweis_erforderlich.label }}</label>
                                        </div>
                                    </div>
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.letzter_studiennachweis.id_for_label }}" class="form-label">{{ form.letzter_studiennachweis.label }}</label>
                                        {{ form.letzter_studiennachweis }}
                                        <div class="form-text">Stichtage: 15.03 und 15.09</div>
                                    </div>
                                </div>

                                <!-- Status und Notizen -->
                                <div class="row mb-4">
                                    <div class="col-12">
                                        <h6 class="text-primary border-bottom pb-2 mb-3">
                                            <i class="fas fa-cog me-2"></i>Status und Notizen
                                        </h6>
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <div class="form-check">
                                            {{ form.aktiv }}
                                            <label class="form-check-label" for="{{ form.aktiv.id_for_label }}">
                                                {{ form.aktiv.label }}
                                            </label>
                                        </div>
                                        {% if form.aktiv.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.aktiv.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.aktiv.help_text %}
                                            <div class="form-text">{{ form.aktiv.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-12 mb-3">
                                        <label for="{{ form.notizen.id_for_label }}" class="form-label">
                                            {{ form.notizen.label }}
                                        </label>
                                        {{ form.notizen }}
                                        {% if form.notizen.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.notizen.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.notizen.help_text %}
                                            <div class="form-text">{{ form.notizen.help_text }}</div>
                                        {% endif %}
                                    </div>
                                </div>

                                <!-- Form Actions -->
                                <div class="d-flex justify-content-between">
                                    <a href="{% url 'stiftung:destinataer_list' %}" class="btn btn-outline-secondary">
                                        <i class="fas fa-times me-2"></i>Abbrechen
                                    </a>
                                    <button type="submit" class="btn btn-primary">
                                        <i class="fas fa-save me-2"></i>Speichern
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

                <!-- Sidebar mit Hilfe -->
                <div class="col-lg-4">
                    {% help_box 'destinataer_new' user %}
                </div>
            </div>
        </div>
    </div>

{% endblock %} 
