Fleet Table

Can someone please post the code to show which member was the last one to fly the aircraft so it will show up in the table as well? Thanx

This was exactly what I was about to ask!

Would be a great addition to a great module!!

Reasin being …

I duplicated then renamed the original fleet table and edited the out put only to display;

Type

Rego

Location - Location

Now all I need is the last pilot who flew it.

Then I can promote the Module as “Last Known Whereabouts” giving pilots the incentive to take that aircraft and fly it to where they want to go.

Any assistance in coding would be mostly appreciative.

Thanks in advance

Adam

AUZ

I’ve noticed the table lists the planes in order by their registration.

Example:

MD87 MD-87 N214AM 0 0 130 10000 0

MD88 MD-88 N401NV 0 0 150 15000 0

MD88 MD-88 N402NV 0 0 150 15000 0

MD88 MD-88 N403NV 0 0 150 15000 0

MD88 MD-88 N404NV 0 0 150 15000 0

MD83 MD-83 N405NV 0 0 150 15000 0

MD82 MD-82 N406NV 0 0 150 15000 0

MD82 MD-82 N407NV 0 0 150 15000 0

MD82 MD-82 N408NV 0 0 150 15000 0

How do we set it so that it lists in order by aircraft type ?

MD82 MD-82 N406NV 0 0 150 15000 0

MD82 MD-82 N407NV 0 0 150 15000 0

MD82 MD-82 N408NV 0 0 150 15000 0

MD83 MD-83 N405NV 0 0 150 15000 0

MD87 MD-87 N214AM 0 0 130 10000 0

MD88 MD-88 N401NV 0 0 150 15000 0

MD88 MD-88 N402NV 0 0 150 15000 0

MD88 MD-88 N403NV 0 0 150 15000 0

MD88 MD-88 N404NV 0 0 150 15000 0

I’ve noticed the table lists the planes in order by their registration.

Example:

MD87 MD-87 N214AM 0 0 130 10000 0

MD88 MD-88 N401NV 0 0 150 15000 0

MD88 MD-88 N402NV 0 0 150 15000 0

MD88 MD-88 N403NV 0 0 150 15000 0

MD88 MD-88 N404NV 0 0 150 15000 0

MD83 MD-83 N405NV 0 0 150 15000 0

MD82 MD-82 N406NV 0 0 150 15000 0

MD82 MD-82 N407NV 0 0 150 15000 0

MD82 MD-82 N408NV 0 0 150 15000 0

How do we set it so that it lists in order by aircraft type ?

MD82 MD-82 N406NV 0 0 150 15000 0

MD82 MD-82 N407NV 0 0 150 15000 0

MD82 MD-82 N408NV 0 0 150 15000 0

MD83 MD-83 N405NV 0 0 150 15000 0

MD87 MD-87 N214AM 0 0 130 10000 0

MD88 MD-88 N401NV 0 0 150 15000 0

MD88 MD-88 N402NV 0 0 150 15000 0

MD88 MD-88 N403NV 0 0 150 15000 0

MD88 MD-88 N404NV 0 0 150 15000 0

Open up Fleet.php and instead of the default FleetInfo() change it to this code:

/**
	* Return all possible information about the fleet
	* Code by Mitchell W
	* Enhanced by Stu (stuartpb) 		
	* Fleet Table 2.0 Order by Aicraft Type Edit							
	*/
	public static function FleetInfo()
	{
   $sql = 'SELECT a.*, a.name AS aircraft,
     COUNT(p.pirepid) AS routesflown,
     SUM(p.distance) AS distance,
     SEC_TO_TIME(SUM(p.flighttime*60*60)) AS totaltime,
     AVG(p.distance) AS averagedistance,
     AVG(p.flighttime) as averagetime
     FROM '.TABLE_PREFIX.'aircraft a
     LEFT OUTER JOIN '.TABLE_PREFIX.'pireps p ON (p.aircraft = a.id)
     GROUP BY a.name';

		return DB::get_results($sql);
		DB::debug();
		return $ret;

	}

This was exactly what I was about to ask!

Would be a great addition to a great module!!

Reasin being …

I duplicated then renamed the original fleet table and edited the out put only to display;

Type

Rego

Location - Location

Now all I need is the last pilot who flew it.

Then I can promote the Module as “Last Known Whereabouts” giving pilots the incentive to take that aircraft and fly it to where they want to go.

Any assistance in coding would be mostly appreciative.

Thanks in advance

Adam

