38960-vm/includes/pages/test_groups.php
2026-03-04 08:07:04 +00:00

61 lines
3.1 KiB
PHP

<?php
$query = "SELECT * FROM test_groups ORDER BY id DESC";
$stmt = $db->query($query);
$groups = $stmt->fetchAll();
?>
<div class="d-flex justify-content-between align-items-center mb-4">
<h3 class="fw-bold text-secondary"><?php echo __('test_groups'); ?></h3>
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addTestGroupModal">
<i class="bi bi-plus-lg me-1"></i> <?php echo __('add_test_group'); ?>
</button>
</div>
<div class="card shadow-sm border-0">
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="table-light text-secondary">
<tr>
<th class="px-4 py-3">#</th>
<th class="py-3"><?php echo __('name_en'); ?></th>
<th class="py-3"><?php echo __('name_ar'); ?></th>
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
</tr>
</thead>
<tbody>
<?php if (empty($groups)): ?>
<tr>
<td colspan="4" class="text-center py-5 text-muted">
<i class="bi bi-collection display-4 d-block mb-3"></i>
No groups found.
</td>
</tr>
<?php else: ?>
<?php foreach ($groups as $group): ?>
<tr>
<td class="px-4 text-secondary"><?php echo $group['id']; ?></td>
<td class="fw-semibold text-dark"><?php echo htmlspecialchars($group['name_en']); ?></td>
<td class="text-secondary"><?php echo htmlspecialchars($group['name_ar']); ?></td>
<td class="text-end px-4">
<div class="btn-group shadow-sm border rounded bg-white">
<button class="btn btn-link text-primary py-1 px-2 border-end"
onclick="showEditTestGroupModal(<?php echo htmlspecialchars(json_encode($group, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
<i class="bi bi-pencil-square"></i>
</button>
<button class="btn btn-link text-danger py-1 px-2"
onclick="showDeleteTestGroupModal(<?php echo $group['id']; ?>)"
data-bs-toggle="tooltip" title="<?php echo __('delete'); ?>">
<i class="bi bi-trash3"></i>
</button>
</div>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>