<!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;
    }
    .modal-backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 40;
}
.hidden {
    display: none;
}

  </style>
</head>

<body class="bg-gray-100 p-8">
  <?php if(session('error')): ?>
    <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
        <span class="block sm:inline"><?php echo e(session('error')); ?></span>
        <button type="button" class="absolute top-0 bottom-0 right-0 px-4 py-3" onclick="this.parentElement.remove();">
            <svg class="fill-current h-6 w-6 text-red-500" role="button" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M14.348 14.849a1 1 0 01-1.414 0L10 11.414 6.707 14.707a1 1 0 01-1.414-1.414l3.293-3.293-3.293-3.293a1 1 0 011.414-1.414L10 8.586l3.293-3.293a1 1 0 011.414 1.414L11.414 10l3.293 3.293a1 1 0 010 1.414z"/></svg>
        </button>
    </div>
<?php endif; ?>


<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="https://deuxmaizarzis.com/my-app/public/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="https://deuxmaizarzis.com/my-app/public/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="https://deuxmaizarzis.com/my-app/public/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="https://deuxmaizarzis.com/my-app/public/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="https://deuxmaizarzis.com/my-app/public/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 Note</button>
    <form class="max-w-[800px] mx-auto">
        <div class="max-w-[800px] h-[40px] flex items-center justify-center bg-[#113C6B] rounded-full px-4">
        <span class="text-white text-sm"> Le classe <?php echo e($matieres[0]['class_name']); ?> <?php echo e($matieres[0]['class_year']); ?> de enseignant <?php echo e($prof->first_name); ?> <?php echo e($prof->last_name); ?>  Matiere <?php echo e($matieres[0]['name']); ?>


        Coefficient : <?php echo e($matieres[0]['coefficient']); ?></span>
        </div>
    </form>

</div>
<div class="py-4"></div>

 

<div class="relative overflow-x-auto  sm:rounded-lg">
<table class="w-full text-sm text-center 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 class="border border-gray-700 px-2 py-1"></th>

                    <th class="border border-gray-700 px-2 py-1">الحاصل</th>

                    <th class="border border-gray-700 px-2 py-1">الرتبة</th>

                    <th class="border border-gray-700 px-2 py-1">المعدل <br>الثلاثي</th>
                    <th class="border border-gray-700 px-2 py-1">الفرض <br>التأليفي</th>
                    <th class="border border-gray-700 px-4 py-2" colspan="2">
                        <div style="text-align: center; border-bottom: 1px solid gray; margin-bottom: 5px;">فروض المراقبة</div>
                        <div style="display: flex; justify-content: space-evenly; align-items: center;">
                            <span style="flex: 1; text-align: center;">2.ف.م</span>
                            <div style="width: 1px; height: 100%; background-color: gray;"></div>
                            <span style="flex: 1; text-align: center;">1.ف.م</span>
                        </div>
                    </th>
                    <th class="border border-gray-700 px-2 py-1">الاختبارات<br> الكتابية</th>
                    <th class="border border-gray-700 px-2 py-1">الأشغال<br> التطبيقية</th>
                    <th class="border border-gray-700 px-2 py-1">شفاهي</th>
                    <th class="border border-gray-700 px-2 py-1">الاسم<br> اللقب </th>

                   <th class="border border-gray-700 px-2 py-1"></th>
            </tr>
    </thead>
    <tbody>
        <?php $counter = 1; // Initialize counter variable ?>
    <?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__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">
    <td id="tools" class="border border-gray-700 py-1">
        <div class="flex items-center justify-center gap-2">
        <button 
            data-modal-target="crud-modal-update" 
            data-modal-toggle="crud-modal-update"  
            type="button" 
            class="edit-matiere font-medium text-blue-600 dark:text-blue-500 hover:underline bg-blue-500 flex items-center justify-center w-10 h-10 rounded" 
            data-id="<?php echo e($item->id); ?>" 
            data-main="<?php echo e($item->main_exam); ?>" 
            data-eleve ="<?php echo e($item->eleve->id); ?>" 
            data-oral="<?php echo e($item->oral_exam); ?>" 
            data-practical="<?php echo e($item->practical_work); ?>" 
            data-written="<?php echo e($item->written_tests); ?>" 
            data-exam2="<?php echo e($item->monitoring_exam_2); ?>" 
            data-exam1="<?php echo e($item->monitoring_exam_1); ?>">
            <i class="fa-regular fa-pen-to-square" style="color: white;"></i>
        </button>
                    <form action="<?php echo e(route('grades.destroy', $item->id)); ?>" method="POST" onsubmit="return confirm('Êtes-vous sûr de vouloir supprimer Note ?');">
    <?php echo csrf_field(); ?>
    <?php echo method_field('DELETE'); ?>
    <button 
        type="submit" 
        class="btn bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded">
        <i class="fa-regular fa-trash-can text-white"></i>
    </button>
