-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprueba.php
522 lines (389 loc) · 18.3 KB
/
prueba.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
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
<!DOCTYPE html>
<?php
include_once 'con.php';
//include('session.php');
//include('flightsinsert.php');
/*
if(!isset($_SESSION['login_user'])){
header("location: index.php"); // Redirecting To Home Page
}
//las time activity on session and destroy session
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1440)) {
// last request was more than 30 minutes ago
session_unset(); // unset $_SESSION variable for the run-time
session_destroy(); // destroy session data in storage
//header("location: index.php");
}
$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
//Regenerate session id
if (!isset($_SESSION['CREATED'])) {
$_SESSION['CREATED'] = time();
} else if (time() - $_SESSION['CREATED'] > 1440) {
// session started more than 30 minutes ago
session_regenerate_id(true); // change session ID for the current session and invalidate old session ID
$_SESSION['CREATED'] = time(); // update creation time
} */
?>
<head>
<meta charset="utf-8">
<title>GPB Survey from the Sky</title>
<!--<link rel="stylesheet" type="text/css" href="bootstrap.css">-->
<link rel="stylesheet" type="text/css" href="../css/stylesuav5.css">
<link rel="stylesheet" type="text/css" href="../css/stylesuav2.css">
<link rel="stylesheet" type="text/css" href="../css/stylesheet6.css">
<link rel="icon" href="img/picture1.png" type="image/png" sizes="any">
<link rel="script" type="javascript" href="photo.js">
</head>
<body>
<!-- Primer encabezado -->
<div class="row" id="container1">
<div class="col-2 head1" id="izq">
<img src="img/gpblogo2.svg" id="logo2">
</div>
<div class="col-8 head2" id="titulo">
<h1>Survey From The Sky</h1>
</div>
<div class="col-2 head2" id="der">
<img src="img/surveylogo.svg" id="survey">
</div>
</div>
<!-- Nav bar -->
<div class="row" id="container2">
<div class="col-2" id="vacio">
</div>
<div class="col-8" id="navegador">
<ul class="men1">
<li><a href="">RAV</a>
<ul class="smen1">
<li><a href="pdf/RAV_5.pdf">Rav 5</a></li>
<li><a href="pdf/RAV_21.pdf">Rav 21</a></li>
<li><a href="pdf/RAV_39.pdf">Rav 39</a></li>
<li><a href="pdf/RAV_45.pdf">Rav 45</a></li>
<li><a href="pdf/RAV_47.pdf">Rav 47</a></li>
<li><a href="pdf/RAV_60.pdf">Rav 60</a></li>
<li><a href="pdf/RAV_67.pdf">Rav 67</a></li>
<li><a href="pdf/RAV_91.pdf">Rav 91</a></li>
<li><a href="pdf/RAV_130.pdf">Rav 130</a></li>
<li><a href="pdf/RAV_145.pdf">Rav 145</a></li>
<li><a href="pdf/RAV_273.pdf">Rav 273</a></li>
<li><a href="pdf/RAV_281.pdf">Rav 281</a></li>
</ul>
</li>
<li><a href="">Emergency Numbers</a>
<ul class="smen1">
<li><a href="pdf/RAV_5.pdf">ATC</a></li>
</ul>
</li>
</ul>
</div>
<div class="col-2" id="lgt">
<a class="logt" href="logout.php"><img src=img/lgt.svg id="out">  Logout</a>
</div>
</div>
<!-- Cuerpo principal -->
<div class="row" id="container3">
<div class="col-2" id="menup">
<div class="row" id="ipers">
<img id="pers">
</div>
<div class="row" id="u">
<p id="user"><?php echo $login_session; ?></p>
</div>
<div class="row" id="m">
<ul class="mn2">
<li>
<a href="flights.php">Flights</a>
</li>
<li>
<a href="">Maintenance</a>
</li>
<li>
<a href="">Inventory</a>
<ul class="smen2">
<li><a href="">UAV</a></li>
<li><a href="">Batteries</a></li>
<li><a href="">Motors</a></li>
<li><a href="">Servos</a></li>
<li><a href="">Payloads</a></li>
<li><a href="">Consumables</a></li>
<li><a href="">Equipment</a></li>
<li><a href="">Vehicles</a></li>
<li><a href="">Locations</a></li>
</ul>
</li>
<li>
<a href="crewfront.php">Crew</a>
</li>
<li>
<a href="">Reports</a>
</li>
<li>
<a href="">Incidents</a>
</li>
</ul>
</div>
</div>
<div class="col-10" id="form1">
<div class="col-11 borsupe" id="flights">
<div class="topr"> </div>
<div class="topr">
<p>NEW FLIGHT</p>
</div>
<div class="topr right">
</div>
</div>
<div class="col-11 formcontainer" id="">
<form class="incform" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<?php
$sqlsentuav="SELECT *
FROM uav
JOIN status
WHERE uav.status_id=status.status_id
ORDER BY uav_id
";
$resultuav=mysqli_query($conn, $sqlsentuav);
$resultcheckuav = mysqli_num_rows($resultuav);
if ($resultcheckuav > 0)
{
while ($row = mysqli_fetch_assoc($resultuav))
{
$uavserial=$row['uav_serial'];
$uav=$row['uav_id'];
$status=$row['name'];
//date,time,releasecount
$sqlsentdate="SELECT MAX( fdate ) AS fecha
FROM flightslog AS b
WHERE b.uav_id =$uav";
$resultdate=mysqli_query($conn, $sqlsentdate);
$resultcheckdate = mysqli_num_rows($resultdate);
if ($resultcheckdate > 0)
{
while ($row1 = mysqli_fetch_assoc($resultdate))
{
$maxdate=$row1['fecha'];
}
}
//time
$sqlsenttime="SELECT MAX( start_time ) AS tiempo
FROM flightslog AS a
WHERE a.uav_id =$uav
AND a.fdate = '$maxdate'";
$resulttime=mysqli_query($conn, $sqlsenttime);
$resultchecktime = mysqli_num_rows($resulttime);
if ($resultchecktime > 0)
{
while ($row2 = mysqli_fetch_assoc($resulttime))
{
$maxtime=$row2['tiempo'];
}
}
//release
$sqlsentrel="SELECT *
FROM flightslog AS a
JOIN release_control AS b
WHERE a.uav_id =$uav
AND a.fdate = '$maxdate'
AND a.start_time = '$maxtime'
AND a.flights_id=b.flights_id"
;
$resultrel=mysqli_query($conn, $sqlsentrel);
$resultcheckrel = mysqli_num_rows($resultrel);
if ($resultcheckrel > 0)
{
while ($row3 = mysqli_fetch_assoc($resultrel))
{
$count=$row3['release_count'];
$releaseafter=$row3['release_after'];
$lastflight=$row3['flights_id'];
}
if($count>=5)
{
$relalert="Release must be changed";
//alert
}
}
$sqlsenttotime="SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(time_flight))) AS hours FROM flightslog WHERE uav_id=$uav";
$resulttime=mysqli_query($conn, $sqlsenttotime);
$resultcheckttime = mysqli_num_rows($resulttime);
if ($resultcheckttime > 0)
{
while ($row5 = mysqli_fetch_assoc($resulttime))
{
$totaltime=$row5['hours'];
}
}
//Cantidad de vuelos
$sqlsentvuel="SELECT * FROM flightslog WHERE uav_id=$uav";
$resultvuel=mysqli_query($conn, $sqlsentvuel);
$resultcheckvuel = mysqli_num_rows($resultvuel);
echo "<section class='row pres1'>
<section class='col-2 utitle'><p>UAV--$uavserial</p><p> $status</p></section>
<section class='col-10'>
<section class='row pad'>
<section class='col-3'>
<section class='display'><p>Last DT</p><p>$maxdate at $maxtime</p></section>
</section>
<section class='col-3'>
<section class='display'><p>Total FT</p><p>$totaltime</p><p>Cantidad de Vuelos $resultcheckvuel</p></section>
</section>
<section class='col-3'>
<section class='display'><p>Release C</p><p>$count</p></section>
</section>
<section class='col-3'>
<section class='display'><p>Release A</p><p>$releaseafter</p></section>
</section>
</section>";
$sqlsentdamage="SELECT * FROM damages WHERE flight_id='$lastflight'";
$resultdamage=mysqli_query($conn, $sqlsentdamage);
$resultcheckdamage = mysqli_num_rows($resultdamage);
if ($resultcheckdamage > 0)
{
while ($row6 = mysqli_fetch_assoc($resultdamage))
{
$damagetype=$row6['damage_type_id'];
$damagedesc=$row6['damage_description'];
}
if ($damagetype==1)
{
$damimg="../img/xroja.png";
}
elseif ($damagetype==2)
{
$damimg="../img/xrojacirculo.png";
}
elseif ($damagetype==3)
{
$damimg="../img/guion.png";
}
elseif ($damagetype==4)
{
$damimg="../img/diagonal.png";
}
echo "<section class='row pad '>
<section class='col-12 display'>
<section class='col-2'><img src='$damimg' id='imgdam2'></section><section class='col-10 ddes'><p class='ddes'>$damagedesc</p></section>
</section>
</section>";
}
echo "</section>
</section>";
}
}
?>
</form>
</div>
</div>
</div>
</div>
<script src="photo.js" ></script>
</body>
<?php
if(isset($_POST['submit']))
{
//$uav=$_POST['uav'];
$uav=2;
$releasebefore=$_POST['releasech'];
//$releaseafter="YES";
//$releasebefore=$_POST['releasech'];
$releaseafter=strval($_POST['releaseact']);
$d='YES';
//echo $releaseafter;
//echo "release before $releasebefore";
//strcasecmp($releaseafter,$d) == 0
if(strcasecmp($releaseafter,$d) == 0)
{
$releasecount="0";
echo "activated release after 1 count";
echo $releasecount;
}
elseif (strcasecmp($releasebefore,$d) == 0)
{
$releasecount="1";
echo "releasebefore 1 release after 0";
echo $releasebefore;
echo $releaseafter;
echo $releasecount;
}
else
{
//Date
$sqlsentdate="SELECT MAX( fdate ) AS fecha
FROM flightslog AS b
WHERE b.uav_id =$uav";
$resultdate=mysqli_query($conn, $sqlsentdate);
//if($result == true)
$resultcheckdate = mysqli_num_rows($resultdate);
if ($resultcheckdate > 0)
{
echo "el numero de filas es $resultdate->num_rows";
while ($row = mysqli_fetch_assoc($resultdate))
{
$maxdate=$row['fecha'];
echo $maxdate;
}
}
//time
$sqlsenttime="SELECT MAX( start_time ) AS tiempo
FROM flightslog AS a
WHERE a.uav_id =2
AND a.fdate = '2019-04-08'";
$resulttime=mysqli_query($conn, $sqlsenttime);
$resultchecktime = mysqli_num_rows($resulttime);
if ($resultchecktime > 0)
{
echo "el numero de filas es $resulttime->num_rows";
while ($row = mysqli_fetch_assoc($resulttime))
{
$maxtime=$row['tiempo'];
echo $maxtime;
}
}
//release
$sqlsentrel="SELECT *
FROM flightslog AS a
JOIN release_control AS b
WHERE a.uav_id =2
AND a.fdate = '2019-04-08'
AND a.start_time = '17:00:00'
AND a.flights_id=b.flights_id"
;
$resultrel=mysqli_query($conn, $sqlsentrel);
$resultcheckrel = mysqli_num_rows($resultrel);
if ($resultcheckrel > 0)
{
echo "el numero de filas es $resultrel->num_rows";
while ($row = mysqli_fetch_assoc($resultrel))
{
$release=$row['release_count'];
echo $release;
}
}
echo "$resultcheckdate resultcheckdate $resultdate->num_rows resultate";
echo "$resultchecktime resultchecktime $resulttime->num_rows resultate";
echo "$resultchecktime resultcheckrel $resultrel->num_rows resultate";
//if ($resultcheck == 0)
//{
// $releasecount="1";
//echo "no hay registros";
//}
//else
if ($resultcheck > 0)
{
echo "el numero de filas es $result->num_rows";
while ($row = mysqli_fetch_assoc($result))
{
$count=$row['release_count'];
echo $count;
$releasecount=++$count;
echo $releasecount;
echo "0 y 0";
}
if($count>=5)
{
echo "Release must be changed";
//alert
}
}
}
}
?>