<!-- Blank Header -->
<div class="content-header">
    <div class="header-section">
        <h1>
            <i class="gi gi-airplane"></i><Strong>Jumpseat Ticket</Strong><br><small>Flight Operations | <?php echo SITE_NAME?> &copy; <?php echo date("Y"); ?></small>
        </h1>
    </div>
</div>
<ol class="breadcrumb breadcrumb-top">
  <li><a href="<?php echo SITE_URL?>/index.php"><i class="fa fa-home"></i></a></li>
  <li><a href="<?php echo SITE_URL?>/index.php/schedules">Flight Operations</i></a></li>
  <li>Jumpseat Ticket</i></li>
</ol>
<!-- END Blank Header -->
<div class="row">
 <div class="block">
	<div class="block-title">
                <h3><strong>Jumpseat Tickets</strong></h3>
            </div>

<?php $pilotloc = FlightSearchData::getpilotscurrentlocation(Auth::$userinfo->pilotid); ?>
Your current location is: <?php if($pilotloc) { $deplocation = $pilotloc->location; ?> 
<?php echo $pilotloc->location ?> <?php echo $pilotloc->name ?>
<?php } else { $deplocation = Auth::$userinfo->hub; ?><?php echo Auth::$userinfo->hub ?> - <?php echo FlightSearchData::getairportname(Auth::$userinfo->hub) ?>
<?php } ?>
<br />
Your available money: <?php echo FinanceData::formatMoney((floatval(Auth::$userinfo->totalpay) + floatval(Auth::$userinfo->payadjust))) ?>

<br /><br /><br />
         <?php if($setting->allowjumpseat == 0) {
         	?>
         	<p class="alert alert-danger text-center animation-fadeIn">
             The Jumpseat ticket feature is temporarily unavailable. <br> Regards, <strong><?php echo SITE_NAME; ?> Crew Control Division.</strong>
        	</p>
         	<?php
         } else { ?>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>ICAO</th>
<th>Airport</th>
<th>Distance</th>
<th>Ticket Price</th>
<?php if ($setting->jumpseatwait == '1') { ?><th>Transfer Time</th><?php } ?>
<th>Confirm</th>
</tr>
</thead>
<?php if($depapts)
foreach($depapts as $apt) {
	if($deplocation == $apt->depicao)
	{
	continue;	
	}
$pilotmoney = round(floatval(Auth::$userinfo->totalpay) + floatval(Auth::$userinfo->payadjust));
$depairport = FlightSearchData::searchAirport($deplocation);
$arrairport = FlightSearchData::searchAirport($apt->depicao);
$distance = SchedulesData::distanceBetweenPoints($depairport->lat, $depairport->lng, $arrairport->lat, $arrairport->lng);
$tiktprice = FlightSearchData::getprice($distance);
if($pilotmoney < $tiktprice) { $con = '0776c'; } else { $con = '1455nc'; }
$confirmstrg = str_replace('-','', round($depairport->lat)).$con;
	 ?>
<tr>
<td><?php echo $apt->depicao; ?></td>
<td><?php echo $apt->depname; ?></td>
<td><?php echo round($distance) ?>NM</td>
<td><?php echo FinanceData::formatMoney($tiktprice); ?></td>
<?php if ($setting->jumpseatwait == '1') { ?><td><?php echo FlightSearchData::convertToHoursMins(FlightSearchData::gettransfertime($distance), '%02d:%02d h') ?></td><?php } ?>
<td>
<?php if($pilotmoney < $tiktprice)
{ ?>
Not enough Money!
<?php } else { ?>
<a href="<?php echo url('flightsearch/confirmjumpseat/') ?><?php echo $apt->depicao; ?>?cstr=<?php echo $confirmstrg ?>"><button class="btn btn-alt btn-success btn-sm">Travel to <?php echo $apt->depicao; ?></button></a></td>
<?php } ?>
</tr>
<?php } ?>
</table>
<?php } ?>
<br />
</div>
</div>