</form>

        </div>
    </td>

    

    <td class="border border-gray-700 px-2 py-1"><?= $item->sum ?></td>
    <td id="place" class="border border-gray-700 px-2 py-1"><?= $item->rank ?></td>
    <td class="border border-gray-700 px-2 py-1"><?= $item->quarter_average ?></td>
    <td class="border border-gray-700 px-2 py-1"><?= $item->main_exam ?></td>
    <td class="border border-gray-700 px-4 py-2"><?= $item->monitoring_exam_2 ?></td>
    <td class="border border-gray-700 px-4 py-2"><?= $item->monitoring_exam_1 ?></td>
    <td class="border border-gray-700 px-2 py-1"><?= $item->written_tests ?></td>
    <td class="border border-gray-700 px-2 py-1"><?= $item->practical_work ?></td>
    <td class="border border-gray-700 px-2 py-1"><?= $item->oral_exam ?></td>
    <td class="border border-gray-700 px-2 py-1"><?= $item->eleve->first_name ?> <br> <?= $item->eleve->last_name ?></td>
    <td class="border border-gray-700 px-2 py-1"><?= $counter++ ?></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 Notes Matière <?php echo e($matieres[0]['class_name']); ?>


                  </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-update">
                      <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'); ?>
  <input type="hidden" name="eleve_id" id="eleve_id" value="">

      <input type="hidden" name="classe_id" id="classe_id" value="<?php echo e($classe->id); ?>">
      <input type="hidden" name="prof_id" id="prof_id" value="<?php echo e($prof->id); ?>">
      <input type="hidden" name="matiere_id" id="matiere_id" value="<?php echo e($matieres[0]['id']); ?>

 ">
      <input type="hidden" name="coefficient" id="coefficient" value=" <?php echo e($matieres[0]['coefficient']); ?>">
<?php

$urlPath = $_SERVER['REQUEST_URI']; // Get the current URL path
$urlSegments = explode('/', $urlPath); // Split the URL into segments

// Initialize default values
$dataId = 1; // Default value for 'data'
$profId = null; // Default value for 'prof'
$classeId = null; // Default value for 'classe'
$matiereId = null; // Default value for 'matiere'

// Check and assign values based on the URL structure
if (isset($urlSegments[4])) {
    $dataId = $urlSegments[4]; // Extract 'data' value (1 in this example)
}
if (isset($urlSegments[6])) {
    $profId = $urlSegments[6]; // Extract 'prof' value (70 in this example)
}
if (isset($urlSegments[8])) {
    $classeId = $urlSegments[8]; // Extract 'classe' value (22 in this example)
}
if (isset($urlSegments[10])) {
    $matiereId = $urlSegments[10]; // Extract 'matiere' value (25 in this example)
}

// Optional: Debug or use the extracted values
// echo "Data ID: $dataId, Prof ID: $profId, Classe ID: $classeId, Matiere ID: $matiereId";

