Jump to content

Determine Whether Aircraft is Flying or Not


freshJet

Recommended Posts

I've been playing around with this for a while:

<?php
$mystring = ACARSData::GetACARSData($aircraft->registration);
if( strpos( $mystring, '$aircraft->registration' ) !== true )
{
echo '<div style="border-radius:50px; height:10px; width:10px; background-color:green;">';
}
else
{
echo '<div style="border-radius:50px; height:10px; width:10px; background-color:#cccccc;">';
}
?>

I want it to display the green dot if it's flying and grey if not. Simples. But how?

Link to comment
Share on other sites

  • Moderators

itrobb,

$mystring = ACARSData::GetACARSData($aircraft->registration);

There is no class on getting the aircraft by registration.

You would have to create a new data class to pull the aircraft info by registration.

Maybe you might want to create a new data class file so it won't get overwritten in updates.

Title the file something like ACARSAircraftData.class.php

And then you would have to create a WHERE function with the aircraft registration.

NOT TESTED

public static function GetACARSDataByAircraft($registration, $cutofftime = '') {
	//cutoff time in days
	if (empty($cutofftime)) {
		// Go from minutes to hours
		$cutofftime = Config::Get('ACARS_LIVE_TIME');
		//$cutofftime = $cutofftime / 60;
	}

	$sql = 'SELECT a.*, c.name as aircraftname, c.registration,
p.code, p.pilotid as pilotid, p.firstname, p.lastname,
dep.name as depname, dep.lat AS deplat, dep.lng AS deplng,
arr.name as arrname, arr.lat AS arrlat, arr.lng AS arrlng
FROM ' . TABLE_PREFIX . 'acarsdata a
LEFT JOIN ' . TABLE_PREFIX . 'aircraft c ON a.`aircraft`= c.`registration`
LEFT JOIN ' . TABLE_PREFIX . 'pilots p ON a.`pilotid`= p.`pilotid`
LEFT JOIN ' . TABLE_PREFIX . 'airports AS dep ON dep.icao = a.depicao
LEFT JOIN ' . TABLE_PREFIX . 'airports AS arr ON arr.icao = a.arricao
WHERE a.aircraft = '.$registration.' ';

//$sql .= DB::build_where($params);

	if ($cutofftime !== 0) {
		$sql .= 'WHERE DATE_SUB(NOW(), INTERVAL ' . $cutofftime . ' MINUTE) <= a.`lastupdate`';
	}

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

Once you done that. then change the $string code that your trying to do.

$mystring = ACARSAircraftData::GetACARSDataByAircraft($aircraft->registration);

Give this a go and see. The code wasn't tested.

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