diff --git a/code/prof_view_files.php b/code/prof_view_files.php new file mode 100644 index 0000000000000000000000000000000000000000..5e9e25e56b6efc53f7095549780f31f3f008864f --- /dev/null +++ b/code/prof_view_files.php @@ -0,0 +1,77 @@ +<?php +include 'config.php'; +session_start(); + +if (!isset($_SESSION['user']) || $_SESSION['user']['role'] !== 'tutor') { + echo "<div class='container'><p class='error'>Access denied. Only tutors can view files.</p><a href='login.php'>Go back</a></div>"; + exit; +} + +$user = $_SESSION['user']; +$tutor_id = intval($user['id']); // Récupération de l'ID du professeur connecté + +// Récupérer uniquement les dépôts créés par ce professeur +$depots = $conn->query("SELECT * FROM depots WHERE tutor_id = $tutor_id"); + +?> +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>View Files</title> + <link rel="stylesheet" href="style.css"> +</head> +<body> + <?php include 'sidebar.php'; ?> + + <div class="main-content"> + <div class="attendance-page"> + <h1>View Files</h1> + <?php if ($depots->num_rows > 0): ?> + <?php while ($depot = $depots->fetch_assoc()): ?> + <h2><?= htmlspecialchars($depot['nom']) ?></h2> + <p><?= htmlspecialchars($depot['description']) ?></p> + <ul> + <?php + $depot_id = intval($depot['id']); + $files = $conn->query("SELECT * FROM fichiers WHERE depot_id = $depot_id"); + + if ($files->num_rows > 0): + ?> + <table border="1" cellpadding="10"> + <thead> + <tr> + <th>File Name</th> + <th>Sender</th> + <th>Upload Date</th> + <th>Download</th> + </tr> + </thead> + <tbody> + <?php while ($file = $files->fetch_assoc()): ?> + <tr> + <td><?= htmlspecialchars($file['nom_fichier']) ?></td> + <td><?= htmlspecialchars($file['expediteur']) ?></td> + <td><?= date('d-m-Y H:i', strtotime($file['date_upload'])) ?></td> + <td> + <a href="<?= htmlspecialchars($file['path_fichier']) ?>" download> + Download + </a> + </td> + </tr> + <?php endwhile; ?> + </tbody> + </table> + <?php else: ?> + <p>Pas de fichiers téléversés encore</p> + <?php endif; ?> + </ul> + <?php endwhile; ?> + <?php else: ?> + <p>No depots found.</p> + <?php endif; ?> + </div> + </div> +</body> +</html>