Jump to content

Request: Flight Board


CrashGordon

Recommended Posts

Is it possible to have a flight board that first checks the system time and then displays the following.

Flight Number - Departure ICAO - Arrival - Aircraft - Status

This would be eye candy, rather than actual status, since most of us have more flights than pilots. The board would display only flights with an arrival time within 2 hours of system time. Flight status would, depending onwhere they are in relation to system time, be on time, arriving, arrived.

I suppose something similar could be done for departures, but I'm trying to keep it as simple as possible.

Does this sound like something that could be done? Or, maybe I should ask if it has already been done.

  • Like 3
Link to comment
Share on other sites

Is it possible to have a flight board that first checks the system time and then displays the following.

Flight Number - Departure ICAO - Arrival - Aircraft - Status

This would be eye candy, rather than actual status, since most of us have more flights than pilots. The board would display only flights with an arrival time within 2 hours of system time. Flight status would, depending onwhere they are in relation to system time, be on time, arriving, arrived.

I suppose something similar could be done for departures, but I'm trying to keep it as simple as possible.

Does this sound like something that could be done? Or, maybe I should ask if it has already been done.

Sounds like a good idea! hopefully it can be done

Link to comment
Share on other sites

Don't laugh, but I am trying to do it. Looking at code from other pages, trying to figure out what variable names I need, with one eye on the monitor and the other on a book on PHP.ohmy.gif The results, so far are either infuriating or hysterically funny. I don't know which is worse. My approach is this:

Get the system time and convert it to the 24 hour format I'm using in the routes.

Get the routes with arrival times that are equal to or plus/minus one hour to the system time.

Display those routes in a table with flight number, departure and arrival ICAOs, a/c tail number and verbiage based on how far from the system time the arrival time is.

Link to comment
Share on other sites

Don't laugh, but I am trying to do it. Looking at code from other pages, trying to figure out what variable names I need, with one eye on the monitor and the other on a book on PHP.ohmy.gif The results, so far are either infuriating or hysterically funny. I don't know which is worse. My approach is this:

Get the system time and convert it to the 24 hour format I'm using in the routes.

Get the routes with arrival times that are equal to or plus/minus one hour to the system time.

Display those routes in a table with flight number, departure and arrival ICAOs, a/c tail number and verbiage based on how far from the system time the arrival time is.

Is this what you want to do?

flightboard.jpg

http://xlvirtualairways.simmiles.com/arrivals.php

Link to comment
Share on other sites

Similar, but instead of the last two columns, a column with verbiage such as on time, arriving, landed, arrived (based on schedule time vs. system time). That way, any time the page was loaded, different flights would be displayed. A departure board could be done similarly, with different status verbiage.

Link to comment
Share on other sites

Similar, but instead of the last two columns, a column with verbiage such as on time, arriving, landed, arrived (based on schedule time vs. system time). That way, any time the page was loaded, different flights would be displayed. A departure board could be done similarly, with different status verbiage.

Well im defo interested. Something like that would be good :)

Link to comment
Share on other sites

  • Administrators

This is a pretty dirty way to do it (the sql query's really need to be in a data class, not in the page) but you could build a module around it

<?php
$query = "SELECT * FROM phpvms_schedules ORDER BY arrtime + 0 ASC";
$list = DB::get_results($query);
echo '<h3>Upcoming Arrivals - Current Time is '.date('G:i').'</h3>';
echo '<table width="100%" border="1">';
echo '<tr><td>Departure</td><td>Arrival</td><td>Arrival Time</td><td>Aircraft</td><td>Status</td></tr>';
$count = 0;
foreach($list as $flight)
{
   if(($flight->arrtime + 0) > date('G:i'))
   {
       if($count < 5)
       {
           $aircraft = OperationsData::getAircraftInfo($flight->aircraft);
           echo '<tr><td>'.$flight->depicao.'</td><td>'.$flight->arricao.'</td><td>'.$flight->arrtime.'</td><td>'.$aircraft->fullname.'</td>';
           echo '<td>';
           if(($flight->arrtime - date('G:i')) <= 1)
           {
               echo 'Arriving Soon';
           }
           else
           {
               echo 'In Flight';
           }
           echo '</td></tr>';
           $count++;
       }
   }
}
echo '</table>';
?>

This will show the next 5 flights scheduled to arrive and is written to work with 24 hour date format, so if you are using 12 hour date format with am/pm in your schedules you will have to modify the date function.

It should look something like

ar3.jpg

Pretty plain but you can build it up how you would like and skin it. B)

Link to comment
Share on other sites

  • Administrators

I wish I could report I've got it working, but if that happened, whatever would I do for the rest of the day.:D

Is there any output at all? Do you have any schedules or aircraft? It works for me here on ver 934. If there is any error please post it.

Link to comment
Share on other sites

I've obviously missed something I need to do, because it is only echoing the variables and some of the code. I don't know my you know what from my elbow, when it comes to php.

This is the output I get. I obviously have failed to do something necessary.:o I have about 30 aircraft and 700 routes. I've spent all day adding routes, so at this point I can't see straight. I'll look at this again in the morning to see if I can figure what I screwed up.

