-
Notifications
You must be signed in to change notification settings - Fork 0
/
gestion.php
215 lines (178 loc) · 8.79 KB
/
gestion.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?php
require ("inc/config.php"); #Connexion a la base (inclusion de la connexion par CLASSE PDO:Statement)
require 'functions.php';
session_start();
if (!isset($_SESSION['numutil']) ){
header('Location:index.php');
}
if ($_SESSION['admin'] != 1) {
header('Location:accueil.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Parking - Gestion du Parking</title>
</head>
<body>
<div id="bloc_page">
<?php require "inc/header.php"; ?>
<section>
<article>
<h3>Notifications : </h3>
<?php
$check = $bdd->query("SELECT COUNT(*) AS nbnotifss FROM notifications");
$raisultat = $check->fetch();
$raisultat = $raisultat['nbnotifss'];
if($raisultat == 0){ echo '<p>Il n\'y a aucune notifications !</p>'; }
if($raisultat > 0)
{
?><form action ="gestion.php" method="POST">
<input type="submit" name="supp" value="Supprimer toutes les notifications" />
</form><?php
//BOUTON POUR SUPPRIMER UNE NOTIF
if (isset($_POST['supp']))
{
erase_notif(1);
erase_notif(2);
erase_notif(3);
erase_notif(4);
erase_notif(5);
}
$check->closeCursor();
//ON VERIFIE LES NOTIFS
$check = $bdd->query("SELECT * FROM notifications ORDER BY datenotif DESC");
while ($notifs = $check->fetch())
{
$users = $bdd->prepare('SELECT nomutil, prenomutil FROM utilisateurs WHERE numutil = :num');
$users->execute(array('num'=>$notifs['numuser'],))or exit(print_r($users->errorInfo()));
$userfound = $users->fetch();
$client = $notifs['numuser'];
?>
<p><strong><?php date_maker($notifs['datenotif']); ?></strong> : <?php echo $userfound['nomutil'].' '.$userfound['prenomutil'];?> voudrait une place pour une durée de <strong><?php echo $notifs['nbjours']; ?> jours</strong>.
<?php
$reukette = $bdd->query("SELECT COUNT(*) AS nbplaces FROM stationnement WHERE datedebut = '0000-00-00'");
$occurence = $reukette->fetch();
$count = $occurence['nbplaces'];
if ($count < 1) { ?>
<form action ="listedattente.php" method="POST">
<input type="submit" name="listedattente" value="Placer en liste d'attente" />
<input type="hidden" name="client" value="<?php echo $client; ?>" />
<input type="hidden" name="duree" value="<?php echo $notifs['nbjours']; ?>" />
</form><br/>
<?php
}else{ ?>
<a href="attrib_place.php?client=<?php echo $client; ?>&nbjours=<?php echo $notifs['nbjours']; ?>">Attribuer une place</a><br/>
<?php
}
?>
</p>
<?php
}
}
?>
<hr/>
<h3>Places de Parking : </h3>
<table border="3">
<tr>
<th>Numéro de la place</th>
<th>Date de Début</th>
<th>Date de Fin</th>
<th>Statut de la Place</th>
<th>Occupée par</th>
</tr>
<?php
$parking = $bdd->query('SELECT * FROM stationnement');
//$elementpres = $presta->fetch();
while ($places = $parking->fetch())
{
?>
<tr>
<td><?php echo $places['numplace']; ?></td>
<td>
<?php
if($places['datedebut'] == '0000-00-00'){
echo "-";
}else { date_maker($places['datedebut']); }
?>
</td>
<td>
<?php
if($places['echeance'] == '0000-00-00'){
echo "-";
}else { echo date_maker($places['echeance']); }
?>
</td>
<?php
//SAVOIR SI UNE PLACE EST DISPO
if(check_pdispo($places['numplace']) == 1){
$busy = $bdd->query('SELECT * FROM parking_utilisateurs WHERE numplace = '.$places['numplace']);
$busies = $busy->fetch();
?>
<td>Occupée</td>
<td>
<?php
$who = $bdd->query('SELECT nomutil FROM utilisateurs WHERE numutil = '.$busies['numuser']);
if($who){
$whos = $who->fetch();
echo $whos['nomutil'];
}
?>
</td>
<?php
}else{
?>
<td>Libre</td>
<td> - </td>
<?php
}
?>
</tr>
<?php
} ?>
</table>
<hr/>
<h3>Liste d'attentes :</h3>
<?php
$verif = $bdd->query("SELECT COUNT(*) AS nbplaces FROM stationnement WHERE datedebut = '0000-00-00'");
$nbplaces = $verif->fetch();
$count = $nbplaces['nbplaces'];
?>
<table border="3">
<tr>
<th>Position dans la file</th>
<th>Utilisateur</th>
<th>Nombre de jours</th>
<?php if ($count > 0) { echo '<th>Action</th>'; } ?>
</tr>
<?php
$attente = $bdd->query('SELECT * FROM listedattente');
while ($attentes = $attente->fetch())
{
?>
<tr>
<td><strong><?php if($attentes['position'] == 1){echo $attentes['position'].' er';}else echo $attentes['position'].'ème'; ?></strong></td>
<td>
<?php //AFFICHAGE DE LA LISTE D'ATTENTE
$who = $bdd->query('SELECT nomutil, prenomutil FROM utilisateurs WHERE numutil = '.$attentes['codeclient']);
if($who){
$whos = $who->fetch();
echo $whos['nomutil'].' '.$whos['prenomutil'];
}else { echo "-"; }
?>
</td>
<td><?php echo $attentes['duree']; ?></td>
<?php if ($count > 0) { ?>
<td><a href="attrib_place.php?client=<?php echo $attentes['codeclient']; ?>&nbjours=<?php echo $attentes['duree']; ?>">Attribuer une place</a><br/></td>
<?php } ?>
</tr>
<?php } ?>
</table>
</article>
</section>
<?php require "inc/footer.php";?>
</div>
</body>
</html>