<!-- Header -->
<div class="content-header text-center">
    <div class="widget">
        <div class="widget-advanced widget-advanced-alt">
            <div class="widget-header"><img src="https://icrew.ariaairways.org/iCrew/images/a320_dawn.jpg" style="width: 100%; height: auto;" class="widget-background animation-pulseSlow">
                <h3 class="widget-content widget-content-image widget-content-light clearfix"><?php echo SITE_NAME?><br>
                <small>Crew Briefing Sheet</small></h3>
                
                
            </div>
            <div class="widget-main">
                <a href="" class="widget-image-container">
                    <span class="widget-icon themed-background-dark"><i class="fa fa-bolt"></i></span></a>
            </div>
            <div class="text-center">
                <h1><small>Generated by Simbrief &copy; <?php echo date("Y"); ?></small></div>
                 <button onclick="copyToClipboard('<?php echo $_GET['ofp_id']; ?>');" id="rtecopy" class="btn btn-sm btn-default">
               Copy SB OFP ID
         </button>
		</div>
	</div>
</div>


<!-- Header -->

<?php
	// We are updating our own database whenever there is a request with a latest AIRAC
	// Things updated :

	//
	function update_rte($route, $id) {
        $sql = "UPDATE `phpvms_schedules` SET `route` = '$route' WHERE `id` = '$id'";
         return DB::query($sql);
    }
    
    
?>



<div class="widget">
	<div class="widget-simple text-center">
		<h4 class="widget-content">
				<h1 class="text-center animation-fadeIn">
          <?php
           $logo = SITE_URL."/lib/images/airline/".$info->general[0]->icao_airline.".png";
          ?>
      <img src="<?php echo $logo; ?>" style="height: 100px; width: auto;" /><br><br>
					<span class="label label-primary">
						<strong><?php echo (string) $info->general[0]->icao_airline.''.(string) $info->general[0]->flight_number; ?></strong></small></span><br>
						<small><strong>
						<?php
						$epoch = (string) $info->times[0]->sched_out;
						$dt = new DateTime("@$epoch");  // convert UNIX timestamp to PHP DateTime
						echo strtoupper($dt->format('d M Y')); // output = 2012-08-15 00:00:00
						?></strong></small>
				</h1>

                </h4>
	</div>
            <div class="widget-extra themed-background-dark">
                <div class="row text-center">
                    <div class="col-xs-6">
                <h3 class="widget-content-light">
					<a href="javascript:void(0)"><strong>ETD</strong></a><br>
					<small><?php
					$epoch = (string) $info->times[0]->sched_out;
					$dt = new DateTime("@$epoch");  // convert UNIX timestamp to PHP DateTime
					echo $dt->format('H:i'); // output = 2012-08-15 00:00:00
					?></small>
				</h3>
                    </div>
                    <div class="col-xs-6">
                        <h3 class="widget-content-light">
					<a href="javascript:void(0)"><strong>ETA</strong></a><br>
					<small><?php
        $epoch = (string) $info->times[0]->est_on;
$dt = new DateTime("@$epoch");  // convert UNIX timestamp to PHP DateTime
echo $dt->format('H:i'); // output = 2012-08-15 00:00:00
       ?></small>
				</h3>
                    </div>
                </div>
            </div>
        </div>
<script>
	 function copyToClipboard(text) {
	 	hotsnackbar('hsdone', 'Simbrief OFP # copied to clipboard');
	 	 var input = document.createElement('textarea');
    input.innerHTML = text;
    document.body.appendChild(input);
    input.select();
    var result = document.execCommand('copy');
    document.body.removeChild(input);
    return result;
        // window.prompt("Here is the OFP ID, you can use this to retrive your OFP later.", text);
    }
