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

<head>
  <meta charset="UTF-8">
  <title>02 Mai zarzis</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/flowbite@2.5.2/dist/flowbite.min.css" rel="stylesheet" />
  <script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
  <script src="https://cdn.tailwindcss.com"></script>
  <script src="https://cdn.jsdelivr.net/npm/flowbite@2.5.2/dist/flowbite.min.js"></script>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
  <style>
    body {
      font-family: 'Inter', sans-serif;
    }
  </style>
</head>

<body class="bg-gray-100 p-8">
  

<nav class=" bg-white border-gray-200 dark:bg-gray-900">
  <div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
  <a class="flex items-center space-x-3 rtl:space-x-reverse">
      
      <span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">02 Mai zarzis</span>
  </a>
  <div class="flex items-center md:order-2 space-x-3 md:space-x-0 rtl:space-x-reverse">
  <button
  type="button"
  class="flex items-center justify-center text-xl rounded-full p-4 md:me-0 focus:ring-4 focus:ring-gray-300 dark:focus:ring-gray-600 bg-gray-100 dark:bg-gray-800"
  id="user-menu-button"
  aria-expanded="false"
  data-dropdown-toggle="user-dropdown"
  data-dropdown-placement="bottom"
>
  <i class="fa-solid fa-user text-l"></i>
</button>

      <!-- Dropdown menu -->
      <div class="z-50 hidden my-4 text-base list-none bg-white divide-y divide-gray-100 rounded-lg shadow dark:bg-gray-700 dark:divide-gray-600" id="user-dropdown">
        <div class="px-4 py-3">
          <span class="block text-sm text-gray-900 dark:text-white"><?php echo e(Auth::user()->name); ?></span>
          <span class="block text-sm  text-gray-500 truncate dark:text-gray-400"><?php echo e(Auth::user()->email); ?></span>
        </div>
        <ul class="py-2" aria-labelledby="user-menu-button">
          <li>
            <a href="profile" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white">Profil</a>
          </li>
          <li>
          <form method="POST" action="<?php echo e(route('logout')); ?>" class="inline-block">
    <?php echo csrf_field(); ?>
    <a href="<?php echo e(route('logout')); ?>" 
       class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white"
       onclick="event.preventDefault(); this.closest('form').submit();">
        <?php echo e(__('Se déconnecter')); ?>

    </a>
</form>

          </li>
        </ul>
      </div>
      <button data-collapse-toggle="navbar-user" type="button" class="inline-flex items-center p-2 w-10 h-10 justify-center text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600" aria-controls="navbar-user" aria-expanded="false">
        <span class="sr-only">Open main menu</span>
        <svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 17 14">
            <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 1h15M1 7h15M1 13h15"/>
        </svg>
    </button>
  </div>
  <div class="items-center justify-between hidden w-full md:flex md:w-auto md:order-1" id="navbar-user">
    <ul class="flex flex-col font-medium p-4 md:p-0 mt-4 border border-gray-100 rounded-lg bg-gray-50 md:space-x-8 rtl:space-x-reverse md:flex-row md:mt-0 md:border-0 md:bg-white dark:bg-gray-800 md:dark:bg-gray-900 dark:border-gray-700">
      <!-- <li>
        <a href="#" class="block py-2 px-3 text-white text-gray-900 rounded md:bg-transparent md:text-gray-900 md:p-0 md:dark:text-gray-900" aria-current="page">Parents</a>
      </li> -->
      <li>
        <a href="/annees" class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700">Année Scolaire</a>
      </li>
      
      <li>
        <a href="/profs" class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700">Enseignants</a>
      </li>
      <li>
        <a href="/eleves" class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700">Eleve</a>
      </li>
      <li>
        <a href="/classes" class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700">Classe</a>
      </li>
      <li>
        <a href="/matieres" class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700">Matière</a>
      </li>
      <!-- <li>
        <a href="#" class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700">Bulletin</a>
      </li> -->
    </ul>
  </div>
  </div>
</nav>

