Fixing untested code with more untested code
Interamente fatto con Claude AI Pro, se ne vedranno delle belle...
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
include("lib/db.php");
|
||||
$teacher = $_GET['teacher'];
|
||||
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
||||
$hours = [
|
||||
1 => "Prima ora<br>7:50 - 8:50",
|
||||
@@ -10,16 +9,19 @@ $hours = [
|
||||
5 => "Quinta ora<br>11:55 - 12:50",
|
||||
6 => "Sesta ora<br>12:50 - 13:50"
|
||||
];
|
||||
if ($teacher == "No Lezione" || $teacher == "sconosciuto") {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
else if (!isset($_GET['teacher'])) {
|
||||
|
||||
if (!isset($_GET['teacher'])) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$teacher = $conn->real_escape_string($_GET['teacher']);
|
||||
|
||||
if ($teacher == "No Lezione" || $teacher == "sconosciuto") {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$res = $conn->query("SELECT DISTINCT teacher FROM subjects WHERE teacher = '$teacher' LIMIT 1");
|
||||
|
||||
if ($res->num_rows === 0) {
|
||||
@@ -42,8 +44,11 @@ if ($res->num_rows === 0) {
|
||||
<a href="index.php">Home</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h1>Orario docente <?php echo htmlspecialchars($teacher); ?></h1>
|
||||
<table>
|
||||
|
||||
<!-- Visualizzazione Desktop -->
|
||||
<table class="desktop-schedule">
|
||||
<tr>
|
||||
<th></th>
|
||||
<?php foreach($days as $d) echo "<th>$d</th>"; ?>
|
||||
@@ -59,10 +64,12 @@ if ($res->num_rows === 0) {
|
||||
WHERE subjects.teacher='$teacher' AND timetable.day='$d' AND timetable.hour=$hnum");
|
||||
if($row = $q->fetch_assoc()){
|
||||
echo "<td data-label='$d'>
|
||||
<div class='subject'>{$row['name']}</div>
|
||||
<div class='teacher'>{$row['class_name']}</div>
|
||||
<div class='room'>{$row['room']}</div>
|
||||
</td>";
|
||||
<div class='subject'>" . htmlspecialchars($row['name']) . "</div>
|
||||
<div class='teacher'>" . htmlspecialchars($row['class_name']) . "</div>";
|
||||
if(!empty($row['room'])) {
|
||||
echo "<div class='room'>" . htmlspecialchars($row['room']) . "</div>";
|
||||
}
|
||||
echo "</td>";
|
||||
} else {
|
||||
echo "<td data-label='$d'></td>";
|
||||
}
|
||||
@@ -71,6 +78,41 @@ if ($res->num_rows === 0) {
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
<!-- FIX: Visualizzazione Mobile aggiunta -->
|
||||
<div class="mobile-schedule">
|
||||
<?php foreach($days as $d): ?>
|
||||
<div class="day">
|
||||
<h2><?= htmlspecialchars($d) ?></h2>
|
||||
<?php
|
||||
foreach($hours as $hnum => $hlabel):
|
||||
$q = $conn->query("SELECT subjects.name, classes.name AS class_name, subjects.room
|
||||
FROM timetable
|
||||
LEFT JOIN subjects ON timetable.subject_id = subjects.id
|
||||
LEFT JOIN classes ON timetable.class_id = classes.id
|
||||
WHERE subjects.teacher='$teacher' AND timetable.day='$d' AND timetable.hour=$hnum");
|
||||
|
||||
if($row = $q->fetch_assoc()):
|
||||
?>
|
||||
<div class="lesson">
|
||||
<div class="hour"><?= strip_tags($hlabel) ?></div>
|
||||
<div class="subject"><?= htmlspecialchars($row['name']) ?></div>
|
||||
<div class="teacher"><?= htmlspecialchars($row['class_name']) ?></div>
|
||||
<?php if(!empty($row['room'])): ?>
|
||||
<div class="room"><?= htmlspecialchars($row['room']) ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="lesson empty">
|
||||
<div class="hour"><?= strip_tags($hlabel) ?></div>
|
||||
<div class="subject">—</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<p style="text-align: center;">Copyright (C) 2025 EmmeV. - Released under <a href="https://git.vichingo455.freeddns.org/emmev-code/orario/src/branch/stable/LICENSE.txt" target="_blank">GNU AGPL 3.0 License</a>.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user