</script>
		<?php 
			// print_r($info);
			// echo $info->plan_ramp;
			// foreach($info as $infox) {
			// 	print_r($infox);
			// 	echo "<hr>";
			// }
		?>
        <div class="row">
            <div class="col-md-4">
                <a href="#modal-regular2" data-toggle="modal" class="widget widget-hover-effect2">
                    <div class="widget-extra themed-background-success">
                        <h4 class="widget-content-light"><span class="animation-pulse"> <strong>Departure </strong> Airport</h4></span>
                    </div>
                    <div class="widget-extra-full text-muted"><span class="h2 animation-expandOpen"></span> <font color="#0f0f0f">
			<h3><strong><?php echo (string) $info->origin[0]->icao_code; ?></strong> <?php echo 'RWY'.$info->origin[0]->plan_rwy; ?> </h3></font>
                        <br>
                        <?php echo (string) $info->origin[0]->name; ?>
                    </div>
                </a>
            </div>

            <!-- Modal for Departure Airport METAR -->
            <div id="modal-regular2" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" style="display: none;">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h3 class="modal-title text-center">
                     	<small><?php echo SITE_NAME?> <Strong>Rostering</Strong> | WX Briefing <br>
                     	</small> <span class="label label-primary"><strong>
                     		<?php echo (string) $info->origin[0]->icao_code; ?>
                     	</strong></span> </h3>
                        </div>
                        <div class="modal-body">
                            <Strong>METAR</Strong>
                            <?php echo (string) $info->weather[0]->orig_metar; ?>
                                <br>
                                <br><strong>TAF</strong>
                                <?php echo (string) $info->weather[0]->orig_taf; ?>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <a href="#altnmetar" data-toggle="modal" class="widget widget-hover-effect2">
                    <div class="widget-extra themed-background-muted">
                        <h4 class="widget-content-light"><span class="animation-pulse"> <strong>Alternate </strong> Airport</h4></span>
                    </div>
                    <div class="widget-extra-full text-muted"><span class="h2 animation-expandOpen"></span> <font color="#bababa">
			<h3><strong><?php echo (string) $info->alternate[0]->icao_code; ?></strong>  <?php echo 'RWY'.$info->alternate[0]->plan_rwy; ?></h3></font>
                        <br>
                        <?php echo (string) $info->alternate[0]->name; ?>
                    </div>
                </a>
            </div>

            <div class="col-md-4">
                <a href="#modal-regular3" data-toggle="modal" class="widget widget-hover-effect2">
                    <div class="widget-extra themed-background-danger">
                        <h4 class="widget-content-light"><span class="animation-pulse">Arrival <strong>Airport</strong></h4></span>
                    </div>
                    <div class="widget-extra-full text-muted"><span class="h2 themed-color-dark animation-expandOpen"></span>
                        <font color="#0f0f0f"><h3><strong><?php echo (string) $info->destination[0]->icao_code; ?></strong>  <?php echo 'RWY'.$info->destination[0]->plan_rwy; ?></h3></font>
                        <br>
                        <?php echo (string) $info->destination[0]->name; ?>
                    </div>
                </a>
            </div>
            <!-- Modal for Arrival Airport METAR -->
            <div id="modal-regular3" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" style="display: none;">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h3 class="modal-title text-center"><small><?php echo SITE_NAME?> <Strong>Rostering</Strong> | WX Briefing <br></small>
                     <span class="label label-primary"><strong><?php echo (string) $info->destination[0]->icao_code; ?></strong></span> </h3>
                        </div>
                        <div class="modal-body">
                            <Strong>METAR</Strong>
                            <?php echo (string) $info->weather[0]->dest_metar; ?>
                                <br>
                                <br>
                                <Strong>TAF</Strong>
                                <?php echo (string) $info->weather[0]->dest_taf; ?>
                        </div>
                    </div>
                </div>
            </div>

            <div id="altnmetar" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" style="display: none;">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h3 class="modal-title text-center"><small><?php echo SITE_NAME?> <Strong>Rostering</Strong> | WX Briefing <br></small>
                     <span class="label label-primary"><strong><?php echo (string) $info->alternate[0]->icao_code; ?></strong></span> </h3>
                        </div>
                        <div class="modal-body">
                            <Strong>METAR</Strong>
                            <?php echo (string) $info->weather[0]->altn_metar; ?>
                                <br>
                                <br>
                                <Strong>TAF</Strong>
                                <?php echo (string) $info->weather[0]->altn_taf; ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-4">
                <div class="block">
                    <div class="block-title">
                        <h3><Strong>ATC</Strong> Flight Plan</h3>
                    </div>
                    <div class="alert alert-info">
                        Paste this into your IVAO / VATSIM Flight Plan, Remarks Column (Item 18)
                    </div>
                    <p class="well well-sm">
                        <?php echo (string) $info->atc[0]->flightplan_text; ?>
                    </p>
                    <?php

                      $vatsim_prefile = $info->vatsim_prefile;
                      $vatsim_btn = str_replace('type="submit"', 'type="submit" class="btn btn-primary btn-block"', $vatsim_prefile);
                      $vatsim_btn = str_replace('Pre-file on VATSIM', 'Pre-File flight plan on VATSIM', $vatsim_btn);
                      echo $vatsim_btn;
                     ?><br>


                    <?php

                    $ivao_prefile = $info->ivao_prefile;
                    $ivao_btn = str_replace('type="submit"', 'type="submit" class="btn btn-primary btn-block"', $ivao_prefile);
                    $ivao_btn = str_replace('Pre-file on IVAO', 'Pre-File flight plan on IVAO', $ivao_btn);
                    echo $ivao_btn;
                    ?><br>


                    <?php

                    $poscon_prefile = $info->poscon_prefile;
                    //$poscon_btn = str_replace('type="submit"', 'type="submit" class="btn btn-primary btn-block"', $poscon_prefile);
                    //$poscon_btn = str_replace('Pre-file on POSCON', 'Pre-File flight plan on IVAO', $poscon_btn);
                    $poscon_btn = '<a target="_blank" class="btn btn-primary btn-block" href="'.$poscon_prefile.'">Pre-File flight plan on POSCON</a>';
                    echo $poscon_btn;
                    ?><br>

                     <a target="_blank" href="<?php echo (string) $info->files->directory; ?><?php echo (string) $info->files->pdf->link; ?>" class="btn btn-block btn-default">
                       View Operational Flight Plan
                     </a>

                     <br />
                     <a href="<?php echo (string) $info->files->directory; ?><?php echo (string) $info->files->pdf->link; ?>" class="btn btn-block btn-default" download>
                       Download Operational Flight Plan
                     </a>


					              <br><br>
                </div>
                <div class="block">
                    <div class="block-title">
                        <h3><Strong>OFP</Strong> Details</h3>
                    </div>
                    <p>
                        <strong>Dispatcher : </strong>
                    		 <?php echo (string) $info->crew[0]->dx;?>
                            <br>
                        <strong>Time Generated :</strong>
                            <?php
					        $epoch = (string) $info->params[0]->time_generated;
							$dt = new DateTime("@$epoch");  // convert UNIX timestamp to PHP DateTime
							echo $dt->format('H:i:s').'z  ';
							echo $dt->format('d/m/Y'); // output = 2012-08-15 00:00:00
    						?><br>
    					<strong>Remarks :</strong>
    						<?php
    						$remarks = $info->general[0]->sys_rmk[0];
    						if(!$remarks)
    						{
    							echo 'NO DISPATCHER REMARKS';
    						}
    						else {
    						echo '<span class="text-danger">'.(string) $info->general[0]->sys_rmk[0];
    						echo '<br>'.(string) $info->general[0]->sys_rmk[1];
    						echo '<br>'.(string) $info->general[0]->sys_rmk[2];
    						echo '<br>'.(string) $info->general[0]->sys_rmk[3];
    						echo '<br>'.(string) $info->general[0]->sys_rmk[4];
    						echo '<br>'.(string) $info->general[0]->sys_rmk[5];
    						echo '<br>'.(string) $info->general[0]->sys_rmk[6].'</span>';
    						}

    						?>
                    </p>
                </div>

                <div class="block">
                	<div class="block-title">
                		<h3><strong>Weight & Load</strong> (Calculated as per Airline Policy)</h3>
                	</div>
                	Passengers : <?php $pax = (string) $info->weights[0]->pax_count; echo $pax; ?> <br>
                	Cargo : <?php  echo $info->weights[0]->cargo; ?> <br>
                	Operating Empty Weight (OEW) : <?php  echo (string) $info->weights[0]->oew; ?><br>
                	Payload : <?php  echo (string) $info->weights[0]->payload; ?> <br>
                	Estimated Zero Fuel Weight : <?php  echo (string) $info->weights[0]->est_zfw; ?> <br>
                	Max Zero Fuel Weight : <?php  echo (string) $info->weights[0]->max_zfw; ?> <br>
                	Maximum Take Off Weight : <?php  echo (string) $info->weights[0]->max_tow; ?> <br>
                	Maximum Structural Take off Weight : <?php  echo (string) $info->weights[0]->max_tow_struct; ?> <br>
                	Take off weight Limit code : <?php  echo (string) $info->weights[0]->tow_limit_code; ?> <br>
                	Estimated Landing Weight : <?php  echo (string) $info->weights[0]->est_ldw; ?> <br>
                	Maximum Landing Weight : <?php  echo (string) $info->weights[0]->max_ldw; ?> <br>
                	Estimated Ramp Weight : <?php  echo (string) $info->weights[0]->est_ramp; ?> <br>
                	<br>
                </div>
            </div>

            <div class="col-md-8">

                <div class="block">
                    <div class="block-title">
                        <h3><Strong>Crew</Strong> Information</h3>
                    </div>
                    <table class="table table-hover">
                        <thead>
                            <Strong><td>Pilot In Command</td>
					<td>Pilot Monitoring</td>
					<td>Cabin Crew (Lead)</td>
					<td>Cabin Crew
						<strong>
							<?php
							$cabin_crew = $info->crew->fa;
							$total_crew = count($cabin_crew);
							$crewcount = 0; //Cuz the arrays always start with 0 Einstein!
							$comma_trick = $total_crew - 1;
							echo '('.$comma_trick .'+ 1)';
                        	?>
						</strong>

					</td>
					<td>Base Airport</td>
					<td>Crew ID</td></Strong>
                        </thead>
                        <tbody>
                            <td>
                                <?php
							$rank = Auth::$userinfo->rankid;
							$minimumrank = 4; //This varies with each and every airline. UPDATE it accordingly.
							if($rank >= $minimumrank)
							{
								$captain = (string) $info->crew[0]->cpt;
								$firstofficer = (string) $info->crew[0]->fo;
							}
							else
							{
								$firstofficer = (string) $info->crew[0]->cpt;
								$captain = (string) $info->crew[0]->fo;
							}
						?>
                                    <?php echo 'CAPT '.$captain; ?>
                            </td>
                            <td>
                                <?php echo 'FO '.$firstofficer; ?>
                            </td>
                            <td>
                                <?php echo (string) $info->crew->fa[0]; ?>
                            </td>
                            <td>
                            	<!--
                            		To place the commas properly, we are first finding out howmany crew are rostered.
                            		Then we do a small loop to find out the number before the total crew count.
                            		and we place the comma accordingly.
                            	-->

                            	<?php

                            		foreach ($cabin_crew as $cc) {

                            			echo $cc[0];
                            			if($crewcount < $comma_trick) {
                            				echo ', ';
                            			} else {
                            				echo '.';
                            			}
                            			$crewcount++;
                            		}
                            	?>
                            </td>
                            <td>
                                <?php $hub = OperationsData::getAirportInfo(Auth::$userinfo->hub);
						echo $hub->name; ?>
                            </td>
                            <td>
                                <?php echo Auth::$userinfo->code.''.Auth::$userinfo->pilotid; ?>
                            </td>
                        </tbody>
                    </table>
                </div>
                <div class="block">
                    <div class="block-title">
                        <h3><Strong>Other</Strong> Information</h3>
                    </div>
                    <table class="table">
                        <tbody>
                            <tr>
                                <td>
                                    <form target="_blank" action="<?php echo url('/AdvancedWX/metarxml');?>" method="post" class="form-horizontal form-bordered">
                                        <input type="hidden" value="<?php echo (string) $info->origin[0]->icao_code; ?>" name="icao" class="form-control">
                                        <br>
                                        <input type="submit" class="btn btn-md btn-success" value="DEPP ATIS">
                                     </form>
                                     <form target="_blank" action="<?php echo url('/AdvancedWX/metarxml');?>" method="post" class="form-horizontal form-bordered">
                                        <input type="hidden" value="<?php echo (string) $info->alternate[0]->icao_code; ?>" name="icao" class="form-control">
                                        <br>
                                        <input type="submit" class="btn btn-md btn-default" value="ALTN ATIS">
                                    </form>

                                    <form target="_blank" action="<?php echo url('/AdvancedWX/metarxml');?>" method="post" class="form-horizontal form-bordered">
                                        <input type="hidden" value="<?php echo (string) $info->destination[0]->icao_code; ?>" name="icao" class="form-control">
                                        <br>
                                        <input type="submit" class="btn btn-md btn-danger" value="ARRV ATIS">
                                    </form>
                                </td>
                                <td></td>
                                 <td><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#depairport"><?php echo $icao; ?> Runway Data</button>
									<button type="button" class="btn btn-success" data-toggle="modal" data-target="#arr"><?php echo $icao2; ?> Runway Data</button>
								</td>

                                <td>
                                    <Strong>Distance</Strong> :
                                    <?php echo (string) $info->general[0]->route_distance.'(Nm)'; ?>
                                </td>
                                <td><strong>EET</strong> :
                                    <?php
    					$epoch = (string) $info->times[0]->est_block;
						$dt = new DateTime("@$epoch");  // convert UNIX timestamp to PHP DateTime
						echo $dt->format('H:i'); // output = 2012-08-15 00:00:00
    					?>
                                        <br>
                                        <?php
    					$cload = $dt->format('H');
			if($cload > 0 && $cload < 3)
			{
				$cload_clr = 'success';
				$notes ='<small><span class="label label-success">SHORT HAUL</span></small>';
			}
			else if($cload > 3 && $cload < 6)
			{
				$cload_clr = 'warning';
				$notes ='<small><span class="label label-warning">MEDIUM HAUL</span></small>';
			}
			else if($cload > 6 && $cload < 15)
			{
				$cload_clr = 'danger';
				$notes = '<small><span class="label label-danger">LONG HAUL</span></small>';
			}
			else if($clod <- 16)
			{
				$cload_clr = 'danger';
				$notes = '<small><span class="label label-danger">ULTRA LONG HAUL</span></small>';
			}
		?>
                                            <?php echo $notes ?>
                                </td>
                                <td>
                                    <Strong>Airframe</Strong> :
                                    <?php echo (string) $info->aircraft[0]->icaocode.'('.(string) $info->aircraft[0]->reg.')'; ?>
                                </td>
                                <td><strong>Download Format</strong> :
                                    <script type="text/javascript">
                                        function download(d) {
                                            if (d == 'Select Format') return;
                                            // window.location = 'https://www.simbrief.com/ofp/flightplans/' + d;
                                            
                                            var a = document.createElement("a");
											  a.href = 'https://www.simbrief.com/ofp/flightplans/' + d;
											  a.setAttribute("download", d);
											  a.setAttribute("target", '_blank');
											  a.click();
                                        }
                                    </script>

                                    <select name="download" class="form-control" onChange="download(this.value)">
                                        <option>Select Format</option>
                                        <option value="<?php echo $info->files->pdf->link; ?>">
                                            <?php echo $info->files->pdf->name; ?>
                                        </option>
                                        <?php
										foreach($info->files->file as $file)
                						{
											?>
											<option value="<?php echo $file->link; ?>">
                                            	<?php echo $file->name; ?>
                                            </option>
                                            <?php
                    					}
    									?>
                                    </select>

                                </td>
                                <td>
                                    <a href="<?php echo SITE_URL; ?>/index.php/airports/get_airport?icao=<?php echo (string) $info->origin[0]->icao_code; ?>" class="btn btn-md btn-success">Airport Info</a>
                                    <br>
                                    <a href="<?php echo SITE_URL; ?>/index.php/airports/get_airport?icao=<?php echo (string) $info->alternate[0]->icao_code; ?>" class="btn btn-md btn-default">Airport Info</a>
                                    <br>
                                    <a href="<?php echo SITE_URL; ?>/index.php/airports/get_airport?icao=<?php echo (string) $info->destination[0]->icao_code; ?>" class="btn btn-md btn-danger">Airport Info</a>
                                </td>
                                <td></td>
                                <td></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="block">
                	<div class="block-title">
                		<div class="block-options pull-right">
                			AIRAC Cycle : <label class="label label-success">
                				<?php echo (string) $info->params->airac; ?>
                			</label>
                		</div>
                		<h3><strong>Route</strong> Details</h3>
                	</div>
                	<p class="well well-sm">
                		<?php echo (string) $info->api_params[0]->route; ?>
                	</p>
                	<div class="row">
                		<div class="col-md-4">
                			<strong>Great Circle Distance : </strong>
                			<?php echo (string) $info->general[0]->gc_distance; ?> nm<br>
                			<Strong>Air Distance :</Strong>
                			<?php echo (string) $info->general[0]->air_distance; ?> nm<br>

                		</div>
                		<div class="col-md-4">
                			<Strong>Burn off :</Strong>
                			<?php echo (string) $info->general[0]->total_burn; ?><br>
                			<Strong>Initial CRZ :</Strong>
                			<?php echo (string) $info->general[0]->initial_altitude; ?> ft<br>
                		</div>
                		<div class="col-md-2">
                			<strong>Cost Index : </strong>
                			<?php echo (string) $info->general[0]->costindex; ?><br>
                		</div>
                		<div class="col-md-12">
                			<br>
                			<div class="alert alert-warning">
                			<strong>Attention</strong>
                			<br>
                			If your flight briefing package contains an older AIRAC cycle, please purchase and unlock your AIRAC via logging on to SimBrief.com. <?php echo SITE_NAME; ?> will not be responsible for older AIRAC Cycles used during flights, however there is no restrictions to it.
                		</div>
                		</div>
                		<?php  if(!$metar)
    						 {
    	 	'.';
    		$arl = (string) $info->general[0]->icao_airline;
    		if($arl == 'UAE')
    		{
    			$airline = 'Emirates';
    		}
    		else if($arl == 'CH')
    		{
    			$airline = 'a Charter flight ';
    		}
    		elseif($arl == 'DAC')
    		{
    			$airline = 'a Delta Virtual Charter flight';
    		}
    		else
    		{
    			$airline = SITE_NAME;
    		}
    		$k = (string) $info->general[0]->flight_number;
        	$flightnum = (string)$k;


        	$origin = str_replace("INTL","International Airport",(string) $info->origin[0]->name);
        	$dest = str_replace("INTL","International Airport",(string) $info->destination[0]->name);
        	$registration = (string) $info->aircraft[0]->reg;
        	$aircraft_name = str_replace("A320","A Three twenty",(string) $info->aircraft[0]->icaocode);
        	$j = $aircraft_name;
        	$manf = (string)$j;
        	$first_letter = $manf[0];
        	if($first_letter == 'A')
        	{
        		if($manf[1] == 'T') {
        			$manufacturer = 'A T R';
        		}
        		else
        		{
        				$manufacturer = 'Airbus';
        		}
        	}
        	elseif($first_letter == 'B')
        	{
        		$manufacturer = 'Boeing';
        	}
        	else
        	{
        		$manufacturer = 'Aircraft';
        	}


    		$l = $registration;
        	$regi = (string)$l;
        	$stringlength = count($regi);
        	for($x = 0; $x <= 5; $x++) { ICSAdmin::phonetic($regi[$x]).' ';}
        	$pax = (string) $info->weights[0]->pax_count;
        	$crew = count($info->crew->fa);
        	$cargo = $info->weights[0]->cargo;
        	// $fuel = $info->impacts->minus_6000ft[0]->ramp_fuel;
        	$fuel =$info->fuel->plan_ramp;
        	$f = $fuel;
        	$fuelf = (string)$f;
        	$tow = $info->weights[0]->est_tow;
        	$tw = $tow;
        	$tww = (string)$tw;
        	$epoch = (string) $info->times[0]->est_block;
			$dt = new DateTime("@$epoch");  // convert UNIX timestamp to PHP DateTime
			$enrtime_hr = $dt->format('H');
			$enrtime_mn = $dt->format('i');
			$k = (string) $info->aircraft[0]->reg;
        	$flightnum = (string)$k;
        	$aa = ICSAdmin::phonetic($flightnum[0]);
        	$ab = ICSAdmin::phonetic($flightnum[1]);
        	$ac = ICSAdmin::phonetic($flightnum[3]);
        	$ad = ICSAdmin::phonetic($flightnum[4]);
        	$ae = ICSAdmin::phonetic($flightnum[5]);
    	 	$broadcast = "Okay ".$firstofficer.", i am Captain ".$captain.". walk around is complete, maintenace is cleared, we will carry out with the pre flight briefing now. Today our flight will be ".$airline."  ".$flightnum[0]."  ".$flightnum[1]."  ".$flightnum[2]."  ".$flightnum[3]."   non stop from ".$origin." to ".$dest.". We are operating ".$aa.",  ".$ab.",  ".$ac.",  ".$ad.", ".$ae.", $manufacturer ".$aircraft_name.". We are carrying ".$pax." Passengers, ".$crew." crew and ".$cargo." tonnes of Cargo today. We require ".$fuelf[0].''.$fuelf[1]." thousand pounds of fuel for this flight. Our take off weight is ".$tww[0].''.$tww[1]." Tons. Our flight time would be approximately ".$enrtime_hr." hour and ".$enrtime_mn." minutes. As per company policy we will use Cost Index ".$info->general[0]->costindex." for this flight. Any doubts";
    	 	$takeoff_briefing = "The take off Briefing, are you ready?. As i said earlier, We have no M E L issues today. i'll be the pilot flying and you will be the pilot monitoring. We will use Standard Noise Abatement Departure procedure 1 for takeoff. We will use an A T C Assigned Standard instrument departure. WE will use Flaps 1 for take off and engine bleeds will be ON. Confirm you have charts on board. For the failures, from 0 - 100 knots for any malfunctions detected, i will call reject takeoff and you confirm the auto brakes are working, if not operational, you apply maximum manual braking and max reverse thrust and we expedite a full stop on the runway and carryout with the evacuation. from 100 to V 1, we will only reject take off for three reasons, engine fire, engine failure or take off configuration warning. at or above V 1, we bring her in the air and the only actions for you below 400 ft would be to confirm the failures and to silence the alarm bells. If we are above the maximum landing weight, we will decide as the situation requires whether to land or to expedite a holding pattern. And before starting the flight, confirm you have started the ACARS software so that our actions are logged. Any questions";
    	 }
    	 
    						?>
        <audio src="https://api.voicerss.org/?key=<?php echo VOICE_API; ?>&src='<?php echo $broadcast?>'" id="audio"></audio>
        <audio src="https://api.voicerss.org/?key=<?php echo VOICE_API; ?>&src='<?php echo $takeoff_briefing?>'" id="takeoff"></audio>
    	<div class="col-md-6">
    		<button class="btn btn-info btn-alt btn-block" id="play" onclick="play()">Preflight Briefing</button>
    	</div>
    	<div class="col-md-6">
    		<button class="btn btn-success btn-alt btn-block" id="takeoff" onclick="takeoff()">Take off Briefing</button>
    	</div>



                	</div>
                	<br>
                </div>
            </div>

        </div>

		<div class="row">
			<?php
				foreach($info->images->map as $file)
                {
				?>
			<div class="col-md-6">
				<div class="block">
					<div class="block-title">
						<h3><Strong><?php echo $file->name; ?></Strong></h3>
					</div>
					<center>
            <img style="border-radius: 5px;" src="<?php echo (string) $info->images[0]->directory[0]; ?><?php echo $file->link; ?>" width="450px;" height="auto;">
            <br /><br />
          </center>
				</div>
			</div>
				<?php
                }
			?>
		</div>
		<?php $icao = $info->destination[0]->icao_code;
		$name = OperationsData::getAirportInfo($icao);
		?>

		<?php $icao2 = $info->origin[0]->icao_code;
		$name2 = OperationsData::getAirportInfo($icao2);
		?>