?>

             <input type="hidden" name="score_id" id="score_id" value="<?php echo htmlspecialchars($dataId); ?>">



      <div class="grid gap-4 mb-4  grid-cols-2">
     
          <!-- Oral Exam -->
          <div class="col-span-2">
              <label for="oral_exam" class="block mb-2 text-sm text-right font-medium text-gray-900 dark:text-white">شفاهي</label>
              <input type="number" step="0.01" name="oral_exam" id="oral_exam" 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" >
          </div>




          <!-- Written Tests -->
          <div class="col-span-2 sm:col-span-1">
              <label for="written_tests" class="block mb-2 text-sm text-right font-medium text-gray-900 dark:text-white">الاختبارات الكتابية</label>
              <input type="number" step="0.01" name="written_tests" id="written_tests" 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" >
          </div>

          <!-- Practical Work -->
          <div class="col-span-2 sm:col-span-1">
              <label for="practical_work" class="block mb-2 text-sm text-right font-medium text-gray-900 dark:text-white">الأشغال التطبيقية</label>
              <input type="number" step="0.01" name="practical_work" id="practical_work" 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" >
          </div>
                              <!-- Monitoring Exam 2 -->
                              <div class="col-span-2 sm:col-span-1">
              <label for="monitoring_exam_2" class="block mb-2 text-sm text-right font-medium text-gray-900 dark:text-white">2.ف.م</label>
              <input type="number" step="0.01" name="monitoring_exam_2" id="monitoring_exam_2" 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" >
          </div>

          <!-- Monitoring Exam 1 -->
          <div class="col-span-2 sm:col-span-1">
              <label for="monitoring_exam_1" class="block mb-2 text-sm text-right font-medium text-gray-900 dark:text-white">1.ف.م</label>
              <input type="number" step="0.01" name="monitoring_exam_1" id="monitoring_exam_1" 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" >
          </div>
          <!-- Main Exam -->
          <div class="col-span-2">
              <label for="main_exam" class="block mb-2 text-sm font-medium text-right text-gray-900 dark:text-white">الفرض التأليفي</label>
              <input type="number" step="0.01" name="main_exam" id="main_exam" 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" >
          </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>
          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">
                   Notes Matière <?php echo e($matieres[0]['class_name']); ?>


                </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('grades.store')); ?>" method="POST">

                <?php echo csrf_field(); ?>

                <input type="hidden" name="classe_id" id="classe_id" value="<?php echo e($classe->id); ?>">
                <input type="hidden" name="prof_id" id="prof_id" value="<?php echo e($prof->id); ?>">
                <input type="hidden" name="matiere_id" id="matiere_id" value="<?php echo e($matieres[0]['matiere_id']); ?>

 ">
                <input type="hidden" name="coefficient" id="coefficient" value=" <?php echo e($matieres[0]['coefficient']); ?>">
<?php

$urlPath = $_SERVER['REQUEST_URI']; // Get the current URL path
$urlSegments = explode('/', $urlPath); // Split the URL into segments

// Initialize default values
$dataId = 1; // Default value for 'data'
$profId = null; // Default value for 'prof'
$classeId = null; // Default value for 'classe'
$matiereId = null; // Default value for 'matiere'

// Check and assign values based on the URL structure
if (isset($urlSegments[4])) {
    $dataId = $urlSegments[4]; // Extract 'data' value (1 in this example)
}
if (isset($urlSegments[6])) {
    $profId = $urlSegments[6]; // Extract 'prof' value (70 in this example)
}
if (isset($urlSegments[8])) {
    $classeId = $urlSegments[8]; // Extract 'classe' value (22 in this example)
}
if (isset($urlSegments[10])) {
    $matiereId = $urlSegments[10]; // Extract 'matiere' value (25 in this example)
}

// Optional: Debug or use the extracted values
// echo "Data ID: $dataId, Prof ID: $profId, Classe ID: $classeId, Matiere ID: $matiereId";

