<div id="arrivals" style="width:100%; height: 420px"></div>
<script type="text/javascript">
var MY_MAPTYPE_ID_2 = 'alaskamap';

var stylez_2 = [{"elementType":"labels.icon","stylers":[{"color":"#365779"},{"visibility":"off"}]},{"featureType":"landscape","stylers":[{"color":"#042E58"}]},{"featureType":"road.highway","stylers":[{"color":"#A51A1D"}]},{"featureType":"road.local","stylers":[{"color":"#808080"},{"visibility":"off"}]},{"featureType":"road.arterial","stylers":[{"color":"#808080"},{"visibility":"off"}]},{"elementType":"labels.text","stylers":[{"color":"#ffffff"},{"weight":0.1}]},{"featureType":"poi","stylers":[{"color":"#365779"}]},{"featureType":"poi","elementType":"labels.text","stylers":[{"color":"#ffffff"}]},{"featureType":"water"},{"featureType":"transit","stylers":[{"color":"#365779"}]}]
	var latlng = new google.maps.LatLng(<?php echo Config::Get('MAP_CENTER_LAT')?>,<?php echo Config::Get('MAP_CENTER_LNG')?>);
	var bounds = new google.maps.LatLngBounds();
	bounds.extend(latlng);

	var center = bounds.getCenter();

	var options = {
		center : center,
		backgroundColor : '#FFFFFF',
		streetViewControl : false,
		zoomControlOptions : {
			style : google.maps.ZoomControlStyle.SMALL
		},
		minZoom : 2,
		mapTypeControlOptions : {
			mapTypeIds : [google.maps.MapTypeId.SATELLITE, MY_MAPTYPE_ID_2]
		},
		mapTypeId : MY_MAPTYPE_ID_2
	};
	var styledMapOptions_2 = {
		name : "skyBlue Air"
	};

	var map_2 = new google.maps.Map(document.getElementById("arrivals"), options);
	var alaskamap = new google.maps.StyledMapType(stylez_2, styledMapOptions_2);

	map_2.mapTypes.set(MY_MAPTYPE_ID_2, alaskamap);

	var flightMarkers_2 = [];
	
	var image = new google.maps.MarkerImage('<?php echo SITE_URL; ?>/lib/images/airp.png',
			new google.maps.Size(10, 10),
			new google.maps.Point(0, 0),
			new google.maps.Point(5, 5));
	
	var depmarker = [];
	var arrmarker = [];
<?php
$pirep_list = PIREPData::getRecentReportsByCount(10);
$shown = array();
foreach($pirep_list as $pirep) {
	// Dont show repeated routes
	if(in_array($pirep->code.$pirep->flightnum, $shown))
		{ continue; }
	else
		$shown[] = $pirep->code.$pirep->flightnum;

	if(empty($pirep->arrlat) || empty($pirep->arrlng)
		|| empty($pirep->deplat) || empty($pirep->deplng))
	{ continue; }
?>
	dep_location = new google.maps.LatLng( <?php echo $pirep->deplat ?> ,  <?php echo $pirep->deplng ?> );
	arr_location = new google.maps.LatLng( <?php echo $pirep->arrlat ?> ,  <?php echo $pirep->arrlng ?> );

	flightMarkers_2[flightMarkers_2.length] = new google.maps.Marker({
			position : dep_location,
			map : map_2,
			icon : image,
			title : "<?php echo "$pirep->depname ($pirep->depicao)";?>"
		});

	flightMarkers_2[flightMarkers_2.length] = new google.maps.Marker({
			position : arr_location,
			map : map_2,
			icon : image,
			title : "<?php echo "$pirep->arrname ($pirep->arricao)";?>"
		});

	depmarker[depmarker.length] = new google.maps.Marker({
			position : dep_location,
			map : map_2,
			icon : new google.maps.MarkerImage(
				"http://chart.googleapis.com/chart?chst=d_text_outline&chld=FF0000|9|h|000000|b|<?php echo "$pirep->depicao";?>",
				null, null, new google.maps.Point(20, 20))
		});

	arrmarker[arrmarker.length] = new google.maps.Marker({
			position : arr_location,
			map : map_2,
			icon : new google.maps.MarkerImage(
				"http://chart.googleapis.com/chart?chst=d_text_outline&chld=0ACC2D|9|h|000000|b|<?php echo "$pirep->arricao";?>",
				null, null, new google.maps.Point(20, 20))
		});

	var flightPath_2 = new google.maps.Polyline({
			path : [dep_location, arr_location],
			strokeColor : "#FF0000",
			strokeOpacity : 0.5,
			strokeWeight : 2,
			geodesic : true
		}).setMap(map_2);
<?php
}
?>
if (flightMarkers_2.length > 0) {
	var bounds = new google.maps.LatLngBounds();
	for (var i = 0; i < flightMarkers_2.length; i++) {
		bounds.extend(flightMarkers_2[i].position);
	}
}

map_2.fitBounds(bounds);
</script>
<?php
$count = 10;
$pireps = PIREPData::getRecentReportsByCount($count);
?>
<table class="sky_table" width="100%" cellspacing="0">
    <tr>
        <th>Flight</th>
        <th>Pilot</th>
        <th>Departure</th>
        <th>Arrival</th>
        <th>Aircraft</th>
        <th>Duration</th>
        <th>V/S</th>
        <th>Status</th>
	</tr>
<?php
if(count($pireps) > 0)
{
  foreach ($pireps as $pirep)
  {
    $pilotinfo = PilotData::getPilotData($pirep->pilotid);
    $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);
    $acrid = OperationsData::getAircraftByReg($pirep->registration);

    echo '<tr>';
    echo '<td><a href="'.SITE_URL.'/index.php/pireps/viewreport/'.$pirep->pirepid.'">'.$pirep->code.$pirep->flightnum.'</a></td>';
    echo '<td><a href="'.SITE_URL.'/index.php/profile/view/'.$pilotinfo->pilotid.'">'.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</a></td>';
    echo '<td>'.$pirep->depicao.'</td>';
    echo '<td>'.$pirep->arricao.'</td>';
    echo '<td>'.$pirep->aircraft.'</td>';
    echo '<td>'.$pirep->flighttime.'</td>';
    echo '<td>'.$pirep->landingrate.' ft/m</td>';
if($pirep->accepted == PIREP_ACCEPTED)

echo '<td><span class="label label-important"><font color="green">Accepted</font></span></td>';

                                elseif($pirep->accepted == PIREP_REJECTED)

echo '<td><span class="label label-important"><font color="red">Rejected</font></span></td>';

                                elseif($pirep->accepted == PIREP_PENDING)

echo '<td><span class="label label-warning"><font color="3c1900">Pending</font></span></td>';

                                elseif($pirep->accepted == PIREP_INPROGRESS)

echo '<td>On Progress</td>';
    echo '</tr>';
  }
}
else
{
    echo '<tr><td>There are no recent flights!</td></tr>';
}
?>
</tbody>
</table>
<div class="clear"></div>
<div class="clear"></div>
