-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
131 lines (113 loc) · 4.96 KB
/
index.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
<?php
session_start();
spl_autoload_register(function ($class_name) {
require 'class/' . $class_name . '.php';
});
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voir tout les events</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
</head>
<body>
<?php
include_once 'includes/header.php';
if (isset($_SESSION['error'])) {
echo "<div class='alert alert-danger'>" . $_SESSION['error'] . "</div>";
unset($_SESSION['error']);
}
if (isset($_SESSION['event_added'])) {
$event = $_SESSION['event_added'];
echo "<div class='alert alert-success'>L'événement " . $event . " a bien été ajouté !</div>";
unset($_SESSION['event_added']);
}
if (isset($_SESSION['event_deleted'])) {
$event = $_SESSION['event_deleted'];
echo "<div class='alert alert-success'>L'événement " . $event . " a bien été supprimé !</div>";
unset($_SESSION['event_deleted']);
}
if (isset($_SESSION['message'])) {
echo "<div class='alert alert-success'>" . $_SESSION['message'] . "</div>";
unset($_SESSION['message']);
}
$events = Event::getAllEvents();
?>
<div id="alert_box"></div>
<main class="container">
<h1>Accueil</h1>
<p>
<?php
if ($user = BaseUsers::getUser()) {
echo "Bonjour " . $user->getEmail() . "<br>";
if ($user instanceof PremiumUsers) {
echo "Votre réduction est de " . PremiumUsers::getAbonnementReduction() * 100 . "%<br>";
} else if ($user instanceof VIPUsers) {
echo "Votre réduction est de " . VIPUsers::getAbonnementReduction() * 100 . "%<br>";
}
if ($user instanceof PremiumUsers || $user instanceof StandardUsers) {
echo "<br><a href='convert_to_vip.php' class='btn btn-primary mt-2' id='convert_to_vip'>
Evoluer vers un compte VIP
</a><br>";
}
} else {
echo "Bonjour, vous n'êtes pas connecté.<br>";
}
?>
</p>
<section>
<h2>Evénements à venir</h2>
<?php
echo "<table class='table table-striped'>";
echo "<thead>";
echo "<tr>";
echo "<th>Nom</th>";
echo "<th>Date</th>";
echo "<th>Lieu</th>";
echo "<th>Prix</th>";
echo "<th>Places disponibles</th>";
echo "<th>Status</th>";
if ($user instanceof AdminUsers) {
echo "<th>Actions</th>";
}
echo "</tr>";
echo "</thead>";
echo "<tbody>";
if (empty($events)) {
if ($user instanceof AdminUsers) {
echo "<tr><td colspan='7' class='text-center'>Aucun événement à venir.</td></tr>";
} else {
echo "<tr><td colspan='6' class='text-center'>Aucun événement à venir.</td></tr>";
}
} else {
foreach ($events as $event) {
$event_obj = Event::getEventById($event['id']);
echo "<tr>";
echo "<td>" . $event_obj->getNom() . "</td>";
echo "<td>" . $event_obj->getDate() . "</td>";
echo "<td>" . $event_obj->getLieu() . "</td>";
echo "<td>" . $event_obj->getPrix() . "</td>";
echo "<td>" . $event_obj->getAvailablePlaces() . "</td>";
echo "<td>" . $event_obj->getStatus() . "</td>";
if ($user instanceof AdminUsers) {
echo "<form action='delete_event.php' method='post'>";
echo "<td><input type='hidden' name='id' value='" . $event['id'] . "'>";
echo "<button type='submit' class='btn btn-danger'>Supprimer</button></td>";
echo "</form>";
}
echo "</tr>";
}
}
echo "</tbody>";
echo "</table>";
if (isset($_SESSION['email'])) {
echo "<a href='add_event.php' class='btn btn-primary'>Ajouter un événement</a>";
}
?>
</section>
</main>
<?php include_once 'includes/footer.php'; ?>
</body>
</html>