{% extends "base.html" %}

{% block boutons_droite %}
    {% include './famille_boutons.html' with active='suivi' %}
{% endblock %}

{% block content %}
<div class="row border-bottom lead mt-3 mb-3">
    <div class="col">Famille {{ famille.nom }} - {{ famille.adresse }}</div>
    <div class="col text-end">Dossier de suivi</div>
</div>

<form name="Suivi" action= "." method="post">{% csrf_token %}
    <input type="hidden" name="famille" value="{{ famille.pk }}">
    <div class="row ">
        <div class="col">
            <table class="table table-sm table-borderless border-bottom">
                <tr>
                    <th class="left-label">Enfant(s) suivi(s)</th>
                    <td>
                        <table class="table table-sm table-hover">
                            {% for enfant in famille.membres_suivis %}
                            <tr>
                                <th width="400"><a href="{% url 'personne-edit' famille.pk enfant.pk %}">{{ enfant.nom_prenom }}</a></th>
                                <td width="100">{{ enfant.age|floatformat }} ans</td>
                                <td>{{ enfant.formation.info_scol }}</td>
                            </tr>
                            {% endfor %}
                        </table>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div class="row border-bottom pb-3 mb-3">
        <div class="col-3"><label>Equipe:</label> {{ form.equipe }}</div>
        <div class="col-5"><label>Annonceur:</label> {{ form.service_annonceur }}</div>
        <div class="col-4"><label>Service orienteur:</label> {{ form.service_orienteur }}</div>
    </div>

    <div class="row mb-4">
        <div class="col-3">
            <label>Intervenants Fondation:</label>
            {% if can_edit %}
            <span>
                <a href=""
                    class="btn btn-sm btn-mini btn-primary js-add"
                    data-url="{% url 'intervenant-add' famille.pk %}"
                    role="button"
                    title="Ajouter un intervenant">+</a>
            </span>
            {% endif %}
            {% for interv in intervenants %}
                {% if not interv.date_fin  %}
                <div><em>{{ interv.role }}</em>: {{ interv.intervenant.nom_prenom }}
                    {% if can_edit %}
                    <span class="hoverimage">
                        <a href=""
                            class="btn btn-sm btn-mini js-edit"
                            data-url="{% url 'intervenant-edit' famille.pk  interv.pk %}"
                            role="button"
                            title="Modifier une intervention">
                            <img src="{% static 'admin/img/icon-changelink.svg' %}">
                        </a>
                    </span>
                    {% endif %}
                </div>
            {% else %}
                <div class="text-secondary"><em>{{ interv.role }}</em>: {{ interv.intervenant.nom_prenom }}</div>
            {% endif %}
            {% endfor %}
        </div>
        <div class="col-9">
            <div class="row">
                <div class="col-6">
                    <label for="id_ope_referent">Ass. soc. OPE:</label>{{ form.ope_referent }}
                </div>
                <div class="col-6">
                    <label for="id_ope_referent_2">Ass. soc. OPE (2):</label>{{ form.ope_referent_2 }}
                </div>
                <div class="col-12">
                    {{ form.mandat_ope }}
                </div>

            </div>
        </div>
    </div>
    <div class="row border-bottom pb-3 mb-5">
        <div class="col-6">
            <label>Niveau d'intervention:</label>
            {% if can_edit %}
            <span>
                <a href=""
                    class="btn btn-sm btn-mini btn-primary js-edit"
                    data-url="{% url 'niveau-add' famille.pk %}"
                    role="button"
                    title="Ajouter un niveau">+</a>
            </span>
            {% endif %}
            <table class="table table-sm w-75">
                <tr>
                    <th width="30%">Du</th><th width="30%">Au</th><th>Niveau d'interv.</th><th></th>
                </tr>
            {% for niv in niveaux %}
                <tr>
                    <td>{{ niv.date_debut|date:"d.m.Y" }}</td>
                    <td>{{ niv.date_fin_calc|date:"d.m.Y"|default:"---" }}</td>
                    <td>{{ niv.niveau_interv }}</td>
                    <td>
                        <a href=""
                            class="btn btn-sm btn-mini js-edit"
                            data-url="{% url 'niveau-edit' famille.pk niv.pk %}"
                            role="button"
                            title="Modifier"><img src="{% static 'admin/img/icon-changelink.svg' %}">
                        </a>
                    </td>
                </tr>
            {% endfor %}
            </table>

        </div>
        <div class="col-3">
            <div class="form-check">
                {{ form.demande_prioritaire }} <label for="id_demande_prioritaire">Demande prioritaire</label>
            </div>
        </div>
        <div class="col-3">
            {{ form.heure_coord }} {{ form.heure_coord.label_tag|strip_colon }}
        </div>

    </div>
    <div class="row mb-1">
        <div class="col-2 fw-bold">Motif standardisé:</div>
        <div class="col-10">{{ form.motif_demande.errors }}{{ form.motif_demande }}</div>
    </div>
    <div class="row mb-1">
        <div class="col-2 fw-bold">Motif de la demande:</div>
        <div class="col-10">{{ form.motif_detail.errors }}{{ form.motif_detail }}</div>
    </div>
    <div class="row mb-1">
        <div class="col-2 fw-bold">Collaborations:</div>
        <div class="col-10">{{ form.collaboration.errors }}{{ form.collaboration }}</div>
    </div>
    <div class="row mb-1">
        <div class="col-2 fw-bold">Ressources:</div>
        <div class="col-10">{{ form.ressource.errors }}{{ form.ressource }}</div>
    </div>
    <div class="row mb-1">
        <div class="col-2 fw-bold">Gestion de crise:</div>
        <div class="col-10">{{ form.crise.errors }}{{ form.crise }}</div>
    </div>
    <div class="row mb-1">
        <div class="col-2 fw-bold">Remarque:</div>
        <div class="col-10">{{ form.remarque.errors }}{{ form.remarque }}</div>
    </div>

    {% include 'partial_table_documents.html' %}

    <div class="row mb-1">
        <div class="col">
            <a type="button" class="btn btn-sm btn-outline-primary"
               href="{% static 'docs/sifp_agenda_hebdo.doc' %}">Modèle d’agenda hebdo.
            </a>
        </div>
    </div>

    {% if can_edit %}
    <div class="row">
        <div class="col">
            {% include "actions.html" %}
        </div>
    </div>
    {% endif %}
</form>
{% endblock %}
