Jump to content

Request: Flight Board


CrashGordon

Recommended Posts

here is the flight board i'm using.I am using obsessblue skin, you may need to add the font colour to you stylesheet.css in this example.

flight-schedule.jpg

the code in frontpage.tpl placed where you want the table to show.

<?php


#
#
$query = "SELECT * FROM phpvms_schedules ORDER BY deptime + 0 ASC";
#
       $list = DB::get_results($query);
#
       echo '<h3>Expected Departures - Current Time is '.date('G:i').'</h3>';
#
       echo '<table width="90%" border="1" bgcolor="#030A0A" >';
#
       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 < 5) {
#
                   $aircraft = OperationsData::getAircraftInfo($flight->aircraft);
                   $depname = OperationsData::RetrieveAirportInfo($flight->depicao);
				$arrname = OperationsData::RetrieveAirportInfo($flight->arricao);
#
                   echo '<tr><td>'.$flight->flightnum.'</td><td>'.$depname->name.'</td><td>'.$arrname->name.'</td><td>'.$flight->deptime.'</td><td>'.$aircraft->fullname.'</td>';
#
                   echo '<td>';
#
                   $minutes = explode(':', $flight->deptime);
#
                   if($minutes['0'] <= date('G')) {
#
                       if(($minutes['1'] - date('i')) <= 0) {
#
                           echo 'Departed';
#
                       }
#
                       elseif(($minutes['1'] - date('i')) <= 15 && ($minutes['1'] - date('i')) >= 1) {
#
                           echo 'Final Call';
#
                       }
#
                       elseif(($minutes['1'] - date('i')) >= 30 && ($minutes['1'] - date('i')) <= 20) {
#
                           echo 'Proceed to Gate';
#
                       }
#
                       else {
#
                           echo 'Scheduled Departure';
#
                       }
#
                   }
#
                   else {
#
                       echo 'Scheduled Departure';
#
                   }
#
                   echo '</td></tr>';
#
                   $count++;
#
               }
#
           }
#
       }
#
       echo '</table>';
#

#
       echo '<h3>Expected Arrivals - Current Time is '.date('G:i').'</h3>';
#
       echo '<table width="90%" border="1" bgcolor="#030A0A" >';
#
       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 < 5) {
#
                   $aircraft = OperationsData::getAircraftInfo($flight->aircraft);
                   $depname = OperationsData::RetrieveAirportInfo($flight->depicao);
				$arrname = OperationsData::RetrieveAirportInfo($flight->arricao);
#
                   echo '<tr><td>'.$flight->flightnum.'</td><td>'.$depname->name.'</td><td>'.$arrname->name.'</td><td>'.$flight->arrtime.'</td><td>'.$aircraft->fullname.'</td>';
#
                   echo '<td>';
#
                   $minutes2 = explode(':', $flight->arrtime);
#
                   if($minutes2['0'] <= date('G')) {
#
                       if($minutes2['1'] - (date('i')) >= 30) {
#
                           echo 'On Time';
#
                       }
#
                       elseif(($minutes2['1'] - date('i')) >= 1 && ($minutes2['1'] - date('i')) <= 30) {

#
                           echo 'On Approach';
#
                       }
#
                       else {
#
                           echo 'Landed';
#
                       }
#

#
                   }
#
                   else {
#
                       echo 'On Time';
#
                   }
#
                   echo '</td></tr>';
#
                   $count++;
#
               }
#
           }
#
       }
#
       echo '</table>';



       $flights = PIREPData::getRecentReportsByCount(10);                                                                      
       $string = "";
       foreach($flights as $flight)
       {       
            $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+';
       }                                                                       
       ?>

the text color change in stylesheet.css

.mc020301
{
font-size: 12px;
color: #FFC600;
line-height: 18px;
letter-spacing: -0.1px;
width: 700px;

ideally i always set up a duplicate site for development purposes.

Link to comment
Share on other sites

  • 1 month later...

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)

please someone help me, I put the same code in my virtual airline, and now I have problem with the area of the map, the map can not see anything. remove the code again but the problem persists.

can someone please help me solve this problem?

Link to comment
Share on other sites

  • 1 month later...

I cant get this right, allways having this warnings...

Warning: Invalid argument supplied for foreach() in /home/croatia/public_html/russian/lib/skins/ObsessBlue/frontpage_main.tpl on line 68

Warning: Invalid argument supplied for foreach() in /home/croatia/public_html/russian/lib/skins/ObsessBlue/frontpage_main.tpl on line 106

