<!-- Ajouter Note========================================================= -->
<div class="modal animate__animated animate__fadeInLeft" id="modal_ajouter_note">
    <div onclick="closeForm('modal_ajouter_note')" class="modal-background"></div>
    <div class="modal-card">
        <header class="modal-card-head">
            <p class="modal-card-title">Ajouter Note</p>
            <button type="button" onclick="closeForm('modal_ajouter_note')" class="delete"
                aria-label="close"></button>
        </header>
        <section class="modal-card-body">
            <div class="content">
                <form id="form_ajouter_note">
                    @csrf
                    <div class="field mb-5">
                        <label class="label title is-6" for="evaluation_id">Evaluation</label>
                        <div class="control">
                            <div class="select is-info is-rounded">
                                <select name="evaluation" id="evaluation_id"
                                    class="@error('evaluation') is-invalid
                                    @enderror"
                                    required>
                                    <option value="" disabled selected>Sélectionner</option>
                                    @foreach ($evaluations->sortByDesc('id') as $evaluation)
                                        <option class="{{$matieres->find($evaluation->matiere_id)->coefficient}}" value="{{ $evaluation->id }}">
                                            @foreach ($matieres as $matiere)
                                                @if ($matiere->id == $evaluation->matiere_id)
                                                    Evaluation {{ $matiere->libelle }} du
                                                    {{ date('d/m/Y', strtotime($evaluation->date)) }}
                                                @endif
                                            @endforeach
                                        </option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        @error('evaluation')
                            <div class="help is-danger error">{{ $message }}</div>
                        @enderror
                    </div>
                    <div class="field mb-5">
                        <label class="label title is-6" for="type_note_id">Type de Note</label>
                        <div class="control">
                            <div class="select is-info is-rounded">
                                <select id="type_note_id" name="type_note"
                                    class="@error('type_note') is-invalid
                                    @enderror"
                                    required>
                                    <option value="" disabled selected>Sélectionner</option>
                                    @if ($classe->type == 'Primaire')
                                        <option value="Contrôle">Contrôle</option>
                                        <option value="Composition">Composition</option>
                                    @else
                                        <option value="Devoir">Devoir</option>
                                        <option value="Examen">Examen</option>
                                    @endif
                                </select>
                            </div>
                        </div>
                        @error('type_note')
                            <div class="help is-danger error">{{ $message }}</div>
                        @enderror
                    </div>
                    <div class="field">
                        <label class="label title is-6" for="valeur_note_id">Valeur</label>
                        <p class="control">
                            <input id="valeur_note_id" min="0" max="{{$classe->type == 'Primaire' ? '60' : '20'}}" type="number" class="input is-info is-rounded"
                                title="{{$classe->type == 'Primaire' ? 'Respectez le barême' : 'Entre 0 et 20'}}" name="valeur_note" placeholder="00" required>
                        </p>
                        @error('valeur_note')
                            <div class="help is-danger error">{{ $message }}</div>
                        @enderror
                    </div>
                    <button id="submit_form_ajouter_note" hidden></button>
                    <button type="reset" class="btn_reset" hidden></button>
                </form>
            </div>
        </section>
        <footer class="modal-card-foot">
            <button type="button" class="button is-light is-danger is-rounded"
                onclick="closeForm('modal_ajouter_note')">Annuler</button>
            <button class="button is-info is-link is-rounded"
                onclick="$('#submit_form_ajouter_note').click()">Enregistrer</button>
        </footer>
    </div>
</div>
