<!-- Modifier cours========================================================= -->
<div class="modal animate__animated animate__bounce" id="modal_modifier_cours">
    <div onclick="closeForm('modal_modifier_cours')" class="modal-background"></div>
    <div class="modal-card">
        <header class="modal-card-head">
            <p class="modal-card-title">Modifier le cours</p>
            <button type="button" onclick="closeForm('modal_modifier_cours')" class="delete"
                aria-label="close"></button>
        </header>
        <section class="modal-card-body">
            <div class="content">
                <form id="form_modifier_cours">
                    @csrf
                    <div class="field">
                        <label class="label title is-6" for="nv_description_id">Description du cours</label>
                        <p class="control">
                            <textarea id="nv_description_id" class="textarea is-info is-rounded
                                @error('nv_description') is-invalid @enderror"
                                placeholder="Donnez les détails du cours" name="nv_description" required></textarea>
                        </p>
                        @error('nv_description')
                            <div class="help is-danger error">{{ $message }}</div>
                        @enderror
                    </div>
                    <div class="field mb-5">
                        <label class="label title is-6" for="nv_prof_id">Professeur</label>
                        <div class="control">
                            <div class="select is-info is-rounded">
                                <select id="nv_prof_id" name="nv_prof" class="@error('nv_prof') is-invalid @enderror"
                                    required>
                                    <option value="" disabled selected>Sélectionner</option>
                                    @if ($classe->type == 'Primaire')
                                        @foreach ($professeurs->sortBy('nom') as $professeur)
                                            @if ($professeur->niveau == 'Primaire')
                                                <option value="{{ $professeur->id }}">{{ $professeur->prenom }}
                                                    {{ $professeur->nom }}</option>
                                            @endif
                                        @endforeach
                                    @else
                                        @foreach ($professeurs->sortBy('nom') as $professeur)
                                            @if ($professeur->niveau == 'Secondaire')
                                                <option value="{{ $professeur->id }}">{{ $professeur->prenom }}
                                                    {{ $professeur->nom }}</option>
                                            @endif
                                        @endforeach
                                    @endif
                                </select>
                            </div>
                        </div>
                        @error('nv_prof')
                            <div class="help is-danger error">{{ $message }}</div>
                        @enderror
                    </div>
                    <div class="field mb-5">
                        <label class="label title is-6" for="nv_matiere_id">Matière</label>
                        <div class="control">
                            <div class="select is-info is-rounded">
                                <select id="nv_matiere_id" name="nv_matiere"
                                    class="@error('nv_matiere') is-invalid @enderror" required>
                                    <option value="" disabled selected>Sélectionner</option>
                                    @if ($classe->type == 'Primaire')
                                        @if (auth()->user()->role == 'professeur')
                                            @foreach ($professeurs as $professeur)
                                                @if (str_replace(' ', '', $professeur->telephone) == auth()->user()->nom_utilisateur)
                                                    @foreach ($professeur->matieres as $matiere)
                                                        @if ($matiere->niveau == 'Primaire')
                                                            <option value="{{ $matiere->id }}">
                                                                {{ $matiere->libelle }}</option>
                                                        @endif
                                                    @endforeach
                                                @endif
                                            @endforeach
                                        @else
                                            @foreach ($matieres as $matiere)
                                                @if ($matiere->niveau == 'Primaire')
                                                    <option value="{{ $matiere->id }}">{{ $matiere->libelle }}
                                                    </option>
                                                @endif
                                            @endforeach
                                        @endif
                                    @else
                                        @if (auth()->user()->role == 'professeur')
                                            @foreach ($professeurs as $professeur)
                                                @if (str_replace(' ', '', $professeur->telephone) == auth()->user()->nom_utilisateur)
                                                    @foreach ($professeur->matieres as $matiere)
                                                        @if ($matiere->niveau == 'Secondaire')
                                                            <option value="{{ $matiere->id }}">
                                                                {{ $matiere->libelle }}</option>
                                                        @endif
                                                    @endforeach
                                                @endif
                                            @endforeach
                                        @else
                                            @foreach ($matieres as $matiere)
                                                @if ($matiere->niveau == 'Secondaire')
                                                    <option value="{{ $matiere->id }}">{{ $matiere->libelle }}
                                                    </option>
                                                @endif
                                            @endforeach
                                        @endif
                                    @endif
                                </select>
                            </div>
                        </div>
                        @error('nv_matiere')
                            <div class="help is-danger error">{{ $message }}</div>
                        @enderror
                    </div>
                    <div class="field">
                        <label class="label title is-6" for="nv_debut_id">Heure de début</label>
                        <p class="control">
                            <input id="nv_debut_id"
                                class="input is-info is-rounded
                                @error('nv_debut') is-invalid @enderror"
                                type="time" name="nv_debut" required />
                        </p>
                        @error('nv_debut')
                            <div class="help is-danger error">{{ $message }}</div>
                        @enderror
                    </div>
                    <div class="field">
                        <label class="label title is-6" for="nv_fin_id">Heure de fin</label>
                        <p class="control">
                            <input id="nv_fin_id"
                                class="input is-info is-rounded
                                @error('nv_fin') is-invalid @enderror"
                                type="time" name="nv_fin" required />
                        </p>
                        @error('nv_fin')
                            <div class="help is-danger error">{{ $message }}</div>
                        @enderror
                    </div>
                    <button id="submit_form_modifier_cours" hidden></button>
                    <button type="reset" class="btn_reset" hidden></button>
                </form>
            </div>
        </section>
        <footer class="modal-card-foot">
            <button type="button" onclick="closeForm('modal_modifier_cours')"
                class="button is-light is-danger is-rounded">Annuler</button>
            <button onclick="get_classe_slug('{{ $classe->slug }}'); $('#submit_form_modifier_cours').click()"
                class="button is-info is-link is-rounded">Enregistrer</button>
        </footer>
    </div>
</div>