Template iz in skin folder, is that have something to do because of dbase?

Thank you

Link to comment
Share on other sites

Hallo ich möchte das bei uns auf der Webseite auch darstellen aber wenn ich den Code in die Front_main.tpl speichere dann erscheint nix und wenn ich das php am Anfang weglasse dann werden die Variablen nicht aufgelöst.

Kann mir jemand eine Anleitung geben wie ich das einfüge?

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Hi I want to represent us on your website but when I save the code in the Front_main.tpl appears then nothing and if I leave out the php to the beginning then the variables are not resolved.

Can anyone give an explanation on how I add it?

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Hi guys,

Happy New Year!

I have a question, I've been trying to add the flightboard and it is working partially. I have adjusted the code which can be found elsewhere in this topic to reflect our circumstances etc. but the flight board comes up with a few gaps.

First, the code I used/altered

<?php

$h = "6";// Hour for time zone goes here e.g. +7 or -4, just remove the + or -
$hm = $h * 60;
$ms = $hm * 60;
$gmdate = gmdate("H:i", time()+($ms));

#
#
$query = "SELECT * FROM phpvms_schedules WHERE deptime>='$gmdate' AND depicao='UAAA' ORDER BY deptime";
#
       $list = DB::get_results($query);
#
       echo '<h1>Almaty Departures - Current time is '.$gmdate.'</h1>';
#
       echo '<table width="100%" border="1" bgcolor="#FFFFFF" >';
#
       echo '<tr><td><b>Flight Number</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 < 5) {
#
                   $aircraft = OperationsData::getAircraftInfo($flight->aircraft);
                   $depname = OperationsData::RetrieveAirportInfo($flight->depicao);
                                       $arrname = OperationsData::RetrieveAirportInfo($flight->arricao);
#
                   echo '<tr><td>TZE'.$flight->flightnum.'</td><td>'.$arrname->name.'</td><td>'.$flight->deptime.'</td><td>'.$aircraft->fullname.'</td>';
#
                   echo '<td>';
#
                   $minutes = explode(':', $flight->deptime);
#
                   if($minutes['0'] <= date('G')) {
#
                       if(($minutes['1'] - date('i')) <= 0) {
#
                           echo 'Departed';
#
                       }
#
                       elseif(($minutes['1'] - date('i')) <= 15 && ($minutes['1'] - date('i')) >= 1) {
#
                           echo 'Final Call';
#
                       }
#
                       elseif(($minutes['1'] - date('i')) >= 30 && ($minutes['1'] - date('i')) <= 20) {
#
                           echo 'Proceed to Gate';
#
                       }
#
                       else {
#
                           echo 'Scheduled Departure';
#
                       }
#
                   }
#
                   else {
#
                       echo 'Scheduled Departure';
#
                   }
#
                   echo '</td></tr>';
#
                   $count++;
#
               }
#
           }
#
       }
#
       echo '</table>';
#

#
       echo '<h1>Expected Arrivals - Current Time is '.date('G:i').'</h1>';
#
       echo '<table width="90%" border="1" bgcolor="#FFFFFF" >';
#
       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 < 5) {
#
                   $aircraft = OperationsData::getAircraftInfo($flight->aircraft);
                   $depname = OperationsData::RetrieveAirportInfo($flight->depicao);
                                       $arrname = OperationsData::RetrieveAirportInfo($flight->arricao);
#
                   echo '<tr><td>TZE'.$flight->flightnum.'</td><td>'.$depname->name.'</td><td>'.$arrname->name.'</td><td>'.$flight->arrtime.'</td><td>'.$aircraft->fullname.'</td>';
#
                   echo '<td>';
#
                   $minutes2 = explode(':', $flight->arrtime);
#
                   if($minutes2['0'] <= date('G')) {
#
                       if($minutes2['1'] - (date('i')) >= 30) {
#
                           echo 'On Time';
#
                       }
#
                       elseif(($minutes2['1'] - date('i')) >= 1 && ($minutes2['1'] - date('i')) <= 30) {

#
                           echo 'On Approach';
#
                       }
#
                       else {
#
                           echo 'Landed';
#
                       }
#

#
                   }
#
                   else {
#
                       echo 'On Time';
#
                   }
#
                   echo '</td></tr>';
#
                   $count++;
#
               }
#
           }
#
       }
