list.php
2.95 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
<?php
$GLOBALS['sked_params'] = $sked_params;
function setparam($key, $val) {
return setparams(array($key => $val));
}
function setparams($params) {
global $sked_params;
$i = false;
$stub = "?";
foreach ($params as $k => $v) {
if ($v) {
if ($i) $stub .= "&";
else $i = true;
$stub .= $k . "=" . $v;
}
}
foreach ($_GET as $k => $v) {
if (!array_key_exists($k, $params) && in_array($k, $sked_params)) {
if ($i) $stub .= "&";
else $i = true;
$stub .= $k . "=" . $v;
}
}
return htmlspecialchars($stub);
}
function setsort($key) {
if (isset($_GET['sort']) && $_GET['sort'] == $key) {
if (isset($_GET['order']) && strtoupper($_GET['order']) == "DESC") {
return setparam("order", "ASC");
} else {
return setparam("order", "DESC");
}
} else {
return setparams(array("sort" => $key,
"order" => "ASC"));
}
}
function sort_direction($key) {
if (isset($_GET['sort']) && $_GET['sort'] == $key) {
$order = isset($_GET['order']) ? strtoupper($_GET['order']) : "ASC";
if ($order == "ASC") return 1;
elseif ($order == "DESC") return -1;
}
return 0;
}
function sortind($key) {
$dir = sort_direction($key);
if ($dir > 0) {
return ' class="realops-sort-asc"';
} elseif ($dir < 0) {
return ' class="realops-sort-desc"';
} else {
return '';
}
}
?>
<h1>Flight Schedule</h1>
<h2>5 July 2014</h2>
<p>Filter: <a href="<?=setparam("filter", "dep")?>">Departures</a> |
<a href="<?=setparam("filter", "arr")?>">Arrivals</a> |
<a href="<?=setparam("filter", false)?>">All</a>
<br />Show: <a href="<?=setparam("show", "available")?>">Available</a> |
<a href="<?=setparam("show", false)?>">All</a></p>
<table class="table table-hover" id="realops-flight-schedule">
<thead>
<tr>
<th<?=sortind("acid")?>><a href="<?=setsort("acid")?>">Flight</a></th>
<th>Type</th>
<th<?=sortind("adep")?>><a href="<?=setsort("adep")?>">Origin</a></th>
<th<?=sortind("std")?>><a href="<?=setsort("std")?>">STD</a></th>
<th<?=sortind("ades")?>><a href="<?=setsort("ades")?>">Destination</a></th>
<th<?=sortind("sta")?>><a href="<?=setsort("sta")?>">STA</a></th>
<th>Booked by</th>
</tr>
</thead>
<tbody>
<?php
foreach ($flights as $flight) { ?>
<tr data-url="<?=Route::link('schedule/view', array('flightid' => $flight->id))?>">
<td><?=$flight->acid?></td>
<td><?=$flight->type?></td>
<td><?=$flight->adep?></td>
<td><?=date('H:i', strtotime($flight->std))?></td>
<td><?=$flight->ades?></td>
<td><?=date('H:i', strtotime($flight->sta))?></td>
<td><a href="<?=Route::link('schedule/view', array('flightid' => $flight->id))?>">
<?php
if ($flight->user) { ?>
<?=$flight->user->name?>
<?php
} else { ?>
<button type="button" class="btn btn-primary btn-xs">Book</button>
<?php
} ?></a>
</td>
</tr>
<?php
} ?>
</tbody>
</table>