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

<?php $__env->startSection('content'); ?>
    <section class="courses-listing bg-gray">
        <div class="container">
            <!-- Header -->
            <div class="header d-flex justify-content-between align-items-center mb-4">
                <h1 class="text-primary">Les offres disponibles</h1>
            </div>

            <!-- Barre de Recherche -->
            <form method="GET" action="<?php echo e(route('etudiants.index')); ?>" 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>



            <?php if($offres->isEmpty() && !request('query')): ?>
                <div class="alert alert-info">
                    Actuellement, il n'y a aucune offre disponible.
                </div>
            <?php else: ?>
                <div class="courses-table">
                    <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>Entreprise</th>
                                <th>Date de début</th>
                                <th style="color: red">Date limite</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?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>
                                        <a style="margin-bottom: 5px;" href="<?php echo e(route('etudiants.show-offres', $offre->id)); ?>" class="btn btn-success" title="Voir">
                                            <i class="fa fa-eye" aria-hidden="true"></i>
                                        </a>
                                        <?php if($offre->url): ?>
                                            <a href="<?php echo e($offre->url); ?>" class="btn btn-info" target="_blank" title="Postuler">
                                                <i class="fa fa-paper-plane" aria-hidden="true"></i>
                                            </a>
                                        <?php else: ?>
                                            <span class="btn btn-info disabled" title="Lien non disponible">
                                                <i class="fa fa-paper-plane" aria-hidden="true"></i>
                                            </span>
                                        <?php endif; ?>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
            <?php endif; ?>

            <nav aria-label="Page navigation example" class="d-flex justify-content-center">
                <?php echo e($offres->links('pagination::bootstrap-5')); ?>

            </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/etudiants/index.blade.php ENDPATH**/ ?>