Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / accident-detailed.php
blobc18952f0016a5a7825d1af21cdcef385f09f3f30
1 <?php
2 require_once('require/class.Connection.php');
3 require_once('require/class.Accident.php');
4 require_once('require/class.Language.php');
5 $Accident = new Accident();
6 $title = _("Latest accidents");
7 require_once('header.php');
8 $page_url = $globalURL.'/accident-detailed';
9 if (!isset($_GET['date']))
11 $date = date('Y-m-d');
12 } else {
13 $date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
16 if(!isset($_GET['limit']))
18 $limit_start = 0;
19 $limit_end = 25;
20 $absolute_difference = 25;
21 } else {
22 $limit_explode = explode(",", $_GET['limit']);
23 $limit_start = $limit_explode[0];
24 $limit_end = $limit_explode[1];
25 if (!ctype_digit(strval($limit_start)) || !ctype_digit(strval($limit_end))) {
26 $limit_start = 0;
27 $limit_end = 25;
30 $absolute_difference = abs($limit_start - $limit_end);
31 $limit_next = $limit_end + $absolute_difference;
32 $limit_previous_1 = $limit_start - $absolute_difference;
33 $limit_previous_2 = $limit_end - $absolute_difference;
35 print '<div class="select-item">';
36 print '<form action="'.$globalURL.'/accident" method="post" class="form-inline">';
37 print '<div class="form-group">';
38 print '<label for="datepickeri">'._("Select a Date").'</label>';
39 print '<div class="input-group date" id="datepicker">';
40 print '<input type="text" class="form-control" id="datepickeri" name="date" value="" />';
41 print '<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>';
42 print '</div>';
43 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
44 print '</div>';
45 print '</form>';
46 print '</div>';
47 print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ keepInvalid: true, useStrict: false, format: "YYYY-MM-DD", extraFormats: ["YYYY-MM"], defaultDate: "'.$date.'"}); }); </script>';
48 print '<br />';
50 print '<div class="info column">';
51 if (preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/',$date)) {
52 print '<h1>'.sprintf(_("Accidents from %s"),date("l F j, Y",strtotime($date))).'</h1>';
53 } elseif (preg_match('/^[0-9]{4}-[0-9]{2}$/',$date)) {
54 print '<h1>'.sprintf(_("Accidents from %s"),date("F, Y",strtotime($date))).'</h1>';
55 } elseif (preg_match('/^[0-9]{4}$/',$date)) {
56 print '<h1>'.sprintf(_("Accidents from %s"),$date).'</h1>';
58 print '</div>';
60 print '<div class="table column">';
62 if (preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/',$date)) {
63 print '<p>'.sprintf(_("The table below shows the Accidents on <strong>%s</strong>."),date("l M j, Y",strtotime($date))).'</p>';
64 } elseif (preg_match('/^[0-9]{4}-[0-9]{2}$/',$date)) {
65 print '<p>'.sprintf(_("The table below shows the Accidents on <strong>%s</strong>."),date("M, Y",strtotime($date))).'</p>';
66 } elseif (preg_match('/^[0-9]{4}$/',$date)) {
67 print '<p>'.sprintf(_("The table below shows the Accidents on <strong>%s</strong>."),$date).'</p>';
69 $spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference,'accident',$date);
70 //print_r($spotter_array);
71 if (!empty($spotter_array) && isset($spotter_array[0]['query_number_rows']) && $spotter_array[0]['query_number_rows'] != 0) {
72 include('table-output.php');
73 print '<div class="pagination">';
74 if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$date.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
75 if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$date.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
76 print '</div>';
78 print '</div>';
80 require_once('footer.php');