#
       echo '</table>';



       $flights = PIREPData::getRecentReportsByCount(10);                                                                      
       $string = "";
       foreach($flights as $flight)
       {       
            $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+';
       }                                                                       

			?>	

Here's a screenshot of what I mean - problempic.jpg

Note the gap in the destination on the second or so line. Don't know how that happens? Maybe this has something to do with flights that don't happen each day?

Also, the code suggests the status should receive updates from Scheduled Departure to Go To Gate etc. and that's not happening either.

As I know pretty much not a great deal about PHP, could anyone please suggest any solutions?

Many thanks

Peter

Link to comment
Share on other sites

Sorry everyone. I forgot I posted in this thread. The code I am using is the code that Simpilot gave us all. The only thing I have changed is some css stuff. You will nee to find where I edited it and redo it to fit your site. Other then that, like I said it is IDENTICAL to what Simpilot released. I have not altered any php or sql.

<?php
$query = "SELECT * FROM phpvms_schedules ORDER BY arrtime + 0 ASC";
$list = DB::get_results($query);
echo '<center><h3>Upcoming Arrivals - Current Time is '.date('G:i').'</h3></center>';
echo '<table width="98%" cellpadding="3" cellspacing="1" border="0">';
echo '<tr><th>Departure</th><th>Arrival</th><th>Arrival Time</th><th>Aircraft</th><th>Status</th></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><center>'.$flight->depicao.'</center></td><td><center>'.$flight->arricao.'</td></center><td><center>'.$flight->arrtime.'</td></center><td><center>'.$aircraft->fullname.'</td></center>';
           echo '<td><center>';
           if(($flight->arrtime - date('G:i')) <= 1)
           {
               echo 'Arriving Soon';
           }
           else
           {
               echo 'In Flight';
           }
           echo '</td></center></tr>';
           $count++;
       }
   }
}
echo '</table>';
?>
	<br />

Link to comment
Share on other sites

Sorry everyone. I forgot I posted in this thread. The code I am using is the code that Simpilot gave us all. The only thing I have changed is some css stuff. You will nee to find where I edited it and redo it to fit your site. Other then that, like I said it is IDENTICAL to what Simpilot released. I have not altered any php or sql. Er uhhhh I think it was Simpilot. If not I apologize to the Author. ;)

And please note that around midnight...ish, the table is going to go blank. If does not like to pull data from 23:00-24:00 or something like that. THe rest of the day it works great.

<?php
$query = "SELECT * FROM phpvms_schedules ORDER BY arrtime + 0 ASC";
$list = DB::get_results($query);
echo '<center><h3>Upcoming Arrivals - Current Time is '.date('G:i').'</h3></center>';
echo '<table width="98%" cellpadding="3" cellspacing="1" border="0">';
echo '<tr><th>Departure</th><th>Arrival</th><th>Arrival Time</th><th>Aircraft</th><th>Status</th></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><center>'.$flight->depicao.'</center></td><td><center>'.$flight->arricao.'</td></center><td><center>'.$flight->arrtime.'</td></center><td><center>'.$aircraft->fullname.'</td></center>';
           echo '<td><center>';
           if(($flight->arrtime - date('G:i')) <= 1)
           {
               echo 'Arriving Soon';
           }
           else
           {
               echo 'In Flight';
           }
           echo '</td></center></tr>';
           $count++;
       }
   }
}
echo '</table>';
?>
	<br />

Link to comment
Share on other sites

  • 5 weeks later...

I am not sure if this would help, but in my phpvms DB the table for schedules is named schedules not phpvms_schedules, so check it out. Guess you get that error since array list$ is empty, due to the naming error of the table in the SQL.

To get date converted. You seem to not need all the fields in the query, use rather this selec function:

select id, depicao, arricao, date_format(convert_TZ(concat(curdate()," ", left(deptime,5)) , '+00:00','+2:00'),'%T') as 'deptime',
date_format(convert_TZ(concat(curdate()," ", left(arrtime,5)), '+00:00','+2:00'),'%T') as 'arrtime', aircraft, daysofweek from schedules
where instr(daysofweek,'6')>0 order by arrtime ASC

Make a php variable which finds out which day of week it is, and convert to a value that fits in with the daysofweek field.

<$php $curday=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y")); ?>

or something... and put $curday in to where clause rather than six. This query will select all flight for a saturday.

To convert the time to local, change the timenumbera after the both '+' om the sql. The first is the time relative to GMT and second is your relative to GMT.

I have not testet other than as pure SQL directly on the server. So test at own risk.

Regards

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...