-
Notifications
You must be signed in to change notification settings - Fork 0
/
vehicule_details.php
executable file
·232 lines (191 loc) · 9.92 KB
/
vehicule_details.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
<?php
/* FLOTTE - Gestion de flotte.
Copyright (C) 2023 Thierry HUCHARD <thierryh@vivaldi.net>
This file is part of the FLOTTE.
FLOTTE is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
FLOTTE is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with sane; see the file COPYING.
If not, see <https://www.gnu.org/licenses/>.
*/
include_once('common.php');
$page_limit = 10;
if(isset($_GET['page']) && !empty($_GET['page'])){
$currentPage = (int) strip_tags($_GET['page']);
}else{
$currentPage = 1;
}
////// Releve Kilometrique /////////////////////
$query_count = 'SELECT count(id) AS count FROM releve_kilometrique WHERE id_vehicule = '.$_REQUEST['id'].' ';
$res_obj = $conn->query($query_count);
$results_count = $res_obj->fetch_assoc();
$nbArticles = (int)$results_count['count'];
// On détermine le nombre d'articles par page
$parPage = 10;
// On calcule le nombre de pages total
$pages = ceil($nbArticles / $parPage);
$page_link = $BASE_PATH.'/vehicule_details.php?id='.$_REQUEST['id'].'&page=';
// Calcul du 1er article de la page
$premier = ($currentPage * $parPage) - $parPage;
///////////////// INCIDENT /////////////////
if(isset($_GET['page2']) && !empty($_GET['page2'])){
$currentPage2 = (int) strip_tags($_GET['page2']);
}else{
$currentPage2 = 1;
}
$query_count2 = 'SELECT count(id) AS count FROM incident WHERE id_vehicule = '.$_REQUEST['id'].' ';
$res_obj2 = $conn->query($query_count2);
$results_count2 = $res_obj2->fetch_assoc();
$nbArticles2 = (int)$results_count2['count'];
// On détermine le nombre d'articles par page
$parPage2 = 10;
// On calcule le nombre de pages total
$pages2 = ceil($nbArticles2 / $parPage2);
$page_link2 = $BASE_PATH.'/vehicule_details.php?id='.$_REQUEST['id'].'&page2=';
// Calcul du 1er article de la page
$premier2 = ($currentPage2 * $parPage2) - $parPage2;
include_once('headerhtml.php');
?>
<main id="main" class="flex-shrink-0" role="main">
<div class="container">
<?php
$sql = 'SELECT v.plaque, ma.nom AS marque, mo.nom AS model, v.date1_immatriculation, v.date_cate_grise FROM vehicule AS v, marque AS ma, model AS mo WHERE v.id_marque = ma.id AND v.id_model = mo.id AND v.id = '.$_REQUEST['id'].' ';
$result = $conn->query($sql);
if ($result->num_rows == 0) {
die('Aucun enregistrement trouvé.');
}
// output data of each row
$row = $result->fetch_assoc();
?>
<div class="vehicule-index">
<h1>Vehicule</h1>
<p><a class="btn btn-success" href="vehicule.php">Retour</a></p>
<div class="vehicule-view">
<div class="form-group field-vehicule-plaque">
<label class="control-label">Plaque</label>
<label class="form-control hasDatepicker"><?php echo $row['plaque'];?></label>
</div>
<div class="form-group field-vehicule-marque">
<label class="control-label">Marque</label>
<label class="form-control hasDatepicker"><?php echo $row['marque'];?></label>
</div>
<div class="form-group field-vehicule-model">
<label class="control-label">Model</label>
<label class="form-control hasDatepicker"><?php echo $row['model'];?></label>
</div>
<div class="form-group field-vehicule-date1_immatriculation">
<label class="control-label">Date 1er immatriculation</label>
<label class="form-control hasDatepicker"><?php echo date_fr($row['date1_immatriculation']);?></label>
</div>
<div class="form-group field-vehicule-date_carte_grise">
<label class="control-label">Date carte grise</label>
<label class="form-control hasDatepicker"><?php echo date_fr($row['date_cate_grise']);?></label>
</div>
</div>
<div id="p0" data-pjax-container="" data-pjax-push-state="" data-pjax-timeout="1000">
<h3>Suivi intervention</h3>
<p><a class="btn btn-success" href="releve_kilometrique_form.php?action=create&id_vehicule=<?php echo $_REQUEST['id'];?>"> + </a></p>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th><a href="<?php echo $BASE_PATH;?>/index.php?r=vehicule%2Findex&sort=plaque" data-sort="plaque">Date</a></th>
<th><a href="<?php echo $BASE_PATH;?>/index.php?r=vehicule%2Findex&sort=id_marque" data-sort="id_marque">Intervention</a></th>
<th><a href="<?php echo $BASE_PATH;?>/index.php?r=vehicule%2Findex&sort=id_model" data-sort="id_model">Km</a></th>
<th class="action-column"> </th>
<th class="action-column"> </th>
</tr>
</thead>
<tbody>
<?php
$sql = 'SELECT rk.id, rk.km, i.nom, rk.date, rk.facture FROM releve_kilometrique AS rk, intervention AS i WHERE rk.id_intervention = i.id AND id_vehicule = '.$_REQUEST['id'].' ORDER BY rk.date DESC LIMIT '. $premier .','. $parPage .';';
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo '<tr><td>'.date_fr($row["date"]).'</td><td>'.$row["nom"].'</td><td>'.$row["km"].'</td><td><a href="'.$BASE_PATH.'/releve_kilometrique_details.php?action=detail&id='.$row['id'].'&id_vehicule='.$_REQUEST['id'].'">Détail</a></td><td><a href="'.$BASE_PATH.'/releve_kilometrique_form.php?action=update&id='.$row['id'].'&id_vehicule='.$_REQUEST['id'].'">Modifier</a></td></tr>';
}
}
?>
</tbody>
</table>
<nav>
<ul class="pagination">
<!-- Lien vers la page précédente (désactivé si on se trouve sur la 1ère page) -->
<li class="page-item <?php echo (($currentPage == 1) ? 'disabled' : '') ?>">
<a href="<?php echo "$page_link".($currentPage - 1); ?>" class="page-link">Précédente</a>
</li>
<?php for($page = 1; $page <= $pages; $page++): ?>
<!-- Lien vers chacune des pages (activé si on se trouve sur la page correspondante) -->
<li class="page-item <?php echo (($currentPage == $page) ? 'active' : ''); ?>">
<a href="<?php echo "$page_link".$page; ?>" class="page-link"><?= $page ?></a>
</li>
<?php endfor ?>
<!-- Lien vers la page suivante (désactivé si on se trouve sur la dernière page) -->
<li class="page-item <?php echo (($currentPage == $pages) ? "disabled" : ""); ?>">
<a href="./?page=<?php echo "$page_link".($currentPage + 1); ?>" class="page-link">Suivante</a>
</li>
</ul>
</nav>
</div>
</div>
<!-- incident -->
<div id="p0" data-pjax-container="" data-pjax-push-state="" data-pjax-timeout="1000">
<h3>Suivi incident</h3>
<p><a class="btn btn-success" href="incident_form.php?action=create&id_vehicule=<?php echo $_REQUEST['id'];?>"> + </a></p>
<?php
$sql = 'SELECT i.id, i.km, a.nom, i.date FROM incident AS i, accident AS a WHERE i.id_accident = a.id AND i.id_vehicule = '.$_REQUEST['id'].' ORDER BY i.date DESC LIMIT '. $premier2 .','. $parPage2 .';';
$result = $conn->query($sql);
if ($result->num_rows > 0) {
?>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Date</a></th>
<th>Incident</a></th>
<th>Km</a></th>
<th class="action-column"> </th>
<th class="action-column"> </th>
</tr>
</thead>
<tbody>
<?php
// output data of each row
while($row = $result->fetch_assoc()) {
echo '<tr><td>'.date_fr($row["date"]).'</td><td>'.$row["nom"].'</td><td>'.$row["km"].'</td><td><a href="'.$BASE_PATH.'/incident_details.php?action=detail&id='.$row['id'].'&id_vehicule='.$_REQUEST['id'].'">Détail</a></td><td><a href="'.$BASE_PATH.'/incident_form.php?action=update&id='.$row['id'].'&id_vehicule='.$_REQUEST['id'].'">Modifier</a></td></tr>';
}
echo '</tbody></table>';
?>
<nav>
<ul class="pagination">
<!-- Lien vers la page précédente (désactivé si on se trouve sur la 1ère page) -->
<li class="page-item <?php echo (($currentPage2 == 1) ? 'disabled' : '') ?>">
<a href="<?php echo "$page_link2".($currentPage2 - 1); ?>" class="page-link">Précédente</a>
</li>
<?php for($page2 = 1; $page2 <= $pages2; $page2++): ?>
<!-- Lien vers chacune des pages (activé si on se trouve sur la page correspondante) -->
<li class="page-item <?php echo (($currentPage2 == $page2) ? 'active' : ''); ?>">
<a href="<?php echo "$page_link2".$page2; ?>" class="page-link"><?= $page2 ?></a>
</li>
<?php endfor ?>
<!-- Lien vers la page suivante (désactivé si on se trouve sur la dernière page) -->
<li class="page-item <?php echo (($currentPage2 == $pages2) ? "disabled" : ""); ?>">
<a href="./?page=<?php echo "$page_link2".($currentPage2 + 1); ?>" class="page-link">Suivante</a>
</li>
</ul>
</nav>
<?php
}
?>
</div>
</div>
</div>
</div>
</main>
</body>
</html>