code.jpg

Link to comment
Share on other sites

  • Moderators

Hi, It looks looke you are adding this via the add page in the admin section, just add the code in to the frontpage_main,tpl, when i tried earlier nothing was displayed in the table ill have another look at it again because like the post says its great eye candy :)

Link to comment
Share on other sites

  • Administrators

I've obviously missed something I need to do, because it is only echoing the variables and some of the code. I don't know my you know what from my elbow, when it comes to php.

This is the output I get. I obviously have failed to do something necessary.:o I have about 30 aircraft and 700 routes. I've spent all day adding routes, so at this point I can't see straight. I'll look at this again in the morning to see if I can figure what I screwed up.

code.jpg

Remember that this is php coding - it needs to be enclosed in php tags - ie <?php and ?>

I have changed the original post to include them - sorry.

Link to comment
Share on other sites

  • Administrators

How strange is that, i have just done it again and its populated, it could be something to do with the time though, last night it was23:45 when i tried today its 11:04, ill let you know when it get to 13:00 if it still works.

If this is what you guys are looking for I will have to mess with it a little. Right now it is just looking for upcoming flights between the current time and midnight, it does not look "around the corner" until after midnight.

Link to comment
Share on other sites

Now, that I've got it working, I added the flight number.

code-2.jpg

If it helps others as clueless about PHP as I am, the code is here.

<?php 
$query = "SELECT * FROM phpvms_schedules ORDER BY arrtime + 0 ASC"; 
$list = DB::get_results($query); 
echo '<h3>Upcoming Arrivals - Current Time is '.date('G:i').'</h3>'; 
echo '<table width="100%" border="1">'; 
echo '<tr><td>Flight Number</td><td>Departure</td><td>Arrival</td><td>Arrival Time</td><td>Aircraft</td><td>Status</td></tr>'; 
$count = 0; 
foreach($list as $flight) 
{ 
if(($flight->arrtime + 0) > date('G:i')) 
{ 
   	if($count < 5) 
   	{ 
       	$aircraft = OperationsData::getAircraftInfo($flight->aircraft); 
       	echo '<tr><td>'.$flight->flightnum.'</td><td>'.$flight->depicao.'</td><td>'.$flight->arricao.'</td><td>'.$flight->arrtime.'</td><td>'.$aircraft->fullname.'</td>'; 
       	echo '<td>'; 
       	if(($flight->arrtime - date('G:i')) <= 1) 
       	{ 
           	echo 'Arriving Soon'; 
       	} 
       	else 
       	{ 
           	echo 'In Flight'; 
       	} 
       	echo '</td></tr>'; 
       	$count++; 
   	} 
} 
} 
echo '</table>'; 
?>

Now that you showed me how this type of thing is done, I'm doing a departure board.

Link to comment
Share on other sites

I have this in frontpage_mail.tpl, now. I have to look at the schedule to see if it is working as expected. I also have to explore having one table sort based on departure dime and the other on arrival time. When it is working properly, I'll post the code.

EDIT: I changed the code to get the departures working, though I still need to add another parameter to show recently departed flights.

frontpage2.jpg

Link to comment
Share on other sites

I pretty much expected this to happen when it got to this time of nite.

fperror.jpg

There is nothing to specify that the hour after 23 isn't 24, but 0.

I'm not sure I can cobble together the "correct" fix, but having the board down for 1 hour out of 24 is something I can live with. I suppose I could put some code in that if the"hour" is 23, it gets changed to 0. That would give me the same display for 2 hours, but there would be some flights listed.

Just thinking out loud here. It would probably mean that I couldn't display the current time twice, but that's no problem.

Some pseudo code here::blink:

get current time

display current time

if current time = 23

set current time to minus 1

else

proceed as normal

Would setting the current time to minus 1, then cause it to display flights beginning in the current time+1 (meaning 00:00 and after)? That would at least overcome the problem of no flights appearing.

Please don't laugh too loudly.:(

Link to comment
Share on other sites

  • Administrators

Give this a shot, works for me to get the flights after the midnight hour.

<?php
$query = "SELECT * FROM phpvms_schedules ORDER BY arrtime + 0 ASC";
$list = DB::get_results($query);
echo '<h3>Upcoming Arrivals - Current Time is '.date('G:i').'</h3>';
echo '<table width="100%" border="1">';
echo '<tr><td>Flight Number</td><td>Departure</td><td>Arrival</td><td>Arrival Time</td><td>Aircraft</td><td>Status</td></tr>';
$count = 0;
foreach($list as $flight)
{
   if(date('G:i') >= '23')
       {$time = '0';}
     else
       {$time = date('G:i');}
           if(($flight->arrtime + 0) > $time)
           {
           if($count < 5)
               {
                   $aircraft = OperationsData::getAircraftInfo($flight->aircraft);
                   echo '<tr><td>'.$flight->flightnum.'</td><td>'.$flight->depicao.'</td><td>'.$flight->arricao.'</td><td>'.$flight->arrtime.'</td><td>'.$aircraft->fullname.'</td>';
                   echo '<td>';
                   if(($flight->arrtime - $time) <= 1)
                   {
                   echo 'Arriving Soon';
                   }
                   else
                   {
                   echo 'In Flight';
                   }
                   echo '</td></tr>';
                   $count++;
               }
           }
}
echo '</table>';
?>