<div class="py-4"></div>
<div class="flex items-center justify-between">
<button data-modal-target="crud-modal" data-modal-toggle="crud-modal"  type="button" class="py-2.5 px-5 me-2 mb-2 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700">Créer Matière</button>
<!-- <button type="button" class="py-2.5 px-5 me-2 mb-2 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700" onclick="document.getElementById('dropdown').classList.toggle('hidden')">Filtre</button>
<div id="dropdown" class="hidden absolute bg-white border border-gray-200 rounded-lg shadow-lg mt-2 p-2">
        <ul class="space-y-2">
            <li>
                <button class="block w-full text-sm py-2 px-4 text-gray-700 hover:bg-gray-100 rounded-lg">
                    Option 1
                </button>
            </li>
            <li>
                <button class="block w-full text-sm py-2 px-4 text-gray-700 hover:bg-gray-100 rounded-lg">
                    Option 2
                </button>
            </li>
            <li>
                <button class="block w-full text-sm py-2 px-4 text-gray-700 hover:bg-gray-100 rounded-lg">
                    Option 3
                </button>
            </li>
        </ul>
    </div> -->
    <form class="max-w-lg mx-auto">
    <div class="flex">
        <label for="search-dropdown" class="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white">Your Email</label>
        <button id="dropdown-button" data-dropdown-toggle="dropdown" class="flex-shrink-0 z-10 inline-flex items-center py-2.5 px-4 text-sm font-medium text-center text-gray-900 bg-gray-100 border border-gray-300 rounded-s-lg hover:bg-gray-200 focus:ring-4 focus:outline-none focus:ring-gray-100 dark:bg-gray-700 dark:hover:bg-gray-600 dark:focus:ring-gray-700 dark:text-white dark:border-gray-600" type="button">Année<svg class="w-2.5 h-2.5 ms-2.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
            <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
        </svg></button>
        <div id="dropdown" class="z-10 hidden bg-white divide-y divide-gray-100 rounded-lg shadow w-44 dark:bg-gray-700">
            <ul class="py-2 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="dropdown-button">
            <?php $__currentLoopData = $annees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $annee): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>


<li>
                    <button type="button" class="inline-flex w-full px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white" data-year="<?php echo e($annee->name); ?>"><?php echo e($annee->name); ?></button> 
                </li>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    
            </ul>
        </div>
        <div class="relative w-full">
            <input type="search" id="search-dropdown" class="block p-2.5 w-full z-20 text-sm text-gray-900 bg-gray-50 rounded-e-lg border-s-gray-50 border-s-2 border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-s-gray-700  dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:border-blue-500" placeholder="Recherche" required />
            <button type="submit" class="absolute top-0 end-0 p-2.5 text-sm font-medium h-full text-white bg-blue-700 rounded-e-lg border border-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
                <svg class="w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
                    <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z"/>
                </svg>
                <span class="sr-only">Recherche</span>
            </button>
        </div>
    </div>
</form>
</div>
<div class="py-4"></div>

 

<div class="relative overflow-x-auto  sm:rounded-lg">
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400" id="data-table">
    <thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
        <tr>
            <th scope="col" class="p-4"></th>
            <th scope="col" class="px-6 py-3">Matière</th>
            <th scope="col" class="px-6 py-3">Coefficient</th>
            <th scope="col" class="px-6 py-3">Année</th>
            <th scope="col" class="px-6 py-3">Action</th>
        </tr>
    </thead>
    <tbody>
        <?php $__currentLoopData = $matieres; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $matiere): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 <?php echo e($matiere->year); ?>">
            <th scope="col" class="p-4"></th>
            <td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white"><?php echo e($matiere->name); ?></td>
            <td class="px-6 py-4"><?php echo e($matiere->coefficient); ?></td>
            <td id = "year" class="px-6 py-4"><?php echo e($matiere->year); ?></td>
            <td class="px-6 py-4">
                <div class="flex gap-4">
                    <a href="#" class="edit-matiere font-medium text-blue-600 dark:text-blue-500 hover:underline" data-id="<?php echo e($matiere->id); ?>" data-name="<?php echo e($matiere->name); ?>" data-coefficient="<?php echo e($matiere->coefficient); ?>" data-year="<?php echo e($matiere->year); ?>">
                        <i class="fa-regular fa-pen-to-square"></i>
                    </a>
                    <form action="<?php echo e(route('matieres.destroy', $matiere->id)); ?>" method="POST" onsubmit="return confirm('Êtes-vous sûr de vouloir supprimer cette matière ?');">
                        <?php echo csrf_field(); ?>
                        <?php echo method_field('DELETE'); ?>
                        <button type="submit" class="btn btn-danger text-red-600"><i class="fa-regular fa-trash-can"></i></button>
                    </form>
                </div>
            </td>
        </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </tbody>
