Lachenzelg/s/categories.php

72 lines
3.0 KiB
PHP
Raw Normal View History

2025-01-07 03:02:25 +01:00
<?php
include('includes/header.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) {
$categoryID = $category['data']['id'];
$classID = $studentInfos['data']['class'];
$deadline = getDeadline($categoryID, $classID);
if (strtotime($deadline) >= strtotime('today')) {
?>
<div class="row mb-4">
<div class="col-2">
<a href="index.php" class="btn btn-light float-end"> <i class="ti ti-arrow-left"></i></a>
</div>
<div class="col-10">
<h4> <?= $category['data']['name']; ?></h4>
</div>
</div>
<?php
$category_id = $category['data']['id'];
$class_id = $studentInfos['data']['class'];
$courses = getCoursesByClassAndCategory($class_id, $category_id);
if (!empty($courses)) {
$bgColors = ['border-danger', 'border-secondary', 'border-warning', 'border-success'];
$index = 0;
foreach ($courses as $courseentry) {
// Abfrage, um die individuelle Deadline für diesen Kurs zu erhalten
$courseID = $courseentry['id'];
$courseDeadline = getCourseDeadline($courseID);
$course = getById('tbl_courses', $courseID);
$courseImage = $course['data']['image'] ?? '../assets/images/backgrounds/course.png'; // Standardbild, falls kein Bild vorhanden
// Überprüfen, ob die Deadline überschritten ist
if (strtotime($courseDeadline) >= strtotime('today')) {
$bgColor = $bgColors[$index % count($bgColors)];
$index++;
echo '<div class="container p-0">';
echo '<div class="card rounded-2 ' . $bgColor . ' bg-gradient w-100 mb-2" style="border-width: 0px;">';
echo '<div class="card-body d-flex align-items-center p-0">';
echo '<img src="' . $courseImage .'" style="height: 69px; width: 69px; object-fit: cover; border-radius: 5%; margin-right: 10px;">';
echo '<div class="flex-grow-1">';
echo '<h5 class="mb-0 ms-2 text-dark fw-bolder py-4">' . $courseentry['name'] . '</h5>';
echo '</div>';
echo '<a href="course.php?id=' . $courseentry['id'] . '" class="stretched-link"></a>';
echo '</div>';
echo '</div>';
echo '</div>';
}
}
} else {
echo '<h6>Aktuell sind keine Kurse verfügbar.<br> Schau später nochmals vorbei.</h6>';
}
} else {
echo '<div class="alert alert-danger" role="alert">Die Anmeldefrist ist abgelaufen</div>';
}
}
?>
<?php include('includes/footer.php'); ?>