@extends('layout')

@section('contenu')

    @include('/partials/modalModifierEvaluation')
    @include('/partials/modalConfirmSuppEvaluation')

    <section
        style="background-image: url('/img/bgclasse.png'); background-attachment: fixed; background-repeat: no-repeat; background-size: cover; min-height: 93.2vh"
        class="section mt-0 columns mx-0 mb-0 is-centered">
        <section class="section container column is-two-thirds">
            <section class="section is-link is-light p-0">
                <h1 class="title is-1 is-size-3-touch has-text-centered has-text-white">{{ $classe->libelle }}</h1>
                <h1 class="subtitle is-6 has-text-centered has-text-white">{{ $classe->type }}</h1>
            </section>
            <nav class="panel has-background-light is-info mt-2">
                <p class="panel-heading mb-3">
                    L'historique des évaluations dans cette classe
                </p>
                @if (count($evaluations) == 0)
                    <p class="title is-6 has-text-centered pb-4">Il n'y pas encore d'évaluations dans cette classe</p>
                @else
                    @foreach ($evaluations->sortByDesc('id') as $evaluation)
                        <div class="content box has-background-light">
                            <div class="has-text-weight-bold has-text-success"><span
                                    class="has-text-weight-bold">Date:</span>
                                {{ date('d/m/Y', strtotime($evaluation->date)) }}</div>
                            @foreach ($matieres as $matiere)
                                @if ($matiere->id == $evaluation->matiere_id)
                                    <div><span class="has-text-weight-bold">Matière:</span> {{ $matiere->libelle }}</div>
                                @endif
                            @endforeach
                            @if ($classe->type == 'Secondaire')
                                <div><span class="has-text-weight-bold">Trimestre/Semestre:</span> {{ $evaluation->semestre }}</div>
                            @else
                                <div><span class="has-text-weight-bold">Trimestre:</span> {{ $evaluation->semestre }}</div>
                            @endif

                            <div class="buttons">
                                @if (auth()->user()->administrateur == 1)
                                    <a type="button" class="button is-info is-light"
                                        onclick="get_classe_slug('{{$classe->slug}}'); get_eval_id({{ $evaluation->id }}); get_classe_libelle('{{ $classe->libelle }}'); openForm('modalSuppEvaluation')">Supprimer</a>
                                    <a type="button" class="button is-info is-light"
                                        onclick="get_classe_slug('{{$classe->slug}}') ; getOldMatiere({{ $evaluation->matiere_id }}); getOldDate('{{ date('Y-m-d', strtotime($evaluation->date)) }}'); get_eval_id({{ $evaluation->id }}); get_classe_libelle('{{ $classe->libelle }}'); openForm('modal_modifier_evaluation');">Modifier</a>
                                @endif
                                <a href="/accueil/classe/{{ $classe->slug }}/evaluationHistory/{{ $evaluation->slug }}/details"
                                    type="button" class="button supp_cours is-info is-light">Détails</a>
                            </div>
                        </div>
                    @endforeach
                @endif
            </nav>
        </section>
    </section>
    @include('/partials/evaluationJs')
@endsection
