<div class="cc_hubadm_content">
    <div class="cc_hubadm_box cc_hubadm_full">
    <div class="cc_hubadm_boxtitle">Flight Form</div>
<form action="<?php echo SITE_URL ?>/<?php echo $mloc ?>.php/HubOps/saveflight" method="post">
<table width="100%" class="cc_hubadm_tablea">
<tr>
	<td valign="top"><strong>Code: </strong></td>
	<td>
		<select name="code">
		<?php
		foreach($allairlines as $airline) {
            $sel = ($airline->code == $schedule->code) ? 'selected' : '';
			echo '<option value="'.$airline->code.'" '.$sel.'>'.$airline->code.' - '.$airline->name.'</option>';
		}
		?>
		</select>
	</td>
</tr>
<tr>
	<td><strong>Flight Number:</strong></td>
	<td>
		<?php if($detail->limitfnum == "1")
{
	?>
		<input type="number" min="<?php echo $detail->minflnum; ?>" max="<?php echo $detail->maxflnum; ?>" name="flightnum" value="<?php echo $schedule->flightnum;?>" /><br />
		Allowed Range: From <?php echo $detail->minflnum; ?> to <?php echo $detail->maxflnum; ?>
<?php } else { ?>
		<input type="text" name="flightnum" value="<?php echo $schedule->flightnum;?>" />
		<?php } ?>
	</td>
</tr>
<tr>
	<td width="3%" nowrap><strong>Departure Airport:</strong></td>
	<td><input id="depicao" name="depicao" class="airport_select" value="<?php echo $schedule->depicao;?>" onclick="" /><br />
		<span id="depaptwarn" style="color:red;"></span>
	</td>
</tr>
<tr>
	<td><strong>Arrival Airport:</strong></td>
	<td><input id="arricao" name="arricao" class="airport_select" value="<?php echo $schedule->arricao;?>" onclick="" /><br />
		<span id="arraptwarn" style="color:red;"></span>
	</td>
</tr>
<tr>
	<td valign="top"><strong>Departure Time:</strong> </td>
	<td><input type="text" name="deptime" value="<?php echo $schedule->deptime?>" />
		<p>Please enter time as: HH::MM Timezone (eg: 17:30 EST, or 5:30 PM EST)</p>
	</td>
</tr>
<tr>
	<td valign="top"><strong>Arrival Time:</strong> </td>
	<td><input type="text" name="arrtime" value="<?php echo $schedule->arrtime?>" />
		<p>Please enter time as: HH::MM Timezone (eg: 17:30 EST, or 5:30 PM EST)</p>
	</td>
</tr>
<tr>
	<td valign="top"><strong>Days of Week: </strong></td>
	<td>
    <?php		
		$days = Config::Get('DAYS_LONG');
		
		for($i=0; $i<=6; $i++){
			# Add blank string to typecast from int to string, otherwise it won't search
			if(strpos($schedule->daysofweek, $i.'') === false)
				$checked = '';
			else
				$checked = 'checked';
			
			echo '<input type="checkbox" class="checkweek" name="daysofweek[]" value="'.$i.'" '.$checked.'>'.$days[$i].'  ';			
		}
		?>
	</td>
</tr>
<tr>
	<td valign="top"><strong>Flight Time:</strong> </td>
	<td><input type="text" name="flighttime" value="<?php echo $schedule->flighttime?>" />
	<p>Please enter as HH:MM</p>
	</td>
</tr>
<tr>
	<td><strong>Equipment: </strong></td>
	<td><select name="aircraft">
		<?php
		
		foreach($allaircraft as $aircraft)
		{
			if($aircraft->registration == $schedule->registration)
				$sel = 'selected';
			else
				$sel = '';
	
			echo '<option value="'.$aircraft->id.'" '.$sel.'>'.$aircraft->name.' ('.$aircraft->registration.')</option>';
		} ?>
		</select>
	</td>
</tr>
<tr>
	<td valign="top"><strong>Flight Level:</strong></td>
	<td><input type="text" name="flightlevel" value="<?php echo $schedule->flightlevel?>" />
	<p>Please enter as a full-numeric altitude. Should be in feet, to remain accurate with any ACARS.</p>
	</td>
</tr>
<tr>
	<td valign="top"><strong>Flight Type</strong></td>
	<td><select name="flighttype">
			<?php
			foreach($flighttypes as $flightkey=>$flighttype) {
				if($schedule->flighttype == $flightkey)
					$sel = 'selected';
				else	
					$sel = '';
			?>
				<option value="<?php echo $flightkey?>" <?php echo $sel; ?>><?php echo $flighttype?> Flight</option>
			<?php
			}
			?>
		</select>
	</td>
</tr>
<tr>
	<td valign="top"><strong>Route (optional)</strong></td>
	<td><textarea name="route" style="width: 60%; height: 75px" id="route"><?php echo $schedule->route?></textarea>
	</td>
</tr>
<tr>
	<td valign="top"><strong>Price</strong> </td>
	<td><input type="text" name="price" value="<?php echo $schedule->price?>" />
		<p>This is the ticket price, or price per <?php echo Config::Get('CARGO_UNITS'); ?>
			for a cargo flight.</p>
	</td>
</tr>
<tr>
	<td valign="top"><strong>Notes</strong></td>
	<td valign="top" style="padding-top: 0px">
		Any notes about the flight, including frequency, dates flown, etc.<br /><br />
		<textarea name="notes" style="width: 60%; height: 150px"><?php echo $schedule->notes?></textarea>
	</td>
</tr>
<tr>
	<td valign="top"><strong>Enabled?</strong></td>
	<?php $checked = ($schedule->enabled==1 || !$schedule)?'CHECKED':''; ?>
	<td><input type="checkbox" id="enabled" name="enabled" <?php echo $checked ?> /></td>
</tr>
<tr>
	<td></td>
	<td>
		<input type="hidden" name="id" value="<?php echo $schedule->id?>" />
		<input type="submit" name="submit" class="cc_hubadm_greenbutt" value="Save Flight" />
	</td>
</tr>
</table>
</form>
</div>
</div>