Skip to content

Commit

Permalink
v1.3 - Added Global Aircraft Location Map
Browse files Browse the repository at this point in the history
  • Loading branch information
Vansers committed Jul 19, 2013
1 parent edac372 commit 276fe91
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/common/vFleetTrackData.class.php
Expand Up @@ -38,6 +38,21 @@ public static function getLastFlightAircraft($id)
WHERE aircraft = {$id} ORDER BY submitdate DESC LIMIT 1");
}

public static function getAllLastLocation()
{
return DB::get_results("SELECT flight.*, UNIX_TIMESTAMP(flight.submitdate) as submitdate,
dep.name as depname, dep.lat AS deplat, dep.lng AS deplng,
arr.name as arrname, arr.lat AS arrlat, arr.lng AS arrlng,
ac.icao AS acicao, ac.name AS acname, ac.fullname AS acfullname,
ac.registration AS acregistration
FROM (SELECT * FROM phpvms_pireps ORDER BY submitdate DESC) AS flight
LEFT JOIN phpvms_aircraft AS ac ON ac.id = flight.aircraft
LEFT JOIN phpvms_airports AS dep ON dep.icao = flight.depicao
LEFT JOIN phpvms_airports AS arr ON arr.icao = flight.arricao
GROUP BY flight.aircraft
ORDER BY submitdate DESC");
}

public static function getLastNumFlightsAircraft($id, $count = "5")
{
return DB::get_results("SELECT p.*, UNIX_TIMESTAMP(p.submitdate) as submitdate,
Expand Down
6 changes: 6 additions & 0 deletions core/modules/vFleetTracker/vFleetTracker.php
Expand Up @@ -25,6 +25,12 @@ public function view($registration)
$this->render('vFleetTrack/view.tpl');
}

public function viewallmap()
{
$this->set('data', vFleetTrackData::getAllLastLocation());
$this->render('vFleetTrack/map.tpl');
}

public function buildLastFlightTable($id, $count)
{
$this->set('flights', vFleetTrackData::getLastNumFlightsAircraft($id, $count));
Expand Down
3 changes: 3 additions & 0 deletions core/templates/vFleetTrack/index.tpl
Expand Up @@ -21,6 +21,9 @@ This module is only use for phpVMS (www.phpvms.net) - (A Virtual Airline Admin S
return;
}
?>

<?php MainController::Run('vFleetTracker', 'viewallmap');?>

<table id="tabledlist" class="tablesorter">
<thead>
<tr>
Expand Down
37 changes: 37 additions & 0 deletions core/templates/vFleetTrack/map.tpl
@@ -0,0 +1,37 @@
<div class="mapcenter" align="center">
<div id="routemap" style="width: 960px; height: 520px;"></div>
</div>

<script type="text/javascript">
var options = {
zoom: 4,
center: new google.maps.LatLng(<?php echo Config::Get('MAP_CENTER_LAT'); ?>, <?php echo Config::Get('MAP_CENTER_LNG'); ?>),
mapTypeId: google.maps.MapTypeId.ROADMAP,
}
var map = new google.maps.Map(document.getElementById("routemap"), options);
</script>

<?php
$count = 0;
foreach($data as $l)
{
?>
<script type="text/javascript">
var pointer_<?php echo $count;?> = new google.maps.LatLng(<?php echo $l->arrlat?>, <?php echo $l->arrlng?>);
var point_<?php echo $count;?> = new google.maps.Marker({
position: pointer_<?php echo $count;?>,
map: map,
title: "<?php echo "$l->acregistration is at $l->arrname ($l->arricao)";?>",
});
var contentString = '<?php echo $l->acname;?> (<?php echo $l->acregistration;?>) is at <?php echo $l->arrname.'('.$l->arricao.')';?>';
var infowindow_<?php echo $count;?> = new google.maps.InfoWindow({
content: contentString
});
google.maps.event.addListener(point_<?php echo $count;?>, 'click', function() {
infowindow_<?php echo $count;?>.open(map,point_<?php echo $count;?>);
});
</script>
<?php
$count = 1 + $count;
}
?>

0 comments on commit 276fe91

Please sign in to comment.