{% extends "base.html" %}

{% block extra_javascript %}
<script type="text/javascript">
    $(document).ready(function() {
        function setup() {
            var statut = $("#id_statut").val();
            if (statut) {
                $('table#formation_table tr[class!=always]').each(function(){
                    if ($(this).hasClass(statut)) { $(this).show(); } else {$(this).hide();}
                });
            } else {
                $('table#formation_table tr').show();
            }
        }
        $("#id_statut").change(function() {
            setup();
        });
        setup();
    });
</script>
{% endblock %}

{% block content %}
    <div class="row border-bottom mt-3 mb-3">
        <div class="col">
            <p class="lead">Famille {{ form.instance.personne.famille.nom }} - {{ form.instance.personne.famille.adresse }}</p>
        </div>
        <div class="col text-end">
            <p class="lead">Formation de {{ form.instance.personne.nom_prenom }}</p>
        </div>
    </div>
    <div class="row mb-3 justify-content-center">
        <div class="col-10">
            <form method="post" action=".">{% csrf_token %}
                <input type="hidden" name="personne" value="{{ personne.pk }}">
                <table id="formation_table" class="table table-sm table-borderless">
                    <tr class="always">
                        <th>Niveau de formation:</th><td>{{ form.statut }}<td>
                    </td>
                    <tr class="cycle1 cycle2 cycle3 etudiant apprenti">
                        <th>École:</th><td>{{ form.cercle_scolaire }}</td>
                        <th>Collège:</th><td >{{ form.college }}</td>
                    </tr>
                    <tr class="cycle1 cycle2 cycle3 etudiant apprenti">
                        <th>Classe:</th><td>{{ form.classe }}</td>
                        <th>Enseignant:</th><td>{{ form.enseignant }}</td>
                    </tr>
                    <tr class="pre_scol cycle1 cycle2 cycle3">
                        <th>Accueil extra-fam.:</th><td>{{ form.creche }}</td>
                        <th>Responsable:</th><td>{{ form.creche_resp }}</td>
                    </tr>
                    <tr class="apprenti en_emploi sans_emploi">
                        <th>Entreprise:</th><td>{{ form.entreprise }}</td>
                        <th>Maître d'apprent.:</th><td>{{ form.maitre_apprentissage }}</td>
                    </tr>
                    <tr class="always">
                        <th>Remarque:</th><td colspan="3">{{ form.remarque }}</td>
                    </tr>
                </table>
                {% if form.instance|can_edit:user %}
                    {% include "actions.html" %}
                {% endif %}
            </form>
        </div>
    </div>
{% endblock %}
