<?php $__env->startSection('menu'); ?>
    <?php echo $__env->make('admin.menu', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->stopSection(); ?>



<?php
    $stats = [
        'pending' => "en attente", 
        'published' => "publié",  
        'stopped' => "arrêté",
    ];
    $i = 1;
?>

<?php $__env->startSection('content'); ?>
<?php if(session('success')): ?>
    <div class="alert alert-success">
        <?php echo e(session('success')); ?>

    </div>
<?php endif; ?>

<section class="courses-listing bg-gray">
    <div class="container">
      <nav class="nav nav-pills nav-justified d-flex justify-content-center">
        <a href="<?php echo e(route('admin.offres')); ?>" 
           class="nav-link <?php echo e(Route::currentRouteName() === 'admin.offres' ? 'active' : ''); ?>">
            Les offres
        </a>
        <a href="<?php echo e(route('admin.type-offres')); ?>" 
           class="nav-link <?php echo e(Route::currentRouteName() === 'admin.type-offres' ? 'active' : ''); ?>">
            Les types d'offres
        </a>
        <a href="<?php echo e(route('admin.domaines')); ?>" 
           class="nav-link <?php echo e(Route::currentRouteName() === 'admin.domaines' ? 'active' : ''); ?>">
            Les domaines
        </a>
    </nav>
              <div class="header d-flex justify-content-between align-items-center mb-4">
                  <h1 class="text-primary">Les offres </h1>
              </div>

       
            <!-- Barre de Recherche -->
            <form method="GET" action="<?php echo e(route('admin.offres')); ?>" class="mb-4" id="search-form">
                <div class="row">
                    <div class="col-md-6">
                        <input 
                            type="text" 
                            name="query" 
                            class="form-control" 
                            placeholder="Rechercher..." 
                            value="<?php echo e(request('query')); ?>" 
                        />
                    </div>
                    <div class="col-md-2">
                        <button type="submit" class="btn btn-primary">Rechercher</button>
                    </div>
                </div>
            </form>

          <div class="courses-table" >
             <div class="courses-table-header bg-primary d-flex justify-content-between align-items-center flex-column flex-md-row">
          
          <div class="left">
            <ul class="list-inline mb-0">
              
            </ul>
          </div>
           
          <form id="filterForm" method="GET" action="<?php echo e(route('admin.offres')); ?>">
            <div class="right">
                <select title="Trie par:" data-style="btn-outline-light" class="selectpicker" name="status" onchange="this.form.submit()">
                    <option value="" <?php echo e(request('status') == '' ? 'selected' : ''); ?>>Tous</option>
                    <option value="pending" <?php echo e(request('status') == 'pending' ? 'selected' : ''); ?>>En attente</option>
                    <option value="published" <?php echo e(request('status') == 'published' ? 'selected' : ''); ?>>Publié</option>
                    <option value="stopped" <?php echo e(request('status') == 'stopped' ? 'selected' : ''); ?>>Suspendu</option>
                </select>
                <a href="<?php echo e(route('admin.offres.create')); ?>" class="btn btn-success ml-3"><i class="fa fa-plus" aria-hidden="true"></i> Nouveau </a>
            </div>
        </form>

        </div>
        <div class="courses-table-body">
            
          <table id="offresTable" class="table table-hover table-responsive-xl" style="width: 100%;"> 
                <thead>
                    <tr>
                        <th>Code</th>
                        <th>Intitulé de l'offre</th>
                      <!--  <th>Description</th> -->
                        <th>Entreprise</th>
                        <th>Date de debut</th>
                        <th style="color: red">Date limite</th>
                        <th>Status</th>
                        <th style="width: 200px;">Actions</th>
                    </tr>
                </thead>  
                <tbody>
                  <?php if($offres->isEmpty()): ?>
                  <tr>
                      <td colspan="7" class="text-center">Aucune offre disponible pour le moment.</td>
                  </tr>
                  <?php else: ?>
                      <?php $__currentLoopData = $offres; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $offre): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                      <tr>
                          <td><?php echo e($offre->reference); ?></td>
                          <td><?php echo e($offre->title); ?></td>
                          <td><?php echo e($offre->company_name); ?></td>
                          <td><?php echo e($offre->start_date ? (new \DateTime($offre->start_date))->format('d/m/Y') : 'Date non disponible'); ?></td>
                          <td style="color: red"><?php echo e($offre->end_date ? (new \DateTime($offre->end_date))->format('d/m/Y') : 'Date non disponible'); ?></td>
                          <td><?php echo e($stats[$offre->status]); ?></td>
                          <td class="d-flex align-items-center">
                              <a style="margin-bottom: 5px;" href="<?php echo e(route('admin.show-offres', $offre->id)); ?>" class="btn btn-success" title="Voir">
                                  <i class="fa fa-eye" aria-hidden="true"></i>
                              </a>
                              <a style="margin-bottom: 5px;" href="<?php echo e(route('admin.edite-offres', $offre->id)); ?>" class="btn btn-primary ml-2" title="Modifier">
                                  <i class="fa fa-edit" aria-hidden="true"></i>
                              </a>
                              <a style="margin-bottom: 5px;" href="<?php echo e(route('admin.delete-offres', $offre->id)); ?>" class="btn btn-danger ml-2" title="Supprimer">
                                  <i class="fa fa-trash" aria-hidden="true"></i>
                              </a>
                          </td>
                      </tr>
                      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                  <?php endif; ?>
              </tbody>
              
          </table>
        </div>
      </div>
      <nav aria-label="Page navigation example" class="d-flex justify-content-center">
        <ul class="pagination">
          <li class="page-item"><a href="#" aria-label="Previous" class="page-link"><span aria-hidden="true">«</span><span class="sr-only">Previous</span></a></li>
          <li class="page-item active"><a href="#" class="page-link">1</a></li>
          <li class="page-item"><a href="#" class="page-link">2</a></li>
          <li class="page-item"><a href="#" class="page-link">3</a></li>
          <li class="page-item"><a href="#" aria-label="Next" class="page-link"><span aria-hidden="true">»</span><span class="sr-only">Next</span></a></li>
        </ul>
      </nav>
    </div>
  </section>
<!-- Scripts -->
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>
<script>
   $(document).ready(function () {
$('#offresTable').DataTable({
    language: {
        url: "https://cdn.datatables.net/plug-ins/1.13.6/i18n/fr-FR.json"
    },
    responsive: true, 
    pageLength: 10, 
    order: [[0, "asc"]] 
});
});


</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.base', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/africawebstudent/public_html/alumnis/resources/views/admin/offres.blade.php ENDPATH**/ ?>