Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / pilot.php
blob87a13840e0cd80161ba26d28740b2b8d755e8f1a
1 <?php
2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Language.php');
5 require_once('require/class.Stats.php');
6 require_once('require/class.Common.php');
8 if (isset($_POST['pilot']))
10 header('Location: '.$globalURL.'/pilot/'.filter_input(INPUT_POST,'pilot',FILTER_SANITIZE_STRING));
11 //} else if (isset($_GET['airport'])){
12 } else {
13 $Spotter= new Spotter();
14 $Stats = new Stats();
15 $Common = new Common();
16 $title = _("Pilots");
17 require_once('header.php');
18 print '<div class="column">';
19 print '<h1>'._("Pilots").'</h1>';
20 $pilot_names = $Stats->getAllPilotNames();
21 if (empty($pilot_names)) {
22 $pilot_names = $Spotter->getAllPilotNames();
24 //ksort($pilot_names);
25 $previous = null;
26 print '<div class="alphabet-legend">';
27 foreach($pilot_names as $value) {
28 $firstLetter = strtoupper($Common->replace_mb_substr($value['pilot_name'], 0, 1));
29 if($previous !== $firstLetter && $firstLetter != "'")
31 if ($previous !== null){
32 print ' | ';
34 print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>';
36 if ($firstLetter != "'") $previous = $firstLetter;
38 print '</div>';
39 $previous = null;
40 foreach($pilot_names as $value) {
41 $firstLetter = strtoupper($Common->replace_mb_substr($value['pilot_name'], 0, 1));
42 if ($firstLetter != "")
44 if($previous !== $firstLetter && $firstLetter != "'")
46 if ($previous !== null){
47 print '</div>';
49 print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">';
51 if ($firstLetter != "'") $previous = $firstLetter;
52 print '<div class="alphabet-item">';
53 if (isset($value['pilot_id']) && $value['pilot_id'] != '') print '<a href="'.$globalURL.'/pilot/'.$value['pilot_id'].'">'.$value['pilot_name'].' ('.$value['pilot_id'].')';
54 else print '<a href="'.$globalURL.'/pilot/'.$value['pilot_name'].'">'.$value['pilot_name'];
55 print '</a>';
56 print '</div>';
59 print '</div>';
62 require_once('footer.php');