@extends('admin.template')

@section('sidebar')
    <aside id="sidebar" class="sidebar">

        <ul class="sidebar-nav" id="sidebar-nav">

            <li class="nav-item">
                <a class="nav-link" href="{{ url('admin') }}">
                    <i class="bi bi-grid"></i>
                    <span>Tableau de Bord</span>
                </a>
            </li><!-- End Dashboard Nav -->

            <li class="nav-item">
                <a class="nav-link collapsed" data-bs-target="#components-nav" data-bs-toggle="collapse" href="#">
                    <i class="bi bi-menu-button-wide"></i><span>Gestion des livres </span><i
                        class="bi bi-chevron-down ms-auto"></i>
                </a>
                <ul id="components-nav" class="nav-content collapse" data-bs-parent="#sidebar-nav">
                    <li>
                        <a href="{{ url('admin/consulter_book') }}">
                            <i class="bi bi-circle"></i><span>Livres disponibles </span>
                        </a>
                    </li>
                    <li>
                        <a href="{{ url('admin/add') }}">
                            <i class="bi bi-circle"></i><span>Ajouter un livre</span>
                        </a>
                    </li>
                    <li>
                        <a href="{{ url('admin/supp') }}">
                            <i class="bi bi-circle"></i><span>Livres supprimés</span>
                        </a>
                    </li>
                    <li>
                        <a href="{{ url('admin/attente') }}">
                            <i class="bi bi-circle"></i><span>Livres en attente </span>
                        </a>
                    </li>


                </ul>


            <li class="nav-item">
                <a class="nav-link collapsed" data-bs-target="#forms-nav" data-bs-toggle="collapse" href="#">
                    <i class="bi bi-journal-text"></i><span>Documentations </span><i
                        class="bi bi-chevron-down ms-auto"></i>
                </a>
                <ul id="forms-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
                    <li>
                        <a href="{{ url('admin/add_document') }}">
                            <i class="bi bi-circle"></i><span>Ajouter un document </span>
                        </a>
                    </li>
                    <li>
                        <a href="{{ url('admin/supp_document') }}">
                            <i class="bi bi-circle"></i><span>Documents supprimés  </span>
                        </a>
                    </li>
                    <li>
                        <a href="{{ url('admin/consulter') }}">
                            <i class="bi bi-circle"></i><span>Documents disponibles </span>
                        </a>
                    </li>
                </ul>
            </li><!-- End Forms Nav -->
            <li class="nav-heading">Pages</li>

            <li class="nav-item">
                <a class="nav-link collapsed" href="{{ route('profil',  0) }}">
                    <i class="bi bi-person"></i>
                    <span>Profil</span>
                </a>
            </li><!-- End Profile Page Nav -->

            <li class="nav-item">
                <a class="nav-link collapsed" href="{{ url('admin/pages-faq') }}">
                    <i class="bi bi-question-circle"></i>
                    <span>Aide</span>
                </a>
            </li><!-- End F.A.Q Page Nav -->


        </ul>
    </aside>
@endsection

@section('main')
    <main id="main" class="main">

        <!--Affichage du livre-->
        <section class="container myframe" style="margin-top: 80px;">
            <h3>{{ $book->titre }} - {{ $book->auteur }}</h3>
            <p> {{ $book['description'] }} </p>
            <p class="text-success">
                <strong>Très utile en :</strong>
                @php
                    $i = 0;
                    $book_disc = \App\Models\Book_Discipline::all();
                    $disciplines = \App\Models\Discipline::all();
                @endphp
                @foreach ($book_disc as $b_d)
                    @if ($b_d['book_id'] == $book['id'])
                        @foreach ($disciplines as $discipline)
                            @if ($discipline['id'] == $b_d['discipline_id'])
                                @if ($i == 0)
                                    {{ $discipline['nameDiscipline'] }}
                                    @php
                                        $i = 1;
                                    @endphp
                                @else
                                    , {{ $discipline['nameDiscipline'] }}
                                @endif
                            @endif
                        @endforeach
                    @endif
                @endforeach
                .
            </p>
            <small class="text-primary">
                @if ($book['edition'])
                    Edition : {{ $book['edition'] }} -
                @endif
                ISBN : {{ $book['ISBN'] }}
            </small>
            @if ($book->etat == 0)
                <div class="col-12" style="text-align:right;"><a class="btn btn-secondary col-7 col-lg-3 text-white"
                    href="#" data-toggle="modal" data-target="#confModal">Valider l'ajout du livre</a></div>
            @endif
            <br>
            <section class="mb-5 position-relative">
                <div class="cacher position-absolute"></div>
                <iframe src="{{ $book->fichier }}" class="iframe container" frameborder="0" width="100%"
                    height="1000px"></iframe>
            </section>
            <br>
            @if ($book->etat == 0)
                <div class="col-12" style="text-align:center;"><a class="btn btn-secondary col-7 col-lg-3 text-white"
                    href="#" data-toggle="modal" data-target="#confModal">Valider l'ajout du livre</a></div>
                <br><br>
            @endif
        </section>

        <div class="modal fade" id="confModal" tabindex="-1" role="dialog" aria- labelledby="confModalLabel"
            aria-hidden="true">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="confModalLabel">{{ $book['titre'] }} -
                            {{ $book['auteur'] }}</h5>
                        <button type="button" class="close" data-dismiss="modal" aria- label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        Souhaitez-vous vraiment ajouter ce livre à la base de données des livres ?
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
                        <button type="button" class="btn btn-primary"><a class="col-10 text-white"
                                href="{{ route('book.valid.ajout', $book->id) }}">Ajouter</a></button>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <script src="/js/jquery-3.2.1.min.js"></script>
    @if (session()->has('success'))
    <script type="text/javascript">
        $(window).on('load',function(){
        $('#confModal1').modal('show');
        });
    </script>
    <!-- Fenetre modale 1-->

    <div class="modal fade" id="confModal1" tabindex="-1" role="dialog" aria-
    labelledby="confModalLabel1" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title text-success" id="confModalLabel1">{{session('success')}}</h5>
                        <button type="button" class="close" data-bs-dismiss="modal" aria-
                        label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-success" data-bs-dismiss="modal">D'accord</button>
                </div>
            </div>
        </div>
    </div>
    <!-- Fin fenetre modale 1-->
    @elseif (session()->has('error'))
        <script src="/js/jquery-3.2.1.min.js"></script>
        <script type="text/javascript">
            $(window).on('load',function(){
            $('#confModal2').modal('show');
            });
        </script>
        <!-- Fenetre modale 2-->

        <div class="modal fade" id="confModal2" tabindex="-1" role="dialog" aria-
        labelledby="confModalLabel2" aria-hidden="true">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title text-danger" id="confModalLabel2">{{session('error')}}</h5>
                            <button type="button" class="close" data-bs-dismiss="modal" aria-
                            label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-danger" data-bs-dismiss="modal">D'accord</button>
                    </div>
                </div>
            </div>
        </div>
    @endif
    <!-- Fin fenetre modale 2-->
    <script src="/js/popper.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/jquery.magnific-popup.min.js"></script>
    <script src="/js/owl.carousel.min.js"></script>
    <script src="/js/slick.min.js"></script>
    <script src="/js/jquery.meanmenu.min.js"></script>
    <script src="/js/wow.min.js"></script>
    <!-- Counter Script -->
    <script src="/js/waypoints.min.js"></script>
    <script src="/js/jquery.counterup.min.js"></script>
    <script src="/js/custom.js"></script>
@endsection


<!--Affichage -->