?>

             <input type="hidden" name="score_id" id="score_id" value="<?php echo htmlspecialchars($dataId); ?>">



                <div class="grid gap-4 mb-4  grid-cols-2">
                    <div class="col-span-2">
                    <label for="eleve" class="block mb-2 text-sm font-medium text-right text-gray-900 dark:text-white">تلميذ</label>
                      <select id="eleve_id" name="eleve_id" 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 = $classe->eleves; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $eleve): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                              <option value="<?php echo e($eleve->id); ?>"><?php echo e($eleve->first_name); ?> <?php echo e($eleve->last_name); ?></option>
                          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                      </select>

                      </div>
                    <!-- Oral Exam -->
                    <div class="col-span-2">
                        <label for="oral_exam" class="block mb-2 text-sm text-right font-medium text-gray-900 dark:text-white">شفاهي</label>
                        <input type="number" step="0.01" name="oral_exam" id="oral_exam" 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" >
                    </div>




                    <!-- Written Tests -->
                    <div class="col-span-2 sm:col-span-1">
                        <label for="written_tests" class="block mb-2 text-sm text-right font-medium text-gray-900 dark:text-white">الاختبارات الكتابية</label>
                        <input type="number" step="0.01" name="written_tests" id="written_tests" 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" >
                    </div>

                    <!-- Practical Work -->
                    <div class="col-span-2 sm:col-span-1">
                        <label for="practical_work" class="block mb-2 text-sm text-right font-medium text-gray-900 dark:text-white">الأشغال التطبيقية</label>
                        <input type="number" step="0.01" name="practical_work" id="practical_work" 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" >
                    </div>
                                        <!-- Monitoring Exam 2 -->
                                        <div class="col-span-2 sm:col-span-1">
                        <label for="monitoring_exam_2" class="block mb-2 text-sm text-right font-medium text-gray-900 dark:text-white">2.ف.م</label>
                        <input type="number" step="0.01" name="monitoring_exam_2" id="monitoring_exam_2" 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" >
                    </div>

                    <!-- Monitoring Exam 1 -->
                    <div class="col-span-2 sm:col-span-1">
                        <label for="monitoring_exam_1" class="block mb-2 text-sm text-right font-medium text-gray-900 dark:text-white">1.ف.م</label>
                        <input type="number" step="0.01" name="monitoring_exam_1" id="monitoring_exam_1" 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" >
                    </div>
                    <!-- Main Exam -->
                    <div class="col-span-2">
                        <label for="main_exam" class="block mb-2 text-sm font-medium text-right text-gray-900 dark:text-white">الفرض التأليفي</label>
                        <input type="number" step="0.01" name="main_exam" id="main_exam" 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" >
                    </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');
    
    // Overlay for outside clicks
    const overlay = modal;

    // Correct input fields
    const mainInput = document.getElementById('main_exam');
  
    const oralInput = document.getElementById('oral_exam');
    const practicalInput = document.getElementById('practical_work');
    const writtenInput = document.getElementById('written_tests');
    const exam2Input = document.getElementById('monitoring_exam_2');
    const exam1Input = document.getElementById('monitoring_exam_1');

    // Open modal
    editButtons.forEach(button => {
        button.addEventListener('click', (e) => {
            e.preventDefault();

            // Populate modal fields
            const { id, main,eleve, oral, practical, written, exam2, exam1 } = button.dataset;
            console.log(eleve);
            // Get the input element by its ID
const inputElement = document.getElementById('eleve_id');

// Update the value of the input element
if (inputElement) {
    inputElement.value = eleve;
    console.log(`Input value updated: ${inputElement.value}`);
}
            mainInput.value = main || '';
            oralInput.value = oral || '';
            practicalInput.value = practical || '';
            writtenInput.value = written || '';
            exam2Input.value = exam2 || '';
            exam1Input.value = exam1 || '';

            // Set form action
            form.action = `https://deuxmaizarzis.com/my-app/public/grades/${id}`;

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

    // Close modal function
    const closeModalHandler = () => {
        modal.classList.add('hidden'); // Hide modal
    };

    // Close on button click
    closeModal.addEventListener('click', closeModalHandler);

    // Close when clicking outside the modal
    overlay.addEventListener('click', (e) => {
        if (e.target === modal) closeModalHandler();
    });

    // Close with Escape key
    document.addEventListener('keydown', (e) => {
        if (e.key === 'Escape' && !modal.classList.contains('hidden')) {
            closeModalHandler();
        }
    });
});



 


</script>
</html>




<?php /**PATH C:\Users\Toby\Desktop\02 mai zarzis\version 2026\v2\my-app\resources\views/classes/students.blade.php ENDPATH**/ ?>