-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdto.flight.php
More file actions
119 lines (105 loc) · 4.26 KB
/
dto.flight.php
File metadata and controls
119 lines (105 loc) · 4.26 KB
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
<?php
/*
Copyright 2023-2025 Eric Vyncke
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// TODO remove weather items per David Gaspard's request
require_once "dbi.php" ;
if ($userId == 0) {
header("Location: https://www.spa-aviation.be/resa/mobile_login.php?cb=" . urlencode($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']) , TRUE, 307) ;
exit ;
}
$header_postamble = '<style>
@media print {
.page-break {
page-break-before: always; /* ou page-break-after: always; */
}
}
</style>' ;
require_once 'mobile_header5.php' ;
require_once 'dto.class.php' ;
if (isset($_REQUEST['flight']))
if ($_REQUEST['flight'] == 'all' and isset($_REQUEST['student']) and is_numeric($_REQUEST['student'])) {
if (! ($userIsBoardMember or $userIsInstructor or $userId == $_REQUEST['student']))
journalise($userId, "F", "Vous devez être administrateur, instructeur, ou être l'élève pour voir cette page.") ;
$flights = new Flights($_REQUEST['student']) ;
} else if (is_numeric($_REQUEST['flight']) and $_REQUEST['flight'] != '') {
$flight_id = $_REQUEST['flight'] ;
$flight = new Flight() ;
$flight->getById($flight_id) ;
if (! $flight->id) {
journalise($userId, "F", "The flight #$flight_id does not exist") ;
}
if (! ($userIsBoardMember or $userIsInstructor or $userId == $flight->student))
journalise($userId, "F", "Vous devez être administrateur, instructeur, ou être l'élève pour voir ce vol.") ;
$flights = array($flight) ;
} else {
journalise($userId, 'F', "Invalid parameter flight=$_REQUEST[flight].") ;
} else
journalise($userId, 'F', "Missing parameter flight.") ;
if (isset($_REQUEST['action']))
$action = $_REQUEST['action'] ;
else
$action = NULL ;
// Check if header data needs to be updated
if ($action == 'header') {
$flight->remark = $_REQUEST['remark'] ;
$flight->flightType = $_REQUEST['type'] ;
$flight->sessionGrade = $_REQUEST['grading'] ;
$flight->save() ;
journalise($userId, "I", "Flight #$flight_id for $flight->studentLastName updated.") ;
} else if ($action == 'exercice') {
if (!isset($_REQUEST['exercice']))
journalise($userId, "F", "Missing parameter exercice") ;
$exercice = new StudentExercice() ;
$exercice->getByFlightExercice($flight_id, $_REQUEST['exercice']) ;
// apply changes
if (!isset($_REQUEST['grade']))
journalise($userId, "F", "Missing parameter grade") ;
if (!isset($_REQUEST['value']))
journalise($userId, "F", "Missing parameter grade") ;
switch ($_REQUEST['grade']) {
case 'demo': $grade = 'demo' ; break ;
case 'trained': $grade = 'trained' ; break ;
case 'acquired': $grade = 'acquired' ; break ;
case 'yes': $grade = 'yes' ; break ;
default: journalise($userId, "F", "Wrong value for grade=$_REQUEST[grade]") ;
}
switch ($_REQUEST['value']) {
case 'set': $exercice->grade[$grade] = $grade ; break ;
case 'unset': unset($exercice->grade[$grade]) ; break ;
default: journalise($userId, "F", "Invalid value for value=$_REQUEST[value]") ;
}
$exercice->save() ;
}
if (isset($flight)) { // Changes allowed only when a single flight is displayed TODO
?>
<script type="text/javascript">
function gradeChanged(object, reference, grade) {
if (object.checked)
value = 'set' ;
else
value = 'unset' ;
window.location.href = "https://www.spa-aviation.be/resa/dto.flight.php?flight=<?=$flight->id?>&action=exercice&exercice=" + reference + "&grade=" + grade + "&value=" + value;
}
</script>
<?php
}
require_once('dto.print.flight.php') ;
foreach($flights as $flight) {
printDtoFlight($flight) ;
print('
<div class="page-break"></div>
') ;
}
?>
</body>
</html>