-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
executable file
·415 lines (369 loc) · 13.7 KB
/
admin.php
File metadata and controls
executable file
·415 lines (369 loc) · 13.7 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
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
<html>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<head>
<style>
.container {
background: rgba(150, 190, 225, 0.35);
}
h3{
color: #111; font-family: 'Georgia'
}
p {
color: #111; font-family: 'Tahoma'
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse" data-offset-top= "200">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li><a href="menu.php">Home</a></li>
<li><a href="cust.php">Customers</a></li>
<li><a href="crew.php">Flight Crew</a></li>
<li class="active"><a href="admin.php">Admin</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="login.html"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div>
</nav>
<tr valign="top"><td width="40%">
<div class="container">
<div id="viewModelInfo">
<h3>View Model Info</h3>
<form method="POST" action= <?php __FILE__ ?> >
<table>
<tr>
<td>Model Number</td>
<td><label for="input-id" class="sr-only">000</label>
<input type="input" maxlength="3" name="model" placeholder="000" id="input-id"></td>
</tr>
<tr>
<td><button type="submit" value="submit" name="viewModelInfo" class="btn btn-primary btn-md">View</button></td>
</tr>
</table>
</form>
</div>
<div id="editCapacity">
<h3>Edit Model Capacity</h3>
<form method="POST" action= <?php __FILE__ ?> >
<table>
<tr>
<td>Model Number</td>
<td><label for="input-id" class="sr-only">000</label>
<input type="input" maxlength="3" name="model" required placeholder="000" id="input-id"></td>
</tr>
<tr>
<td>New Capacity</td>
<td><label for="input-id" class="sr-only">000</label>
<input type="number" name="capacity" required placeholder="000" id="input-id"></td>
</tr>
<tr>
<td><button type="submit" value="submit" name="editCapacitySubmit" class="btn btn-primary btn-md">Edit</button></td>
</tr>
</table>
</form>
</div>
<div id="viewModelInfoByCompany">
<h3>View Model Info By Company</h3>
<form method="POST" action= <?php __FILE__ ?> >
<table>
<tr>
<td><input type="checkbox" name="check_list[]" value="AVG(capacity)">
<label for="cbox1">Find average capacity for company</label></td>
</tr>
<tr>
<td><input type="checkbox" name="check_list[]" value="MAX(capacity)">
<label for="cbox2">Find largest capacity for company</label></td>
</tr>
<tr>
<td><input type="checkbox" name="check_list[]" value="MIN(capacity)">
<label for="cbox3">Find smallest capacity for company</label></td>
</tr>
<tr>
<td><input type="checkbox" name="check_list[]" value="COUNT(capacity)">
<label for="cbox4">Find number of unique capacities for company</label></td>
</tr>
<tr>
<td><button type="submit" value="submit" name="viewModelInfoByCompany" class="btn btn-primary btn-md">View</button></td>
</tr>
</table>
</form>
</div>
<div id="addFlight">
<h3>Add a Flight</h3>
<form method="POST" action= <?php __FILE__ ?> >
<table>
<tr>
<td>Flight No.</td>
<td><label for="input-id" class="sr-only">F000</label>
<input type="input" maxlength="4" name="fno" required placeholder="F000" id="input-id"></td>
</tr>
<tr>
<td>Departure Date</td>
<td><label for="input-id" class="sr-only">yyyy-mm-dd</label>
<input type="date" name="dateflight" required placeholder="yyyy-mm-dd" id="input-id"></td>
</tr>
<tr>
<td>Departure Time</td>
<td><input type="time" name="deptime" required></td>
</tr>
<tr>
<td>Departure Airport</td>
<td> <label for="input-id" class="sr-only">A000</label>
<input type="input" maxlength="4" name="depacode" required placeholder="A000" id="input-id"></td>
</tr>
<tr>
<td>Arrival Date</td>
<td><input type="date" name="arrdate" required></td>
</tr>
<tr>
<td>Arrival Time</td>
<td><input type="time" name="arrtime" required></td>
</tr>
<tr>
<td>Arrival Airport</td>
<td><label for="input-id" class="sr-only">A000</label>
<input type="input" maxlength="4" name="arracode" required placeholder="A000" id="input-id"></td>
</tr>
<tr>
<td>Aircraft ID</td>
<td><label for="input-id" class="sr-only">001</label>
<input type="input" maxlength="5" name="regno" required placeholder="00001" id="input-id"></td>
</tr>
<tr>
<td><button type="submit" value="submit" name="addFlightSubmit" class="btn btn-primary btn-md">Add</button></td>
</tr>
</table>
</form>
</div>
<div id="removeFlight">
<h3>Remove a Flight</h3>
<form method="POST" action= <?php __FILE__ ?> >
<table>
<tr>
<td>Flight No.</td>
<td><label for="input-id" class="sr-only">F000</label>
<input type="input" maxlength="4" name="fno" required placeholder="F000" id="input-id"></td>
</tr>
<tr>
<td>Departure Date</td>
<td><input type="date" name="dateflight" required></td>
</tr>
<tr>
<td><button type="submit" value="submit" name="removeFlightSubmit" class="btn btn-primary btn-md">Remove</button></td>
</tr>
</table>
</form>
</div>
<div id="purchaseAllFlights">
<h3>Customer Who Purchased All Flights</h3>
<form method="POST" action= <?php __FILE__ ?> >
<button type="submit" value="submit" name="purchaseAllFlights" class="btn btn-primary btn-md">Search</button>
</form>
</div>
<br>
<center>
<div class= "row">
<div class="col-sm-2">
<form>
<center> <button type="submit" formaction="cust.php" class= "btn btn-success btn-lg">View as Customer</button></center></form>
</div>
<div class="col-sm-2">
<form>
<center><button type="submit" formaction="crew.php" class= "btn btn-success btn-lg">View as Crew</button></center></form>
</div>
<div class="col-sm-2">
<form>
<center> <button type="submit" class= "btn btn-success btn-lg disabled">View as Admin</button></center></form>
</div>
</div>
</center>
</td><td>
<?php
//error_reporting(-1);
//ini_set('display_errors',1);
date_default_timezone_set('UTC');
$hasRequiredFields = false;
$print = true;
if (array_key_exists('removeFlightSubmit', $_POST)) {
$fno = "'".$_POST['fno']."'";
$dateflight = "'".strtoupper(date('Y-m-d', strtotime($_POST['dateflight'])))."'";
if ($fno !== "''" && $dateflight !== "'1970-01-01'")
$hasRequiredFields = true;
// $query = "delete from crewassn where fno = $fno and dateflight = $dateflight";
$query = "delete from flight where fno = $fno and dateflight = $dateflight";
// $query2 = "delete from ticket where fno = $fno and dateflight = $dateflight";
$print = false;
}
if (array_key_exists('editCapacitySubmit', $_POST)) {
$model = "'".$_POST['model']."'";
$capacity = "'".$_POST['capacity']."'";
if ($model != "'" && $capacity != "'")
$hasRequiredFields = true;
$query = "update modelinfo set capacity = $capacity where model = $model";
$print = false;
}
if (array_key_exists('addFlightSubmit', $_POST)) {
$fno = "'".$_POST['fno']."'";
$dateflight = "'".strtoupper(date('Y-m-d', strtotime($_POST['dateflight'])))."'";
$deptime = "'".$_POST['deptime']."'";
$arrtime = "'".$_POST['arrtime']."'";
$depacode = "'".$_POST['depacode']."'";
$arracode = "'".$_POST['arracode']."'";
$arrdate = "'".strtoupper(date('Y-m-d', strtotime($_POST['arrdate'])))."'";
$regno = "'".$_POST['regno']."'";
$hasRequiredFields = true;
$print = false;
$query = "insert into flight values($fno, $dateflight, $deptime, $depacode, $arrdate, $arrtime, $arracode,$regno)";
}
if (array_key_exists('viewModelInfo', $_POST)) {
$model = "'".$_POST['model']."'";
if ($model === "''") $model = 'model';
$hasRequiredFields = true;
$query = "select * from modelinfo where model = $model";
}
if (array_key_exists('viewModelInfoByCompany', $_POST)) {
if(!empty($_POST['check_list'])){
$selected="";
$hasRequiredFields=true;
foreach($_POST['check_list'] as $check) {
$selected.=(string)$check.",";
}
$selected=chop($selected,",");
$query= "select company,".$selected." from modelinfo group by company";
}
}
if (array_key_exists('purchaseAllFlights', $_POST)) {
$query = "select p.pid, p.pname from passenger p where not exists ((select f.fno, f.dateflight from flight f) minus (select t.fno, t.dateflight from ticket t where t.pid = p.pid))";
}
if (array_key_exists('purchaseAllFlights', $_POST)) {
require('sqlfn.php');
$username = $_COOKIE['username'];
$password = $_COOKIE['password'];
$db_conn = dbConn($username, $password);
$result = executePlainSQL($query);
OCICommit($db_conn);
dbDisconn($db_conn);
echo '<table border="3"><thead>' . '<td><b>Passenger ID</b></td>' . '<td><b>Name</b></td>' . '</thead>';
while ($row = OCI_Fetch_Array($result, OCI_BOTH)) {
echo "<tr align='center'>";
echo "<td>" . $row[0] . "</td>";
echo "<td>" . $row[1] . "</td>";
echo "</tr>";
}
echo '</table>';
} else if (array_key_exists('viewModelInfo', $_POST)) {
require('sqlfn.php');
$username = $_COOKIE['username'];
$password = $_COOKIE['password'];
$db_conn = dbConn($username, $password);
$result = executePlainSQL($query);
OCICommit($db_conn);
dbDisconn($db_conn);
echo '<table border="3"><thead>'.
'<td><b>Model No.</b></td>'.
'<td><b>Capacity</b></td>'.
'</thead>';
if ($print != true) {
return;
}
while ($row = OCI_Fetch_Array($result, OCI_BOTH)) {
echo "<tr align = 'center'>";
echo "<td>" . $row[0] . "</td>";
echo "<td>" . $row[1] . "</td>";
echo "</tr>";
}
echo '</table>';
}
else if (array_key_exists('viewModelInfoByCompany', $_POST)) {
require('sqlfn.php');
$username = $_COOKIE['username'];
$password = $_COOKIE['password'];
$db_conn = dbConn($username, $password);
if(!empty($_POST['check_list'])){
$result = executePlainSQL($query);
OCICommit($db_conn);
dbDisconn($db_conn);
$count=0;
echo '<table border="3"><thead>';
echo '<td><b>Company</b></td>';
foreach($_POST['check_list'] as $check) {
//echo $check;
if($check=="AVG(capacity)"){
echo '<td><b>Average Capacity</b></td>';
$count++;
}
if($check=="MAX(capacity)"){
echo '<td><b>Maximum Capacity</b></td>';
$count++;
}
if($check=="MIN(capacity)"){
echo '<td><b>Minimum Capacity</b></td>';
$count++;
}
if($check=="COUNT(capacity)"){
echo '<td><b>Count of unique Capacity</b></td>';
$count++;
}
}
echo '</thead>';
if ($print != true) {
return;
}
while ($row = OCI_Fetch_Array($result, OCI_BOTH)) {
echo "<tr align = 'center'>";
for($i=0;$i<=$count;$i++){
echo "<td>" . $row[$i] . "</td>";
}
echo "</tr>";
}
echo '</table>';
}
else{
echo '<table border="3"><thead>';
echo '<td><b>Company</b></td>';
echo '</thead>';
echo '</table>';
}
}
else
if ($hasRequiredFields) {
require('sqlfn.php');
$username = $_COOKIE['username'];
$password = $_COOKIE['password'];
$db_conn = dbConn($username, $password);
$result = executePlainSQL($query);
OCICommit($db_conn);
dbDisconn($db_conn);
if ($print){
echo '<table border="3"><thead>'.
'<td><b>Flight No.</b></td>'.
'<td><b>Departure Airport</b></td>'.
'<td><b>Arrival Airport</b></td>'.
'<td><b>Departure Date</b></td>'.
'<td><b>Arrival Date</b></td>'.
'</thead>';
while ($row = OCI_Fetch_Array($result, OCI_BOTH)) {
echo "<tr align='center'>";
echo "<td>" . $row[0] . "</td>";
echo "<td>" . $row[3] . "</td>";
echo "<td>" . $row[6] . "</td>";
echo "<td>" . $row[1] . "</td>";
echo "<td>" . $row[4] . "</td>";
echo "</tr>";
}
echo '</table>';
}
}
?>
</td></tr>
<!--?php
echo "<hr>";
include("cust.php");
echo "<hr>";
include("crew.php");
?>-->
</body>
</html>