Lachenzelg/admin/students.php

117 lines
5.6 KiB
PHP
Raw Permalink Normal View History

2025-01-07 03:02:25 +01:00
<?php include('includes/header.php'); ?>
<div>
<div class="card card-body p-4">
<div class="row">
<div class="col-4">
<h3 class="fw-semibold mb-4">Schüler:innen</h3>
</div>
<div class="col-4">
<input type="text" class="form-control" id="myInput" onkeyup="myFunction()" placeholder="Suche...">
</div>
<div class="col-4">
<a href="students-create.php" class="btn btn-info mx-1 float-end"> <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="students.php">Schüler:innen 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)">Benutzer-ID</th>
<th style="cursor: pointer;" onclick="sortTable(3)">Klasse</th>
<th style="cursor: pointer;" onclick="sortTable(4)">Geburtsdatum</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$students = getAll('id, firstname, lastname, userid, class, dateofbirth, status', 'tbl_students', "WHERE status != 'archived'");
if(mysqli_num_rows($students) > 0)
{
foreach($students as $studentEntry)
{
$studentEntry['dateofbirth'] = date("d.m.Y", strtotime($studentEntry['dateofbirth']));
if($studentEntry['status'] == 'active'){$studentEntry['status'] = 'aktiv'; $colour = "success";}
elseif($studentEntry['status'] == 'disabled'){$studentEntry['status'] = 'inaktiv'; $colour = "danger";}
$classOptions = getAllClasses('active');
$classID = $studentEntry['class'];
$className = isset($classOptions[$classID]) ? $classOptions[$classID] : 'Nicht verfügbar';
?>
<tr>
<td ><?= $studentEntry['firstname']; ?></td>
<td><?= $studentEntry['lastname']; ?></td>
<td><?= $studentEntry['userid']; ?></td>
<td><?= $className; ?></td>
<td><?= $studentEntry['dateofbirth']; ?></td>
<td><span style="font-size:0.8em;" class="badge rounded-pill text-bg-<?= $colour;?>"><?= $studentEntry['status']; ?></span></td>
<td>
<button type="button"
class="btn btn-warning btn-sm float-end mx-1"
data-bs-toggle="modal" data-bs-target="#archiveStudent<?= $studentEntry['id']; ?>"> <i class="ti ti-archive"></i>
</button>
<a href="students-edit.php?id=<?= $studentEntry['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="archiveStudent<?= $studentEntry['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">Schüler:in archivieren</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> <?= $studentEntry['firstname'] . ' ' . $studentEntry['lastname']?></b> archivieren möchten?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Abbrechen</button>
<a href="students-archive.php?id=<?= $studentEntry['id']; ?>" class="btn btn-warning"><i class="ti ti-archive"></i> Archivieren</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'); ?>