forked from anas-araid/Gestione-RapportiVVF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
editReport.php
465 lines (445 loc) · 25.2 KB
/
editReport.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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
<html>
<head>
<?php
include "core/_header.php";
session_start();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// error_reporting per togliere il notice quando non trova isLogged
//error_reporting(0);
include "core/dbConnection.php";
include "core/getData.php";
include "core/functions.php";
if ($error_message) {
echo "
<script>
flatAlert('Accesso', 'Impossibile connettersi al database', 'error', 'index.php');
</script>";
}
if (isset($_GET['id'])){
$rapporto = getReportData($_GET['id'], $db_conn);
$_SESSION['rapporto'] = $rapporto;
}
?>
</head>
<body>
<div class="mdl-layout mdl-js-layout">
<main class="mdl-layout__content">
<div class="page-content">
<div class="mdl-grid">
<section class="mdl-cell mdl-cell--middle mdl-cell--3-col mdl-cell--hide-phone mdl-cell--hide-tablet">
<div style="padding:5px">
<h1>
<mark style="background-color:white;border:none;border-radius:10px;padding:5px;">
<span class="style-gradient-text">Rapporti</span>
</mark>
</h1>
<h1>
<mark style="background-color:white;border:none;border-radius:10px;padding:5px;">
<span class="style-gradient-text">d'intervento</span>
</mark>
</h1>
<h3 class="style-gradient-text">
<mark style="background-color:white;border:none;border-radius:10px;padding:5px;">
<span class="style-gradient-text">vvf Pergine</span>
</mark>
<br>
<br>
<mark style="background-color:white;border:none;border-radius:10px;padding:5px;">
<span class="style-gradient-text">Valsugana</span>
</mark>
</h3>
</div>
<div class="mdl-cell mdl-cell--middle mdl-cell--12-col">
<button class="mdl-button mdl-js-button mdl-button--raised style-gradient style-button"
style="width:100%;height:35px;color:white;border:none;border-radius:20px;;text-align:center;margin-bottom:15px"
type="reset"
onclick="location.href='index.php?back=true'">
Indietro
<i class="material-icons">cancel</i>
</button>
</div>
</section>
<section class="mdl-cell mdl-cell--middle mdl-cell--9-col">
<div class="mdl-card mdl-shadow--8dp style-card" style="width:100%">
<form action="core/updateReport.php" method="post" style="text-align:center;max-height:650px;overflow:auto">
<div class="mdl-grid mdl-card mdl-shadow--8dp style-card" style="width:90%">
<div class="mdl-cell mdl-cell--middle mdl-cell--6-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:60%">
<input class="mdl-textfield__input" type="text" id="IdRapporto" name="rapporto" required="" value="<?php echo getLastReportId($db_conn)?>">
<label class="mdl-textfield__label" for="IdRapporto">Inserisci id del rapporto</label>
</div>
</div>
<div class="mdl-cell mdl-cell--middle mdl-cell--6-col" style="text-align:left">
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="idUrgente" id="lblUrgente">
<?php
$urgente = $rapporto['Urgente'];
?>
<input type="checkbox" id="idUrgente" class="mdl-checkbox__input" name="urgente" value="<?php echo $urgente ?>">
<span class="mdl-checkbox__label">Urgente</span>
</label>
</div>
</div>
<h6 class="style-gradient-text">Segnalazione pervenuta da:</h6>
<div class="mdl-grid mdl-card mdl-shadow--8dp style-card" style="width:90%">
<?php
$prov = getProvChiamata(null, $db_conn);
$rows = count($prov) / 2;
if(!is_int($rows)){
$rows = (int)$rows + 1;
}
$index = 0;
for ($i=0; $i < $rows;$i++){
for($j=0;$j < 2; $j++){
if ($index < count($prov)){
$checked = "";
if ($rapporto['FK_ProvChiamata'] == $prov[$index][0]){
$checked = "checked";
}
echo '
<div class="mdl-cell mdl-cell--middle mdl-cell--6-col" style="text-align:left">
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="prov_'.$index.'" id="radioProv_'.$prov[$index][0].'" ">
<input type="radio" id="prov_'.$index.'" class="mdl-radio__button" name="provChiamata" value="'.$prov[$index][0].'" '.$checked.'>
<span class="mdl-radio__label">'.$prov[$index][1].'</span>
</label>
</div> ';
$index++;
}
}
echo "<br>";
}
?>
</div>
<div class="mdl-grid mdl-card mdl-shadow--8dp style-card" style="width:90%">
<div class="mdl-cell mdl-cell--middle mdl-cell--8-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:90%">
<select id="IdIntervento" class="mdl-textfield__input" name="intervento" required="">
<?php
$interventi = getCallType(null, $db_conn);
for ($i =0; $i < count($interventi); $i++){
$selected = "";
if ($rapporto['FK_TipoChiamata'] == $interventi[$i][0]){
$selected = "selected";
}
echo '<option value="'.$interventi[$i][0].'"'.$selected.'>'.$interventi[$i][1].'</option>';
}
?>
</select>
<label class="mdl-textfield__label" for="IdIntervento">Evento</label>
</div>
</div>
<div class="mdl-cell mdl-cell--middle mdl-cell--4-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:100%">
<input class="mdl-textfield__input" type="date" id="IdData" name="data" required="" value="<?php echo date_create($rapporto['Data'])->format('Y-m-d'); ?>">
</div>
</div>
<br>
<div class="mdl-cell mdl-cell--middle mdl-cell--8-col">
<?php
$localita = getLocalita($rapporto['FK_Localita'], null, null, $db_conn);
?>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:90%">
<input class="mdl-textfield__input" type="text" id="idVia" name="via" required="" value="<?php echo $localita['via'] ?>">
<label class="mdl-textfield__label" for="idVia">Via*</label>
</div>
</div>
<div class="mdl-cell mdl-cell--middle mdl-cell--4-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:90%">
<select id="IdComune" class="mdl-textfield__input" name="comune" required="">
<?php
$comuni = getComuni(null, $db_conn);
for ($i =0; $i < count($comuni); $i++){
$selected = "";
if ($comuni[$i][1] == $localita['via']){
$selected = "selected";
}
echo '<option value="'.$comuni[$i][0].'"'.$selected.' >'.$comuni[$i][1].'</option>';
}
?>
</select>
<label class="mdl-textfield__label" for="IdComune">Comune</label>
</div>
</div>
<br>
<div class="mdl-cell mdl-cell--middle mdl-cell--6-col">
<span>Ora di partenza*  </span>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:50%">
<input class="mdl-textfield__input" type="time" id="IdOraUscita" name="oraUscita" required="" value="<?php echo $rapporto['OraUscita'] ?>">
</div>
</div>
<div class="mdl-cell mdl-cell--middle mdl-cell--6-col">
<span>Ora di rientro*  </span>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:50%">
<input class="mdl-textfield__input" type="time" id="IdOraRientro" name="oraRientro" required="" value="<?php echo $rapporto['OraRientro'] ?>">
</div>
</div>
</div>
<h6 class="style-gradient-text">Generalità del colpito:</h6>
<?php
$colpito = getColpito($rapporto['FK_GeneralitaColpito'], null, null, null, null, $db_conn);
//print_r($colpito);
?>
<div class="mdl-grid mdl-card mdl-shadow--8dp style-card" style="width:90%">
<div class="mdl-cell mdl-cell--middle mdl-cell--6-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:90%">
<input class="mdl-textfield__input" type="text" id="idNome" name="nome" value="<?php echo $colpito['Nome'] ?>">
<label class="mdl-textfield__label style-gradient-text" for="idNome">Nome</label>
</div>
</div>
<div class="mdl-cell mdl-cell--middle mdl-cell--6-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:90%">
<input class="mdl-textfield__input" type="text" id="idCognome" name="cognome" value="<?php echo $colpito['Cognome'] ?>">
<label class="mdl-textfield__label style-gradient-text" for="idCognome">Cognome</label>
</div>
</div>
<br>
<div class="mdl-cell mdl-cell--middle mdl-cell--9-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:90%">
<input class="mdl-textfield__input" type="text" id="idResidenza" name="residenza" value="<?php echo $colpito['Residenza'] ?>">
<label class="mdl-textfield__label style-gradient-text" for="idResidenza">Residenza</label>
</div>
</div>
<div class="mdl-cell mdl-cell--middle mdl-cell--3-col">
<?php
$dataDiNascita = '';
if($colpito['DataDiNascita'] != date_create('1900-01-01')->format('Y-m-d')){
$dataDiNascita = $colpito['DataDiNascita'];
}
?>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:80%">
<input class="mdl-textfield__input" type="date" id="idDataDiNascita" name="dataDiNascita" value="<?php echo date_create($dataDiNascita)->format('Y-m-d'); ?>">
</div>
</div>
<br>
<div class="mdl-cell mdl-cell--middle mdl-cell--8-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:90%">
<input class="mdl-textfield__input" type="number" id="idTelefono" name="telefono" value="<?php echo $colpito['Telefono'] ?>">
<label class="mdl-textfield__label style-gradient-text" for="idTelefono">Telefono</label>
</div>
</div>
<div class="mdl-cell mdl-cell--middle mdl-cell--4-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:100%">
<input class="mdl-textfield__input" type="text" id="idCartaIdentita" name="cartaIdentita" value="<?php echo $colpito['CartaIdentita'] ?>">
<label class="mdl-textfield__label style-gradient-text" for="idCartaIdentita">Carta d'identità</label>
</div>
</div>
<br>
<div class="mdl-cell mdl-cell--middle mdl-cell--12-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:95%">
<input class="mdl-textfield__input" type="text" id="idAltro" name="altro" value="<?php echo $colpito['Altro'] ?>">
<label class="mdl-textfield__label style-gradient-text" for="idAltro">Altro</label>
</div>
</div>
</div>
<h6 class="style-gradient-text">Dettagli:</h6>
<div class="mdl-grid mdl-card mdl-shadow--8dp style-card" style="width:90%">
<div class="mdl-cell mdl-cell--middle mdl-cell--12-col">
<div class="mdl-textfield mdl-js-textfield" style="width:90%">
<textarea class="mdl-textfield__input" type="text" rows= "4" id="idOperazioni" name="operazioni"><?php echo $rapporto['OperazioniEseguite'] ?></textarea>
<label class="mdl-textfield__label style-gradient-text" for="idOperazioni">Operazioni eseguite</label>
</div>
</div>
<div class="mdl-cell mdl-cell--middle mdl-cell--12-col">
<div class="mdl-textfield mdl-js-textfield" style="width:90%">
<textarea class="mdl-textfield__input " type="text" rows= "4" id="idOsservazioni" name="osservazioni"><?php echo $rapporto['Osservazioni'];?></textarea>
<label class="mdl-textfield__label style-gradient-text" for="idOsservazioni">Osservazioni</label>
</div>
</div>
</div>
<h6 class="style-gradient-text">Mezzi intervenuti:</h6>
<div class="mdl-grid mdl-card mdl-shadow--8dp style-card" style="width:90%">
<?php
$mezzi = getMezzi(null, $db_conn);
//print_r($mezzi);
$rows = count($mezzi) / 2;
if(!is_int($rows)){
$rows = (int)$rows + 1;
}
$index = 0;
for ($i=0; $i < $rows;$i++){
for($j=0;$j < 2; $j++){
if ($index < count($mezzi)){
echo '
<div class="mdl-cell mdl-cell--middle mdl-cell--6-col" style="text-align:left">
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="idMezzi_'.$index.'" id="lblMezzi_'.$mezzi[$index][0].'">
<input type="checkbox" id="idMezzi_'.$index.'" class="mdl-checkbox__input" name="mezzo_'."$index".'" value="'.$mezzi[$index][0].'">
<span class="mdl-checkbox__label">'.$mezzi[$index][1].'</span>
</label>
</div> ';
$index++;
}
}
echo "<br>";
}
?>
</div>
<h6 class="style-gradient-text">Altri soccorsi:</h6>
<div class="mdl-grid mdl-card mdl-shadow--8dp style-card" style="width:90%">
<?php
$soccorsi = getSoccorsi(null, $db_conn);
//print_r($prov);
$rows = count($soccorsi) / 2;
if(!is_int($rows)){
$rows = (int)$rows + 1;
}
$index = 0;
for ($i=0; $i < $rows;$i++){
for($j=0;$j < 2; $j++){
if ($index < count($soccorsi)){
echo '
<div class="mdl-cell mdl-cell--middle mdl-cell--6-col" style="text-align:left">
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="idSoccorsi_'.$index.'" id="lblSoccorsi_'.$soccorsi[$index][0].'">
<input type="checkbox" id="idSoccorsi_'.$index.'" class="mdl-checkbox__input" name="soccorsi_'."$index".'" value="'.$soccorsi[$index][0].'">
<span class="mdl-checkbox__label">'.$soccorsi[$index][1].'</span>
</label>
</div> ';
$index++;
}
}
echo "<br>";
}
?>
</div>
<h6 class="style-gradient-text">Vigili intervenuti:</h6>
<div class="mdl-grid mdl-card mdl-shadow--8dp style-card" style="width:90%">
<?php
$vigili = getFiremanData(null, $db_conn);
//print_r($prov);
$rows = count($vigili) / 2;
if(!is_int($rows)){
$rows = (int)$rows + 1;
}
$index = 0;
for ($i=0; $i < $rows;$i++){
for($j=0;$j < 2; $j++){
if ($index < count($vigili)){
echo '
<div class="mdl-cell mdl-cell--middle mdl-cell--6-col" style="text-align:left">
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="idVigile_'.$index.'" id="lblVigili_'.$vigili[$index][0].'">
<input type="checkbox" id="idVigile_'.$index.'" class="mdl-checkbox__input" name="vigile_'."$index".'" value="'.$vigili[$index][0].'">
<span class="mdl-checkbox__label">'.$vigili[$index][1].'</span>
</label>
</div> ';
$index++;
}
}
echo "<br>";
}
?>
</div>
<br>
<div class="mdl-grid mdl-card mdl-shadow--8dp style-card" style="width:90%">
<div class="mdl-cell mdl-cell--middle mdl-cell--6-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:90%">
<select id="IdRos" class="mdl-textfield__input" name="ros" required="">
<?php
$ros = getFiremanData(null, $db_conn);
for ($i =0; $i < count($ros); $i++){
$selected = "";
if ($rapporto['FK_Responsabile'] == $ros[$i][0]){
$selected = "selected";
}
echo '<option value="'.$ros[$i][0].'" '.$selected.'>'.$ros[$i][1].'</option>';
}
?>
</select>
<label class="mdl-textfield__label" for="IdRos">Responsabile Operazioni</label>
</div>
</div>
<div class="mdl-cell mdl-cell--middle mdl-cell--6-col">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width:90%">
<select id="IdCompilatore" class="mdl-textfield__input" name="compilatore" required="">
<?php
$compilatore = getFiremanData(null, $db_conn);
for ($i =0; $i < count($compilatore); $i++){
$selected = "";
if ($rapporto['FK_Compilatore'] == $compilatore[$i][0]){
$selected = "selected";
}
echo '<option value="'.$compilatore[$i][0].'" '.$selected.'>'.$compilatore[$i][1].'</option>';
}
?>
</select>
<label class="mdl-textfield__label" for="IdCompilatore">Compilatore</label>
</div>
</div>
</div>
<br>
<div class="mdl-grid">
<div class="mdl-cell mdl-cell--middle mdl-cell--12-col mdl-cell--hide-desktop">
<button class="mdl-button mdl-js-button mdl-button--raised style-gradient style-button"
style="width:100%;height:35px;color:white;border:none;border-radius:20px;;text-align:center;margin-bottom:15px"
type="reset"
onclick="location.href='index.php?back=true'">
Indietro
<i class="material-icons">cancel</i>
</button>
</div>
<div class="mdl-cell mdl-cell--middle mdl-cell--12-col">
<button class="mdl-button mdl-js-button mdl-button--raised style-gradient style-button"
style="width:100%;height:35px;color:white;border:none;border-radius:20px;;text-align:center;margin-bottom:15px"
type="submit"
id="btnSave"
name="btnSave">
Salva
<i class="material-icons">save</i>
</button>
</div>
</div>
<br>
<br>
</form>
</div>
</section>
</div>
<script>
window.onload = function(){
<?php
// attiva la checkbox urgente
if ($urgente == 1){
echo "
document.getElementById('lblUrgente').classList.add('is-checked');
";
}
// attiva il radio button della provenienza della chiamata
$radioBtn = $rapporto['FK_ProvChiamata'];
if ($radioBtn != null){
$radioProv = "'radioProv_$radioBtn'";
echo "
document.getElementById($radioProv).classList.add('is-checked');
";
}
// attiva le checkbox dei mezzi
$arrayMezzi = getMezziByReport($rapporto['ID'], $db_conn);
for ($i=0; $i < count($arrayMezzi); $i++){
$mezzo = $arrayMezzi[$i];
echo "
document.getElementById('lblMezzi_$mezzo').classList.add('is-checked');
";
}
// attiva le checkbox dei soccorsi
$arraySoccorsi = getSoccorsiByReport($rapporto['ID'], $db_conn);
for ($i=0; $i < count($arraySoccorsi); $i++){
$soccorsi = $arraySoccorsi[$i];
echo "
document.getElementById('lblSoccorsi_$soccorsi').classList.add('is-checked');
";
}
// attiva le checkbox dei vigili intervenuti
$arrayVigili = getVigiliByReport($rapporto['ID'], $db_conn);
for ($i=0; $i < count($arrayVigili); $i++){
$vigili = $arrayVigili[$i];
echo "
document.getElementById('lblVigili_$vigili').classList.add('is-checked');
";
}
?>
}
</script>
<?php
include "core/_footer.php";
?>
</div>
</main>
</div>
</body>
</html>