Lachenzelg/admin/categories-reports-class.php

68 lines
2.3 KiB
PHP
Raw Permalink Normal View History

<?php include('includes/header.php'); ?>
<div>
<?php
$paramResult = checkParamId('id');
if(!is_numeric($paramResult)){
echo '<div class="alert alert-danger" role="alert">'.$paramResult.'</div>';
return false;
}
$category = getById('tbl_categories', checkParamId('id'));
if($category['status'] == 200) {
?>
<div class="card card-body p-4">
<?= alertMessage(); ?>
<div class="row">
<div class="col-8">
<h3 class="fw-semibold mb-4">Statistik nach Klasse zu <?=$category['data']['name'];?></h3>
</div>
<div class="col-4">
<a href="categories-edit.php?id=<?=$category['data']['id'];?>" class="btn btn-light float-end">
<i class="ti ti-arrow-left"></i> Zurück zur Übersicht
</a>
</div>
</div>
<div class="table-responsive">
<table class="table table-hover" id="sortTable">
<thead>
<tr>
<th style="cursor: pointer;" onclick="sortTable(0)">Klasse</th>
<th style="cursor: pointer;" onclick="sortTable(1)">Schüler</th>
<th style="cursor: pointer;" onclick="sortTable(2)">Mit Auswahl</th>
<th style="cursor: pointer;" onclick="sortTable(3)">Nichts ausgewählt</th>
</tr>
</thead>
<tbody>
<?php
$classes = mysqli_query($conn, "
SELECT
c.id AS classID,
CONCAT(c.sek, ' ', c.type, ' - ', c.name) AS classDisplayName
FROM tbl_classes c
");
while ($class = mysqli_fetch_assoc($classes)) {
$classID = $class['classID'];
$classDisplayName = $class['classDisplayName'];
$totalStudents = countStudentsInClass($classID);
$studentsWithSelection = countStudentsWithSelection($classID, $category['data']['id']);
$studentsWithoutSelection = $totalStudents - $studentsWithSelection;
?>
<tr>
<td><?= $classDisplayName; ?></td>
<td><?= $totalStudents; ?></td>
<td><?= $studentsWithSelection; ?></td>
<td><?= $studentsWithoutSelection; ?></td>
</tr>
<?php }
} ?>
</tbody>
</table>
</div>
</div>
</div>
<?php include('includes/footer.php'); ?>