Jump to content

Recent 5 Flights


Jeff

Recommended Posts

I'm trying to show a table of the 5 recent flights flown, and keep running into a brick wall here. Can someone please post the code to show the last 5 flight.

Flight Number - Departure Airport - Arrival Airport - Flight Time - Pilot - Landing %

Link to comment
Share on other sites

Guest lorathon

Here you go

<?php MainController::Run('PIREPS', 'RecentFrontPage', 5); ?>

or to just get the data

<?php

$count = 5;
$pireps = PIREPData::getRecentReportsByCount($count);

?>

Link to comment
Share on other sites

Guest lorathon

try this

<?php
$count = 5;
$pireps = PIREPData::getRecentReportsByCount($count);
?>

<table>
  <thead>
    <tr>
      <th>Flight #</th>
      <th>Departure</th>
      <th>Arrival</th>
      <th>Duration</th>
      <th>Pilot</th>
      <th>Landing Rate</th>
    </tr>
   </thead>
   <tbody>

<?php

if(count($pireps) > 0)
{
 foreach ($pireps as $pirep)
 {
   $pilotinfo = PilotData::getPilotData($pirep->pilotid);
   $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid); 

   echo '<tr>';
   echo '<td>'.$pirep->code.$pirep->flightnum.'</td>';
   echo '<td>'.$pirep->depicao.'</td>';
   echo '<td>'.$pirep->arricao.'</td>';
   echo '<td>'.$pirep->flighttime.'</td>';
   echo '<td>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</td>';
   echo '<td>'.$pirep->landingrate.'</td>';
   echo '</tr>';
 }
}
else
{
   echo '<tr><td>There are no recent flights!</td></tr>';
}
?>
  </tbody>
</table>

Edited by lorathon
EDITED to repair code - Code is 100%
Link to comment
Share on other sites

Parse error: syntax error, unexpected $end in /home/oneworld/public_html/lib/skins/crystal-II/frontpage_main.tpl on line 162

This is line 162
</div>

Here is the whole code for that page
<div id="mainbox">
<h3>Welcome To One World Virtual</h3>
<?php

// Show the News module, call the function ShowNewsFront
//	This is in the modules/Frontpage folder

MainController::Run('News', 'ShowNewsFront', 5);
?>
<?php
       $flights = PIREPData::getRecentReportsByCount(15);                                                                      
       $string = "";
       foreach($flights as $flight)
       {       
            $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+';
       }                                                                       
       ?>
       <table>
         <tr>
           <th>LAST 15 FLIGHT LEGS</th>
         </tr>
         <tr>
           <td><p align="center"><img src="http://www.gcmap.com/map?P=<?php echo $string ?>&MS=bm&MR=240&MX=690x360&PM=pemr:diamond7:red%2b%22%25I%22:red&PC=%230000ff" /><br />
             Maps generated by the <a href="http://www.gcmap.com/">Great Circle Mapper</a> - copyright © <a href="http://www.kls2.com/~karl/">Karl L. Swartz</a>.</p></td>
             </tr>
                   </table>
                   <?php
$count = 5;
$pireps = PIREPData::getRecentReportsByCount($count);
?>

<table>
  <thead>
    <tr>
      <th>Flight #</th>
      <th>Departure</th>
      <th>Arrival</th>
      <th>Duration</th>
      <th>Pilot</th>
      <th>Landing Rate</th>
    </tr>
   </thead>
   <tbody>

<?php

