Limmat/admin/archive.php

184 lines
12 KiB
PHP
Raw Normal View History

2025-01-07 03:45:35 +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">Archiv</h3>
</div>
</div>
<?php
alertMessage();
$archivedStudentsWithActiveClasses = getArchivedStudentsWithActiveClasses();
if(count($archivedStudentsWithActiveClasses) > 0)
{
?>
<div class="accordion mb-3">
<div class="accordion-item">
<h2 class="accordion-header" id="panelsStayOpen-headingOne">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseOne" aria-expanded="true" aria-controls="panelsStayOpen-collapseOne">
<div class="row col-12">
<div class="my-auto">
Archivierte Schüler:innen
</div>
</button>
</h2>
<div id="panelsStayOpen-collapseOne" class="accordion-collapse collapse show" aria-labelledby="panelsStayOpen-headingOne">
<div class="accordion-body">
<?php
if(count($archivedStudentsWithActiveClasses) > 1)
{
?>
<div class="row">
<div class="col-12">
<button class="btn btn-success float-end mx-1" data-bs-toggle="modal" data-bs-target="#reactivateAllArchivedStudentsWithActiveClasses"><i class="ti ti-archive-off pe-2"></i>Alle freigeben</button>
<button class="btn btn-danger float-end mx-1" data-bs-toggle="modal" data-bs-target="#deleteAllArchivedStudentsWithActiveClasses"><i class="ti ti-trash pe-2"></i>Alle löschen</button>
</div>
</div>
<?php
}
?>
<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></th>
</tr>
</thead>
<tbody>
<?php
foreach($archivedStudentsWithActiveClasses as $studentEntry)
{
?>
<tr>
<td><?= $studentEntry['student_firstname']; ?></td>
<td><?= $studentEntry['student_lastname']; ?></td>
<td><?= $studentEntry['student_userid']; ?></td>
<td><?= $studentEntry['display_name']; ?></td>
<td>
<button type="button"
class="btn btn-success btn-sm float-end mx-1"
data-bs-toggle="modal" data-bs-target="#reactivateStudent<?= $studentEntry['student_id']; ?>"> <i class="ti ti-archive-off"></i>
</button>
<button type="button"
class="btn btn-danger btn-sm float-end mx-1"
data-bs-toggle="modal" data-bs-target="#deleteStudent<?= $studentEntry['student_id']; ?>"> <i class="ti ti-trash"></i>
</button>
</td>
</tr>
<!-- Modal -->
<div class="modal fade" id="deleteStudent<?= $studentEntry['student_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 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> <?= $studentEntry['student_firstname'] . ' ' . $studentEntry['student_lastname']?></b> entfernen möchten? </br> Diese Aktion kann nicht rückgängig gemacht werden!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Abbrechen</button>
<a href="students-delete.php?id=<?= $studentEntry['student_id']; ?>" class="btn btn-danger"><i class="ti ti-trash"></i> Endgültig löschen</a>
</div>
</div>
</div>
</div>
<!-- Modal Ende -->
<!-- Modal -->
<div class="modal fade" id="reactivateStudent<?= $studentEntry['student_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 freigeben</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 Archivierung von <b> <?= $studentEntry['student_firstname'] . ' ' . $studentEntry['student_lastname']?></b> aufheben möchten?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Abbrechen</button>
<a href="students-reactivate.php?id=<?= $studentEntry['student_id']; ?>" class="btn btn-success"><i class="ti ti-archive-off"></i> Freigeben</a>
</div>
</div>
</div>
</div>
<!-- Modal Ende -->
<?php
}
?>
</tbody>
</table>
</div>
<!-- Modal -->
<div class="modal fade" id="reactivateAllArchivedStudentsWithActiveClasses" 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">Alle archivierten Schüler:innen mit aktiver Klasse freigeben</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 Archivierung von folgenden Schüler:innen aufheben möchten?
<ul>
<?php foreach ($archivedStudentsWithActiveClasses as $studentEntry) : ?>
<li><b>- <?= $studentEntry['student_firstname'] . ' ' . $studentEntry['student_lastname']; ?></b></li>
<?php endforeach; ?>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Abbrechen</button>
<a href="students-reactivate-archived-with-active-classes.php" class="btn btn-success"><i class="ti ti-archive-off"></i> Freigeben</a>
</div>
</div>
</div>
</div>
<!-- Modal Ende -->
<!-- Modal -->
<div class="modal fade" id="deleteAllArchivedStudentsWithActiveClasses" 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">Alle archivierten Schüler:innen mit aktiver Klasse löschen</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 folgende Schüler:innen endgültig entfernen möchten?
<ul>
<?php foreach ($archivedStudentsWithActiveClasses as $studentEntry) : ?>
<li><b>- <?= $studentEntry['student_firstname'] . ' ' . $studentEntry['student_lastname']; ?></b></li>
<?php endforeach; ?>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Abbrechen</button>
<a href="students-delete-archived-with-active-classes.php" class="btn btn-danger"><i class="ti ti-trash"></i> Endgültig löschen</a>
</div>
</div>
</div>
</div>
<!-- Modal Ende -->
</div>
</div>
</div>
</div>
<?php
}
else{
echo("Keine archivierte Klasse oder Schüler:in gefunden");
}
$archivedClassesWithStudents = getArchivedClasses();
?>
</div>
</div>
<?php include('includes/footer.php'); ?>