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

$result = $conn->query("SELECT * FROM accreditations ORDER BY name ASC");
?>

<div class="container py-4">

<div class="d-flex justify-content-between mb-3">
<h4>Accreditations</h4>
<a href="accreditation_form.php" class="btn btn-success">Add Accreditation</a>
</div>

<table class="table table-bordered">

<thead>
<tr>
<th>ID</th>
<th>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><?= $row['status'] ?></td>

<td>

<a href="accreditation_form.php?id=<?=$row['id']?>" class="btn btn-sm btn-primary">Edit</a>

<a href="accreditation_delete.php?id=<?=$row['id']?>" 
class="btn btn-sm btn-danger"
onclick="return confirm('Delete this accreditation?')">
Delete
</a>

</td>
</tr>

<?php } ?>

</tbody>
</table>

</div>

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