Compare commits

...

11 Commits

Author SHA1 Message Date
4614cd330c Update README.md 2025-09-22 08:48:54 +00:00
7d8760febb Update htdocs/index.php 2025-09-11 08:39:05 +00:00
940426e45c Testo del copyright 2025-09-11 10:35:01 +02:00
78eb485ef7 Link al codice sorgente 2025-09-11 08:21:45 +00:00
060f05247a Altra piccola modifica 2025-09-11 07:58:53 +00:00
e5fb838445 piccola modifica 2025-09-11 07:31:02 +00:00
72ca358139 bruh 2025-09-11 07:18:25 +00:00
0a3de8a846 Merge pull request 'Push to stable' (#1) from dev into stable
Reviewed-on: #1
2025-09-11 07:17:41 +00:00
141d78d08b Change estetica gestione orario 2025-09-11 08:47:26 +02:00
81078ddf9c Change gestione orario 2025-09-11 08:32:33 +02:00
397b2bffe3 Update README.md 2025-09-10 21:56:59 +00:00
10 changed files with 167 additions and 132 deletions

View File

@@ -62,10 +62,10 @@ $pass = "password123";
```php ```php
$oidc = new OpenIDConnectClient( $oidc = new OpenIDConnectClient(
'https://keycloak.local/realms/master/', 'https://keycloak.local/realms/master/',
'orario', 'orario', // Client ID Keycloak
'abcdefghijklmnop' 'abcdefghijklmnop' // Client secret Keycloak
); );
$oidc->setRedirectURL('https://orario.local/admin/login.php'); $oidc->setRedirectURL('https://orario.local/admin/login.php'); // orario.local è il dominio base di questa piattaforma
``` ```
- Esempio (``logout.php`` con keycloak): - Esempio (``logout.php`` con keycloak):
```php ```php

View File

@@ -57,7 +57,7 @@ if (isset($_GET['delete'])) {
<p> <p>
Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio. Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio.
</p> </p>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</p> <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>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -34,7 +34,7 @@ if (!isset($_SESSION['admin'])) {
<p> <p>
Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio. Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio.
</p> </p>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</p> <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>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -45,6 +45,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
<button type="submit">Login</button> <button type="submit">Login</button>
</form> </form>
</div> </div>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</p> <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> </body>
</html> </html>

View File

@@ -72,7 +72,7 @@ if (isset($_GET['delete'])) {
<p> <p>
Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio. Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio.
</p> </p>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</p> <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>
</div> </div>
</body> </body>

View File

@@ -1,33 +1,53 @@
<?php <?php
session_start(); session_start();
if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; } // if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; }
include("../db.php"); include("../db.php");
if ($_SERVER["REQUEST_METHOD"] == "POST") { // --- Recupera tutte le materie ---
$class_id = $_POST['class_id']; $subjects = [];
$day = $_POST['day']; $res = $conn->query("SELECT * FROM subjects ORDER BY name ASC");
$hour = $_POST['hour']; while ($r = $res->fetch_assoc()) {
$subject_id = $_POST['subject_id']; $label = $r['name'];
$conn->query("INSERT INTO timetable (class_id,day,hour,subject_id) VALUES ($class_id,'$day',$hour,$subject_id)"); if (!empty($r['teacher'])) $label .= " ({$r['teacher']})";
header("Location: timetable.php"); exit; if (!empty($r['room'])) $label .= " ({$r['room']})";
} $subjects[] = ['id' => $r['id'], 'label' => $label];
?>
<?php
include("../db.php"); // o il percorso corretto al tuo DB
// Funzione per eliminare una voce del timetable
function deleteTimetableEntry($conn, $id) {
$id = intval($id); // sicurezza
$conn->query("DELETE FROM timetable WHERE id=$id");
} }
// Se è stato cliccato il link "Elimina" // --- Salvataggio orario ---
if(isset($_GET['delete'])) { if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST['class_id']) && isset($_POST['subject'])) {
deleteTimetableEntry($conn, $_GET['delete']); $class_id = intval($_POST['class_id']);
// Dopo l'eliminazione, reindirizza per evitare duplicazioni if ($class_id > 0) {
header("Location: timetable.php"); // Cancella solo l'orario di questa classe
$conn->query("DELETE FROM timetable WHERE class_id=$class_id");
foreach ($_POST['subject'] as $day => $hours) {
foreach ($hours as $hour => $sub_ids) {
foreach ($sub_ids as $subject_id) {
$subject_id = intval($subject_id);
if (!empty($subject_id)) {
$conn->query("INSERT INTO timetable (class_id, day, hour, subject_id)
VALUES ($class_id, '" . $conn->real_escape_string($day) . "', $hour, $subject_id)");
}
}
}
}
header("Location: timetable.php?class_id=$class_id&saved=1");
exit; exit;
} }
}
// --- Selezione classe corrente ---
$class_id = isset($_GET['class_id']) ? intval($_GET['class_id']) : 0;
// --- Precaricamento dati orario ---
$preselectedData = [];
if ($class_id > 0) {
$res = $conn->query("SELECT * FROM timetable WHERE class_id=$class_id");
while ($r = $res->fetch_assoc()) {
$preselectedData[$r['day']][$r['hour']][] = $r['subject_id'];
}
}
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
@@ -35,9 +55,25 @@ if(isset($_GET['delete'])) {
<title>Gestisci Orario</title> <title>Gestisci Orario</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
<style>
.subject-container select { min-width: 120px; }
.subject-container button { cursor: pointer; margin-left: 3px; }
.admin-container { max-width: 95%; margin: auto; background: #fff; padding: 15px; border-radius: 8px; }
table { border-collapse: collapse; width: 100%; overflow-x: auto; display: block; }
th, td { text-align: center; padding: 6px; border: 1px solid #ccc; }
@media (max-width: 768px) {
table { font-size: 14px; }
th, td { padding: 4px; }
}
.saved-message {
margin-top: 15px;
text-align: center;
font-weight: bold;
color: green;
}
</style>
</head> </head>
<body> <body>
<!-- Navbar -->
<div class="navbar"> <div class="navbar">
<div class="logo">Admin Dashboard</div> <div class="logo">Admin Dashboard</div>
<div class="links"> <div class="links">
@@ -52,98 +88,96 @@ if(isset($_GET['delete'])) {
<form method="POST" autocomplete="off"> <form method="POST" autocomplete="off">
Classe: Classe:
<select name="class_id" required> <select name="class_id" required onchange="window.location='timetable.php?class_id='+this.value;">
<option value="" selected disabled>--Scegli un'opzione--</option> <option value="" disabled <?= $class_id === 0 ? 'selected' : '' ?>>--Scegli un'opzione--</option>
<?php <?php
$res = $conn->query("SELECT * FROM classes ORDER BY name ASC"); $res = $conn->query("SELECT * FROM classes ORDER BY name ASC");
while($r=$res->fetch_assoc())
echo "<option value='{$r['id']}'>{$r['name']}</option>";
?>
</select>
Giorno:
<select name="day" required>
<option value="" selected disabled>--Scegli un'opzione--</option>
<option>Lunedì</option><option>Martedì</option><option>Mercoledì</option>
<option>Giovedì</option><option>Venerdì</option><option>Sabato</option>
</select>
Ora:
<select name="hour" required>
<option value="" selected disabled>--Scegli un'opzione--</option>
<option value="1">1</option><option value="2">2</option><option value="3">3</option>
<option value="4">4</option><option value="5">5</option><option value="6">6</option>
</select>
Materia:
<select name="subject_id" required>
<option value="" selected disabled>--Scegli un'opzione--</option>
<?php
$res = $conn->query("SELECT * FROM subjects ORDER BY name ASC");
while ($r = $res->fetch_assoc()) { while ($r = $res->fetch_assoc()) {
$label = $r['name']; $selected = ($class_id == $r['id']) ? 'selected' : '';
if(!empty($r['teacher'])) { echo "<option value='{$r['id']}' $selected>{$r['name']}</option>";
$label .= " (" . $r['teacher'] . ")";
}
if(!empty($r['room'])) {
$label .= " (" . $r['room'] . ")";
}
echo "<option value='{$r['id']}'>" . htmlspecialchars($label) . "</option>";
} }
?> ?>
</select> </select>
<button type="submit">Aggiungi</button> <br><br>
</form> <?php if ($class_id > 0): ?>
<?php <table>
// Recupera tutte le entry del timetable <thead>
$res = $conn->query("SELECT timetable.id, classes.name AS class_name, timetable.day, timetable.hour, subjects.name AS subject_name, subjects.teacher as teacher, subjects.room as room
FROM timetable
LEFT JOIN classes ON timetable.class_id = classes.id
LEFT JOIN subjects ON timetable.subject_id = subjects.id
ORDER BY class_name, day, hour");
?>
<h2>Orario Inserito</h2>
<div class="table-container">
<table class="responsive-table" border="1" cellpadding="5" style="border-collapse:collapse; width:100%; max-width:1000px; margin:auto;">
<tr> <tr>
<th>Classe</th>
<th>Giorno</th>
<th>Ora</th> <th>Ora</th>
<th>Materia</th> <th>Lunedì</th>
<th>Azione</th> <th>Martedì</th>
<th>Mercoledì</th>
<th>Giovedì</th>
<th>Venerdì</th>
<th>Sabato</th>
</tr> </tr>
</thead>
<?php while($row = $res->fetch_assoc()): ?> <tbody>
<tr> <?php
<td data-label="Classe"><span><?php echo htmlspecialchars($row['class_name']); ?></span></td> $days = ['Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'];
<td data-label="Giorno"><span><?php echo htmlspecialchars($row['day']); ?></span></td> for ($hour = 1; $hour <= 6; $hour++) {
<td data-label="Ora"><span><?php echo htmlspecialchars($row['hour']); ?></span></td> echo "<tr>";
<td data-label="Materia"><span><?php echo "<td>{$hour}ª ora</td>";
echo htmlspecialchars($row['subject_name']); foreach ($days as $day) {
if(!empty($row['teacher'])) { $preselected = $preselectedData[$day][$hour] ?? [''];
echo " (" . htmlspecialchars($row['teacher']) . ")"; echo "<td>";
echo "<div class='subject-container' data-day='$day' data-hour='$hour'>";
foreach ($preselected as $subject_id) {
echo "<div class='subject-row' style='display:flex;align-items:center;gap:5px;margin-bottom:3px;'>";
echo "<select name='subject[$day][$hour][]'>";
echo "<option value=''>--</option>";
foreach ($subjects as $s) {
$sel = ($subject_id == $s['id']) ? 'selected' : '';
echo "<option value='{$s['id']}' $sel>" . htmlspecialchars($s['label']) . "</option>";
} }
// if(!empty($row['room'])) { echo "</select>";
// echo " (" . htmlspecialchars($row['room']) . ")"; echo "<button type='button' class='remove-subject' style='background:#e74c3c;color:white;border:none;border-radius:3px;padding:2px 6px;'></button>";
// } echo "</div>";
?></span></td> }
<td data-label="Azione"><span> echo "<button type='button' class='add-subject' style='background:#28a745;color:white;border:none;border-radius:3px;padding:2px 6px;'>+</button>";
<a href="timetable.php?delete=<?php echo $row['id']; ?>" echo "</div>";
onclick="return confirm('Sei sicuro di voler eliminare questa voce?');" class='delete-link'> echo "</td>";
Elimina }
</a> echo "</tr>";
</span></td> }
</tr> ?>
<?php endwhile; ?> </tbody>
</table> </table>
</div>
<p> <br>
<button type="submit">Salva orario</button>
<?php endif; ?>
<?php if (isset($_GET['saved'])): ?>
<p class="saved-message">✅ Orario salvato con successo!</p>
<?php endif; ?>
</form>
<p style="text-align: center;">
Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio. Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio.
</p> </p>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</p> <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>
</div> </div>
<script>
document.addEventListener('click', function(e){
if(e.target.classList.contains('add-subject')){
const container = e.target.closest('.subject-container');
const firstRow = container.querySelector('.subject-row');
const clone = firstRow.cloneNode(true);
clone.querySelector('select').value = '';
container.insertBefore(clone, e.target);
}
if(e.target.classList.contains('remove-subject')){
const container = e.target.closest('.subject-container');
const rows = container.querySelectorAll('.subject-row');
if(rows.length > 1){
e.target.closest('.subject-row').remove();
} else {
rows[0].querySelector('select').value = '';
}
}
});
</script>
</body> </body>
</html> </html>

View File

@@ -10,7 +10,7 @@ $hours = [
5 => "Quinta ora<br>11:55 - 12:50", 5 => "Quinta ora<br>11:55 - 12:50",
6 => "Sesta ora<br>12:50 - 13:50" 6 => "Sesta ora<br>12:50 - 13:50"
]; ];
if ($teacher == "No Lezione") { if ($teacher == "No Lezione" || $teacher == "sconosciuto") {
header("Location: index.php"); header("Location: index.php");
exit; exit;
} }
@@ -72,6 +72,6 @@ if ($res->num_rows === 0) {
} }
?> ?>
</table> </table>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</p> <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> </body>
</html> </html>

View File

@@ -15,6 +15,7 @@ include("db.php");
<div class="links"> <div class="links">
<a href="index.php">Home</a> <a href="index.php">Home</a>
<a href="admin/index.php">Admin</a> <a href="admin/index.php">Admin</a>
<a href="https://git.vichingo455.freeddns.org/emmev-code/orario" target="_blank">Codice sorgente</a>
</div> </div>
</div> </div>
<h1>Orario - a.s. 2025/26</h1> <h1>Orario - a.s. 2025/26</h1>
@@ -41,7 +42,7 @@ include("db.php");
<?php <?php
$res = $conn->query("SELECT DISTINCT teacher FROM subjects ORDER BY teacher"); $res = $conn->query("SELECT DISTINCT teacher FROM subjects ORDER BY teacher");
while($row = $res->fetch_assoc()){ while($row = $res->fetch_assoc()){
if ($row['teacher'] != "No Lezione") { if ($row['teacher'] != "No Lezione" && $row['teacher'] != "sconosciuto") {
$teacher_name = htmlspecialchars($row['teacher']); $teacher_name = htmlspecialchars($row['teacher']);
echo "<ul><li><b>$teacher_name</b></li>"; echo "<ul><li><b>$teacher_name</b></li>";
echo "<li><a href='docenti.php?teacher=".urlencode($teacher_name)."'>Visualizza orario</a></li>"; echo "<li><a href='docenti.php?teacher=".urlencode($teacher_name)."'>Visualizza orario</a></li>";
@@ -65,6 +66,6 @@ while($row = $res->fetch_assoc()){
?> ?>
</div> </div>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</p> <p style="text-align: center;">Copyright (C) 2025 EmmeV. - Released under GNU AGPL 3.0 License.</p>
</body> </body>
</html> </html>

View File

@@ -74,6 +74,6 @@ if ($res->num_rows === 0) {
} }
?> ?>
</table> </table>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</p> <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> </body>
</html> </html>

View File

@@ -66,6 +66,6 @@ if ($res->num_rows === 0) {
} }
?> ?>
</table> </table>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</p> <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> </body>
</html> </html>