</table>

</div>

<!-- Single Modal -->
<div id="crud-modal-update" tabindex="-1" aria-hidden="true" class="hidden fixed top-0 right-0 left-0 z-50 flex justify-center items-center w-full h-screen">
    <div class="relative p-4 w-full max-w-md max-h-full">
        <div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
        <div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t dark:border-gray-600">
                  <h3 class="text-lg font-semibold text-gray-900 dark:text-white">
                  Modifier Matière
                  </h3>
                  <button type="button" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" id="close-modal">
                      <svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
                          <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
                      </svg>
                      <span class="sr-only">Close modal</span>
                  </button>
              </div>
            <form class="p-4 md:p-5" id="update-form" method="POST">
                <?php echo csrf_field(); ?>
                <?php echo method_field('PUT'); ?>
                <div class="grid gap-4 mb-4 grid-cols-2">
                    <div class="col-span-2 sm:col-span-1">
                        <label for="name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Matière</label>
                        <input type="text" name="name" id="modal-name" class="bg-gray-50 border text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500" required>
                    </div>
                    <div class="col-span-2 sm:col-span-1">
                        <label for="coefficient" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Coefficient</label>
                        <input type="number" name="coefficient" id="modal-coefficient" class="bg-gray-50 border text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500" required>
                    </div>
                    <div class="col-span-2">
                        <label for="year" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Année</label>
                        <select id="modal-year" name="year" class="bg-gray-50 border text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500">
                        <?php $__currentLoopData = $annees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $annee): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                            <option value="<?php echo e($annee->name); ?>"><?php echo e($annee->name); ?> </option>

                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
    
                    </div>
                </div>
                <button type="submit" class="text-white bg-blue-700 hover:bg-blue-800 rounded-lg text-sm px-5 py-2.5">
                    Modifier
                </button>
            </form>
        </div>
    </div>
</div>

  
  <!-- Main modal -->
  <div id="crud-modal" tabindex="-1" aria-hidden="true" class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
      <div class="relative p-4 w-full max-w-md max-h-full">
          <!-- Modal content -->
          <div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
              <!-- Modal header -->
              <div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t dark:border-gray-600">
                  <h3 class="text-lg font-semibold text-gray-900 dark:text-white">
                    Créer Matière
                  </h3>
                  <button type="button" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" data-modal-toggle="crud-modal">
                      <svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
                          <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
                      </svg>
                      <span class="sr-only">Close modal</span>
                  </button>
              </div>
              <!-- Modal body -->
              <form class="p-4 md:p-5" action="<?php echo e(route('matieres.store')); ?>" method="POST">

                  <?php echo csrf_field(); ?>

                  <div class="grid gap-4 mb-4 grid-cols-2">
                      <div class="col-span-2 sm:col-span-1">
                          <label for="name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Matière</label>
                          <input type="text" name="name" id="name" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"  required="">
                      </div>
                      <div class="col-span-2 sm:col-span-1">
                            <label for="coefficient" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Coefficient</label>
                            <input type="number" name="coefficient" id="coefficient" 
                                step="any" 
                                class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" 
                                
                                required>
                        </div>

                      <div class="col-span-2">
                          <label for="year" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Année</label>
                          <select id="year" name="year" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">
                              <option selected="">Sélectionner</option>
                              <?php $__currentLoopData = $annees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $annee): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                        <option value="<?php echo e($annee->name); ?>"><?php echo e($annee->name); ?> </option>

                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                        </div>
                        <button type="submit" class="text-white inline-flex items-center bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
                            <svg class="me-1 -ms-1 w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z" clip-rule="evenodd"></path></svg>
                            Créer
                        </button>
              </form>
          </div>
      </div>
  </div> 
  
