-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathespace.php
257 lines (232 loc) · 8.6 KB
/
espace.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<?php
include("./includes/init.php");
include_once("./includes/variables.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include("./includes/head.php"); ?>
<title>Espace personnel</title>
</head>
<body>
<?php include("./includes/topbar.php");
$reqfail = 0;
if (! isConnected()) {
?>
<div class="container" style="padding-top : 20px;">
<div class="col-md-offset-4 col-sm-4">
<div class="panel panel-danger">
<div class="panel-heading">
<h3 class="panel-title">Problème</h3>
</div>
<div class="panel-body">
Vous devez être connecté pour utiliser cette page
</div>
</div>
</div>
</div>
<div class="container" style="text-align: center;">
<a href="./" class="btn btn-success btn-lg" role="button">Retour à l'accueil</a>
</div>
<?php
}
else {
// Récupération des données
include("./includes/process/espace.php");
if ($reqfail == 0) {
?>
<div class="jumbotron">
<div class="container">
<h1>Espace personnel</h1>
</div><!-- /.container -->
<div class="container" style="padding-top : 30px;">
<div class="col-md-2" style="text-align: center;">
<?php switch ($vehicule['categorie']) {
case 'voiture':
?><img id="imgShadow" src="./assets/img/voiture.png" ><?php
break;
case 'camion':
?><img id="imgShadow" src="./assets/img/camion.png" ><?php
break;
default:
?><img id="imgShadow" src="./assets/img/inconnu.png" ><?php
break;
}; ?>
</div>
<div class="col-md-4" style="text-align: center;">
Carburant : <span class="label label-primary" ><?php echo $vehicule['carburant'] ; ?></span><br>
Consommation : <span class="label label-primary" ><?php echo $vehicule['consommation'] ; ?> l/100km</span><br>
Kilométrage : <span class="label label-primary" ><span id="fieldKilometrage"><?php echo $vehicule['kilometrage'] ; ?></span> km</span>
</div>
<div class="col-md-3" style="margin: auto;">
<div id="gauge1" style="width:200px; height:160px"></div>
</div>
<div class="col-md-3" style="margin: auto;">
<div id="gauge2" style="width:200px; height:160px"></div>
</div>
</div><!-- /.container -->
</div>
<div class="container">
<div class="col-md-offset-2 col-md-3" style="text-align: center;">
<div class="well">
<legend>Acheter du carburant</legend>
<div class="form-horizontal" role="form">
<div class="form-group">
<div class="input-group">
<input type="number" class="form-control" id="inputCarbu" placeholder="Quantité de carburant" onkeypress="if (event.keyCode == 13) buyCarbu();" autocomplete=off required>
<span class="input-group-addon">litre</span>
</div>
</div>
</div>
<button type="button" class="btn btn-success" onclick="buyCarbu()">Valider</button>
</div>
</div>
<div class="col-md-offset-2 col-md-3">
<div class="well" style="text-align: center;">
<legend>Rouler</legend>
<div class="form-horizontal" role="form">
<div class="form-group">
<div class="input-group">
<input type="number" class="form-control" id="inputDrive" placeholder="Distance" onkeypress="if (event.keyCode == 13) drive();" autocomplete=off required>
<span class="input-group-addon">km</span>
</div>
</div>
</div>
<button type="button" class="btn btn-success" onclick="drive()">Valider</button>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel"></h4>
</div>
<div class="modal-body">
<div id="myModalAlert"></div>
</div>
<div class="modal-footer" id="myModalFooter">
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Fermer</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<?php
}
else {
?>
<div class="container" style="padding-top : 20px;">
<div class="col-md-offset-4 col-sm-4">
<div class="panel panel-danger">
<div class="panel-heading">
<h3 class="panel-title">Problème</h3>
</div>
<div class="panel-body">
Erreur dans l'éxécution des requêtes ou votre compte n'existe pas.
</div>
</div>
</div>
<?php
}
}?>
<?php include("./includes/js.php"); ?>
<?php if (isConnected() && $reqfail == 0) {
?>
<script type="text/javascript">
var g1, g2;
var g1 = new JustGage({
id: "gauge1",
value: <?php echo $compte ; ?>,
min: 0,
max: <?php echo $argentmaxi; ?>,
title: "Porte monnaie",
label: "Euro",
levelColors: ["#ff0000","#f9c802","#a9d70b"]
});
var g2 = new JustGage({
id: "gauge2",
value: <?php echo $vehicule['volume_restant'] ?>,
min: 0,
max: <?php echo $vehicule['volume_reservoir'] ?>,
title: "Niveau réservoir",
label: "litre",
levelColors: ["#ff0000","#f9c802","#a9d70b"]
});
function buyCarbu () {
var reqform = $.ajax({
type:"POST",
data: {
"quantite" : $("#inputCarbu").val()
},
url:"./ajax/buycarbu.php"
});
reqform.done(function(data, textStatus, jqXHR){
var result = jQuery.parseJSON(data);
if (result.errorlist.length > 0) {
listerreur = "";
$.each(result.errorlist, function (key, value) {
listerreur += "<li>" + value + "</li>";
});
$('#myModalLabel').html("Erreur");
$('#myModalAlert').html('<div class="panel panel-danger"><div class="panel-heading"><h3 class="panel-title">Erreur dans la saisie !</h3></div><div class="panel-body">Vous avez incorrectement saisi les données suivantes :<ul>'+listerreur+'</ul></div></div>');
$('#myModal').modal('show');
}
else if (result.reqfail == 1) {
$('#myModalLabel').html("Erreur");
$('#myModalAlert').html('<div class="panel panel-danger"><div class="panel-heading"><h3 class="panel-title">Erreur</h3></div><div class="panel-body">Il y a eu une problème dans l\'éxécution d\'une requête</div></div>');
$('#myModal').modal('show');
}
else {
$('#myModalAlert').html('');
$("#inputCarbu").val('');
g1.refresh(result.money);
g2.refresh(result.reservoir);
}
});
reqform.fail(function(jqXHR, textStatus){
$('#myModalAlert').html('<div class="panel panel-danger"><div class="panel-heading"><h3 class="panel-title">Erreur</h3></div><div class="panel-body">Impossible d\'envoyer le formulaire</div></div>');
});
}
function drive () {
var reqform = $.ajax({
type:"POST",
data: {
"distance" : $("#inputDrive").val()
},
url:"./ajax/drive.php"
});
reqform.done(function(data, textStatus, jqXHR){
var result = jQuery.parseJSON(data);
if (result.errorlist.length > 0) {
listerreur = "";
$.each(result.errorlist, function (key, value) {
listerreur += "<li>" + value + "</li>";
});
$('#myModalLabel').html("Erreur");
$('#myModalAlert').html('<div class="panel panel-danger"><div class="panel-heading"><h3 class="panel-title">Erreur dans la saisie !</h3></div><div class="panel-body">Vous avez incorrectement saisi les données suivantes :<ul>'+listerreur+'</ul></div></div>');
$('#myModal').modal('show');
}
else if (result.reqfail == 1) {
$('#myModalLabel').html("Erreur");
$('#myModalAlert').html('<div class="panel panel-danger"><div class="panel-heading"><h3 class="panel-title">Erreur</h3></div><div class="panel-body">Il y a eu une problème dans l\'éxécution d\'une requête</div></div>');
$('#myModal').modal('show');
}
else {
$('#myModalAlert').html('');
$("#inputDrive").val('');
g2.refresh(result.reservoir);
$('#fieldKilometrage').html(result.kilometrage)
}
});
reqform.fail(function(jqXHR, textStatus){
$('#myModalAlert').html('<div class="panel panel-danger"><div class="panel-heading"><h3 class="panel-title">Erreur</h3></div><div class="panel-body">Impossible d\'envoyer le formulaire</div></div>');
});
}
</script>
<?php
}
?>
</body>
</html>