Lachenzelg/admin/teachers.php
2025-01-07 03:02:25 +01:00

88 lines
4.2 KiB
PHP

<?php include('includes/header.php'); ?>
<div>
<div class="card card-body p-4">
<div class="row">
<div class="col-8">
<h3 class="fw-semibold mb-4">Lehrpersonen</h3>
</div>
<div class="col-4">
<a href="teachers-create.php" class="btn btn-info float-end mx-1"> <i class="ti ti-plus"></i> Hinzufügen</a>
<a class="btn btn-success float-end mx-1 dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"><i class="ti ti-table-import"></i> Importieren</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="teachers.php">Lehrpersonen importieren</a></li>
<li><a class="dropdown-item" href="includes/import-lehrer.csv">Musterdatei herunterladen</a></li>
</ul>
</div>
</div>
<?= alertMessage(); ?>
<div class="table-responsive">
<table class="table table-hover" id="sortTable">
<thead>
<tr>
<th style="cursor: pointer;" onclick="sortTable(0)">Vorname</th>
<th style="cursor: pointer;" onclick="sortTable(1)">Nachname</th>
<th style="cursor: pointer;" onclick="sortTable(2)">E-Mail Adresse</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$teachers = getAll('id,firstname,lastname,email','tbl_teachers','');
if(mysqli_num_rows($teachers) > 0)
{
foreach($teachers as $teacherEntry)
{
?>
<tr>
<td><?= $teacherEntry['firstname']; ?></td>
<td><?= $teacherEntry['lastname']; ?></td>
<td><?= $teacherEntry['email']; ?></td>
<td>
<button type="button"
class="btn btn-danger btn-sm float-end mx-1"
data-bs-toggle="modal" data-bs-target="#deleteTeacher<?= $teacherEntry['id']; ?>"> <i class="ti ti-trash"></i>
</button>
<a href="teachers-edit.php?id=<?= $teacherEntry['id']; ?>" class="btn btn-light btn-sm float-end mx-1"> <i class="ti ti-pencil"></i></a>
</td>
</tr>
<!-- Modal -->
<div class="modal fade" id="deleteTeacher<?= $teacherEntry['id']; ?>" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="staticBackdropLabel">Lehrperson entfernen</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Sind Sie sicher, dass Sie <b><?= $teacherEntry['firstname'] . ' ' . $teacherEntry['lastname']?></b> entfernen möchten?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Abbrechen</button>
<a href="teachers-delete.php?id=<?= $teacherEntry['id']; ?>" class="btn btn-danger"><i class="ti ti-trash"></i> Löschen</a>
</div>
</div>
</div>
</div>
<!-- Modal Ende -->
<?php
}
}
else
{
?>
<tr>
<td colspan="7"> Keine Einträge gefunden</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php include('includes/footer.php'); ?>