<!DOCTYPE html>
<html lang="fr">

<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">

  <title>Admin | Bookcase</title>
  <meta content="" name="description">
  <meta content="" name="keywords">

  <!-- Favicons -->
  <link rel="shortcut icon" href="/images/favicon.png" type="image/x-icon">

  <!-- Google Fonts -->
  <link href="https://fonts.gstatic.com" rel="preconnect">
  <link
    href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i"
    rel="stylesheet">

  <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />

  <!-- Vendor CSS Files -->
  <link href="/assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href="/assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
  <link href="/assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
  <link href="/assets/vendor/quill/quill.snow.css" rel="stylesheet">
  <link href="/assets/vendor/quill/quill.bubble.css" rel="stylesheet">
  <link href="/assets/vendor/remixicon/remixicon.css" rel="stylesheet">
  <link href="/assets/vendor/simple-datatables/style.css" rel="stylesheet">

  <!-- Template Main CSS File -->
  <link href="/assets/css/style.css" rel="stylesheet">
  <style media="screen">
    .lien,
    .form1 {
      width: 40%;
      display: inline-block;
    }
  </style>

  <!-- =======================================================
  * Template Name: NiceAdmin - v2.2.2
  * Template URL: https://bootstrapmade.com/nice-admin-bootstrap-admin-html-template/
  * Author: BootstrapMade.com
  * License: https://bootstrapmade.com/license/
  ======================================================== -->
</head>

