-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvolunteer_delete.php
55 lines (48 loc) · 1.35 KB
/
volunteer_delete.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
<?php
session_start();
require 'databaseconnect.php';
require 'session_check.php';
require 'role_middleware.php';
checkRole('admin');
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
$id = (int) $_GET['id'];
try {
// Marquer le bénévole comme supprimé
$stmt = $pdo->prepare("
UPDATE benevoles
SET deleted_at = NOW()
WHERE id = :id AND deleted_at IS NULL
");
$stmt->execute([':id' => $id]);
header("Location: volunteer_list.php?success=1");
exit();
} catch (PDOException $e) {
error_log("Erreur soft delete: " . $e->getMessage());
die("Erreur lors de la suppression: " . $e->getMessage());
}
} else {
echo "ID invalide.";
}
// Fonction pour obtenir la liste des bénévoles actifs
function getActiveBenevoles($pdo) {
$stmt = $pdo->prepare("
SELECT *
FROM benevoles
WHERE deleted_at IS NULL
ORDER BY nom
");
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
// Fonction pour obtenir la liste des bénévoles supprimés
function getDeletedBenevoles($pdo) {
$stmt = $pdo->prepare("
SELECT *
FROM benevoles
WHERE deleted_at IS NOT NULL
ORDER BY nom
");
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
?>