<!-- Modal -->
<div id="depairport" class="modal fade" role="dialog">
  <div class="modal-dialog modal-lg">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title "><h3 class="text-center"><strong><?php echo SITE_NAME; ?> Flight Briefing Services </strong><br><small><?php echo $name2->name;?>, <?php echo $name2->country;?></small></h3></h4>
      </div>
      <div class="modal-body">
         <p><table class="table table-hover">
<tr>
<th>Runway Designators</th>
<th>Magnetic Variation</th>
<th>Runway Heading</th>
<th>Runway Length</th>
<th>Runway Elevation</th>
<th>Surface Composition</th>
<th>ILS Frequency</th>
<th>ILS Identifier</th>
<th>ILS Glide Slope</th>
</tr>
<?php $runways1 = AirportData::getrunwaysforairport($icao2); ?>
<?php if($runways1) foreach($runways1 as $runway1) { ?>
<tr>
<td align="center"><?php echo $runway1->RunwayID; ?></td>
<td align="center"><?php echo $runway1->MagVar; ?></td>
<td align="center"><?php echo $runway1->Hdg; ?>&deg;</td>
<td align="center"><?php echo $runway1->Len; ?>&nbsp;ft</td>
<td align="center"><?php echo $runway1->Altitude; ?>&nbsp;ft</td>
<td align="center"><?php echo $runway1->Def; ?></td>
<?php if ($runway1->ILSFreq == 0){ ?>
<td align="center">Unequipped</td>
<td align="center">Unequipped</td>
<td align="center">Unequipped</td>
<?php } else {?>
<td align="center"><?php echo $runway1->ILSFreq; ?></td>
<td align="center"><?php echo $runway1->ILSid; ?></td>
<td align="center"><?php echo $runway1->ILSslope; ?></td>
</tr>
<?php }} ?>
</tr>
</table>
<br />
</br></p>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>


