-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcollection_list.php
133 lines (124 loc) · 7.3 KB
/
collection_list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
session_start();
require 'databaseconnect.php';
require 'session_check.php';
try {
$stmt = $pdo->query("
SELECT c.id, c.date_collecte, c.lieu, b.nom,
d.type_dechet, d.quantite_kg
FROM collectes c
LEFT JOIN benevoles b ON c.id_benevole = b.id
LEFT JOIN dechets_collectes d ON c.id = d.id_collecte
ORDER BY c.date_collecte DESC
");
$query = $pdo->prepare("SELECT nom FROM benevoles WHERE role = 'admin'");
$query->execute();
$admin = $query->fetch(PDO::FETCH_ASSOC);
$adminNom = $admin ? htmlspecialchars($admin['nom']) : 'Aucun administrateur trouvé';
$collectes = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
echo "Erreur de base de données : " . $e->getMessage();
exit;
}
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Liste des Collectes</title>
<head>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&family=Lora:wght@400;700&family=Montserrat:wght@300;400;700&family=Open+Sans:wght@300;400;700&family=Poppins:wght@300;400;700&family=Playfair+Display:wght@400;700&family=Raleway:wght@300;400;700&family=Nunito:wght@300;400;700&family=Merriweather:wght@300;400;700&family=Oswald:wght@300;400;700&display=swap" rel="stylesheet">
</head>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" rel="stylesheet">
</head>
<body class="bg-green-950 text-gray-900">
<div class="flex h-screen">
<!-- Barre de navigation -->
<div class="bg-white text-green w-64 p-6 list-none">
<h2 class="text-2xl font-bold mb-6">Dashboard</h2>
<li><a href="collection_list.php" class="flex items-center py-2 px-3 hover:bg-green-950 hover:text-white rounded-lg"><i class="fas fa-tachometer-alt mr-3"></i> Tableau de bord</a></li>
<li><a href="collection_add.php" class="flex items-center py-2 px-3 hover:bg-green-950 hover:text-white rounded-lg"><i class="fas fa-plus-circle mr-3"></i> Ajouter une collecte</a></li>
<li><a href="volunteer_list.php" class="flex items-center py-2 px-3 hover:bg-green-950 hover:text-white rounded-lg"><i class="fa-solid fa-list mr-3"></i> Liste des bénévoles</a></li>
<li><a href="user_add.php" class="flex items-center py-2 px-3 hover:bg-green-950 hover:text-white rounded-lg"><i class="fas fa-user-plus mr-3"></i> Ajouter un bénévole</a></li>
<li><a href="my_account.php" class="flex items-center py-2 px-3 hover:bg-green-950 hover:text-white rounded-lg"><i class="fas fa-cogs mr-3"></i> Mon compte</a></li>
<div class="mt-6">
<button onclick="window.location.href='logout.php'" class="w-full bg-red-700 hover:bg-red-500 text-white py-2 rounded-lg shadow-md">
Déconnexion
</button>
</div>
</div>
<!-- Contenu principal -->
<div class="flex-1 p-8 overflow-y-auto">
<!-- Titre et nom de l'utilisateur -->
<div class="flex items-center justify-between mb-6">
<h1 class="text-4xl font-bold text-white">Liste des Collectes de Déchets</h1>
<div class="text-lg text-white">Bienvenue, <?= $_SESSION["nom"] ?> !</div>
</div>
<!-- Message de notification (ex: succès de suppression ou ajout) -->
<?php if (isset($_GET['message'])): ?>
<div class="bg-green-100 text-green-800 p-4 rounded-md mb-6">
<?= htmlspecialchars($_GET['message']) ?>
</div>
<?php endif; ?>
<!-- Cartes d'informations -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 mb-8">
<!-- Nombre total de collectes -->
<div class="bg-white p-6 rounded-lg shadow-lg p-3 border border-green-950">
<h3 class="text-xl font-semibold text-gray-800 mb-3">Total des Collectes</h3>
<p class="text-3xl font-bold text-green-950"><?= count($collectes) ?></p>
</div>
<!-- Dernière collecte -->
<div class="bg-white p-6 rounded-lg shadow-lg p-3 border border-green-950">
<h3 class="text-xl font-semibold text-gray-800 mb-3">Dernière Collecte</h3>
<p class="text-lg text-gray-600"><?= htmlspecialchars($collectes[0]['lieu']) ?></p>
<p class="text-lg text-gray-600"><?= date('d/m/Y', strtotime($collectes[0]['date_collecte'])) ?></p>
</div>
<!-- Bénévole Responsable -->
<div class="bg-white p-6 rounded-lg shadow-lg p-3 border border-green-950">
<h3 class="text-xl font-semibold text-gray-800 mb-3">Bénévole Admin</h3>
<p class="text-lg text-gray-600"><?= $adminNom ?></p>
</div>
</div>
<!-- Tableau des collectes -->
<div class="overflow-hidden rounded-lg shadow-lg bg-white">
<table class="w-full table-auto border-collapse divide-y divide-green-950">
<thead class="bg-white-950 text-green-950">
<tr>
<th class="py-3 px-4 text-left">Date</th>
<th class="py-3 px-4 text-left">Lieu</th>
<th class="py-3 px-4 text-left">Bénévole Responsable</th>
<th class="py-3 px-4 text-left">Type de déchets</th>
<th class="py-3 px-4 text-left">Quantité</th>
<th class="py-3 px-4 text-left">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-green-950">
<?php foreach ($collectes as $collecte) : ?>
<tr class="hover:bg-green-100 transition duration-200">
<td class="py-3 px-4"><?= date('d/m/Y', strtotime($collecte['date_collecte'])) ?></td>
<td class="py-3 px-4"><?= htmlspecialchars($collecte['lieu']) ?></td>
<td class="py-3 px-4"><?= $collecte['nom'] ? htmlspecialchars($collecte['nom']) : 'Aucun bénévole' ?></td>
<td class="py-3 px-4"><?= $collecte['type_dechet'] ?></td>
<td class="py-3 px-4"><?= floatval($collecte['quantite_kg']) ?></td>
<td class="py-3 px-4 flex space-x-2">
<a href="collection_edit.php?id=<?= $collecte['id'] ?>" class="bg-green-950 hover:bg-green-500 text-white px-4 py-2 rounded-lg shadow-lg focus:outline-none focus:ring-2 focus:ring-blue-500 transition duration-200">
✏️ Modifier
</a>
<a href="collection_delete.php?id=<?= $collecte['id'] ?>" class="bg-red-700 hover:bg-red-500 text-white px-4 py-2 rounded-lg shadow-lg focus:outline-none focus:ring-2 focus:ring-red-500 transition duration-200" onclick="return confirm('Êtes-vous sûr de vouloir supprimer cette collecte ?');">
🗑️ Supprimer
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>