Link to comment
Share on other sites

Hey guys,

thanks for this solution!!

Is there any possibility that you post the php code for the departures as well? :-)

By the way, the time on my side is fine it's a 24h format. but the only problem is that my location the time is +6 hours... or is this zulu time?

Thanks again guys!

Lucas

ps. the data showing is not correct at the moment. should i wait a day?

www.serious-airlines.com

Link to comment
Share on other sites

This is what is running on my site, right now. Omega-Air Virtual Airlines

I reduced the width to 80% from 100% to fit my site better. I also reduced the table border from 1 to 0. I also changed the verbiage a little to suit my own taste.

	$query = "SELECT * FROM phpvms_schedules ORDER BY deptime + 0 ASC"; 
$list = DB::get_results($query); 
echo '<h3>Upcoming Departures - Current Time is '.date('G:i').'</h3>'; 
echo '<table width="80%" border="0">'; 
echo '<tr><td><b>Flight Number</b></td><td><b>Departure</b></td><td><b>Arrival</b></td><td><b>Departure Time</b></td><td><b>Aircraft</b></td><td><b>Status</b></td></tr>'; 
$count = 0; 
foreach($list as $flight) 
{ 
if(date('G:i') >= '23') 
   	{$time = '0';} 
 	else 
   	{$time = date('G:i');} 
       	if(($flight->deptime + 0) > $time) 
       	{ 
   	if($count < 10) 
   	{ 
       	$aircraft = OperationsData::getAircraftInfo($flight->aircraft); 
       	echo '<tr><td>'.$flight->flightnum.'</td><td>'.$flight->depicao.'</td><td>'.$flight->arricao.'</td><td>'.$flight->deptime.'</td><td>'.$aircraft->fullname.'</td>'; 
       	echo '<td>'; 
       	if(($flight->deptime - date('G:i')) <= 1) 
       	{ 
           	echo 'Now Boarding'; 
       	} 

  else
       	{ 
           	echo 'Scheduled Departure'; 
       	} 
       	echo '</td></tr>'; 
       	$count++; 
   	} 
} 
} 
echo '</table>';

echo '<h3>Upcoming Arrivals - Current Time is '.date('G:i').'</h3>'; 
echo '<table width="80%" border="0">'; 
echo '<tr><td><b>Flight Number</b></td><td><b>Departure</b></td><td><b>Arrival</b></td><td><b>Arrival Time</b></td><td><b>Aircraft</b></td><td><b>Status</b></td></tr>'; 
$count = 0; 
foreach($list as $flight) 
{ 
if(date('G:i') >= '23') 
   	{$time = '0';} 
 	else 
   	{$time = date('G:i');} 
       	if(($flight->arrtime + 0) > $time) 
       	{ 
   	if($count < 10) 
   	{ 
       	$aircraft = OperationsData::getAircraftInfo($flight->aircraft); 
       	echo '<tr><td>'.$flight->flightnum.'</td><td>'.$flight->depicao.'</td><td>'.$flight->arricao.'</td><td>'.$flight->arrtime.'</td><td>'.$aircraft->fullname.'</td>'; 
       	echo '<td>'; 
       	if(($flight->arrtime - date('G:i')) <= 1) 
       	{ 
           	echo 'Arriving Soon'; 
       	} 
       	else 
       	{ 
           	echo 'On Time'; 
       	} 
       	echo '</td></tr>'; 
       	$count++; 
   	} 
} 
} 
echo '</table>';  

I have it running in frontpage_main_tpl. If you want it as a stand-alone page, remember to it in in <?php and ?>

It isn't perfect, yet, but it does work. Not being proficient in PHP, I still have to figure out how to make it pretty.:D

Oops, almost forgot to mention this, but as it stands now, it is possible for the arrival board to show a flight as in flight or on time while it is still boarding in the departure board.:lol:

Link to comment
Share on other sites

I forgot to mention earlier, that I had kludged both the departure and arrival code into one blob. For that reason the sort is done on the departure ICAO, only. I'm working on displaying more statuses, such as on approach, final call, etc. I'm also trying to display these based on the number of minutes before and after the current time, rather than the hour.

Thanks to simpilot, the hard part is done. I'm just tinkering with bits and pieces.

Link to comment
Share on other sites

I waited for this hour because I figured when the server time hit 23 and the new code changed it to 0, the results would be interesting. First, there are flights in the schedule with departure or arrival times of 00:15 or similar. They don't appear because the forst hour after 0 is 01:00. And for some reason nothing displays as arriving soon or now boarding when some of them should show scheduled departure on time (in flight) instead of arriving soon. Still, there is only one hour in 24 that has this problem.

frontpage5.jpg

Here is what appears after the time goes to the next day.

frontpage6.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...