<!-- Modal -->
<div id="arr" class="modal fade" role="dialog">
  <div class="modal-dialog modal-lg">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
    <h4 class="modal-title "><h3 class="text-center"><strong><?php echo SITE_NAME; ?> Flight Briefing Services </strong><br><small><?php echo $name2->name;?>, <?php echo $name2->country;?></small></h3></h4>
      </div>
      <div class="modal-body">
        <p><table class="table table-hover">
<tr>
<th>Runway Designators</th>
<th>Magnetic Variation</th>
<th>Runway Heading</th>
<th>Runway Length</th>
<th>Runway Elevation</th>
<th>Surface Composition</th>
<th>ILS Frequency</th>
<th>ILS Identifier</th>
<th>ILS Glide Slope</th>
</tr>
<?php $runways1 = AirportData::getrunwaysforairport($icao2); ?>
<?php if($runways1) foreach($runways1 as $runway1) { ?>
<tr>
<td align="center"><?php echo $runway1->RunwayID; ?></td>
<td align="center"><?php echo $runway1->MagVar; ?></td>
<td align="center"><?php echo $runway1->Hdg; ?>&deg;</td>
<td align="center"><?php echo $runway1->Len; ?>&nbsp;ft</td>
<td align="center"><?php echo $runway1->Altitude; ?>&nbsp;ft</td>
<td align="center"><?php echo $runway1->Def; ?></td>
<?php if ($runway1->ILSFreq == 0){ ?>
<td align="center">Unequipped</td>
<td align="center">Unequipped</td>
<td align="center">Unequipped</td>
<?php } else {?>
<td align="center"><?php echo $runway1->ILSFreq; ?></td>
<td align="center"><?php echo $runway1->ILSid; ?></td>
<td align="center"><?php echo $runway1->ILSslope; ?></td>
</tr>
<?php }} ?>
</tr>
</table>
<br />
</br></p>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>

<script type="text/javascript">
    function play() {
        var audio = document.getElementById('audio');
        if (audio.paused) {
            audio.play();
            $('#play').removeClass('glyphicon-play-circle')
            $('#play').addClass('glyphicon-pause')
        }else{
            audio.pause();
            audio.currentTime = 0
            $('#play').addClass('glyphicon-play-circle')
            $('#play').removeClass('glyphicon-pause')
        }
    }
</script>
<script type="text/javascript">
    function takeoff() {
        var audio = document.getElementById('takeoff');
        if (audio.paused) {
            audio.play();
            $('#takeoff').removeClass('glyphicon-play-circle')
            $('#takeoff').addClass('glyphicon-pause')
        }else{
            audio.pause();
            audio.currentTime = 0
            $('#takeoff').addClass('glyphicon-play-circle')
            $('#takeoff').removeClass('glyphicon-pause')
        }
    }
</script>





		<?php //print_r($info);?>