if(count($pireps) > 0)
{
 foreach ($pireps as $pirep)
 {
   $pilotinfo = PilotData::getPilotData($pirep->pilotid);
   $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid); 

   echo "<tr>";
   echo "<td>'.$pirep->code.$pirep->flighnum.'</td>";
   echo "<td>'.$pirep->depicao.'</td>";
   echo "<td>'.$pirep->arricao.'</td>";
   echo "<td>'.$pirep->flighttime.'</td>";
   echo "<td>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</td>";
   echo "<td>'.$pirep->landingrate.'</td>";
   echo "</tr>";
 }
}
else
{
   echo "<tr><td>There are no recent flights!</td></tr>";
?>
  </tbody>
</table>


</div>

</div>


<div id="sidebar">
 <h3>Pilot Center</h3>


	<?php 
	/* 
	Quick example of how to see if they're logged in or not
	Only show this login form if they're logged in */
	if(Auth::LoggedIn() == false)
	{ ?>
		<form name="loginform" action="<?php echo url('/login'); ?>" method="post">
			<p>Log in to your pilot center or <a href="<?php echo url('/registration'); ?>">register</a><br />
		<input type="text" name="email" value="Email/Pilot ID" onClick="this.value=''" />
			</p>
			<p>
			  <input type="password" name="password" value="Password" />
		  </p>
			<p>
			  <input type="hidden" name="remember" value="on" />
			  <input type="hidden" name="redir" value="index.php/profile" />
			  <input type="hidden" name="action" value="login" />
			  <input type="submit" name="submit" value="Log In" />
		  </p>
 </form>
		<p>
		<?php
	}	
	/* End the Auth::LoggedIn() if */
	else /* else - they're logged in, so show some info about the pilot, and a few links */
	{

	/*	Auth::$userinfo has the information about the user currently logged in
		We will use this next line - this gets their full pilot id, formatted properly */
	$pilotid = PilotData::GetPilotCode(Auth::$userinfo->code, Auth::$userinfo->pilotid);
	?>
	    <strong>Pilot ID: </strong> <?php echo $pilotid ; ?>
	    <strong>Rank: </strong><?php echo Auth::$userinfo->rank;?><br />
	    <strong>Total Flights: </strong><?php echo Auth::$userinfo->totalflights?>, <strong>Total Hours: </strong><?php echo Auth::$userinfo->totalhours;?>
	<br /><?php
	} /* End the else */
	?>

 </p>
		<p>
		  <?php MainController::Run('Mail', 'checkmail'); ?>
		</p>
<h3>Recent Reports</h3>

<?php MainController::Run('PIREPS', 'RecentFrontPage', 5); ?>

<h3>Newest Pilots</h3>

<p>
  <?php MainController::Run('Pilots', 'RecentFrontPage', 5); ?>
 </p>
<h3>Airline Stats</h3>
<p><strong>Total Schedules: </strong><?php echo StatsData::totalschedules(); ?></p>
<p><strong>Total Aircraft: </strong><?php echo StatsData::TotalAircraftInFleet(); ?></p>
<p><strong>Total Pilots: <?php echo StatsData::PilotCount(); ?></strong></p>
<p><strong>Miles Flown: </strong><?php echo StatsData::TotalMilesFlown(); ?></p>
       <p><strong>Total Flights Flown: </strong><?php echo StatsData::TotalFlights(); ?></p>
       <p><strong>Total Hours Flown: </strong><?php echo StatsData::TotalHours(); ?></p>
       <p><strong>Passengers Carried: </strong><?php echo StatsData::TotalPaxCarried(); ?></p>
       <p><strong>Fuel Burned (lbs.): </strong><?php echo StatsData::TotalFuelBurned(); ?></p>
       <p><strong>Avg Landing Rate: </strong><?php echo ''.round(TouchdownStatsData::airline_average('airline'), 2); ?></p>
       <p><strong>Total Flights Today: </strong><?php echo StatsData::totalflightstoday(); ?></p>
       <p><strong>Total Cargo Carried: </strong><?php echo StatsData::TotalCargoCarried(); ?>
<h3>Users Online</h3>
<?php
      foreach($usersonline as $pilot)  

       {

               echo "<p>";
               echo '<img src="'.Countries::getCountryImage($pilot->location).'" alt="'.Countries::getCountryName($pilot->location).'" />';
               echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid). ' ' .$pilot->firstname . ' ' . $pilot->lastname; 
               echo "</p>";

       }


       ?>
              <br />
              Have <?php echo count($usersonline);?> Pilots Online.
              <h3 class="style3">Guests Online </h3>
              <p class="txt-red10"> Have <?php echo count($guestsonline);?> Guests Online.</div>
</div>

Link to comment
Share on other sites

Guest lorathon

I can not get this to show the full flight Number. As we have 5 Wings(Airlines) it only show the letters of the Wings(Airlines) but not the actual flight number. EX. VMC1001 just will show as VMC or 57V0401-1 will only show 57V. any Ideas? :D

thanks

Try it on more time. I had a type on the flightnum call. Original code is repaired again :D

Link to comment
Share on other sites

  • 6 months later...

Hi guys. I know this post is real old and I hate to necro post, but I must.

I have been itching to add this for a long time but never got around to it. I used the code posted above and it shows up on my site but with some errors.

When it outputs the data to the table it shows up like this :

tableerror.jpg

I have been trying to fix it, but not sure what is going on. Would love some guiding light.

Thanks in advance.

Ray

Link to comment
Share on other sites

Fixed! I got rid of all the " and replaced with ' .

Now I want to get rid of the landing rate and add Status. So it would show Pending, Accepted, Rejected etc,etc.

I tried nabbing the code from the viewall_pireps.tpl but it just tossed me out a syntax error.

