111 lines
5.4 KiB
PHP
111 lines
5.4 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">Klassen</h3>
|
||
|
</div>
|
||
|
<div class="col-4">
|
||
|
<a href="classes-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="classes.php">Klassen 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">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th></th>
|
||
|
<th></th>
|
||
|
<th></th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<?php
|
||
|
$classCounts = getStudentCountsPerClass();
|
||
|
$classOptions = getAllClasses('active');
|
||
|
|
||
|
if (!empty($classOptions)) {
|
||
|
foreach ($classCounts as $classID => $count) {
|
||
|
$className = isset($classOptions[$classID]) ? $classOptions[$classID] : 'Nicht verfügbar';
|
||
|
|
||
|
$buttonText = '';
|
||
|
$buttonClass = '';
|
||
|
$ModalText = '';
|
||
|
if ($count == 0) {
|
||
|
$buttonText = 'Keine Schüler:innen zugewiesen';
|
||
|
$ModalText = '';
|
||
|
$buttonClass = 'btn btn-light';
|
||
|
} elseif ($count == 1) {
|
||
|
$buttonText = $count . ' Schüler:in';
|
||
|
$ModalText = 'Sie beinhaltet <b>' . $count . ' Schüler:in,</b> der/die ebenfalls archiviert wird:';
|
||
|
$buttonClass = 'btn btn-secondary';
|
||
|
} else {
|
||
|
$buttonText = $count . ' Schüler:innen';
|
||
|
$ModalText = 'Sie beinhaltet <b>' . $count . ' Schüler:innen,</b> die ebenfalls archiviert werden:';
|
||
|
$buttonClass = 'btn btn-secondary';
|
||
|
}
|
||
|
|
||
|
$studentsInClass = getAll('id, firstname, lastname', 'tbl_students', "WHERE class = $classID AND status!='archived'");
|
||
|
?>
|
||
|
|
||
|
<tr>
|
||
|
<td><?= $className; ?></td>
|
||
|
<td>
|
||
|
<button type="button" class="<?= $buttonClass; ?> btn-sm"><?= $buttonText; ?></button>
|
||
|
</td>
|
||
|
<td>
|
||
|
<button type="button"
|
||
|
class="btn btn-warning btn-sm float-end mx-1"
|
||
|
data-bs-toggle="modal" data-bs-target="#archiveClass<?= $classID; ?>"><i class="ti ti-archive"></i>
|
||
|
</button>
|
||
|
<a href="classes-edit.php?id=<?= $classID; ?>" 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="archiveClass<?= $classID; ?>" 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">Klasse 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 die Klasse <b><?= $className ?></b> archivieren möchten?</p>
|
||
|
<?php if (!empty($studentsInClass)) : ?>
|
||
|
<p><?= $ModalText ?></p>
|
||
|
<ul>
|
||
|
<?php foreach ($studentsInClass as $student) : ?>
|
||
|
<li>- <?= $student['firstname'] . ' ' . $student['lastname']; ?></li>
|
||
|
<?php endforeach; ?>
|
||
|
</ul>
|
||
|
<?php endif; ?>
|
||
|
</div>
|
||
|
<div class="modal-footer">
|
||
|
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Abbrechen</button>
|
||
|
<a href="classes-archive.php?id=<?= $classID; ?>" class="btn btn-warning"><i class="ti ti-archive"></i> Archivieren</a>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<!-- Modal Ende -->
|
||
|
<?php
|
||
|
}
|
||
|
} else {
|
||
|
?>
|
||
|
<tr>
|
||
|
<td colspan="3">Keine Einträge gefunden</td>
|
||
|
</tr>
|
||
|
<?php
|
||
|
}
|
||
|
?>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<?php include('includes/footer.php'); ?>
|