<?php
include("../includes/db_connection.php");
include("../includes/auth.php");
include("partials/header.php");

$result = $conn->query("SELECT * FROM standards ORDER BY id DESC");
?>

<div class="container py-4">
<div class="card shadow">
<div class="card-header bg-dark text-white d-flex justify-content-between">
<h5>Manage Standards</h5>
<a href="standard_form.php" class="btn btn-success btn-sm">+ Add Standard</a>
</div>

<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead class="table-light">
<tr>
<th>ID</th>
<th>Standard Name</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>

<tbody>
<?php while($row=$result->fetch_assoc()): ?>
<tr>
<td><?= $row['id'] ?></td>
<td><?= $row['name'] ?></td>
<td>
<span class="badge <?= $row['status']=='Active'?'bg-success':'bg-secondary' ?>">
<?= $row['status'] ?>
</span>
</td>
<td>
<a href="standard_form.php?id=<?= $row['id'] ?>" class="btn btn-sm btn-info">Edit</a>
<a href="standard_delete.php?id=<?= $row['id'] ?>"
class="btn btn-sm btn-danger"
onclick="return confirm('Delete this standard?')">
Delete
</a>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>

<?php include("partials/footer.php"); ?>