</body>
<script>
   
   document.addEventListener('DOMContentLoaded', () => {
    const editButtons = document.querySelectorAll('.edit-matiere');
    const modal = document.getElementById('crud-modal-update');
    const closeModal = document.getElementById('close-modal');
    const form = document.getElementById('update-form');
    const nameInput = document.getElementById('modal-name');
    const coefficientInput = document.getElementById('modal-coefficient');
    const yearSelect = document.getElementById('modal-year');

    editButtons.forEach(button => {
        button.addEventListener('click', (e) => {
            e.preventDefault();
            const { id, name, coefficient, year } = button.dataset;

            // Populate modal fields
            nameInput.value = name;
            coefficientInput.value = coefficient;
            yearSelect.value = year;

            // Update form action
            form.action = `/matieres/${id}`;

            // Show modal
            modal.classList.remove('hidden');
        });
    });

    closeModal.addEventListener('click', () => {
        modal.classList.add('hidden');
    });
});




// Dropdown button click event to toggle visibility of the dropdown
document.getElementById('dropdown-button').addEventListener('click', function () {
        document.getElementById('dropdown').classList.toggle('hidden');
    });

 // When a dropdown option is clicked, update the button text and filter the table
 const yearButtons = document.querySelectorAll('#dropdown button');
    yearButtons.forEach(function (button) {
        button.addEventListener('click', function () {
            const selectedYear = button.getAttribute('data-year');
            console.log("Dropdown option selected: ", selectedYear);  // Log the selected year
            document.getElementById('dropdown-button').textContent = selectedYear;
            
            // If "Annuler" is selected, reset the filter
            if (selectedYear === 'Année') {
                resetFilter();
            } else {
                filterTable(selectedYear);
            }
            
            document.getElementById('dropdown').classList.add('hidden'); // Close the dropdown
        });
    });

    // Function to filter the table based on the selected year
    function filterTable(year) {
        console.log("Filtering table by year: ", year);  // Log the filtering action
        const rows = document.querySelectorAll('#data-table tbody tr');
        let rowsVisible = 0;
        rows.forEach(function (row) {
            const yearCell = row.querySelector('td#year'); // Get the <td> with id="year"
            if (yearCell) {
                const cellYear = yearCell.textContent.trim();
                if (cellYear === year || year === '') {
                    row.style.display = '';  // Show the row
                    rowsVisible++;
                } else {
                    row.style.display = 'none';  // Hide the row
                }
            }
        });
        console.log("Rows visible after filtering: ", rowsVisible);  // Log the number of visible rows
    }

   // Function to reset the filter and show all rows
   function resetFilter() {
        console.log("Resetting filter, showing all rows.");
        const rows = document.querySelectorAll('#data-table tbody tr');
        rows.forEach(function (row) {
            row.style.display = '';  // Show all rows
        });
    }

    // Optional: Filter by the search input (search across all columns)
    document.getElementById('search-dropdown').addEventListener('input', function () {
        const searchTerm = this.value.toLowerCase();
        const rows = document.querySelectorAll('#data-table tbody tr');
        rows.forEach(function (row) {
            const cells = row.getElementsByTagName('td');
            let match = false;
            for (let i = 0; i < cells.length; i++) {
                if (cells[i].textContent.toLowerCase().includes(searchTerm)) {
                    match = true;
                    break;
                }
            }
            row.style.display = match ? '' : 'none';  // Show or hide the row based on the search term
        });
    });
</script>
</html>
<?php /**PATH C:\Users\Toby\Desktop\my-app\resources\views/matieres/index.blade.php ENDPATH**/ ?>