Compare commits
2 Commits
ecbcfe953a
...
e370435801
| Author | SHA1 | Date | |
|---|---|---|---|
| e370435801 | |||
| 1453a8028e |
98
README.md
98
README.md
@@ -26,7 +26,7 @@ sudo apt install -y composer php-cli curl php-mysql php-curl php-mbstring php-xm
|
|||||||
3. **Installa le dipendenze del pannello d'amministrazione**
|
3. **Installa le dipendenze del pannello d'amministrazione**
|
||||||
- Debian:
|
- Debian:
|
||||||
```bash
|
```bash
|
||||||
cd /var/www/orario/admin
|
cd /var/www/html/admin
|
||||||
composer install
|
composer install
|
||||||
```
|
```
|
||||||
- Windows (con XAMPP):
|
- Windows (con XAMPP):
|
||||||
@@ -37,41 +37,95 @@ composer install
|
|||||||
4. **(opzionale) Genera una password hashata**
|
4. **(opzionale) Genera una password hashata**
|
||||||
- Debian
|
- Debian
|
||||||
```bash
|
```bash
|
||||||
cd /var/www/orario/utils
|
cd orario/utils
|
||||||
php generate_hash.php <password>
|
php generate_hash.php <password>
|
||||||
```
|
```
|
||||||
- Windows:
|
- Windows:
|
||||||
```batch
|
```batch
|
||||||
cd C:\xampp\htdocs\utils
|
cd orario\utils
|
||||||
C:\xampp\php\php.exe generate_hash.php <password>
|
C:\xampp\php\php.exe generate_hash.php <password>
|
||||||
```
|
```
|
||||||
- Modifica quindi questa linea nel file ``schema.sql``, sostituendo l'hash predefinito con quello generato prima:
|
- Modifica quindi questa linea nel file ``schema.sql``, sostituendo l'hash predefinito con quello generato prima:
|
||||||
```sql
|
```sql
|
||||||
VALUES ('admin', '$2y$10$IS9v8CJNJnRXslV1NWDSquAjJ0GgU1sm6spBmGp6mjTLiNApfGcQi');
|
VALUES ('admin', '$2y$10$IS9v8CJNJnRXslV1NWDSquAjJ0GgU1sm6spBmGp6mjTLiNApfGcQi');
|
||||||
```
|
```
|
||||||
5. **Importa il file ``schema.sql`` nel tuo database MySQL**
|
5. **Importa il file ``schema.sql`` nel tuo database MySQL**
|
||||||
6. **Modifica il file ``db.php`` cambiando l'host, il nome utente e la password (necessari per la connessione al database MySQL)**
|
- Esempio Debian:
|
||||||
- Esempio:
|
```bash
|
||||||
```php
|
mysql -u root -p < orario/schema.sql
|
||||||
$host = "localhost";
|
|
||||||
$user = "utente";
|
|
||||||
$pass = "password123";
|
|
||||||
```
|
```
|
||||||
7. **Modifica ``admin/login.php`` e ``admin/logout.php`` con i dati di un'istanza keycloak. In caso tu voglia usare l'autenticazione via nome utente e password (e non keycloak), cancella quei due file e rinomina ``admin/login.php.backup`` in ``login.php`` e ``admin/logout.php.backup`` in ``logout.php``**
|
|
||||||
- Esempio (``login.php`` con keycloak):
|
6. **Modifica il file ``config/config.php`` inserendo i valori richiesti**
|
||||||
|
- Esempio file ``config/config.php``:
|
||||||
```php
|
```php
|
||||||
$oidc = new OpenIDConnectClient(
|
<?php
|
||||||
'https://keycloak.local/realms/master/',
|
// Impostazioni Database
|
||||||
'orario', // Client ID Keycloak
|
if (!defined('DB_HOST')) {
|
||||||
'abcdefghijklmnop' // Client secret Keycloak
|
define('DB_HOST', 'localhost'); // Host del database (ad esempio localhost)
|
||||||
);
|
}
|
||||||
$oidc->setRedirectURL('https://orario.local/admin/login.php'); // orario.local è il dominio base di questa piattaforma
|
if (!defined('DB_USER')) {
|
||||||
|
define('DB_USER', 'orario'); // Utente del database (ad esempio orario)
|
||||||
|
}
|
||||||
|
if (!defined('DB_PASS')) {
|
||||||
|
define('DB_PASS', 'orario'); // Password dell'utente specificato prima (ad esempio password123)
|
||||||
|
}
|
||||||
|
if (!defined('DB_NAME')) {
|
||||||
|
define('DB_NAME', 'school_timetable'); // Nome del database, non modificare se non sai cosa stai facendo.
|
||||||
|
}
|
||||||
|
// Impostazioni sito generali
|
||||||
|
if (!defined('APP_NAME')) {
|
||||||
|
define('APP_NAME', 'Orario Scuola'); // Nome del sito
|
||||||
|
}
|
||||||
|
if (!defined('YEAR')) {
|
||||||
|
define('YEAR', '2025/26'); // Anno Scolastico Corrente
|
||||||
|
}
|
||||||
|
if (!defined('DEV_MODE')) {
|
||||||
|
define('DEV_MODE', false); // Modalita' di sviluppo: abilita messaggi di debug aggiuntivi. Imposta su false se sei in produzione
|
||||||
|
}
|
||||||
|
// Impostazioni autenticazione dashboard amministrativa
|
||||||
|
if (!defined('AUTH_TYPE')) {
|
||||||
|
define('AUTH_TYPE','local'); // Può essere local (integrata), keycloak
|
||||||
|
}
|
||||||
|
if (!defined('APP_DOMAIN')) {
|
||||||
|
define('APP_DOMAIN',''); // Dominio del sito (ad esempio orario.yourdomain.com), richiesto per autenticazioni non local
|
||||||
|
}
|
||||||
|
// Impostazioni autenticazione via Keycloak (richiesto solo se AUTH_TYPE sta impostato su keycloak)
|
||||||
|
if (AUTH_TYPE === 'keycloak') {
|
||||||
|
if (!defined('KEYCLOAK_DOMAIN')) {
|
||||||
|
define('KEYCLOAK_DOMAIN',''); // Dominio di Keycloak (ad esempio auth.yourdomain.com)
|
||||||
|
}
|
||||||
|
if (!defined('KEYCLOAK_REALM')) {
|
||||||
|
define('KEYCLOAK_REALM',''); // Realm di Keycloak (ad esempio master)
|
||||||
|
}
|
||||||
|
if (!defined('KEYCLOAK_CLIENT_ID')) {
|
||||||
|
define('KEYCLOAK_CLIENT_ID',''); // Client ID per Keycloak (ad esempio orario)
|
||||||
|
}
|
||||||
|
if (!defined('KEYCLOAK_CLIENT_SECRET')) {
|
||||||
|
define('KEYCLOAK_CLIENT_SECRET',''); // Client Secret per Keycloak (ad esempio abcdefghijklm)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
```
|
```
|
||||||
- Esempio (``logout.php`` con keycloak):
|
7. **Apri ``http://localhost`` e goditi il sito**
|
||||||
```php
|
|
||||||
header('Location: https://keycloak.local/realms/master/protocol/openid-connect/logout?post_logout_redirect_uri=https://orario.local&client_id=orario');
|
## Installazione con Docker
|
||||||
|
1. Installa Curl, Git e Docker
|
||||||
|
```bash
|
||||||
|
apt install curl git
|
||||||
|
curl -fsSL https://get.docker.com | bash
|
||||||
```
|
```
|
||||||
8. **Apri ``http://localhost`` e goditi il sito**
|
2. Compila e crea il container:
|
||||||
|
```bash
|
||||||
|
git clone https://git.vichingo455.freeddns.org/emmev-code/orario
|
||||||
|
cd orario
|
||||||
|
git checkout dev # richiesto per passare alla versione di sviluppo
|
||||||
|
docker compose up -d --build
|
||||||
|
```
|
||||||
|
3. Il container dovrebbe diventare disponibile su ``http://localhost:8080``
|
||||||
|
|
||||||
|
### Per utenti Docker avanzati
|
||||||
|
Se sei un utente Docker avanzato e vuoi personalizzare puoi modificare la configurazione di docker nei file ``docker/php/config.php``, ``docker-compose.yml`` e ``Dockerfile`` per adattare tutto al tuo ambiente.
|
||||||
|
Per la maggior parte degli utenti consigliamo di usare la configurazione per Docker predefinita.
|
||||||
|
|
||||||
## Segnalare un problema
|
## Segnalare un problema
|
||||||
Per segnalare un problema puoi usare [Bugzilla](https://bugs.vichingo455.freeddns.org/describecomponents.cgi?product=Orario%20Scuola). Clicca [qui](https://bugs.vichingo455.freeddns.org/describecomponents.cgi?product=Orario%20Scuola) per andare a Bugzilla.
|
Per segnalare un problema puoi usare [Bugzilla](https://bugs.vichingo455.freeddns.org/describecomponents.cgi?product=Orario%20Scuola). Clicca [qui](https://bugs.vichingo455.freeddns.org/describecomponents.cgi?product=Orario%20Scuola) per andare a Bugzilla.
|
||||||
|
|||||||
23
docker-compose.yml
Normal file
23
docker-compose.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
services:
|
||||||
|
web:
|
||||||
|
build: .
|
||||||
|
container_name: orario-web
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
restart: unless-stopped
|
||||||
|
db:
|
||||||
|
image: mariadb:11
|
||||||
|
container_name: orario-db
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: P@ssw0rd
|
||||||
|
MYSQL_DATABASE: school_timetable
|
||||||
|
MYSQL_USER: orario
|
||||||
|
MYSQL_PASSWORD: orario
|
||||||
|
volumes:
|
||||||
|
- db_data:/var/lib/mysql
|
||||||
|
- ./schema.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
||||||
|
volumes:
|
||||||
|
db_data:
|
||||||
47
docker/php/config.php
Normal file
47
docker/php/config.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
// Impostazioni Database
|
||||||
|
if (!defined('DB_HOST')) {
|
||||||
|
define('DB_HOST', 'db');
|
||||||
|
}
|
||||||
|
if (!defined('DB_USER')) {
|
||||||
|
define('DB_USER', 'orario');
|
||||||
|
}
|
||||||
|
if (!defined('DB_PASS')) {
|
||||||
|
define('DB_PASS', 'orario');
|
||||||
|
}
|
||||||
|
if (!defined('DB_NAME')) {
|
||||||
|
define('DB_NAME', 'school_timetable');
|
||||||
|
}
|
||||||
|
// Impostazioni sito generali
|
||||||
|
if (!defined('APP_NAME')) {
|
||||||
|
define('APP_NAME', 'Orario Scuola');
|
||||||
|
}
|
||||||
|
if (!defined('YEAR')) {
|
||||||
|
define('YEAR', '2025/26');
|
||||||
|
}
|
||||||
|
if (!defined('DEV_MODE')) {
|
||||||
|
define('DEV_MODE', false); // Modalita' di sviluppo
|
||||||
|
}
|
||||||
|
// Impostazioni autenticazione dashboard amministrativa
|
||||||
|
if (!defined('AUTH_TYPE')) {
|
||||||
|
define('AUTH_TYPE','local'); // Può essere local (integrata), keycloak, google
|
||||||
|
}
|
||||||
|
if (!defined('APP_DOMAIN')) {
|
||||||
|
define('APP_DOMAIN',''); // Dominio del sito (ad esempio orario.yourdomain.com), richiesto per autenticazioni non local
|
||||||
|
}
|
||||||
|
// Impostazioni autenticazione via Keycloak (richiesto solo se AUTH_TYPE sta impostato su keycloak)
|
||||||
|
if (AUTH_TYPE === 'keycloak') {
|
||||||
|
if (!defined('KEYCLOAK_DOMAIN')) {
|
||||||
|
define('KEYCLOAK_DOMAIN',''); // Dominio di Keycloak (ad esempio auth.yourdomain.com)
|
||||||
|
}
|
||||||
|
if (!defined('KEYCLOAK_REALM')) {
|
||||||
|
define('KEYCLOAK_REALM',''); // Realm di Keycloak (ad esempio master)
|
||||||
|
}
|
||||||
|
if (!defined('KEYCLOAK_CLIENT_ID')) {
|
||||||
|
define('KEYCLOAK_CLIENT_ID',''); // Client ID per Keycloak (ad esempio orario)
|
||||||
|
}
|
||||||
|
if (!defined('KEYCLOAK_CLIENT_SECRET')) {
|
||||||
|
define('KEYCLOAK_CLIENT_SECRET',''); // Client Secret per Keycloak (ad esempio abcdefghijklm)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
1
docker/readme.txt
Normal file
1
docker/readme.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
These files are used by docker compose builder to create a working image in one command.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?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("../lib/db.php");
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['name'])) {
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['name'])) {
|
||||||
$name = $_POST['name'];
|
$name = $_POST['name'];
|
||||||
@@ -49,7 +49,7 @@ if (isset($_GET['delete'])) {
|
|||||||
echo "<tr>
|
echo "<tr>
|
||||||
<td>{$row['id']}</td>
|
<td>{$row['id']}</td>
|
||||||
<td>{$row['name']}</td>
|
<td>{$row['name']}</td>
|
||||||
<td><a href='classes.php?delete={$row['id']}' class='delete-link'>Elimina</a></td>
|
<td><a href='classes.php?delete={$row['id']}' class='delete-link' onclick='return confirm(\"Sei sicuro di voler eliminare questa classe?\")'>Elimina</a></td>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
333
htdocs/admin/importer.php
Normal file
333
htdocs/admin/importer.php
Normal file
@@ -0,0 +1,333 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; }
|
||||||
|
include("../lib/db.php");
|
||||||
|
|
||||||
|
$message = "";
|
||||||
|
$messageType = "";
|
||||||
|
|
||||||
|
// Gestione importazione
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST['import'])) {
|
||||||
|
$classe_codice = trim($_POST['classe_codice']);
|
||||||
|
$classe_id = intval($_POST['classe_id']);
|
||||||
|
$api_url = trim($_POST['api_url']);
|
||||||
|
|
||||||
|
if (empty($classe_codice) || $classe_id === 0) {
|
||||||
|
$message = "Compila tutti i campi obbligatori.";
|
||||||
|
$messageType = "error";
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
// Chiama l'API Node.js
|
||||||
|
$url = $api_url . "?classe=" . urlencode($classe_codice);
|
||||||
|
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||||
|
$response = curl_exec($ch);
|
||||||
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
if ($httpCode !== 200) {
|
||||||
|
throw new Exception("Errore nella chiamata API (HTTP $httpCode)");
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = json_decode($response, true);
|
||||||
|
|
||||||
|
if (!$data || !isset($data['giorni'])) {
|
||||||
|
throw new Exception("Formato JSON non valido");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancella l'orario esistente per questa classe
|
||||||
|
$stmt = $conn->prepare("DELETE FROM timetable WHERE class_id = ?");
|
||||||
|
$stmt->bind_param("i", $classe_id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
$inserimenti = 0;
|
||||||
|
$materie_create = [];
|
||||||
|
|
||||||
|
// Processa ogni giorno
|
||||||
|
foreach ($data['giorni'] as $giorno => $ore) {
|
||||||
|
foreach ($ore as $oraData) {
|
||||||
|
// Salta ore vuote
|
||||||
|
if ($oraData['materia'] === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ora = $oraData['ora'];
|
||||||
|
$materia = $oraData['materia'];
|
||||||
|
$docenti = $oraData['docenti'];
|
||||||
|
$laboratori = $oraData['laboratori']; // Ora è un array
|
||||||
|
|
||||||
|
// Se non ci sono docenti, salta (situazione anomala)
|
||||||
|
if (count($docenti) === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Caso 1: Stesso numero di docenti e laboratori → associazione 1:1
|
||||||
|
if (count($docenti) === count($laboratori) && count($laboratori) > 0) {
|
||||||
|
foreach ($docenti as $idx => $docente) {
|
||||||
|
$laboratorio = $laboratori[$idx];
|
||||||
|
|
||||||
|
// Cerca/crea materia
|
||||||
|
$stmt = $conn->prepare("SELECT id FROM subjects WHERE name = ? AND teacher = ? AND room = ?");
|
||||||
|
$stmt->bind_param("sss", $materia, $docente, $laboratorio);
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
|
if ($result->num_rows > 0) {
|
||||||
|
$subject_id = $result->fetch_assoc()['id'];
|
||||||
|
} else {
|
||||||
|
$stmt2 = $conn->prepare("INSERT INTO subjects (name, teacher, room) VALUES (?, ?, ?)");
|
||||||
|
$stmt2->bind_param("sss", $materia, $docente, $laboratorio);
|
||||||
|
$stmt2->execute();
|
||||||
|
$subject_id = $conn->insert_id;
|
||||||
|
$stmt2->close();
|
||||||
|
$materie_create[] = "$materia ($docente - $laboratorio)";
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
// Inserisci in timetable
|
||||||
|
$stmt3 = $conn->prepare("INSERT INTO timetable (class_id, day, hour, subject_id) VALUES (?, ?, ?, ?)");
|
||||||
|
$stmt3->bind_param("isii", $classe_id, $giorno, $ora, $subject_id);
|
||||||
|
$stmt3->execute();
|
||||||
|
$stmt3->close();
|
||||||
|
$inserimenti++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Caso 2: Più docenti, un laboratorio (o nessuno) → stesso laboratorio per tutti
|
||||||
|
else if (count($laboratori) <= 1) {
|
||||||
|
$laboratorio = count($laboratori) > 0 ? $laboratori[0] : null;
|
||||||
|
|
||||||
|
foreach ($docenti as $docente) {
|
||||||
|
// Cerca/crea materia
|
||||||
|
if ($laboratorio) {
|
||||||
|
$stmt = $conn->prepare("SELECT id FROM subjects WHERE name = ? AND teacher = ? AND room = ?");
|
||||||
|
$stmt->bind_param("sss", $materia, $docente, $laboratorio);
|
||||||
|
} else {
|
||||||
|
$stmt = $conn->prepare("SELECT id FROM subjects WHERE name = ? AND teacher = ? AND (room IS NULL OR room = '')");
|
||||||
|
$stmt->bind_param("ss", $materia, $docente);
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
|
if ($result->num_rows > 0) {
|
||||||
|
$subject_id = $result->fetch_assoc()['id'];
|
||||||
|
} else {
|
||||||
|
$stmt2 = $conn->prepare("INSERT INTO subjects (name, teacher, room) VALUES (?, ?, ?)");
|
||||||
|
$stmt2->bind_param("sss", $materia, $docente, $laboratorio);
|
||||||
|
$stmt2->execute();
|
||||||
|
$subject_id = $conn->insert_id;
|
||||||
|
$stmt2->close();
|
||||||
|
$materie_create[] = "$materia ($docente" . ($laboratorio ? " - $laboratorio" : "") . ")";
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
// Inserisci in timetable
|
||||||
|
$stmt3 = $conn->prepare("INSERT INTO timetable (class_id, day, hour, subject_id) VALUES (?, ?, ?, ?)");
|
||||||
|
$stmt3->bind_param("isii", $classe_id, $giorno, $ora, $subject_id);
|
||||||
|
$stmt3->execute();
|
||||||
|
$stmt3->close();
|
||||||
|
$inserimenti++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Caso 3: Più laboratori che docenti → usa il primo laboratorio per tutti
|
||||||
|
else {
|
||||||
|
$laboratorio = $laboratori[0];
|
||||||
|
|
||||||
|
foreach ($docenti as $docente) {
|
||||||
|
$stmt = $conn->prepare("SELECT id FROM subjects WHERE name = ? AND teacher = ? AND room = ?");
|
||||||
|
$stmt->bind_param("sss", $materia, $docente, $laboratorio);
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
|
if ($result->num_rows > 0) {
|
||||||
|
$subject_id = $result->fetch_assoc()['id'];
|
||||||
|
} else {
|
||||||
|
$stmt2 = $conn->prepare("INSERT INTO subjects (name, teacher, room) VALUES (?, ?, ?)");
|
||||||
|
$stmt2->bind_param("sss", $materia, $docente, $laboratorio);
|
||||||
|
$stmt2->execute();
|
||||||
|
$subject_id = $conn->insert_id;
|
||||||
|
$stmt2->close();
|
||||||
|
$materie_create[] = "$materia ($docente - $laboratorio)";
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
$stmt3 = $conn->prepare("INSERT INTO timetable (class_id, day, hour, subject_id) VALUES (?, ?, ?, ?)");
|
||||||
|
$stmt3->bind_param("isii", $classe_id, $giorno, $ora, $subject_id);
|
||||||
|
$stmt3->execute();
|
||||||
|
$stmt3->close();
|
||||||
|
$inserimenti++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = "Importazione completata con successo!<br>";
|
||||||
|
$message .= "- Inserite $inserimenti ore di lezione<br>";
|
||||||
|
if (count($materie_create) > 0) {
|
||||||
|
$message .= "- Create " . count($materie_create) . " nuove materie";
|
||||||
|
}
|
||||||
|
$messageType = "success";
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$message = "Errore durante l'importazione: " . htmlspecialchars($e->getMessage());
|
||||||
|
$messageType = "error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Importa Orario</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
<style>
|
||||||
|
.import-form {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 20px auto;
|
||||||
|
padding: 20px;
|
||||||
|
background: #f9f9f9;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
.form-group {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
.form-group label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.form-group input,
|
||||||
|
.form-group select {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.form-group small {
|
||||||
|
display: block;
|
||||||
|
margin-top: 5px;
|
||||||
|
color: #666;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
.message {
|
||||||
|
padding: 15px;
|
||||||
|
margin: 20px 0;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
.message.success {
|
||||||
|
background: #d4edda;
|
||||||
|
color: #155724;
|
||||||
|
border: 1px solid #c3e6cb;
|
||||||
|
}
|
||||||
|
.message.error {
|
||||||
|
background: #f8d7da;
|
||||||
|
color: #721c24;
|
||||||
|
border: 1px solid #f5c6cb;
|
||||||
|
}
|
||||||
|
.warning-box {
|
||||||
|
background: #fff3cd;
|
||||||
|
border: 1px solid #ffc107;
|
||||||
|
padding: 15px;
|
||||||
|
margin: 20px 0;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
.warning-box strong {
|
||||||
|
color: #856404;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="navbar">
|
||||||
|
<div class="logo">Admin Dashboard</div>
|
||||||
|
<div class="links">
|
||||||
|
<a href="index.php">Dashboard</a>
|
||||||
|
<a href="logout.php">Logout</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-container">
|
||||||
|
<h1>Importa Orario da Sistema Esterno</h1>
|
||||||
|
<a href="index.php" class="back-link">⬅ Torna al Dashboard</a>
|
||||||
|
|
||||||
|
<?php if ($message): ?>
|
||||||
|
<div class="message <?php echo $messageType; ?>">
|
||||||
|
<?php echo $message; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="warning-box">
|
||||||
|
<strong>Attenzione:</strong> L'importazione cancellerà l'orario esistente della classe selezionata
|
||||||
|
e lo sostituirà con i dati importati dal sistema esterno.
|
||||||
|
Verranno create automaticamente le materie mancanti.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="import-form">
|
||||||
|
<h2>Configura Importazione</h2>
|
||||||
|
<form method="POST">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="classe_id">Classe di destinazione *</label>
|
||||||
|
<select name="classe_id" id="classe_id" required>
|
||||||
|
<option value="">-- Seleziona classe --</option>
|
||||||
|
<?php
|
||||||
|
$res = $conn->query("SELECT * FROM classes ORDER BY name ASC");
|
||||||
|
while ($row = $res->fetch_assoc()) {
|
||||||
|
echo "<option value='{$row['id']}'>{$row['name']}</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
<small>Classe nel tuo database dove importare l'orario</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="classe_codice">Codice classe sorgente *</label>
|
||||||
|
<input type="text" name="classe_codice" id="classe_codice"
|
||||||
|
placeholder="es: 1A, 2B, 3BIN..." required>
|
||||||
|
<small>Codice della classe nel sistema esterno</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="api_url">URL API Node.js</label>
|
||||||
|
<input type="text" name="api_url" id="api_url"
|
||||||
|
value="http://localhost:3006/classe" required>
|
||||||
|
<small>Endpoint dell'API Node.js per lo scraping</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" name="import" style="width: 100%; padding: 12px; font-size: 16px;">
|
||||||
|
🔄 Importa Orario
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-container" style="margin-top: 30px;">
|
||||||
|
<h3>Come funziona l'importazione</h3>
|
||||||
|
<ol>
|
||||||
|
<li>Assicurati che il server Node.js sia avviato (<code>node server.js</code>)</li>
|
||||||
|
<li>Seleziona la classe di destinazione nel tuo database</li>
|
||||||
|
<li>Inserisci il codice della classe nel sistema esterno (es: 3BIN, 1A, 5AINF)</li>
|
||||||
|
<li>Clicca su "Importa Orario"</li>
|
||||||
|
<li>Il sistema cancellerà l'orario esistente e importerà i nuovi dati</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<h3>Gestione casi speciali</h3>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Più docenti, più laboratori</strong>: Associazione 1:1 (docente1→lab1, docente2→lab2)</li>
|
||||||
|
<li><strong>Più docenti, un laboratorio</strong>: Stesso laboratorio per tutti i docenti</li>
|
||||||
|
<li><strong>Più docenti, nessun laboratorio</strong>: Nessun laboratorio per tutti</li>
|
||||||
|
<li><strong>Un docente, più laboratori</strong>: Viene usato il primo laboratorio</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p style="text-align: center; margin-top: 30px;">
|
||||||
|
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>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
include_once __DIR__ . '/../config/config.php';
|
||||||
session_start();
|
session_start();
|
||||||
if (!isset($_SESSION['admin'])) {
|
if (!isset($_SESSION['admin'])) {
|
||||||
header("Location: login.php");
|
header("Location: login.php");
|
||||||
@@ -24,12 +25,22 @@ if (!isset($_SESSION['admin'])) {
|
|||||||
|
|
||||||
<!-- Contenuto Dashboard -->
|
<!-- Contenuto Dashboard -->
|
||||||
<div class="dashboard">
|
<div class="dashboard">
|
||||||
<h1>Benvenuto, <?php echo $_SESSION['admin']; ?>!</h1>
|
<h1>Benvenuto, <?php echo htmlspecialchars($_SESSION['admin']); ?>!</h1>
|
||||||
<p>
|
<p>
|
||||||
<a href="classes.php">Gestisci Classi</a>
|
<a href="classes.php">Gestisci Classi</a>
|
||||||
<a href="subjects.php">Gestisci Materie</a>
|
<a href="subjects.php">Gestisci Materie</a>
|
||||||
<a href="timetable.php">Gestisci Orario</a>
|
<a href="timetable.php">Gestisci Orario</a>
|
||||||
<!--<a href="logout.php">Logout</a>-->
|
<a href="importer.php" style="background: #28a745;">🔄 Importa Orario</a>
|
||||||
|
<?php
|
||||||
|
if ($_SESSION['auth_type'] === 'local') {
|
||||||
|
echo '<a href="password.php">Cambia Password</a>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
if ($_SESSION['auth_type'] === 'local' && $_SESSION['admin'] === 'admin') {
|
||||||
|
echo '<a href="users.php">Gestisci Amministratori</a>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
</p>
|
</p>
|
||||||
<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.
|
||||||
@@ -38,4 +49,3 @@ if (!isset($_SESSION['admin'])) {
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,116 @@
|
|||||||
<?php
|
<?php
|
||||||
require 'vendor/autoload.php';
|
|
||||||
use Jumbojett\OpenIDConnectClient;
|
use Jumbojett\OpenIDConnectClient;
|
||||||
|
require 'vendor/autoload.php';
|
||||||
session_start();
|
session_start();
|
||||||
// Configura il client Keycloak
|
include("../lib/db.php");
|
||||||
$oidc = new OpenIDConnectClient(
|
if (isset($_SESSION['admin'])) { header("Location: index.php"); exit; }
|
||||||
'https://<KEYCLOAK_URL>/realms/<REALM>/',
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && AUTH_TYPE == 'local') {
|
||||||
'<CLIENT_ID>',
|
try {
|
||||||
'<CLIENT_SECRET>'
|
$username = $_POST['username'];
|
||||||
);
|
$password = $_POST['password'];
|
||||||
// Redirect post-login
|
$stmt = $conn->prepare("SELECT * FROM admin WHERE username = ?");
|
||||||
$oidc->setRedirectURL('https://<APP_DOMAIN>/admin/login.php');
|
$stmt->bind_param("s", $username);
|
||||||
|
$stmt->execute();
|
||||||
|
$res = $stmt->get_result();
|
||||||
|
if ($row = $res->fetch_assoc()) {
|
||||||
|
if (password_verify($password, $row['password'])) {
|
||||||
|
$_SESSION['admin'] = $row['username'];
|
||||||
|
$_SESSION['auth_type'] = 'local';
|
||||||
|
header("Location: index.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$error = "Credenziali non valide";
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$error = "Errore durante l'autenticazione. Potrebbe essere un problema con PHP oppure col database. Ulteriori dettagli: " . $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (AUTH_TYPE == 'local') {
|
||||||
|
echo <<<HTML
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Login Admin</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
$oidc->authenticate();
|
<div class="navbar">
|
||||||
$userinfo = $oidc->getVerifiedClaims();
|
<div class="logo">Admin Dashboard</div>
|
||||||
$_SESSION['admin'] = $userinfo->preferred_username;
|
<div class="links">
|
||||||
header("Location: index.php");
|
<a href="/">Torna al sito</a>
|
||||||
exit;
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Container login -->
|
||||||
|
<div class="login-container">
|
||||||
|
<h1>Login Admin</h1>
|
||||||
|
<form method="post">
|
||||||
|
<input type="text" name="username" placeholder="Username" required><br>
|
||||||
|
<input type="password" name="password" placeholder="Password" required><br>
|
||||||
|
<button type="submit">Login</button>
|
||||||
|
</form>
|
||||||
|
HTML;
|
||||||
|
if(isset($error)) echo "<br><div class='error'>$error</div>";
|
||||||
|
echo <<<HTML
|
||||||
|
</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>
|
||||||
|
HTML;
|
||||||
|
}
|
||||||
|
else if (AUTH_TYPE === 'keycloak') {
|
||||||
|
try {
|
||||||
|
// Configura il client Keycloak
|
||||||
|
$oidc = new OpenIDConnectClient(
|
||||||
|
'https://' + KEYCLOAK_DOMAIN + '/realms/' + KEYCLOAK_REALM + '/',
|
||||||
|
KEYCLOAK_CLIENT_ID,
|
||||||
|
KEYCLOAK_CLIENT_SECRET
|
||||||
|
);
|
||||||
|
// Redirect post-login
|
||||||
|
$oidc->setRedirectURL('https://' + APP_DOMAIN + '/admin/login.php');
|
||||||
|
$oidc->authenticate();
|
||||||
|
$userinfo = $oidc->getVerifiedClaims();
|
||||||
|
$_SESSION['admin'] = $userinfo->preferred_username;
|
||||||
|
$_SESSION['auth_type'] = 'keycloak';
|
||||||
|
header("Location: index.php");
|
||||||
|
exit;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
echo <<<HTML
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Login Admin</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="navbar">
|
||||||
|
<div class="logo">Admin Dashboard</div>
|
||||||
|
<div class="links">
|
||||||
|
<a href="/">Torna al sito</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Container login -->
|
||||||
|
<div class="login-container">
|
||||||
|
<h1>Login Admin</h1>
|
||||||
|
HTML;
|
||||||
|
if (DEV_MODE) {
|
||||||
|
echo "<br><div class='error'>Errore durante l'autenticazione con Keycloak. Assicurati di avere impostato i vari parametri correttamente. Ulteriori dettagli: " . $e . "</div>";
|
||||||
|
} else {
|
||||||
|
echo "<br><div class='error'>Errore durante l'autenticazione con Keycloak. Contatta l'amministratore del sito.</div>";
|
||||||
|
}
|
||||||
|
echo <<<HTML
|
||||||
|
</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>
|
||||||
|
HTML;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
include("../db.php");
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
||||||
$username = $_POST['username'];
|
|
||||||
$password = $_POST['password'];
|
|
||||||
$stmt = $conn->prepare("SELECT * FROM admin WHERE username = ?");
|
|
||||||
$stmt->bind_param("s", $username);
|
|
||||||
$stmt->execute();
|
|
||||||
$res = $stmt->get_result();
|
|
||||||
if ($row = $res->fetch_assoc()) {
|
|
||||||
if (password_verify($password, $row['password'])) {
|
|
||||||
$_SESSION['admin'] = $row['username'];
|
|
||||||
header("Location: index.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$error = "Credenziali non valide";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Login Admin</title>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<link rel="stylesheet" href="style.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="navbar">
|
|
||||||
<div class="logo">Admin Dashboard</div>
|
|
||||||
<div class="links">
|
|
||||||
<a href="/">Torna al sito</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Container login -->
|
|
||||||
<div class="login-container">
|
|
||||||
<h1>Login Admin</h1>
|
|
||||||
<?php if(isset($error)) echo "<div class='error'>$error</div>"; ?>
|
|
||||||
<form method="post">
|
|
||||||
<input type="text" name="username" placeholder="Username" required><br>
|
|
||||||
<input type="password" name="password" placeholder="Password" required><br>
|
|
||||||
<button type="submit">Login</button>
|
|
||||||
</form>
|
|
||||||
</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>
|
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
include("../config/config.php");
|
||||||
session_start();
|
session_start();
|
||||||
session_destroy();
|
session_destroy();
|
||||||
header('Location: https://<KEYCLOAK_URL>/realms/<REALM>/protocol/openid-connect/logout?post_logout_redirect_uri=https://<APP_DOMAIN>&client_id=<CLIENT_ID>');
|
if (AUTH_TYPE === 'local')
|
||||||
exit;
|
header("Location: /index.php");
|
||||||
|
else if (AUTH_TYPE === 'keycloak')
|
||||||
|
header('Location: https://' + KEYCLOAK_DOMAIN + '/realms/' + KEYCLOAK_REALM + '/protocol/openid-connect/logout?post_logout_redirect_uri=https://' + APP_DOMAIN + '&client_id=' + KEYCLOAK_CLIENT_ID);
|
||||||
|
?>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
session_destroy();
|
|
||||||
header("Location: /index.php");
|
|
||||||
?>
|
|
||||||
82
htdocs/admin/password.php
Normal file
82
htdocs/admin/password.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
include("../lib/db.php");
|
||||||
|
|
||||||
|
if (!isset($_SESSION['admin']) || $_SESSION['auth_type'] != 'local') {
|
||||||
|
header("Location: login.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = '';
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
|
$old = $_POST['old_password'];
|
||||||
|
$new = $_POST['new_password'];
|
||||||
|
$confirm = $_POST['confirm_password'];
|
||||||
|
$user = $_SESSION['admin'];
|
||||||
|
|
||||||
|
if ($new !== $confirm) {
|
||||||
|
$message = "Le nuove password non coincidono.";
|
||||||
|
} else {
|
||||||
|
// Recupera hash password attuale
|
||||||
|
$stmt = $conn->prepare("SELECT password FROM admin WHERE username = ?");
|
||||||
|
$stmt->bind_param("s", $user);
|
||||||
|
$stmt->execute();
|
||||||
|
$res = $stmt->get_result();
|
||||||
|
$row = $res->fetch_assoc();
|
||||||
|
|
||||||
|
if ($row && password_verify($old, $row['password'])) {
|
||||||
|
$newHash = password_hash($new, PASSWORD_DEFAULT);
|
||||||
|
$stmt = $conn->prepare("UPDATE admin SET password = ? WHERE username = ?");
|
||||||
|
$stmt->bind_param("ss", $newHash, $user);
|
||||||
|
$stmt->execute();
|
||||||
|
$message = "Password cambiata con successo.";
|
||||||
|
} else {
|
||||||
|
$message = "Password attuale errata.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Cambia Password</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="navbar">
|
||||||
|
<div class="logo">Admin Dashboard</div>
|
||||||
|
<div class="links">
|
||||||
|
<a href="index.php">Dashboard</a>
|
||||||
|
<a href="logout.php">Logout</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-container">
|
||||||
|
<h1>Cambia Password</h1>
|
||||||
|
<a href="index.php" class="back-link">⬅ Torna al Dashboard</a>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
<label>Password attuale:<br>
|
||||||
|
<input type="password" name="old_password" required>
|
||||||
|
</label><br><br>
|
||||||
|
|
||||||
|
<label>Nuova password:<br>
|
||||||
|
<input type="password" name="new_password" required>
|
||||||
|
</label><br><br>
|
||||||
|
|
||||||
|
<label>Conferma nuova password:<br>
|
||||||
|
<input type="password" name="confirm_password" required>
|
||||||
|
</label><br><br>
|
||||||
|
|
||||||
|
<button type="submit">Cambia password</button>
|
||||||
|
</form>
|
||||||
|
<?php if ($message): ?>
|
||||||
|
<p style="color:<?php echo strpos($message,'successo')!==false ? 'green':'red'; ?>;"><?php echo $message; ?></p>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Body e font */
|
/* ===== BASE ===== */
|
||||||
body {
|
body {
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
background-color: #f0f2f5;
|
background-color: #f0f2f5;
|
||||||
@@ -7,7 +7,7 @@ body {
|
|||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Navbar */
|
/* ===== NAVBAR ===== */
|
||||||
.navbar {
|
.navbar {
|
||||||
background-color: #2c3e50;
|
background-color: #2c3e50;
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
@@ -20,6 +20,15 @@ body {
|
|||||||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.navbar.text-center {
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar .logo {
|
||||||
|
font-size: 1.3em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
.navbar a {
|
.navbar a {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
@@ -32,27 +41,38 @@ body {
|
|||||||
color: #f39c12;
|
color: #f39c12;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar .logo {
|
/* ===== CONTAINERS ===== */
|
||||||
font-size: 1.3em;
|
.dashboard,
|
||||||
font-weight: bold;
|
.admin-container,
|
||||||
}
|
.login-container {
|
||||||
|
|
||||||
/* Dashboard container */
|
|
||||||
.dashboard {
|
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
text-align: center;
|
|
||||||
background: #fff;
|
background: #fff;
|
||||||
padding: 30px;
|
padding: 30px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard h1 {
|
.login-container {
|
||||||
margin-bottom: 20px;
|
max-width: 400px;
|
||||||
color: #2c3e50;
|
margin: 80px auto;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dashboard {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== HEADINGS ===== */
|
||||||
|
.dashboard h1,
|
||||||
|
.admin-container h1,
|
||||||
|
.login-container h1 {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
color: #2c3e50;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== LINKS ===== */
|
||||||
.dashboard a {
|
.dashboard a {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
@@ -66,26 +86,8 @@ body {
|
|||||||
|
|
||||||
.dashboard a:hover {
|
.dashboard a:hover {
|
||||||
background-color: #f39c12;
|
background-color: #f39c12;
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
/* Container principale */
|
|
||||||
.admin-container {
|
|
||||||
max-width: 800px;
|
|
||||||
margin: 0 auto;
|
|
||||||
background: #fff;
|
|
||||||
padding: 30px;
|
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Titolo */
|
|
||||||
.admin-container h1 {
|
|
||||||
text-align: center;
|
|
||||||
color: #2c3e50;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Link ritorno */
|
|
||||||
.admin-container a.back-link {
|
.admin-container a.back-link {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
@@ -98,54 +100,6 @@ body {
|
|||||||
color: #f39c12;
|
color: #f39c12;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Form aggiungi classe */
|
|
||||||
.admin-container form {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container input[type="text"] {
|
|
||||||
padding: 8px 12px;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-radius: 6px;
|
|
||||||
width: 200px;
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container button {
|
|
||||||
padding: 8px 15px;
|
|
||||||
border: none;
|
|
||||||
background-color: #1f618d;
|
|
||||||
color: #fff;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background-color 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container button:hover {
|
|
||||||
background-color: #f39c12;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Tabella */
|
|
||||||
.admin-container table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container th, .admin-container td {
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
padding: 10px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container th {
|
|
||||||
background-color: #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container tr:hover td {
|
|
||||||
background-color: #f7f7f7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container a.delete-link {
|
.admin-container a.delete-link {
|
||||||
color: #e74c3c;
|
color: #e74c3c;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@@ -156,125 +110,34 @@ body {
|
|||||||
.admin-container a.delete-link:hover {
|
.admin-container a.delete-link:hover {
|
||||||
color: #c0392b;
|
color: #c0392b;
|
||||||
}
|
}
|
||||||
/* Login container */
|
|
||||||
.login-container {
|
|
||||||
max-width: 400px;
|
|
||||||
margin: 80px auto;
|
|
||||||
background: #fff;
|
|
||||||
padding: 30px;
|
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Titolo */
|
.admin-container a.edit-link {
|
||||||
.login-container h1 {
|
color: #4d5cdb;
|
||||||
margin-bottom: 20px;
|
|
||||||
color: #2c3e50;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Input */
|
|
||||||
.login-container input[type="text"],
|
|
||||||
.login-container input[type="password"] {
|
|
||||||
width: 90%;
|
|
||||||
padding: 10px;
|
|
||||||
margin: 10px 0;
|
|
||||||
border-radius: 6px;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
font-size: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Pulsante */
|
|
||||||
.login-container button {
|
|
||||||
padding: 10px 20px;
|
|
||||||
background-color: #1f618d;
|
|
||||||
color: #fff;
|
|
||||||
border: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background-color 0.2s;
|
|
||||||
font-size: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-container button:hover {
|
|
||||||
background-color: #f39c12;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Messaggio errore */
|
|
||||||
.login-container .error {
|
|
||||||
color: #e74c3c;
|
|
||||||
font-weight: bold;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Navbar minima per login */
|
|
||||||
.navbar {
|
|
||||||
background-color: #2c3e50;
|
|
||||||
padding: 10px 20px;
|
|
||||||
color: #fff;
|
|
||||||
text-align: center;
|
|
||||||
border-radius: 0 0 10px 10px;
|
|
||||||
margin-bottom: 30px;
|
|
||||||
}
|
|
||||||
/* Riutilizziamo .admin-container, h1, navbar già definiti */
|
|
||||||
|
|
||||||
/* Form Gestione Materie */
|
|
||||||
.admin-container form input[type="text"] {
|
|
||||||
padding: 8px 12px;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-radius: 6px;
|
|
||||||
margin: 5px;
|
|
||||||
width: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container form button {
|
|
||||||
padding: 8px 20px;
|
|
||||||
background-color: #1f618d;
|
|
||||||
color: #fff;
|
|
||||||
border: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background-color 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container form button:hover {
|
|
||||||
background-color: #f39c12;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Tabella Materie */
|
|
||||||
.admin-container table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
margin-top: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container th, .admin-container td {
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
padding: 10px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container th {
|
|
||||||
background-color: #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container tr:hover td {
|
|
||||||
background-color: #f7f7f7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container a.delete-link {
|
|
||||||
color: #e74c3c;
|
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
transition: color 0.2s;
|
transition: color 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-container a.delete-link:hover {
|
.admin-container a.edit-link:hover {
|
||||||
color: #c0392b;
|
color: #3a2bc0;
|
||||||
}
|
}
|
||||||
/* Form gestione orario */
|
|
||||||
|
.admin-container form a.cancel-edit {
|
||||||
|
display: inline-block;
|
||||||
|
margin: 10px;
|
||||||
|
padding: 12px 25px;
|
||||||
|
background-color: #1f618d;
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-container form a.cancel-edit:hover {
|
||||||
|
background-color: #f39c12;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== FORMS ===== */
|
||||||
.admin-container form {
|
.admin-container form {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
@@ -283,6 +146,28 @@ body {
|
|||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.admin-container input[type="text"],
|
||||||
|
.admin-container input[type="password"],
|
||||||
|
.login-container input[type="text"],
|
||||||
|
.login-container input[type="password"] {
|
||||||
|
padding: 10px 12px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-container input[type="text"],
|
||||||
|
.admin-container input[type="password"] {
|
||||||
|
width: 200px;
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-container input[type="text"],
|
||||||
|
.login-container input[type="password"] {
|
||||||
|
width: 90%;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
.admin-container form select {
|
.admin-container form select {
|
||||||
padding: 8px 12px;
|
padding: 8px 12px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
@@ -290,45 +175,74 @@ body {
|
|||||||
min-width: 120px;
|
min-width: 120px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-container form button {
|
.admin-container button,
|
||||||
padding: 8px 20px;
|
.login-container button {
|
||||||
|
padding: 10px 20px;
|
||||||
|
border: none;
|
||||||
background-color: #1f618d;
|
background-color: #1f618d;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
border: none;
|
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background-color 0.2s;
|
transition: background-color 0.2s;
|
||||||
|
font-size: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-container form button:hover {
|
.admin-container button:hover,
|
||||||
|
.login-container button:hover {
|
||||||
background-color: #f39c12;
|
background-color: #f39c12;
|
||||||
color: #fff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Titolo */
|
/* ===== TABLES ===== */
|
||||||
.admin-container h1 {
|
.table-container {
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-container table,
|
||||||
|
.responsive-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-container th,
|
||||||
|
.admin-container td,
|
||||||
|
.responsive-table th,
|
||||||
|
.responsive-table td {
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 10px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #2c3e50;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Link ritorno */
|
.responsive-table th,
|
||||||
.admin-container a.back-link {
|
.responsive-table td {
|
||||||
display: inline-block;
|
text-align: left;
|
||||||
margin-bottom: 15px;
|
padding: 8px;
|
||||||
text-decoration: none;
|
}
|
||||||
color: #1f618d;
|
|
||||||
|
.admin-container th,
|
||||||
|
.responsive-table th {
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-container tr:hover td {
|
||||||
|
background-color: #f7f7f7;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== MESSAGES ===== */
|
||||||
|
.login-container .error {
|
||||||
|
color: #e74c3c;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-container a.back-link:hover {
|
/* ===== RESPONSIVE DESIGN ===== */
|
||||||
color: #f39c12;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Mobile responsive */
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
|
body {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
/* Form input gestione orario */
|
/* Form responsive */
|
||||||
.admin-container form {
|
.admin-container form {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
@@ -336,27 +250,33 @@ body {
|
|||||||
|
|
||||||
.admin-container form select,
|
.admin-container form select,
|
||||||
.admin-container form input[type="text"],
|
.admin-container form input[type="text"],
|
||||||
|
.admin-container input[type="password"],
|
||||||
.admin-container form button {
|
.admin-container form button {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 5px 0;
|
margin: 5px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tabella */
|
/* Tabelle responsive */
|
||||||
.admin-container table,
|
.admin-container table,
|
||||||
|
.responsive-table {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.admin-container thead,
|
.admin-container thead,
|
||||||
|
.responsive-table thead {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.admin-container tbody,
|
.admin-container tbody,
|
||||||
.admin-container th,
|
.responsive-table tbody,
|
||||||
.admin-container td,
|
.admin-container tr,
|
||||||
.admin-container tr {
|
.responsive-table tr {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-container thead {
|
.admin-container tr,
|
||||||
display: none; /* Nasconde intestazioni */
|
.responsive-table tr {
|
||||||
}
|
|
||||||
|
|
||||||
.admin-container tr {
|
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
@@ -365,28 +285,39 @@ body {
|
|||||||
box-shadow: 0 1px 5px rgba(0,0,0,0.05);
|
box-shadow: 0 1px 5px rgba(0,0,0,0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-container td {
|
.admin-container td,
|
||||||
|
.responsive-table td {
|
||||||
|
display: block;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
padding: 8px 10px;
|
||||||
padding-left: 50%;
|
padding-left: 50%;
|
||||||
position: relative;
|
position: relative;
|
||||||
border: none;
|
border: none;
|
||||||
border-bottom: 1px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
display: flex;
|
word-wrap: break-word;
|
||||||
justify-content: space-between;
|
white-space: normal;
|
||||||
padding: 8px 10px;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-container td::before {
|
.admin-container td:last-child,
|
||||||
|
.responsive-table td:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-container td::before,
|
||||||
|
.responsive-table td::before {
|
||||||
content: attr(data-label);
|
content: attr(data-label);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
|
top: 8px;
|
||||||
width: 45%;
|
width: 45%;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
white-space: nowrap;
|
white-space: normal;
|
||||||
|
color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-container td:last-child {
|
.responsive-table td span {
|
||||||
border-bottom: 0;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-container a.delete-link {
|
.admin-container a.delete-link {
|
||||||
@@ -395,88 +326,23 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extra piccolo schermo */
|
|
||||||
@media (max-width: 480px) {
|
@media (max-width: 480px) {
|
||||||
.admin-container td::before {
|
.admin-container td::before,
|
||||||
|
.responsive-table td::before {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-container td {
|
.admin-container td,
|
||||||
|
.responsive-table td {
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
padding: 6px 8px;
|
padding: 6px 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-container form select,
|
.admin-container form select,
|
||||||
.admin-container form input[type="text"],
|
.admin-container form input[type="text"],
|
||||||
|
.admin-container input[type="password"],
|
||||||
.admin-container form button {
|
.admin-container form button {
|
||||||
font-size: 0.95em;
|
font-size: 0.95em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-container {
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.responsive-table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
|
|
||||||
.responsive-table th,
|
|
||||||
.responsive-table td {
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
padding: 8px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.responsive-table th {
|
|
||||||
background: #f4f4f4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Modalità mobile */
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.responsive-table thead {
|
|
||||||
display: none; /* nasconde l’intestazione */
|
|
||||||
}
|
|
||||||
.responsive-table tr {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 10px;
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
.responsive-table td {
|
|
||||||
display: block;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 8px 5px;
|
|
||||||
padding-top: 30px;
|
|
||||||
border: none;
|
|
||||||
border-bottom: 1px solid #eee;
|
|
||||||
word-wrap: break-word;
|
|
||||||
white-space: normal;
|
|
||||||
max-width: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
.responsive-table td:last-child {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
.responsive-table td::before {
|
|
||||||
content: attr(data-label);
|
|
||||||
font-weight: bold;
|
|
||||||
margin-right: 10px;
|
|
||||||
color: #333;
|
|
||||||
position: absolute;
|
|
||||||
left: 10px;
|
|
||||||
top: 10px;
|
|
||||||
width: 45%;
|
|
||||||
white-space: normal; /* permette a "Materia" di andare a capo */
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
.response-table td span {
|
|
||||||
display: block; /* forza l'output del contenuto su una riga separata */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +1,49 @@
|
|||||||
<?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("../lib/db.php");
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['name'])) {
|
// FIX: Usa prepared statements per sicurezza
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['name']) && !isset($_POST['update'])) {
|
||||||
$name = $_POST['name'];
|
$name = $_POST['name'];
|
||||||
$teacher = $_POST['teacher'];
|
$teacher = $_POST['teacher'];
|
||||||
$room = $_POST['room'];
|
$room = $_POST['room'];
|
||||||
if (!empty($name)) {
|
|
||||||
$conn->query("INSERT INTO subjects (name,teacher,room) VALUES ('$name','$teacher','$room')");
|
if (!empty($name)) {
|
||||||
|
$stmt = $conn->prepare("INSERT INTO subjects (name, teacher, room) VALUES (?, ?, ?)");
|
||||||
|
$stmt->bind_param("sss", $name, $teacher, $room);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
}
|
}
|
||||||
header("Location: subjects.php"); exit;
|
header("Location: subjects.php");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIX: Aggiunto redirect dopo update
|
||||||
|
if(isset($_POST['update'])){
|
||||||
|
$id = intval($_POST['id']);
|
||||||
|
$name = $_POST['name'];
|
||||||
|
$teacher = $_POST['teacher'];
|
||||||
|
$room = $_POST['room'];
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("UPDATE subjects SET name=?, teacher=?, room=? WHERE id=?");
|
||||||
|
$stmt->bind_param("sssi", $name, $teacher, $room, $id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
header("Location: subjects.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIX: Usa prepared statement anche per delete
|
||||||
if (isset($_GET['delete'])) {
|
if (isset($_GET['delete'])) {
|
||||||
$id = intval($_GET['delete']);
|
$id = intval($_GET['delete']);
|
||||||
$conn->query("DELETE FROM subjects WHERE id=$id");
|
$stmt = $conn->prepare("DELETE FROM subjects WHERE id=?");
|
||||||
header("Location: subjects.php"); exit;
|
$stmt->bind_param("i", $id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
header("Location: subjects.php");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -41,6 +68,42 @@ if (isset($_GET['delete'])) {
|
|||||||
<h1>Gestisci Materie</h1>
|
<h1>Gestisci Materie</h1>
|
||||||
<a href="index.php" class="back-link">⬅ Torna al Dashboard</a>
|
<a href="index.php" class="back-link">⬅ Torna al Dashboard</a>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Mostra form di modifica solo se richiesto
|
||||||
|
if(isset($_GET['edit'])){
|
||||||
|
$id = intval($_GET['edit']);
|
||||||
|
$stmt = $conn->prepare("SELECT * FROM subjects WHERE id=?");
|
||||||
|
$stmt->bind_param("i", $id);
|
||||||
|
$stmt->execute();
|
||||||
|
$res = $stmt->get_result();
|
||||||
|
|
||||||
|
if($res->num_rows > 0){
|
||||||
|
$subject = $res->fetch_assoc();
|
||||||
|
?>
|
||||||
|
<h3>Modifica materia</h3>
|
||||||
|
<form method="post" action="subjects.php">
|
||||||
|
<input type="hidden" name="id" value="<?php echo $subject['id']; ?>">
|
||||||
|
|
||||||
|
<label>Materia:</label>
|
||||||
|
<input type="text" name="name" value="<?php echo htmlspecialchars($subject['name']); ?>" required><br>
|
||||||
|
|
||||||
|
<label>Docente:</label>
|
||||||
|
<input type="text" name="teacher" value="<?php echo htmlspecialchars($subject['teacher']); ?>" required><br>
|
||||||
|
|
||||||
|
<label>Laboratorio (opzionale):</label>
|
||||||
|
<input type="text" name="room" value="<?php echo htmlspecialchars($subject['room']); ?>"><br>
|
||||||
|
|
||||||
|
<button type="submit" name="update">Salva modifiche</button>
|
||||||
|
<a class="cancel-edit" href="subjects.php" style="margin-left: 10px;">Annulla</a>
|
||||||
|
</form>
|
||||||
|
<hr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<h2>Aggiungi Nuova Materia</h2>
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<input type="text" name="name" placeholder="Materia" required>
|
<input type="text" name="name" placeholder="Materia" required>
|
||||||
<input type="text" name="teacher" placeholder="Docente" required>
|
<input type="text" name="teacher" placeholder="Docente" required>
|
||||||
@@ -48,12 +111,13 @@ if (isset($_GET['delete'])) {
|
|||||||
<button type="submit">Aggiungi</button>
|
<button type="submit">Aggiungi</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<h2>Elenco Materie</h2>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th>Materia</th>
|
<th>Materia</th>
|
||||||
<th>Docente</th>
|
<th>Docente</th>
|
||||||
<th>Aula</th>
|
<th>Laboratorio</th>
|
||||||
<th>Azione</th>
|
<th>Azione</th>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
@@ -61,10 +125,13 @@ if (isset($_GET['delete'])) {
|
|||||||
while($row=$res->fetch_assoc()){
|
while($row=$res->fetch_assoc()){
|
||||||
echo "<tr>
|
echo "<tr>
|
||||||
<td>{$row['id']}</td>
|
<td>{$row['id']}</td>
|
||||||
<td>{$row['name']}</td>
|
<td>" . htmlspecialchars($row['name']) . "</td>
|
||||||
<td>{$row['teacher']}</td>
|
<td>" . htmlspecialchars($row['teacher']) . "</td>
|
||||||
<td>{$row['room']}</td>
|
<td>" . htmlspecialchars($row['room']) . "</td>
|
||||||
<td><a href='subjects.php?delete={$row['id']}' class='delete-link'>Elimina</a></td>
|
<td>
|
||||||
|
<a href='subjects.php?edit={$row['id']}' class='edit-link'>Modifica</a> |
|
||||||
|
<a href='subjects.php?delete={$row['id']}' class='delete-link' onclick='return confirm(\"Sei sicuro di voler eliminare questa materia?\")'>Elimina</a>
|
||||||
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?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("../lib/db.php");
|
||||||
|
|
||||||
// --- Recupera tutte le materie ---
|
// --- Recupera tutte le materie ---
|
||||||
$subjects = [];
|
$subjects = [];
|
||||||
|
|||||||
115
htdocs/admin/users.php
Normal file
115
htdocs/admin/users.php
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
include("../lib/db.php");
|
||||||
|
|
||||||
|
if (!isset($_SESSION['admin']) || $_SESSION['auth_type'] != 'local' || $_SESSION['admin'] != 'admin') {
|
||||||
|
header("Location: login.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = "";
|
||||||
|
|
||||||
|
// Add admin
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST['add_user'])) {
|
||||||
|
$username = trim($_POST['username']);
|
||||||
|
$password = $_POST['password'];
|
||||||
|
|
||||||
|
if (!empty($username) && !empty($password)) {
|
||||||
|
$hash = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
$stmt = $conn->prepare("INSERT INTO admin (username, password) VALUES (?, ?)");
|
||||||
|
$stmt->bind_param("ss", $username, $hash);
|
||||||
|
if ($stmt->execute()) {
|
||||||
|
$message = "Utente admin aggiunto con successo.";
|
||||||
|
} else {
|
||||||
|
$message = "Errore durante l'aggiunta: " . $conn->error;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$message = "Compila tutti i campi.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete admin
|
||||||
|
if (isset($_GET['delete'])) {
|
||||||
|
$id = intval($_GET['delete']);
|
||||||
|
if ($id != 1) { // proteggi super admin
|
||||||
|
$stmt = $conn->prepare("DELETE FROM admin WHERE id = ?");
|
||||||
|
$stmt->bind_param("i", $id);
|
||||||
|
$stmt->execute();
|
||||||
|
$message = "Utente admin rimosso.";
|
||||||
|
} else {
|
||||||
|
$message = "Non puoi eliminare il super admin.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch admins
|
||||||
|
$result = $conn->query("SELECT id, username FROM admin ORDER BY id ASC");
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Gestione Admin</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="navbar">
|
||||||
|
<div class="logo">Admin Dashboard</div>
|
||||||
|
<div class="links">
|
||||||
|
<a href="index.php">Dashboard</a>
|
||||||
|
<a href="logout.php">Logout</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-container">
|
||||||
|
<h1>Gestione Amministratori</h1>
|
||||||
|
<a href="index.php" class="back-link">⬅ Torna al Dashboard</a>
|
||||||
|
|
||||||
|
<?php if ($message): ?>
|
||||||
|
<p style="color:<?php echo strpos($message,'successo')!==false ? 'green':'red'; ?>;">
|
||||||
|
<?php echo htmlspecialchars($message); ?>
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<h2>Utenti Attivi</h2>
|
||||||
|
<table border="1" cellspacing="0" cellpadding="6" width="100%">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Username</th>
|
||||||
|
<th>Azione</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php while ($row = $result->fetch_assoc()): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $row['id']; ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($row['username']); ?></td>
|
||||||
|
<td>
|
||||||
|
<?php if ($row['id'] != 1): ?>
|
||||||
|
<a href="?delete=<?php echo $row['id']; ?>"
|
||||||
|
onclick="return confirm('Vuoi davvero eliminare questo amministratore?')"
|
||||||
|
style="color:red;">Elimina</a>
|
||||||
|
<?php else: ?>
|
||||||
|
<em>Super Admin</em>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endwhile; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h2>Aggiungi Nuovo Admin</h2>
|
||||||
|
<form method="POST">
|
||||||
|
<label>Username:<br>
|
||||||
|
<input type="text" name="username" required>
|
||||||
|
</label><br><br>
|
||||||
|
<label>Password:<br>
|
||||||
|
<input type="password" name="password" required>
|
||||||
|
</label><br><br>
|
||||||
|
<button type="submit" name="add_user">Aggiungi</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
47
htdocs/config/config.php
Normal file
47
htdocs/config/config.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
// Impostazioni Database
|
||||||
|
if (!defined('DB_HOST')) {
|
||||||
|
define('DB_HOST', '<MYSQL_HOST>'); // Host del database (ad esempio localhost)
|
||||||
|
}
|
||||||
|
if (!defined('DB_USER')) {
|
||||||
|
define('DB_USER', '<MYSQL_USER>'); // Utente del database (ad esempio orario)
|
||||||
|
}
|
||||||
|
if (!defined('DB_PASS')) {
|
||||||
|
define('DB_PASS', '<MYSQL_PASSWORD>'); // Password dell'utente specificato prima (ad esempio password123)
|
||||||
|
}
|
||||||
|
if (!defined('DB_NAME')) {
|
||||||
|
define('DB_NAME', 'school_timetable'); // Nome del database, non modificare se non sai cosa stai facendo.
|
||||||
|
}
|
||||||
|
// Impostazioni sito generali
|
||||||
|
if (!defined('APP_NAME')) {
|
||||||
|
define('APP_NAME', 'Orario Scuola'); // Nome del sito
|
||||||
|
}
|
||||||
|
if (!defined('YEAR')) {
|
||||||
|
define('YEAR', '2025/26'); // Anno Scolastico Corrente
|
||||||
|
}
|
||||||
|
if (!defined('DEV_MODE')) {
|
||||||
|
define('DEV_MODE', false); // Modalita' di sviluppo: abilita messaggi di debug aggiuntivi. Imposta su false se sei in produzione
|
||||||
|
}
|
||||||
|
// Impostazioni autenticazione dashboard amministrativa
|
||||||
|
if (!defined('AUTH_TYPE')) {
|
||||||
|
define('AUTH_TYPE','local'); // Può essere local (integrata), keycloak
|
||||||
|
}
|
||||||
|
if (!defined('APP_DOMAIN')) {
|
||||||
|
define('APP_DOMAIN',''); // Dominio del sito (ad esempio orario.yourdomain.com), richiesto per autenticazioni non local
|
||||||
|
}
|
||||||
|
// Impostazioni autenticazione via Keycloak (richiesto solo se AUTH_TYPE sta impostato su keycloak)
|
||||||
|
if (AUTH_TYPE === 'keycloak') {
|
||||||
|
if (!defined('KEYCLOAK_DOMAIN')) {
|
||||||
|
define('KEYCLOAK_DOMAIN',''); // Dominio di Keycloak (ad esempio auth.yourdomain.com)
|
||||||
|
}
|
||||||
|
if (!defined('KEYCLOAK_REALM')) {
|
||||||
|
define('KEYCLOAK_REALM',''); // Realm di Keycloak (ad esempio master)
|
||||||
|
}
|
||||||
|
if (!defined('KEYCLOAK_CLIENT_ID')) {
|
||||||
|
define('KEYCLOAK_CLIENT_ID',''); // Client ID per Keycloak (ad esempio orario)
|
||||||
|
}
|
||||||
|
if (!defined('KEYCLOAK_CLIENT_SECRET')) {
|
||||||
|
define('KEYCLOAK_CLIENT_SECRET',''); // Client Secret per Keycloak (ad esempio abcdefghijklm)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -1,109 +1,126 @@
|
|||||||
/* Base styles */
|
/* Base styles */
|
||||||
body {
|
body {
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
background-color: #f0f2f5;
|
background-color: #f0f2f5;
|
||||||
color: #333;
|
color: #333;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h2 {
|
h1, h2 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 10px 0 20px 0;
|
margin: 10px 0 20px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 { color: #2c3e50; font-size: 1.8em; }
|
h1 {
|
||||||
h2 { color: #34495e; font-size: 1.4em; }
|
color: #2c3e50;
|
||||||
|
font-size: 1.8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
color: #34495e;
|
||||||
|
font-size: 1.4em;
|
||||||
|
}
|
||||||
|
|
||||||
/* Grid layout */
|
/* Grid layout */
|
||||||
.grid {
|
.grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
max-width: 1000px;
|
max-width: 1000px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Card styles */
|
/* Card styles */
|
||||||
ul {
|
ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||||
transition: transform 0.2s, box-shadow 0.2s;
|
transition: transform 0.2s, box-shadow 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul:hover {
|
ul:hover {
|
||||||
transform: translateY(-3px);
|
transform: translateY(-3px);
|
||||||
box-shadow: 0 5px 10px rgba(0,0,0,0.15);
|
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
li {
|
li {
|
||||||
margin: 6px 0;
|
margin: 6px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
li b {
|
li b {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
color: #1f618d;
|
color: #1f618d;
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #0066cc;
|
color: #0066cc;
|
||||||
padding: 5px 8px;
|
padding: 5px 8px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
transition: background-color 0.2s, color 0.2s;
|
transition: background-color 0.2s, color 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
a:hover {
|
a:hover {
|
||||||
background-color: #0066cc;
|
background-color: #0066cc;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Responsive adjustments */
|
/* Responsive adjustments */
|
||||||
@media screen and (max-width: 768px) {
|
@media screen and (max-width: 768px) {
|
||||||
body {
|
body {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
font-size: 0.95em;
|
font-size: 0.95em;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 { font-size: 1.5em; }
|
h1 {
|
||||||
h2 { font-size: 1.2em; }
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
.grid {
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
h2 {
|
||||||
gap: 10px;
|
font-size: 1.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
.grid {
|
||||||
padding: 10px;
|
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
||||||
}
|
gap: 10px;
|
||||||
|
}
|
||||||
a {
|
|
||||||
padding: 8px 10px;
|
ul {
|
||||||
font-size: 0.95em;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
padding: 8px 10px;
|
||||||
|
font-size: 0.95em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 480px) {
|
@media screen and (max-width: 480px) {
|
||||||
h1 { font-size: 1.3em; }
|
h1 {
|
||||||
h2 { font-size: 1em; }
|
font-size: 1.3em;
|
||||||
|
}
|
||||||
.grid {
|
|
||||||
grid-template-columns: 1fr; /* single column for small screens */
|
h2 {
|
||||||
gap: 10px;
|
font-size: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
.grid {
|
||||||
padding: 8px;
|
grid-template-columns: 1fr;
|
||||||
}
|
gap: 10px;
|
||||||
|
}
|
||||||
a {
|
|
||||||
display: block;
|
ul {
|
||||||
text-align: center;
|
padding: 8px;
|
||||||
padding: 10px;
|
}
|
||||||
}
|
|
||||||
}
|
a {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,29 +1,63 @@
|
|||||||
/* Navbar */
|
/* Navbar */
|
||||||
.navbar {
|
.navbar {
|
||||||
background-color: #2c3e50;
|
background-color: #2c3e50;
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
border-radius: 0 0 10px 10px;
|
border-radius: 0 0 10px 10px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar a {
|
.navbar a {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
transition: color 0.2s;
|
transition: color 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar a:hover {
|
.navbar a:hover {
|
||||||
color: #f39c12;
|
color: #f39c12;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar .logo {
|
.navbar .logo {
|
||||||
font-size: 1.3em;
|
font-size: 1.3em;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Responsive navbar */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.navbar {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar a {
|
||||||
|
margin-left: 0;
|
||||||
|
margin: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar .logo {
|
||||||
|
font-size: 1.2em;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.navbar {
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar .logo {
|
||||||
|
font-size: 1.1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar a {
|
||||||
|
font-size: 0.9em;
|
||||||
|
margin: 0 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,167 +1,145 @@
|
|||||||
|
/* Base styles */
|
||||||
body {
|
body {
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
background-color: #f0f2f5;
|
background-color: #f0f2f5;
|
||||||
color: #333;
|
color: #333;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
color: #2c3e50;
|
color: #2c3e50;
|
||||||
font-size: 1.8em;
|
font-size: 1.8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Table styles */
|
/* Table styles */
|
||||||
table {
|
table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 1000px;
|
max-width: 1000px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
th, td {
|
th, td {
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|
||||||
th {
|
th {
|
||||||
background-color: #e0e0e0;
|
background-color: #e0e0e0;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
transition: background-color 0.2s;
|
transition: background-color 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
td:hover {
|
td:hover {
|
||||||
background-color: #f7f7f7;
|
background-color: #f7f7f7;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subject {
|
.subject {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #1f618d;
|
color: #1f618d;
|
||||||
}
|
}
|
||||||
|
|
||||||
.teacher {
|
.teacher {
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
color: #2c3e50;
|
color: #2c3e50;
|
||||||
}
|
}
|
||||||
|
|
||||||
.room {
|
.room {
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
color: #666;
|
color: #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Desktop/Mobile layout control */
|
||||||
@media (max-width: 768px) {
|
.desktop-schedule {
|
||||||
table, thead, tbody, th, td, tr {
|
display: table;
|
||||||
display: block;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
tr {
|
.mobile-schedule {
|
||||||
margin-bottom: 15px;
|
|
||||||
border-bottom: 2px solid #ddd;
|
|
||||||
padding-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
th {
|
|
||||||
display: none;
|
display: none;
|
||||||
}
|
|
||||||
|
|
||||||
td {
|
|
||||||
text-align: left;
|
|
||||||
padding: 10px 10px 10px 45%;
|
|
||||||
position: relative;
|
|
||||||
border: none;
|
|
||||||
border-bottom: 1px solid #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
td::before {
|
|
||||||
position: absolute;
|
|
||||||
left: 10px;
|
|
||||||
top: 10px;
|
|
||||||
width: 40%;
|
|
||||||
white-space: nowrap;
|
|
||||||
font-weight: bold;
|
|
||||||
content: attr(data-label);
|
|
||||||
}
|
|
||||||
|
|
||||||
td:last-child {
|
|
||||||
border-bottom: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@media (max-width: 480px) {
|
|
||||||
body { padding: 10px; }
|
/* Mobile styles */
|
||||||
h1 { font-size: 1.5em; }
|
|
||||||
td::before { font-size: 0.9em; }
|
|
||||||
td { padding-left: 50%; }
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
table, thead, tbody, th, td, tr {
|
.desktop-schedule {
|
||||||
display: block;
|
display: none;
|
||||||
width: 100%;
|
}
|
||||||
}
|
|
||||||
|
.mobile-schedule {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
tr {
|
.mobile-schedule .day {
|
||||||
margin-bottom: 15px;
|
background: #f8f8f8;
|
||||||
padding: 0;
|
border-radius: 10px;
|
||||||
border-bottom: 2px solid #ddd;
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
|
||||||
}
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
th {
|
.mobile-schedule h2 {
|
||||||
display: none;
|
margin-top: 0;
|
||||||
}
|
margin-bottom: 0.8rem;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
color: #111;
|
||||||
|
border-bottom: 1px solid #ddd;
|
||||||
|
padding-bottom: 0.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
td {
|
.lesson {
|
||||||
position: relative;
|
background: #fff;
|
||||||
padding-left: 50%;
|
border: 1px solid #eee;
|
||||||
text-align: left;
|
border-radius: 8px;
|
||||||
border: none;
|
padding: 0.6rem 0.8rem;
|
||||||
border-bottom: 1px solid #eee;
|
margin-bottom: 0.6rem;
|
||||||
min-height: 50px; /* ensures consistent vertical spacing */
|
}
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
td::before {
|
.lesson.empty {
|
||||||
position: absolute;
|
opacity: 0.6;
|
||||||
top: 10px;
|
}
|
||||||
left: 10px;
|
|
||||||
width: 40%;
|
|
||||||
font-weight: bold;
|
|
||||||
white-space: nowrap;
|
|
||||||
content: attr(data-label);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* make content stack nicely */
|
.hour {
|
||||||
td > .subject,
|
font-size: 0.9rem;
|
||||||
td > .teacher,
|
color: #666;
|
||||||
td > .room {
|
margin-bottom: 3px;
|
||||||
display: block;
|
}
|
||||||
margin: 2px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
td:last-child {
|
.subject {
|
||||||
border-bottom: 0;
|
font-weight: 600;
|
||||||
}
|
color: #222;
|
||||||
|
}
|
||||||
|
|
||||||
|
.teacher {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
.room {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #777;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extra small screens */
|
|
||||||
@media (max-width: 480px) {
|
@media (max-width: 480px) {
|
||||||
td {
|
body {
|
||||||
padding-left: 55%;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
td::before {
|
|
||||||
width: 45%;
|
h1 {
|
||||||
}
|
font-size: 1.5em;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
$host = "<MYSQL_HOST>";
|
|
||||||
$user = "<MYSQL_USER>";
|
|
||||||
$pass = "<MYSQL_PASSWORD>";
|
|
||||||
$dbname = "school_timetable";
|
|
||||||
|
|
||||||
$conn = new mysqli($host, $user, $pass, $dbname);
|
|
||||||
if ($conn->connect_error) {
|
|
||||||
die("Connection failed: " . $conn->connect_error);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
@@ -1,29 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
include("db.php");
|
include("lib/db.php");
|
||||||
$teacher = $_GET['teacher'];
|
|
||||||
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
||||||
$hours = [
|
$hours = [
|
||||||
1 => "Prima ora<br>7:50 - 8:50",
|
1 => "Prima ora<br> 7:50 - 8:50",
|
||||||
2 => "Seconda ora<br>8:50 - 9:45",
|
2 => "Seconda ora<br> 8:50 - 9:45",
|
||||||
3 => "Terza ora<br>9:55 - 10:50",
|
3 => "Terza ora<br> 9:55 - 10:50",
|
||||||
4 => "Quarta ora<br>10:50 - 11:45",
|
4 => "Quarta ora<br> 10:50 - 11:45",
|
||||||
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" || $teacher == "sconosciuto") {
|
|
||||||
header("Location: index.php");
|
if (!isset($_GET['teacher'])) {
|
||||||
exit;
|
|
||||||
}
|
|
||||||
else if (!isset($_GET['teacher'])) {
|
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$teacher = $conn->real_escape_string($_GET['teacher']);
|
$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");
|
$res = $conn->query("SELECT DISTINCT teacher FROM subjects WHERE teacher = '$teacher' LIMIT 1");
|
||||||
|
|
||||||
if ($res->num_rows === 0) {
|
if ($res->num_rows === 0) {
|
||||||
// Insegnante non trovato
|
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@@ -38,13 +39,16 @@ if ($res->num_rows === 0) {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="logo">Orario Scuola 2025/26</div>
|
<div class="logo"><?php echo APP_NAME; ?> <?php echo YEAR; ?></div>
|
||||||
<div class="links">
|
<div class="links">
|
||||||
<a href="index.php">Home</a>
|
<a href="index.php">Home</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h1>Orario docente <?php echo htmlspecialchars($teacher); ?></h1>
|
<h1>Orario docente <?php echo htmlspecialchars($teacher); ?></h1>
|
||||||
<table>
|
|
||||||
|
<!-- Visualizzazione Desktop -->
|
||||||
|
<table class="desktop-schedule">
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<?php foreach($days as $d) echo "<th>$d</th>"; ?>
|
<?php foreach($days as $d) echo "<th>$d</th>"; ?>
|
||||||
@@ -60,10 +64,12 @@ if ($res->num_rows === 0) {
|
|||||||
WHERE subjects.teacher='$teacher' AND timetable.day='$d' AND timetable.hour=$hnum");
|
WHERE subjects.teacher='$teacher' AND timetable.day='$d' AND timetable.hour=$hnum");
|
||||||
if($row = $q->fetch_assoc()){
|
if($row = $q->fetch_assoc()){
|
||||||
echo "<td data-label='$d'>
|
echo "<td data-label='$d'>
|
||||||
<div class='subject'>{$row['name']}</div>
|
<div class='subject'>" . htmlspecialchars($row['name']) . "</div>
|
||||||
<div class='teacher'>{$row['class_name']}</div>
|
<div class='teacher'>" . htmlspecialchars($row['class_name']) . "</div>";
|
||||||
<div class='room'>{$row['room']}</div>
|
if(!empty($row['room'])) {
|
||||||
</td>";
|
echo "<div class='room'>" . htmlspecialchars($row['room']) . "</div>";
|
||||||
|
}
|
||||||
|
echo "</td>";
|
||||||
} else {
|
} else {
|
||||||
echo "<td data-label='$d'></td>";
|
echo "<td data-label='$d'></td>";
|
||||||
}
|
}
|
||||||
@@ -72,6 +78,41 @@ if ($res->num_rows === 0) {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</table>
|
</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>
|
<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>
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
include("db.php");
|
include("lib/db.php");
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Orario - A.S. 2025/26</title>
|
<title><?php echo APP_NAME; ?> - A.S. <?php echo YEAR; ?></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="css/home.css">
|
<link rel="stylesheet" href="css/home.css">
|
||||||
<link rel="stylesheet" href="css/navbar.css">
|
<link rel="stylesheet" href="css/navbar.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="logo">Orario Scuola 2025/26</div>
|
<div class="logo"><?php echo APP_NAME; ?> <?php echo YEAR; ?></div>
|
||||||
<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>
|
<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><?php echo APP_NAME; ?> - A.S. <?php echo YEAR; ?></h1>
|
||||||
|
|
||||||
<!-- Sezione Classi -->
|
<!-- Sezione Classi -->
|
||||||
<h2>Classi</h2>
|
<h2>Classi</h2>
|
||||||
@@ -66,6 +66,6 @@ while($row = $res->fetch_assoc()){
|
|||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p style="text-align: center;">Copyright (C) 2025 EmmeV. - Released under GNU AGPL 3.0 License.</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>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
include("db.php");
|
include("lib/db.php");
|
||||||
$room = $_GET['room']; // aula selezionata
|
|
||||||
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
||||||
$hours = [
|
$hours = [
|
||||||
1 => "Prima ora<br>7:50 - 8:50",
|
1 => "Prima ora<br> 7:50 - 8:50",
|
||||||
2 => "Seconda ora<br>8:50 - 9:45",
|
2 => "Seconda ora<br> 8:50 - 9:45",
|
||||||
3 => "Terza ora<br>9:55 - 10:50",
|
3 => "Terza ora<br> 9:55 - 10:50",
|
||||||
4 => "Quarta ora<br>10:50 - 11:45",
|
4 => "Quarta ora<br> 10:50 - 11:45",
|
||||||
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 (!isset($_GET['room'])) {
|
if (!isset($_GET['room'])) {
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
exit;
|
exit;
|
||||||
@@ -19,7 +19,6 @@ $room = $conn->real_escape_string($_GET['room']);
|
|||||||
$res = $conn->query("SELECT DISTINCT room FROM subjects WHERE room = '$room' LIMIT 1");
|
$res = $conn->query("SELECT DISTINCT room FROM subjects WHERE room = '$room' LIMIT 1");
|
||||||
|
|
||||||
if ($res->num_rows === 0) {
|
if ($res->num_rows === 0) {
|
||||||
// Aula non trovata
|
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@@ -34,7 +33,7 @@ if ($res->num_rows === 0) {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="logo">Orario Scuola 2025/26</div>
|
<div class="logo"><?php echo APP_NAME; ?> <?php echo YEAR; ?></div>
|
||||||
<div class="links">
|
<div class="links">
|
||||||
<a href="index.php">Home</a>
|
<a href="index.php">Home</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -42,7 +41,8 @@ if ($res->num_rows === 0) {
|
|||||||
|
|
||||||
<h1>Orario <?php echo htmlspecialchars($room); ?></h1>
|
<h1>Orario <?php echo htmlspecialchars($room); ?></h1>
|
||||||
|
|
||||||
<table>
|
<!-- Visualizzazione Desktop -->
|
||||||
|
<table class="desktop-schedule">
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<?php foreach($days as $d) echo "<th>$d</th>"; ?>
|
<?php foreach($days as $d) echo "<th>$d</th>"; ?>
|
||||||
@@ -60,11 +60,34 @@ if ($res->num_rows === 0) {
|
|||||||
WHERE subjects.room='". $conn->real_escape_string($room) ."'
|
WHERE subjects.room='". $conn->real_escape_string($room) ."'
|
||||||
AND timetable.day='$d' AND timetable.hour=$hnum
|
AND timetable.day='$d' AND timetable.hour=$hnum
|
||||||
");
|
");
|
||||||
if($row = $q->fetch_assoc()){
|
|
||||||
|
if($q->num_rows > 0){
|
||||||
|
$subject = null;
|
||||||
|
// FIX: Uso array associativo per evitare duplicati classe+docente
|
||||||
|
$class_teacher_pairs = [];
|
||||||
|
|
||||||
|
while($row = $q->fetch_assoc()){
|
||||||
|
if($subject === null) {
|
||||||
|
$subject = $row['subject_name'];
|
||||||
|
}
|
||||||
|
// Creo una coppia unica classe-docente
|
||||||
|
$pair = $row['class_name'] . " (" . $row['teacher'] . ")";
|
||||||
|
$class_teacher_pairs[$pair] = true; // Uso chiave per evitare duplicati
|
||||||
|
}
|
||||||
|
|
||||||
|
// Converto in array e unisco
|
||||||
|
$entries = array_keys($class_teacher_pairs);
|
||||||
|
|
||||||
|
if(count($entries) > 1){
|
||||||
|
$last = array_pop($entries);
|
||||||
|
$entries_list = implode(", ", $entries) . " e " . $last;
|
||||||
|
} else {
|
||||||
|
$entries_list = $entries[0];
|
||||||
|
}
|
||||||
|
|
||||||
echo "<td data-label='$d'>
|
echo "<td data-label='$d'>
|
||||||
<div class='subject'>{$row['subject_name']}</div>
|
<div class='subject'>" . htmlspecialchars($subject) . "</div>
|
||||||
<div class='teacher'>{$row['teacher']}</div>
|
<div class='room'>" . htmlspecialchars($entries_list) . "</div>
|
||||||
<div class='room'>{$row['class_name']}</div>
|
|
||||||
</td>";
|
</td>";
|
||||||
} else {
|
} else {
|
||||||
echo "<td data-label='$d'></td>";
|
echo "<td data-label='$d'></td>";
|
||||||
@@ -74,6 +97,60 @@ if ($res->num_rows === 0) {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<!-- Visualizzazione Mobile -->
|
||||||
|
<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 AS subject_name, subjects.teacher, classes.name AS class_name
|
||||||
|
FROM timetable
|
||||||
|
LEFT JOIN subjects ON timetable.subject_id = subjects.id
|
||||||
|
LEFT JOIN classes ON timetable.class_id = classes.id
|
||||||
|
WHERE subjects.room='". $conn->real_escape_string($room) ."'
|
||||||
|
AND timetable.day='$d' AND timetable.hour=$hnum
|
||||||
|
");
|
||||||
|
|
||||||
|
if($q->num_rows > 0):
|
||||||
|
$subject = null;
|
||||||
|
$class_teacher_pairs = [];
|
||||||
|
|
||||||
|
while($row = $q->fetch_assoc()){
|
||||||
|
if($subject === null) {
|
||||||
|
$subject = $row['subject_name'];
|
||||||
|
}
|
||||||
|
$pair = $row['class_name'] . " (" . $row['teacher'] . ")";
|
||||||
|
$class_teacher_pairs[$pair] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$entries = array_keys($class_teacher_pairs);
|
||||||
|
|
||||||
|
if(count($entries) > 1){
|
||||||
|
$last = array_pop($entries);
|
||||||
|
$entries_list = implode(", ", $entries) . " e " . $last;
|
||||||
|
} else {
|
||||||
|
$entries_list = $entries[0];
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div class="lesson">
|
||||||
|
<div class="hour"><?= strip_tags($hlabel) ?></div>
|
||||||
|
<div class="subject"><?= htmlspecialchars($subject) ?></div>
|
||||||
|
<div class="room"><?= htmlspecialchars($entries_list) ?></div>
|
||||||
|
</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>
|
<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>
|
||||||
|
|||||||
15
htdocs/lib/db.php
Normal file
15
htdocs/lib/db.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
include_once __DIR__ . '/../config/config.php';
|
||||||
|
$host = DB_HOST;
|
||||||
|
$user = DB_USER;
|
||||||
|
$pass = DB_PASS;
|
||||||
|
$dbname = DB_NAME;
|
||||||
|
|
||||||
|
$conn = new mysqli($host, $user, $pass, $dbname);
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
if (DEV_MODE)
|
||||||
|
die("[DEBUG] Connessione al database fallita: " . $conn->connect_error);
|
||||||
|
else
|
||||||
|
die("Connessione al database fallita!");
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -1,26 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
include("db.php");
|
include("lib/db.php"); // FIX: Decommentato
|
||||||
$class_id = intval($_GET['class_id']);
|
$class_id = intval($_GET['class_id']);
|
||||||
$class = $conn->query("SELECT * FROM classes WHERE id=$class_id")->fetch_assoc();
|
$class = $conn->query("SELECT * FROM classes WHERE id=$class_id")->fetch_assoc();
|
||||||
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
||||||
$hours = [
|
$hours = [
|
||||||
1 => "Prima ora<br>7:50 - 8:50",
|
1 => "Prima ora<br> 7:50 - 8:50",
|
||||||
2 => "Seconda ora<br>8:50 - 9:45",
|
2 => "Seconda ora<br> 8:50 - 9:45",
|
||||||
3 => "Terza ora<br>9:55 - 10:50",
|
3 => "Terza ora<br> 9:55 - 10:50",
|
||||||
4 => "Quarta ora<br>10:50 - 11:45",
|
4 => "Quarta ora<br> 10:50 - 11:45",
|
||||||
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"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// FIX: Validazione classe prima di tutto
|
||||||
if (!isset($_GET['class_id'])) {
|
if (!isset($_GET['class_id'])) {
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$class_id = intval($_GET['class_id']); // sicurezza
|
$class_id = intval($_GET['class_id']);
|
||||||
$res = $conn->query("SELECT id FROM classes WHERE id = $class_id LIMIT 1");
|
$res = $conn->query("SELECT id FROM classes WHERE id = $class_id LIMIT 1");
|
||||||
|
|
||||||
if ($res->num_rows === 0) {
|
if ($res->num_rows === 0) {
|
||||||
// Classe non trovata
|
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@@ -28,20 +29,22 @@ if ($res->num_rows === 0) {
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Orario <?php echo $class['name']; ?></title>
|
<title>Orario <?php echo htmlspecialchars($class['name']); ?></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="css/timetable.css">
|
<link rel="stylesheet" href="css/timetable.css">
|
||||||
<link rel="stylesheet" href="css/navbar.css">
|
<link rel="stylesheet" href="css/navbar.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="logo">Orario Scuola 2025/26</div>
|
<div class="logo"><?php echo APP_NAME; ?> <?php echo YEAR; ?></div>
|
||||||
<div class="links">
|
<div class="links">
|
||||||
<a href="index.php">Home</a>
|
<a href="index.php">Home</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h1>Orario della classe <?php echo $class['name']; ?></h1>
|
<h1>Orario della classe <?php echo htmlspecialchars($class['name']); ?></h1>
|
||||||
<table>
|
|
||||||
|
<!-- Visualizzazione Desktop -->
|
||||||
|
<table class="desktop-schedule">
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<?php foreach($days as $d) echo "<th>$d</th>"; ?>
|
<?php foreach($days as $d) echo "<th>$d</th>"; ?>
|
||||||
@@ -54,10 +57,36 @@ if ($res->num_rows === 0) {
|
|||||||
FROM timetable
|
FROM timetable
|
||||||
LEFT JOIN subjects ON timetable.subject_id = subjects.id
|
LEFT JOIN subjects ON timetable.subject_id = subjects.id
|
||||||
WHERE class_id=$class_id AND day='$d' AND hour=$hnum");
|
WHERE class_id=$class_id AND day='$d' AND hour=$hnum");
|
||||||
if($row = $q->fetch_assoc()){
|
|
||||||
echo "<td data-label='$d'><div class='subject'>{$row['name']}</div>
|
if($q->num_rows > 0){
|
||||||
<div class='teacher'>{$row['teacher']}</div>
|
// FIX: Gestione corretta di multipli docenti/materie
|
||||||
<div class='room'>{$row['room']}</div></td>";
|
$entries = [];
|
||||||
|
$subject = null;
|
||||||
|
$room = null;
|
||||||
|
|
||||||
|
while($row = $q->fetch_assoc()){
|
||||||
|
if($subject === null) {
|
||||||
|
$subject = $row['name'];
|
||||||
|
$room = $row['room'];
|
||||||
|
}
|
||||||
|
$entries[] = $row['teacher'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unisci i docenti correttamente
|
||||||
|
if(count($entries) > 1){
|
||||||
|
$last = array_pop($entries);
|
||||||
|
$teachers_list = implode(", ", $entries) . " e " . $last;
|
||||||
|
} else {
|
||||||
|
$teachers_list = $entries[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<td data-label='$d'>
|
||||||
|
<div class='subject'>" . htmlspecialchars($subject) . "</div>
|
||||||
|
<div class='teacher'>" . htmlspecialchars($teachers_list) . "</div>";
|
||||||
|
if(!empty($room)) {
|
||||||
|
echo "<div class='room'>" . htmlspecialchars($room) . "</div>";
|
||||||
|
}
|
||||||
|
echo "</td>";
|
||||||
} else {
|
} else {
|
||||||
echo "<td data-label='$d'></td>";
|
echo "<td data-label='$d'></td>";
|
||||||
}
|
}
|
||||||
@@ -66,6 +95,57 @@ if ($res->num_rows === 0) {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<!-- Visualizzazione Mobile -->
|
||||||
|
<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, subjects.teacher, subjects.room
|
||||||
|
FROM timetable
|
||||||
|
LEFT JOIN subjects ON timetable.subject_id = subjects.id
|
||||||
|
WHERE class_id=$class_id AND day='$d' AND hour=$hnum");
|
||||||
|
|
||||||
|
if($q->num_rows > 0):
|
||||||
|
// FIX: Stessa logica corretta anche per mobile
|
||||||
|
$entries = [];
|
||||||
|
$subject = null;
|
||||||
|
$room = null;
|
||||||
|
|
||||||
|
while($row = $q->fetch_assoc()){
|
||||||
|
if($subject === null) {
|
||||||
|
$subject = $row['name'];
|
||||||
|
$room = $row['room'];
|
||||||
|
}
|
||||||
|
$entries[] = $row['teacher'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($entries) > 1){
|
||||||
|
$last = array_pop($entries);
|
||||||
|
$teachers_list = implode(", ", $entries) . " e " . $last;
|
||||||
|
} else {
|
||||||
|
$teachers_list = $entries[0];
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div class="lesson">
|
||||||
|
<div class="hour"><?= strip_tags($hlabel) ?></div>
|
||||||
|
<div class="subject"><?= htmlspecialchars($subject) ?></div>
|
||||||
|
<div class="teacher"><?= htmlspecialchars($teachers_list) ?></div>
|
||||||
|
<?php if(!empty($room)): ?><div class="room"><?= htmlspecialchars($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>
|
<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>
|
||||||
|
|||||||
Reference in New Issue
Block a user