<?php
/**
 * Fichier  : views/dashboard.php
 * Auteur   : KREMER Régis
 * Version  : 2.6.0
 * Date     : 2026-03-01
 * Description : Vue — Tableau de bord : KPIs, graphiques, alertes cards, activité
 */
/* dashboard.php v2.6.0 */ ?>
<div class="dashboard" id="pgDashboard">

    <!-- KPI Grid -->
    <div class="kpi-grid" id="kpiRow"></div>

    <!-- Charts row : mouvements + valorisation -->
    <div class="dash-charts-row mb-4">
        <div class="card">
            <div class="card-header"><h3 class="card-title">Mouvements (14 derniers jours)</h3></div>
            <div class="card-body" style="padding-top:8px">
                <div style="position:relative;height:160px">
                    <canvas id="dashChartMov"></canvas>
                </div>
            </div>
        </div>
        <div class="card">
            <div class="card-header"><h3 class="card-title">Valorisation par magasin</h3></div>
            <div class="card-body" style="padding-top:8px">
                <div style="position:relative;height:160px">
                    <canvas id="dashChartVal"></canvas>
                </div>
            </div>
        </div>
    </div>

    <!-- Bottom row : activité + alertes -->
    <div class="dash-bottom-row mb-6">

        <!-- Activité récente -->
        <div class="card">
            <div class="card-header">
                <h3 class="card-title">Activité récente</h3>
                <a href="movements" class="btn btn-ghost btn-sm">Voir tout</a>
            </div>
            <div class="card-body card-body-flush">
                <div class="activity-feed" id="activityFeed"></div>
            </div>
        </div>

        <!-- Alertes actives -->
        <div class="card">
            <div class="card-header">
                <h3 class="card-title">Alertes actives</h3>
                <a href="alerts" class="btn btn-ghost btn-sm">Gérer</a>
            </div>
            <div class="card-body" id="alertsWidget" style="padding:12px"></div>
        </div>

    </div>

    <!-- Stock Table -->
    <div class="card mt-4">
        <div class="card-header">
            <h3 class="card-title">Aperçu du stock</h3>
            <select class="form-select" id="dashWh" style="min-width:180px">
                <option value="">Tous magasins</option>
            </select>
        </div>
        <div class="table-container">
            <table class="data-table" id="dashStockTbl">
                <thead>
                    <tr>
                        <th>Produit</th>
                        <th>SKU</th>
                        <th>Magasin</th>
                        <th class="cell-number">Qté</th>
                        <th class="cell-number">Min</th>
                        <th class="cell-number">Max</th>
                        <th class="cell-number">Coût unit.</th>
                        <th class="cell-number">Valeur</th>
                        <th>Statut</th>
                    </tr>
                </thead>
                <tbody id="dashStockBody"></tbody>
            </table>
        </div>
    </div>

</div>
