<?php 
	Template::show('ICSFleet/header.php');
?>


	<link rel="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap.min.css">
	<script src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
	
    
    <div class="row">
    	<div class="col-md-12">
    		<table id="fleettable" class="table">
<thead>
<tr>
	<th>ICAO</th>
	<th>Category</th>
	<th>Name/Type</th>	
	<th>Full Name</th>
	<th>Registration</th>
	<th>Location</th>
	<th>Status</th>
	<th>Health</th>	
	<th align="center">Max Cargo</th>
	<th>Options</th>
</tr>
</thead>
<tbody>
<?php
foreach($allaircraft as $aircraft)
{
		$last_flight = ICSFleetData::get_last_flight($aircraft->id);
                     	if($last_flight == '') {
                     		$status = 'NOT USED YET';
                     	} else {
                     		$status = "In Service";
                     	}
?>
<tr class="<?php echo ($aircraft->enabled==0)?'disabled':''?>">
	<td align="center"><?php echo $aircraft->icao; ?></td>
	<td align="center"><?php echo ICSFleetData::getCategoryNameByID($aircraft->category_id); ?></td>
	<td align="center"><?php echo $aircraft->name; ?></td>
	<td align="center"><?php echo $aircraft->fullname; ?></td>
	<td align="center"><?php echo $aircraft->registration; ?></td>
	<td align="center"><?php echo $aircraft->location; ?></td>
	<td align="center"><?php echo $status; ?></td>
	<td align="center"><?php echo $aircraft->health; ?></td>
	<td align="center"><?php echo $aircraft->maxcargo; ?></td>
	<td align="center">
		<a class="btn btn-primary btn-sm" target="_blank" href="<?php echo adminurl('/operations/editaircraft?id='.$aircraft->id);?>">Edit Details</a>
		<a href="javascript::void(0);" class="btn btn-sm btn-success">
			Add MX Record
		</a>
	</td>
</tr>
<?php
}
?>
</tbody>
</table>

<script>
	$(document).ready(function() {
    $('#fleettable').DataTable({
    	// "ajax": "https://icrew.upsvac.com/admin/action.php/ICSFleet/fleet_json"
    });
    
} );
</script>
    	</div>
    </div>
    