Here is the code tossing the error at me. It is the first div line where it says accepted.

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/xxxxxx/public_html/xxxxxx/lib/skins/brilliancev1/frontpage_main.tpl on line 87

<?php

if(count($pireps) > 0)
{
 foreach ($pireps as $pirep)
 {
   $pilotinfo = PilotData::getPilotData($pirep->pilotid);
   $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid); 

   echo '<tr>';
   echo '<td><center>'.$pirep->code.$pirep->flightnum.'</center></td>';
   echo '<td><center>'.$pirep->depicao.'</center></td>';
   echo '<td><center>'.$pirep->arricao.'</center></td>';
   echo '<td><center>'.$pirep->flighttime.'</center></td>';
   echo '<td><center>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</center></td>';
   echo '<td><?php

	if($pirep->accepted == PIREP_ACCEPTED)
		echo '<div id="success">Accepted</div>';
	elseif($pirep->accepted == PIREP_REJECTED)
		echo '<div id="error">Rejected</div>';
	elseif($pirep->accepted == PIREP_PENDING)
		echo '<div id="error">Pending</div>';
	elseif($pirep->accepted == PIREP_INPROGRESS)
		echo '<div id="error">In Flight</div>';

	?></td>';
   echo '</tr>';
 }
}
else
{
   echo '<tr><td>There are no recent flights!</td></tr>';
}
?>

It is no biggie if I do not get it to work since it is on a dev site only, but would be real nice to get the flight status to work.

And please do ignore all of the center and end center tags. I know they are not right. I just hadn't got to do it the right way yet. ;)

Link to comment
Share on other sites

Anyone got a working copy of this they would care to share? Meaning just for flight status. I got all the rest of it working smoothly. I don't need the touchdown rate so I scrapped it in hopes of getting the flight status in there instead. Like Accepted, pending, Rejected.

Link to comment
Share on other sites

Guest lorathon
<?php
$count = 5;
$pireps = PIREPData::getRecentReportsByCount($count);
?>

<table>
  <thead>
    <tr>
      <th>Flight #</th>
      <th>Departure</th>
      <th>Arrival</th>
      <th>Duration</th>
      <th>Pilot</th>
      <th>Status</th>
    </tr>
   </thead>
   <tbody>

<?php

if(count($pireps) > 0)
{
 foreach ($pireps as $pirep)
 {
   $pilotinfo = PilotData::getPilotData($pirep->pilotid);
   $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);

   if($pirep->accepted == '0') $status = 'PENDING';
   if($pirep->accepted == '1') $status = 'ACCEPTED';
   else $status = 'REJECTED'; 

   echo '<tr>';
   echo '<td>'.$pirep->code.$pirep->flightnum.'</td>';
   echo '<td>'.$pirep->depicao.'</td>';
   echo '<td>'.$pirep->arricao.'</td>';
   echo '<td>'.$pirep->flighttime.'</td>';
   echo '<td>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</td>';
   echo '<td>'.$status.'</td>';
   echo '</tr>';
 }
}
else
{
   echo '<tr><td>There are no recent flights!</td></tr>';
}
?>
  </tbody>
</table>

Link to comment
Share on other sites

Guest lorathon

With link to pirep report on flight number.

<?php
$count = 5;
$pireps = PIREPData::getRecentReportsByCount($count);
?>

<table>
  <thead>
    <tr>
      <th>Flight #</th>
      <th>Departure</th>
      <th>Arrival</th>
      <th>Duration</th>
      <th>Pilot</th>
      <th>Status</th>
    </tr>
   </thead>
   <tbody>

<?php

if(count($pireps) > 0)
{
 foreach ($pireps as $pirep)
 {
   $pilotinfo = PilotData::getPilotData($pirep->pilotid);
   $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);

   if($pirep->accepted == '0') $status = 'PENDING';
   if($pirep->accepted == '1') $status = 'ACCEPTED';
   else $status = 'REJECTED'; 

   echo '<tr>';
   echo '<td><a href="'.SITE_URL.'/index.php/pireps/viewreport/'.$pirep->pirepid.'">'.$pirep->code.$pirep->flightnum.'</a></td>';
   echo '<td>'.$pirep->depicao.'</td>';
   echo '<td>'.$pirep->arricao.'</td>';
   echo '<td>'.$pirep->flighttime.'</td>';
   echo '<td>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</td>';
   echo '<td>'.$status.'</td>';
   echo '</tr>';
 }
}
else
{
   echo '<tr><td>There are no recent flights!</td></tr>';
}
?>
  </tbody>
</table>

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