{% 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-user-tie text-primary me-2"></i>
                    {{ title }}
                </h1>
                <div>
                    <a href="{% url 'stiftung:paechter_list' %}" class="btn btn-outline-secondary">
                        <i class="fas fa-arrow-left me-2"></i>Zurück zur Liste
                    </a>
                </div>
            </div>
        </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>Pächter-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>

                                <!-- 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.strasse.id_for_label }}" class="form-label">
                                            {{ form.strasse.label }}
                                        </label>
                                        {{ form.strasse }}
                                        {% if form.strasse.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.strasse.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.strasse.help_text %}
                                            <div class="form-text">{{ form.strasse.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.plz.id_for_label }}" class="form-label">
                                            {{ form.plz.label }}
                                        </label>
                                        {{ form.plz }}
                                        {% if form.plz.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.plz.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.plz.help_text %}
                                            <div class="form-text">{{ form.plz.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.ort.id_for_label }}" class="form-label">
                                            {{ form.ort.label }}
                                        </label>
                                        {{ form.ort }}
                                        {% if form.ort.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.ort.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.ort.help_text %}
                                            <div class="form-text">{{ form.ort.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.personentyp.id_for_label }}" class="form-label">
                                            {{ form.personentyp.label }}
                                        </label>
                                        {{ form.personentyp }}
                                        {% if form.personentyp.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.personentyp.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.personentyp.help_text %}
                                            <div class="form-text">{{ form.personentyp.help_text }}</div>
                                        {% endif %}
                                    </div>
                                </div>

                                <!-- Pacht-spezifische Informationen -->
                                <div class="row mb-4">
                                    <div class="col-12">
                                        <h6 class="text-primary border-bottom pb-2 mb-3">
                                            <i class="fas fa-tractor me-2"></i>Pacht-spezifische Informationen
                                        </h6>
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.pachtnummer.id_for_label }}" class="form-label">
                                            {{ form.pachtnummer.label }}
                                        </label>
                                        {{ form.pachtnummer }}
                                        {% if form.pachtnummer.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.pachtnummer.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.pachtnummer.help_text %}
                                            <div class="form-text">{{ form.pachtnummer.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.pachtzins_aktuell.id_for_label }}" class="form-label">
                                            {{ form.pachtzins_aktuell.label }}
                                        </label>
                                        {{ form.pachtzins_aktuell }}
                                        {% if form.pachtzins_aktuell.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.pachtzins_aktuell.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.pachtzins_aktuell.help_text %}
                                            <div class="form-text">{{ form.pachtzins_aktuell.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.pachtbeginn_erste.id_for_label }}" class="form-label">
                                            {{ form.pachtbeginn_erste.label }}
                                        </label>
                                        {{ form.pachtbeginn_erste }}
                                        {% if form.pachtbeginn_erste.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.pachtbeginn_erste.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.pachtbeginn_erste.help_text %}
                                            <div class="form-text">{{ form.pachtbeginn_erste.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.pachtende_letzte.id_for_label }}" class="form-label">
                                            {{ form.pachtende_letzte.label }}
                                        </label>
                                        {{ form.pachtende_letzte }}
                                        {% if form.pachtende_letzte.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.pachtende_letzte.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.pachtende_letzte.help_text %}
                                            <div class="form-text">{{ form.pachtende_letzte.help_text }}</div>
                                        {% endif %}
                                    </div>
                                </div>

                                <!-- Landwirtschaftliche Qualifikationen -->
                                <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>Landwirtschaftliche Qualifikationen
                                        </h6>
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <div class="form-check">
                                            {{ form.landwirtschaftliche_ausbildung }}
                                            <label class="form-check-label" for="{{ form.landwirtschaftliche_ausbildung.id_for_label }}">
                                                {{ form.landwirtschaftliche_ausbildung.label }}
                                            </label>
                                        </div>
                                        {% if form.landwirtschaftliche_ausbildung.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.landwirtschaftliche_ausbildung.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.landwirtschaftliche_ausbildung.help_text %}
                                            <div class="form-text">{{ form.landwirtschaftliche_ausbildung.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="{{ form.berufserfahrung_jahre.id_for_label }}" class="form-label">
                                            {{ form.berufserfahrung_jahre.label }}
                                        </label>
                                        {{ form.berufserfahrung_jahre }}
                                        {% if form.berufserfahrung_jahre.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.berufserfahrung_jahre.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.berufserfahrung_jahre.help_text %}
                                            <div class="form-text">{{ form.berufserfahrung_jahre.help_text }}</div>
                                        {% endif %}
                                    </div>
                                    
                                    <div class="col-md-12 mb-3">
                                        <label for="{{ form.spezialisierung.id_for_label }}" class="form-label">
                                            {{ form.spezialisierung.label }}
                                        </label>
                                        {{ form.spezialisierung }}
                                        {% if form.spezialisierung.errors %}
                                            <div class="invalid-feedback d-block">
                                                {% for error in form.spezialisierung.errors %}
                                                    {{ error }}
                                                {% endfor %}
                                            </div>
                                        {% endif %}
                                        {% if form.spezialisierung.help_text %}
                                            <div class="form-text">{{ form.spezialisierung.help_text }}</div>
                                        {% endif %}
                                    </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:paechter_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 'paechter_new' user %}
                </div>
            </div>

{% endblock %} 
