<?php
$title  = "Events";
$menu   = "menus/men_events_list";
$header = "headers/hea_default";

$this->setVar('menu', $menu);
$this->setVar('header', $header);
$this->setVar('title', $title);
$Appconfig = config('App');

?>

<?= $this->extend('layouts/default') ?>
<?= $this->section('content') ?>


<!-- =======================
     PANEL UNIQUE (RAVEN)
======================= -->
<div class="px-4 lg:px-8 py-4">
    <h2 class="text-xl mb-2">Évenements</h2>

</div>
<!--:Page content:-->
<div class="content lg:px-4 flex-grow">
    <div class="grid grid-cols-1 px-4">
        <div class="rounded-xl bg-white dark:bg-zinc-900 shadow-card mb-4">
            <!--:  <div class="flex flex-wrap gap-2 items-center p-4 border-b border-zinc-500/10 dark:border-zinc-800">
                <div class="flex-grow">
                    <div class="relative">
                        <input type="search" class="input !ps-9" name="productSearch" id="productSearch"
                               placeholder="Search product">
                        <span class="iconify icon-[lucide--search] pointer-events-none absolute start-0 top-0 h-full flex items-center justify-center ms-3 text-muted"></span>
                    </div>
                </div>

                <div class="flex items-center flex-wrap justify-end gap-2">
                    <button id="deleteBtn" class="btn bg-red-500 text-white hover:bg-red-600 cursor-pointer"
                            style="display: none;">Delete</button>
                    <div class="flex items-center gap-2">
                        <div class="relative">
                            <button data-bs-toggle="dropdown" type="button" class="btn btn-default">
                                <span class="icon-[lucide--download] text-lg me-1"></span>
                                Download <span class="icon-[lucide--chevron-down] ms-1"></span></button>
                            <div class="dropdown-menu w-48 z-50 absolute !end-0 !start-auto">
                                <a href="#!" class="dropdown-item">
                                    <span class="icon-[lucide--copy] dropdown-icon"></span> Copy Json
                                </a>
                                <a href="#!" class="dropdown-item">
                                    <span class="icon-[lucide--printer] dropdown-icon"></span> Print
                                </a>
                                <a href="#!" class="dropdown-item">
                                    <img src="images/files/excel.svg" class="h-4 me-2" alt=""> Download Exel
                                </a>
                                <a href="#!" class="dropdown-item">
                                    <img src="images/files/csv.svg" class="h-4 me-2" alt=""> Download .CSV
                                </a>
                                <a href="#!" class="dropdown-item">
                                    <img src="images/files/pdf.svg" class="h-4 w-auto me-2" alt=""> Download .PDF
                                </a>
                            </div>
                        </div>
                        <a href="product-add.html"
                           class="btn bg-primary shrink-0 text-white hover:bg-primary-deep">
                            <span class="icon-[lucide--plus] text-lg me-1"></span>
                            Add Product</a>
                    </div>
                </div>
            </div>  -->
            <table id="table_products" class="table-default">
                <thead class="">
                <tr>
                    <th data-orderable="false">

                    </th>
                    <th>
                        <div class="flex items-center">
                            nom
                        </div>
                    </th>
                    <th>
                        course
                    </th>
                    <th>
                        date
                    </th>
                    <th>
                        evenent name
                    </th>
                    <th>

                    </th>
                    <th data-orderable="false">

                    </th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($events as $item): ?>
                    <?php
                    $config = $item['config'];
                    $course = $item['course'];
                    $event  = $item['event'];
                    ?>
                    <tr>
                        <td></td>

                        <!-- Nom de course + lien -->
                        <td class="whitespace-nowrap dark:text-white">
                            <div class="flex flex-nowrap items-center">
                                <img src="<?= esc($Appconfig->eventLogosBaseURL.$event['eve_logo'] ?? 'default.png') ?>"
                                     class="w-10 shrink-0 me-4 bg-zinc-200 dark:bg-zinc-400 rounded-sm">
                                <div class="flex-grow">
                                    <a href="event/reader/<?= esc($config['con_id']) ?>"
                                       class="underline hover:no-underline">
                                        <?= esc($event['eve_nom_fr']) ?>
                                    </a>
                                </div>
                            </div>
                        </td>

                        <!-- Type -->
                        <td>
                            <?= esc($course['cou_type_fr']) ?>
                        </td>

                        <!-- Date -->
                        <td>
                            <?= esc($event['eve_date_debut']) ?>
                        </td>

                        <!-- Config name -->
                        <td>
                            <?= esc($config['con_event_name']) ?>
                        </td>

                        <!-- Exemple : nombre aléatoire ou ce que tu veux afficher -->
                        <td>
                            <?= esc($config['con_id']) ?>/<?= esc($config['rea_active']) ?>
                        </td>

                        <td>
                            <div class="flex items-center justify-end gap-1 relative z-[1]">
                                <a href="event/edit/<?= esc($config['con_id']) ?>"
                                   class="btn !p-1.5 hover:!text-primary">
                                    <span class="icon-[lucide--edit] text-lg"></span>
                                </a>
                                <a href="event/details/<?= esc($config['con_id']) ?>"
                                   class="btn !p-1.5 hover:!text-primary">
                                    <span class="icon-[lucide--eye] text-lg"></span>
                                </a>
                            </div>
                        </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>

            </table>
        </div>
    </div>
</div>
<?= $this->endSection() ?>
