<?php $title = 'AdminSB Pro - Tables'; ?>

<div class="d-sm-flex align-items-center justify-content-between mb-4">
    <h1 class="h3 mb-0 text-gray-800">Tables</h1>
</div>

<div class="card shadow mb-4">
    <div class="card-header py-3"><h6 class="m-0 font-weight-bold text-primary">DataTables Example - Users</h6></div>
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                <thead>
                    <tr><th>ID</th><th>Name</th><th>Email</th><th>Role</th><th>Status</th><th>Created</th></tr>
                </thead>
                <tbody>
                    <?php foreach (isset($users) ? $users : array() as $user): ?>
                    <tr>
                        <td><?= $user->id ?></td>
                        <td><?= htmlspecialchars($user->name) ?></td>
                        <td><?= htmlspecialchars($user->email) ?></td>
                        <td><span class="badge badge-<?= $user->role === 'admin' ? 'primary' : ($user->role === 'editor' ? 'info' : 'secondary') ?>"><?= ucfirst($user->role) ?></span></td>
                        <td><span class="badge badge-<?= $user->status === 'active' ? 'success' : 'danger' ?>"><?= ucfirst($user->status) ?></span></td>
                        <td><?= date('M d, Y', strtotime($user->created_at)) ?></td>
                    </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>

<?php $extraScripts = '
<script src="' . $baseUrl . '/vendor/datatables/jquery.dataTables.min.js"></script>
<script src="' . $baseUrl . '/vendor/datatables/dataTables.bootstrap4.min.js"></script>
<script src="' . $baseUrl . '/js/demo/datatables-demo.js"></script>
'; ?>