<body>

  <!-- ======= Header ======= -->
  <header id="header" class="header fixed-top d-flex align-items-center">

    <div class="d-flex align-items-center justify-content-between">
      <div class="d-flex justify-content-center">
        <a href="{{ url('admin') }}" class="logo d-flex align-items-center">
          <img src="/images/logo.png" alt="" class="img1 d-none d-lg-block">
          <img src="/images/favicon.png" alt="" class="img2 d-block d-lg-none">
        </a>
      </div>
      <i class="bi bi-list toggle-sidebar-btn"></i>
    </div><!-- End Logo -->

    <div class="search-bar">
      <form class="search-form d-flex align-items-center" method="POST" action="{{ route('search') }}">
        @csrf()
        <input type="hidden" name="hidden" value="1">
        <input type="text" name="recherche" placeholder="Recherche" title="Enter search keyword">
        <button type="submit" title="Search"><i class="bi bi-search"></i></button>
      </form>
    </div><!-- End Search Bar -->

    <nav class="header-nav ms-auto">
      <ul class="d-flex align-items-center">

        <li class="nav-item d-block d-lg-none">
          <a class="nav-link nav-icon search-bar-toggle " href="#">
            <i class="bi bi-search"></i>
          </a>
        </li><!-- End Search Icon-->

        <li class="nav-item dropdown">
          <!--Notification Icon-->
          <a class="nav-link nav-icon" href="#" data-bs-toggle="dropdown">
            <i class="bi bi-bell"></i>
            @php
              $countnotification = \App\Models\Notification::where('valider', 0)->count();
            @endphp
            @if ($countnotification)
              <span class="badge bg-primary badge-number">{{ $countnotification }}</span>
            @endif
          </a><!-- End Notification Icon -->

          <ul class="dropdown-menu dropdown-menu-end dropdown-menu-arrow notifications">
            <li class="dropdown-header">
              @if ($countnotification)
                Vous avez {{ $countnotification }} livre(s) en attente de validation.
                <a href="{{ url('admin/attente') }}"><span class="badge rounded-pill bg-primary p-2 ms-2">Tout
                    voir</span></a>
              @else
                Aucun livre en attente de validation.
              @endif
            </li>
            <li>
              <hr class="dropdown-divider">
            </li>
            @php
              $attentevalidation = \App\Models\Notification::where('valider', 0)
                  ->latest('id')
                  ->paginate(5)
                  ->all();
            @endphp
            @foreach ($attentevalidation as $notification)
              @php
                $livre = \App\Models\Book::where('ISBN', $notification->ISBN)->first();
              @endphp
              <a href="/books/read/{{ $livre->id }}" class="text-black">
                <li class="notification-item">
                  <div>
                    <h4>{{ $notification->nom_livre }} : {{ $notification->ISBN }}</h4>
                    <p>Téléversé par <strong>{{ $notification->nom_user }}</strong> le
                      <strong>{{ $notification->created_at->format('d M Y à H : i') }}</strong>.</p>
                  </div>
                </li>
                <li>
                  <hr class="dropdown-divider">
                </li>
              </a>
            @endforeach
            <li class="dropdown-footer">
              <a href="{{ url('admin/attente') }}">Afficher toutes les notifications</a>
            </li>
          </ul><!-- End Notification Dropdown Items -->
        </li><!-- End Notification Nav -->

        <li class="nav-item dropdown">

          <a class="nav-link nav-icon" href="#" data-bs-toggle="dropdown">
            <i class="bi bi-chat-left-text"></i>
            @php
              $countmsg = \App\Models\Contact::where('lu', 0)->count();
            @endphp
            @if ($countmsg)
              <span class="badge bg-success badge-number">{{ $countmsg }}</span>
            @endif

          </a><!-- End Messages Icon -->
          <ul class="dropdown-menu dropdown-menu-end dropdown-menu-arrow messages">
            <li class="dropdown-header">
              @if ($countmsg)
                Vous avez {{ $countmsg }} message(s) non lu
                <a href="{{ route('inbox') }}"><span class="badge rounded-pill bg-primary p-2 ms-2">Tout
                    voir</span></a>
              @else
                Pas de nouveaux messages
              @endif

            </li>
            <li>
              <hr class="dropdown-divider">
            </li>
            @php
              $nonlu = \App\Models\Contact::where('lu', 0)
                  ->latest('id')
                  ->paginate(5)
                  ->all();
            @endphp
            @foreach ($nonlu as $contact)
              <li class="message-item">
                <a href="{{ route('read_msg', $contact->id) }}">
                  <div>
                    <h4>{{ $contact->email }}</h4>
                    <p>{{ substr($contact->commentaire, 0, 50) }}...</p>
                  </div>
                </a>
              </li>
              <li>
                <hr class="dropdown-divider">
              </li>
            @endforeach
            <li class="dropdown-footer">
              <a href="{{ route('inbox') }}">Afficher tous les messages</a>
            </li>
          </ul><!-- End Messages Dropdown Items -->
        </li><!-- End Messages Nav -->

        <li class="nav-item dropdown pe-3">
          <a class="nav-link nav-profile d-flex align-items-center pe-0" href="#" data-bs-toggle="dropdown">
            <img src="/assets/img/admin.jpg" alt="Profile" class="rounded-circle">
            <span class="d-none d-md-block dropdown-toggle ps-2">A. Admin</span>
          </a><!-- End Profile Iamge Icon -->
          <ul class="dropdown-menu dropdown-menu-end dropdown-menu-arrow profile">
            <li class="dropdown-header">
              <h6>A.Admin</h6>
            </li>
            <li>
              <hr class="dropdown-divider">
            </li>
            <li>
              <a class="dropdown-item d-flex align-items-center" href="{{ route('profil', 0) }}">
                <i class="bi bi-person"></i>
                <span>Mon profil</span>
              </a>
            </li>
            <li>
              <hr class="dropdown-divider">
            </li>
            <li>
              <a class="dropdown-item d-flex align-items-center" href="{{ route('profil', 1) }}">
                <i class="bi bi-gear"></i>
                <span>Paramètres du Compte</span>
              </a>
            </li>
            <li>
              <hr class="dropdown-divider">
            </li>
            <li>
              <a class="dropdown-item d-flex align-items-center" href="{{ url('admin/pages-faq') }}">
                <i class="bi bi-question-circle"></i>
                <span>Aide</span>
              </a>
            </li>
            <li>
              <hr class="dropdown-divider">
            </li>
            <li>
              <a class="dropdown-item d-flex align-items-center" href="{{ route('logout') }}">
                <i class="bi bi-box-arrow-right"></i>
                <span>Déconnexion</span>
              </a>
            </li>
          </ul><!-- End Profile Dropdown Items -->
        </li><!-- End Profile Nav -->
      </ul>
    </nav><!-- End Icons Navigation -->
  </header><!-- End Header -->

  <!-- ======= Sidebar ======= -->

  @yield('sidebar')

  @yield('main')

  <!-- ======= Footer ======= -->
  <footer id="footer" class="footer">
    <div class="copyright">
      <a>© <?= now()->format('Y') ?> IITECH - Tous droits réservés.</a>
    </div>
  </footer><!-- End Footer -->

  <a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i
      class="bi bi-arrow-up-short"></i></a>

  <!-- Vendor JS Files -->
  <script src="/assets/vendor/apexcharts/apexcharts.min.js"></script>
  <script src="/assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
  @if (Request::is('admin/users-profile') and session()->has('error'))
    <script type="text/javascript" defer>
      document.getElementsByClassName('bouton')[0].click()
    </script>
  @endif
  <script src="/assets/vendor/simple-datatables/simple-datatables.js"></script>
  <script src="/assets/vendor/tinymce/tinymce.min.js"></script>
  <script src="/assets/vendor/php-email-form/validate.js"></script>
  <!-- Template Main JS File -->
  <script src="/assets/js/main.js"></script>
  <script src="/js/jquery-3.2.1.min.js"></script>
  <script type="text/javascript">
    function supprimer(champ) {
      var isbn = champ.isbn.value
      var titre = champ.titre.value
      var vers = champ.vers.value
      console.log(titre)
      $("#modal-titre1").html(titre);
      $("#modal-version1").html(vers);
      document.getElementById('formM').action = "{{ url('/') }}/admin/supp/" + isbn;
      $('#confModal1').modal('show');
      return false;
    }

    function supprimerD(champ) {
      var isbn = champ.isbn.value
      var titre = champ.titre.value
      var vers = champ.vers.value
      console.log(titre)
      $("#modal-titre2").html(titre);
      $("#modal-version2").html(vers);
      document.getElementById('formD').action = "{{ url('/') }}/admin/force/" + isbn;
      $('#confModal3').modal('show');
      return false;
    }

    function supprimerMsg(champ) {
      document.getElementById("formMsg").action = "{{ url('/') }}/admin/messages/del/" + champ.id.value;
      $('#confModal4').modal('show');
      return false
    }

    function supprimerDef(champ) {
      var nom = champ.nom.value

      $("#modal-titre3").html(nom);
      document.getElementById('formDef').action = "{{ url('/') }}/admin/forceDoc/" + nom;
      $('#confModal4').modal('show');
      return false;
    }

    function supprimerNDef(champ) {
      var nom = champ.nom.value
      $("#modal-titre4").html(nom);
      document.getElementById('formNDef').action = "{{ url('/') }}/admin/suppDoc/" + nom;
      $('#confModal5').modal('show');
      return false;
    }

    function emprunter(champ) {
      var id = champ.iden.value
      var titre = champ.titre.value
      var vers = champ.vers.value
      console.log(titre)
      $("#modal-titre1").html(titre);
      $("#modal-version1").html(vers);
      $('#confModal6').modal('show');
      document.getElementById('lien1').href = "{{ url('/') }}/books/valid_ajout/" + id;
      return false;
    }
  </script>
  <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  <script>
    $(document).ready(function() {
      $('.js-example-basic-multiple').select2({
        placeholder: {
          text: "Choisir une discipline..."
        }
      });
    });
  </script>

</body>

</html>
