@extends('layout')

@section('contenu')
    @include('/partials/modalConfirmSuppProf')
    @include('/partials/modalConfirmReinPassword')
    <section
        style="background-image: url('/img/board.png'); background-attachment: fixed; background-repeat: no-repeat; background-size: cover; min-height: 94.8vh;"
        class="section columns p-0 mt-0 mx-0 mb-0 is-centered">
        <article class="panel is-info column is-8">
            <p class="panel-heading is-flex is-justify-content-space-between">
                {{ $professeur->prenom }} {{ $professeur->nom }}
                @if (auth()->user()->role == 'administration')
                <button class="button is-rounded is-info is-light" onclick="openForm('modalReinPassword')">
                    <span class="icon">
                        <i class="fas fa-key"></i>
                    </span>
                    <span>Restaurer accès</span>
                </button>
                @endif
            </p>
            <p class="panel-tabs has-background-white is-flex is-justify-content-space-around">
                <a title="informations" id="default" onclick="openContent(event, 'info')"
                    class="is-size-7-mobile tab icon-text">
                    <span class="icon">
                        <i class="fas fa-info-circle"></i>
                    </span>
                    <span class="is-hidden-touch">Informations</span>
                </a>
                <a title="Cours" onclick="openContent(event, 'cours')" class="is-size-7-touch tab icon-text">
                    <span class="icon">
                        <i class="fas fa-edit"></i>
                    </span>
                    <span class="is-hidden-touch">Cours</span>
                </a>
                <a title="Salaires" onclick="openContent(event, 'salaires')" class="is-size-7-touch tab icon-text">
                    <span class="icon">
                        <i class="fas fa-money-check-alt"></i>
                    </span>
                    <span class="is-hidden-touch">Salaires</span>
                </a>
            </p>
            <div id="info" class="panel-block is-justify-content-center" style="background: #E4E9F2; display: none">
                <div class="content column is-10">
                    <div class="is-flex is-justify-content-center mb-5">
                        <figure class="image is-128x128">
                            <img class="is-rounded" src="https://bulma.io/assets/images/placeholders/128x128.png">
                        </figure>
                    </div>
                    <form id="info_prof">
                        @csrf
                        <div class="columns mb-0">
                            <div class="field column">
                                <label class="label title is-6" for="prenom_prof_id">Prénom</label>
                                <p class="control">
                                    <input id="prenom_prof_id"
                                        class="input is-info is-rounded
                                @error('prenom_prof') is-invalid @enderror"
                                        type="text" placeholder="Papa Abdou" name="prenom_prof" required
                                        value="{{ $professeur->prenom }}" disabled />
                                </p>
                                @error('prenom_prof')
                                    <div class="help is-danger error">{{ $message }}</div>
                                @enderror
                            </div>
                            <div class="field column">
                                <label class="label title is-6" for="nom_prof_id">Nom</label>
                                <p class="control">
                                    <input id="nom_prof_id"
                                        class="input is-info is-rounded
                                @error('nom_prof') is-invalid @enderror"
                                        type="text" placeholder="Mbodji" name="nom_prof" required
                                        value="{{ $professeur->nom }}" disabled />
                                </p>
                                @error('nom_prof')
                                    <div class="help is-danger error">{{ $message }}</div>
                                @enderror
                            </div>
                        </div>
                        <div class="columns mb-0">
                            <div class="field column">
                                <label class="label title is-6" for="date_naissance_prof_id">Date de naissance</label>
                                <p class="control">
                                    <input id="date_naissance_prof_id"
                                        class="input is-info is-rounded
                                @error('date_naissance_prof') is-invalid @enderror"
                                        type="date" placeholder="01/01/2000" name="date_naissance_prof" required
                                        value="{{ $professeur->date_naissance }}" disabled />
                                </p>
                                @error('date_naissance_prof')
                                    <div class="help is-danger error">{{ $message }}</div>
                                @enderror
                            </div>
                            <div class="field column">
                                <label class="label title is-6" for="lieu_naissance_prof_id">Lieu de naissance</label>
                                <p class="control">
                                    <input id="lieu_naissance_prof_id"
                                        class="input is-info is-rounded
                                @error('lieu_naissance_prof') is-invalid @enderror"
                                        type="text" placeholder="Dakar" name="lieu_naissance_prof" required
                                        value="{{ $professeur->lieu_naissance }}" disabled />
                                </p>
                                @error('lieu_naissance_prof')
                                    <div class="help is-danger error">{{ $message }}</div>
                                @enderror
                            </div>
                        </div>
                        <div class="field">
                            <label class="label title is-6" for="adresse_prof_id">Adresse</label>
                            <p class="control">
                                <input id="adresse_prof_id"
                                    class="input is-info is-rounded
                                @error('adresse_prof') is-invalid @enderror"
                                    type="text" placeholder="Cambérène Quartier Deggo" name="adresse_prof" required
                                    value="{{ $professeur->adresse }}" disabled />
                            </p>
                            @error('adresse_prof')
                                <div class="help is-danger error">{{ $message }}</div>
                            @enderror
                        </div>
                        <div class="columns mb-0">
                            <div class="field column">
                                <label class="label title is-6" for="telephone_prof_id">Téléphone</label>
                                <p class="control">
                                    <input id="telephone_prof_id"
                                        class="input input-phone is-info is-rounded
                                @error('telephone_prof_id') is-invalid @enderror"
                                        type="text" placeholder="76 141 22 78" name="telephone_prof" required
                                        value="{{ $professeur->telephone }}" disabled />
                                </p>
                                @error('telephone_prof')
                                    <div class="help is-danger error">{{ $message }}</div>
                                @enderror
                            </div>
                            <div class="field column">
                                <label class="label title is-6" for="email_prof_id">Email</label>
                                <p class="control">
                                    <input id="email_prof_id"
                                        class="input is-info is-rounded
                                @error('email_prof') is-invalid @enderror"
                                        type="email" placeholder="abdoumbodji1401@gmail.com" name="email_prof" required
                                        value="{{ $professeur->email }}" disabled />
                                </p>
                                @error('email_prof')
                                    <div class="help is-danger error">{{ $message }}</div>
                                @enderror
                            </div>
                        </div>
                        <div class="columns mb-0">
                            @if (auth()->user()->administrateur == 1)
                                <div class="field column">
                                    <label class="label title is-6" for="salaire_prof_id">Salaire</label>
                                    <p class="control">
                                        <input id="salaire_prof_id"
                                            class="input input-numeral is-info is-rounded
                                @error('salaire_prof') is-invalid @enderror"
                                            type="text" placeholder="Salaire du professeur" name="salaire_prof" required
                                            value="{{ $professeur->salaire }}" disabled />
                                    </p>
                                    @error('salaire_prof')
                                        <div class="help is-danger error">{{ $message }}</div>
                                    @enderror
                                </div>
                            @endif
                            <div class="field column">
                                <label class="label title is-6" for="niveau_prof_id">Niveau</label>
                                <div class="control">
                                    <div class="select is-info is-rounded">
                                        <select id="niveau_prof_id" name="niveau_prof"
                                            class="@error('niveau_prof') is-invalid @enderror" required disabled>
                                            <option value="{{ $professeur->niveau }}">{{ $professeur->niveau }}
                                            </option>
                                            @if ($professeur->niveau != 'Primaire')
                                                <option value="Primaire">Primaire</option>
                                            @else
                                                <option value="Secondaire">Secondaire</option>
                                            @endif
                                        </select>
                                    </div>
                                </div>
                                @error('niveau_prof')
                                    <div class="help is-danger error">{{ $message }}</div>
                                @enderror
                            </div>
                        </div>
                        <div class="columns mb-0">
                            <div class="field column">
                                <label class="label title is-6">Classes</label>
                                <div id="classes_prof_id" style="height: 10rem; overflow-y: auto;">
                                    @foreach ($classes as $classe)
                                        @if ($classe->type == 'Primaire')
                                            <label class="checkbox column classe_prof_primaire is-hidden">
                                                <input class="classe_prof" type="checkbox" value="{{ $classe->id }}" disabled>
                                                {{ $classe->libelle }}
                                            </label>
                                        @else
                                            <label class="checkbox column classe_prof_secondaire is-hidden">
                                                <input class="classe_prof" type="checkbox" value="{{ $classe->id }}" disabled>
                                                {{ $classe->libelle }}
                                            </label>
                                        @endif
                                    @endforeach
                                </div>
                            </div>
                            <div class="field column">
                                <label class="label title is-6" for="matieres_prof_id">Matières</label>
                                <div style="height: 10rem; overflow-y: auto;">
                                    @foreach ($matieres as $matiere)
                                        @if ($matiere->niveau == 'Primaire')
                                            <label class="checkbox column matiere_prof_primaire is-hidden">
                                                <input class="matiere_prof" type="checkbox" value="{{ $matiere->id }}" disabled>
                                                {{ $matiere->libelle }}
                                            </label>
                                        @else
                                            <label class="checkbox column matiere_prof_secondaire is-hidden">
                                                <input class="matiere_prof" type="checkbox" value="{{ $matiere->id }}" disabled>
                                                {{ $matiere->libelle }}
                                            </label>
                                        @endif
                                    @endforeach
                                </div>
                            </div>
                        </div>
                        @if (auth()->user()->administrateur == 1)
                            <div class="buttons is-centered">
                                <button type="button" id="" class="button is-info is-light"
                                    onclick="openForm('modalSuppProf')">Supprimer</button>
                                <button id="btn_modif" type="button" class="button is-info is-light"
                                    onclick="modifier('info_prof')">Modifier</button>
                                <button id="btn_enr" class="button is-info is-light" disabled>Enregistrer</button>
                            </div>
                        @endif
                    </form>
                </div>
            </div>
            <div id="cours" class="panel-block is-justify-content-center" style="background: #E4E9F2">
                <div class="content column is-10">
                    @if ($professeur->cours->where('promo', auth()->user()->current_year)->count() == 0)
                        <div class="title is-6 has-text-centered">Pas encore de cours</div>
                    @else
                        @foreach ($professeur->cours->where('promo', auth()->user()->current_year)->sortByDesc('id') as $cour)
                            <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($cour->created_at)) }}</div>
                                <div><span class="has-text-weight-bold">Détails:</span> {!! nl2br($cour->description) !!}</div>
                                @foreach ($classes as $classe)
                                    @if ($classe->id == $cour->classe_id)
                                        <div><span class="has-text-weight-bold">Classe:</span> {{ $classe->libelle }}
                                        </div>
                                    @endif
                                @endforeach
                                @foreach ($matieres as $matiere)
                                    @if ($matiere->id == $cour->matiere_id)
                                        <div><span class="has-text-weight-bold">Matière:</span> {{ $matiere->libelle }}
                                        </div>
                                    @endif
                                @endforeach
                                <div><span class="has-text-weight-bold">Heure de
                                        début:</span>{{ date('H:i', strtotime($cour->debut)) }}</div>
                                <div><span class="has-text-weight-bold">Heure de
                                        fin:</span>{{ date('H:i', strtotime($cour->fin)) }}</div>
                            </div>
                        @endforeach
                    @endif
                </div>
            </div>
            <div id="salaires" class="panel-block is-justify-content-center" style="background: #E4E9F2">
                <div class="content column is-10">
                    @if (auth()->user()->administrateur != 1)
                        <span class="title is-3 is-centered">Vous n'avez pas accès à ces informations</span>
                    @else
                        Les salaires
                    @endif
                </div>
            </div>
        </article>
    </section>
    @include('/partials/detailsProfJs')
@endsection