AUZ

I have tried to get the last pilot who flew it but I can’t seem to get it to work, as soon as I get it working I’ll post the code here

a conclusion in the two tables, first table of Boeing 737 and the second table all Airbus

how can I create this?




First Table is (list of all Boeing aircraft's)

Boeing B737-300

EI-CHH, total flight time 00:12:50. 

Located at the airport Cologne Bonn (EDDK).




Second Table is (list of all Airbus aircraft's)

Airbus A319-100

VP-BBG, total flight time 01:20:15. 

Located at the airport Munich (EDDM).


please help!!


I've created this code but, this code show all aircraft's in list, but i needet 2 tabeles! 




<?php foreach ($fleet as $aircraft) 
{
?>
<?php $airbus = explode("EI", $aircraft->registration); echo $airbus[0];?>, total flight time <?php echo $aircraft->totaltime; ?>.<br> Located at the airport<?php
$params = (array('a.registration'=>$aircraft->registration, 'p.accepted'=>PIREP_ACCEPTED));

$pirep = PIREPData::findPIREPS($params);
$current_location = $pirep[0]->arricao;
$current_location2 = $pirep[0]->arrname;
       {
           echo ''.$current_location2.' ('.$current_location.')';
       }
?>.<br><br>
<?php } ?>

Copy the table and move it below the first table and change the airbus stuff to boeing or whatever.

Ok Mitchell, thanks very much

Waiting patiently

Regards

Adam

AUZ

that put my planes in order by type.. but I only have a list of 5 planes now. instead of a list of 46.

thanks

trev

that put my planes in order by type.. but I only have a list of 5 planes now. instead of a list of 46.

thanks

trev

To solve that do this: in Fleet.php in Fleet folder inside modules folder add at line 36:

GROUP BY a.registration ORDER BY a.name

how can i change the code so that it shows ALL aircraft, even the ones that haven’t flown a single flight yet

is there a possibility to show the current fleet location in google maps?

Maybe someone can share a script in here. That would be nice.

And another question: The script shows all aircraft, also those who are marked as disabled. What do I need to change to see only active aircraft in the list?

Interesting question would like to know that as well

anybody has an idea ?

Best Regards

Thomas

And another question: The script shows all aircraft, also those who are marked as disabled. What do I need to change to see only active aircraft in the list?

I think only the SQL query need to be adopted

public static function FleetInfo()
	{
   $sql = 'SELECT a.*, a.name AS aircraft,
     COUNT(p.pirepid) AS routesflown,
     SUM(p.distance) AS distance,
     SEC_TO_TIME(SUM(p.flighttime*60*60)) AS totaltime,
     AVG(p.distance) AS averagedistance,
     AVG(p.flighttime) as averagetime
     FROM '.TABLE_PREFIX.'aircraft a
     LEFT OUTER JOIN '.TABLE_PREFIX.'pireps p ON (p.aircraft = a.id)
     GROUP BY a.registration';

		return DB::get_results($sql);
		DB::debug();
		return $ret;

	}

to include only enabled aircraft, but I didn’t managed to get it working.

Maybe some sql expert could help.

thanks,

Markus

Hi,

with this one, I get an error on line 4 from the tpl file:

$sql = 'SELECT a.*, a.name AS aircraft,
     COUNT(p.pirepid) AS routesflown,
     SUM(p.distance) AS distance,
     SEC_TO_TIME(SUM(p.flighttime*60*60)) AS totaltime,
     AVG(p.distance) AS averagedistance,
     AVG(p.flighttime) as averagetime
     FROM '.TABLE_PREFIX.'aircraft a
     WHERE a.enabled = 1
     LEFT OUTER JOIN '.TABLE_PREFIX.'pireps p ON (p.aircraft = a.id)
     GROUP BY a.registration';

           return DB::get_results($sql);
           DB::debug();
           return $ret;

Line 4 of the tpl is:

foreach ($fleet as $aircraft)

any idea?

What is the error? I am guessing it may be something like - your variable is undefined - two returns in the model is probably causing some of the headache, also in your controller, how are you defining $fleet?

Hi,

here is the whole fleet.php

<?php



class Fleet extends CodonModule 
{

       public function index()
       {
       $fleet = self::FleetInfo();
       Template::Set('fleet', $fleet);
       Template::Show('fleet_table.tpl');

       }
       /**
       * Return all possible information about the fleet
       * Code by Mitchell W
       * Enhanced by Stu (stuartpb)         
       * Fleet Table 2.0                            
       */
       public static function FleetInfo()
       {
   $sql = 'SELECT a.*, a.name AS aircraft,
     COUNT(p.pirepid) AS routesflown,
     SUM(p.distance) AS distance,
     SEC_TO_TIME(SUM(p.flighttime*60*60)) AS totaltime,
     AVG(p.distance) AS averagedistance,
     AVG(p.flighttime) as averagetime
     FROM '.TABLE_PREFIX.'aircraft a
     WHERE a.enabled = 1
     LEFT OUTER JOIN '.TABLE_PREFIX.'pireps p ON (p.aircraft = a.id)
     GROUP BY a.registration';

           return DB::get_results($sql);
           DB::debug();
           return $ret;

       }

}

?>

and the tpl:

<h1><?php echo SITE_NAME?> Fleet</h1>
<table align="center"><tr><td>
<?php 
foreach ($fleet as $aircraft) 
{
?>
<div style="float: left;" align="right">
ICAO :<br>
Type :<br>
Full Name:<br>
Registration :<br>
Range :<br>
Empty Weight :<br>
Cruise Alt :<br>
Max Pax :<br>
Max Cargo :<br>
Total hours :<br>
Total Routes flown :<br>
current Airport :<br>
current Country :<br>
<br>
Download :
</div>
<div style="float: left;">
<?php echo $aircraft->icao; ?><br>
<?php echo $aircraft->name; ?><br>
<?php echo $aircraft->fullname; ?><br>
<?php echo $aircraft->registration; ?><br>
<?php echo $aircraft->range; ?><br>
<?php echo $aircraft->weight; ?><br>
<?php echo $aircraft->cruise; ?><br>
<?php echo $aircraft->maxpax; ?><br>
<?php echo $aircraft->maxcargo; ?><br>
<?php echo $aircraft->totaltime; ?><br>
<?php echo $aircraft->routesflown; ?><br>

<?php $params = (array('a.registration'=>$aircraft->registration, 'p.accepted'=>PIREP_ACCEPTED));
$pirep = PIREPData::findPIREPS($params);
$current_location = $pirep[0]->arricao;
$current_location2 = $pirep[0]->arrname;
echo $current_location.'-'.$current_location2;
?>
<?php $airport = OperationsData::getAirportInfo($pirep[0]->arricao); ?><br>
<?php echo $airport->country; ?><br>
<br>
<a href="<?php echo $aircraft->downloadlink; ?>">Download!</a>
</div>
<div style="float: right;">
<img src="<?php echo $aircraft->imagelink; ?>" height="97"
width="160"></div>
<br style="clear:both;">
<br>
<hr>
<br>
<?
}
?>
</td></tr></table>

the error says:

Warning: Invalid argument supplied for foreach() in /var/www/web97/html/phpvms/core/templates/fleet_table.tpl on line 4

Thanks for help!

best regards,

Markus

no one able to fix the request? :frowning:

The error is in the sql command for the database, replace it with:

$sql = 'SELECT a.*, a.name AS aircraft,

     COUNT(p.pirepid) AS routesflown,
     SUM(p.distance) AS distance,
     SEC_TO_TIME(SUM(p.flighttime*60*60)) AS totaltime,
     AVG(p.distance) AS averagedistance,
     AVG(p.flighttime) as averagetime
     FROM '.TABLE_PREFIX.'aircraft a
     LEFT OUTER JOIN '.TABLE_PREFIX.'pireps p ON (p.aircraft = a.id)
     WHERE enabled = 1
     GROUP BY a.name';

That will only show enabled aircraft. Also, I am not sure how the current location in the template is relavent unless you only have one unit of each model in your fleet. The module combines all the like aircrtaft in one group, then displays a current location, but that would be just for the last ac in the list. Just pondering…

the module runs slow on my local machine, but I have a lot of data in the database. Might benefit in speed to combine some of the data calls from the template into the model.

Hi,

I have just tried replacing the sql script, but I get the same error:

Warning: Invalid argument supplied for foreach() in /var/www/web97/html/phpvms/core/templates/fleet_table.tpl on line 4

I have only 5 aircraft for our business VA fleet.

Are your aircraft enabled and have schedules attached to them?

Yes, they are enabled. Schedules are existant, but without dep/arr airport. They were delted in the database directly, so that you can book an aircraft, but not a specific route.

and the fleet:

Are there any PIREPS filed? The sql command is trying to count info from them as well?