<?php
ob_start();
$show_outbound = false;
$show_inbound = false;
if(!empty($tpl['arr']['outbound_from']) || !empty($tpl['arr']['outbound_to']) || !empty($tpl['arr']['outbound_departs']) || !empty($tpl['arr']['outbound_arrives']))
{
	$show_outbound = true;
}
if(!empty($tpl['arr']['inbound_from']) || !empty($tpl['arr']['inbound_to']) || !empty($tpl['arr']['inbound_departs']) || !empty($tpl['arr']['inbound_arrives']))
{
	$show_inbound = true;
}
?>
<div class="panel-body pjVpProductSectionBody">
	<ul class="list-unstyled pjVpFlights">
		<?php
		if($show_outbound == true)
		{
			?>
			<li class="pjVpFlight pjVpFlightActive">
				<blockquote>
					<div class="row">
						<div class="col-md-3 col-sm-3 col-xs-12">
							<p class="pjVpFlightTitle"><?php __('front_label_outbound_flight');?></p>
						</div><!-- /.col-md-3 col-sm-3 col-xs-12 -->
				
						<div class="col-md-3 col-sm-3 col-xs-6">
							<p class="text-uppercase pjVpFlightTitleSmall"><?php __('front_label_departure');?></p>
							<?php
							if(!empty($tpl['arr']['outbound_departs']))
							{
								?>
								<strong><span><?php echo pjUtil::formatDate(date('Y-m-d', strtotime($tpl['arr']['outbound_departs'])), 'Y-m-d', $tpl['option_arr']['o_date_format']) . ' ' . pjUtil::formatTime(date('H:i:s', strtotime($tpl['arr']['outbound_departs'])), 'H:i:s', $tpl['option_arr']['o_time_format']);?></span></strong>
								<?php
							}
							if(!empty($tpl['arr']['outbound_from']))
							{
								?>
								<span><?php echo stripslashes($tpl['arr']['outbound_from']);?></span>
								<?php
							} 
							?>
						</div><!-- /.col-md-3 col-sm-3 col-xs-6 -->
				
						<div class="col-md-3 col-sm-3 col-xs-6">
							<p class="text-uppercase pjVpFlightTitleSmall"><?php __('front_label_duration');?></p>
							<strong><?php __('front_label_total_duration');?>:</strong>
							<?php
							$duration = '&nbsp;';
							if(!empty($tpl['arr']['outbound_departs']) && !empty($tpl['arr']['outbound_arrives']))
							{
								$diff = pjUtil::getTotalDuration($tpl['arr']['outbound_departs'], $tpl['arr']['outbound_arrives']);
								if(!empty($diff))
								{
									$duration =  $diff['hours'] . __('front_label_hour', true) . ' ' . $diff['mins'] . __('front_label_minute', true);
								}
							}
							
							?>
							<span><?php echo $duration;?></span>
						</div><!-- /.col-md-3 col-sm-3 col-xs-6 -->
				
						<div class="col-md-3 col-sm-3 col-xs-6">
							<p class="text-uppercase pjVpFlightTitleSmall"><?php __('front_label_arrival');?></p>
							<?php
							if(!empty($tpl['arr']['outbound_arrives']))
							{ 
								?><strong><span><?php echo pjUtil::formatDate(date('Y-m-d', strtotime($tpl['arr']['outbound_arrives'])), 'Y-m-d', $tpl['option_arr']['o_date_format']) . ' ' . pjUtil::formatTime(date('H:i:s', strtotime($tpl['arr']['outbound_arrives'])), 'H:i:s', $tpl['option_arr']['o_time_format']);?></span></strong><?php
							}
							if(!empty($tpl['arr']['outbound_to']))
							{
								?><span><?php echo stripslashes($tpl['arr']['outbound_to']);?></span><?php
							} 
							?>
						</div><!-- /.col-md-3 col-sm-3 col-xs-12 -->
					</div><!-- /.row -->
				</blockquote>
			</li>
			<?php
		}
		if($show_inbound == true)
		{
			?>
			<li class="pjVpFlight pjVpFlightActive">
				<blockquote>
					<div class="row">
						<div class="col-md-3 col-sm-3 col-xs-12">
							<p class="pjVpFlightTitle"><?php __('front_label_outbound_flight');?></p>
						</div><!-- /.col-md-3 col-sm-3 col-xs-12 -->
				
						<div class="col-md-3 col-sm-3 col-xs-6">
							<p class="text-uppercase pjVpFlightTitleSmall"><?php __('front_label_departure');?></p>
							<?php
							if(!empty($tpl['arr']['inbound_departs']))
							{
								?>
								<strong><span><?php echo pjUtil::formatDate(date('Y-m-d', strtotime($tpl['arr']['inbound_departs'])), 'Y-m-d', $tpl['option_arr']['o_date_format']) . ' ' . pjUtil::formatTime(date('H:i:s', strtotime($tpl['arr']['inbound_departs'])), 'H:i:s', $tpl['option_arr']['o_time_format']);?></span></strong>
								<?php
							}
							if(!empty($tpl['arr']['inbound_from']))
							{
								?>
								<span><?php echo stripslashes($tpl['arr']['inbound_from']);?></span>
								<?php
							} 
							?>
						</div><!-- /.col-md-3 col-sm-3 col-xs-6 -->
				
						<div class="col-md-3 col-sm-3 col-xs-6">
							<p class="text-uppercase pjVpFlightTitleSmall"><?php __('front_label_duration');?></p>
							<strong><?php __('front_label_total_duration');?>:</strong>
							<?php
							$duration = '&nbsp;';
							if(!empty($tpl['arr']['inbound_departs']) && !empty($tpl['arr']['inbound_arrives']))
							{
								$diff = pjUtil::getTotalDuration($tpl['arr']['inbound_departs'], $tpl['arr']['inbound_arrives']);
								if(!empty($diff))
								{
									$duration =  $diff['hours'] . __('front_label_hour', true) . ' ' . $diff['mins'] . __('front_label_minute', true);
								}
							}
							
							?>
							<span><?php echo $duration;?></span>
						</div><!-- /.col-md-3 col-sm-3 col-xs-6 -->
				
						<div class="col-md-3 col-sm-3 col-xs-6">
							<p class="text-uppercase pjVpFlightTitleSmall"><?php __('front_label_arrival');?></p>
							<?php
							if(!empty($tpl['arr']['inbound_arrives']))
							{ 
								?><strong><span><?php echo pjUtil::formatDate(date('Y-m-d', strtotime($tpl['arr']['inbound_arrives'])), 'Y-m-d', $tpl['option_arr']['o_date_format']) . ' ' . pjUtil::formatTime(date('H:i:s', strtotime($tpl['arr']['inbound_arrives'])), 'H:i:s', $tpl['option_arr']['o_time_format']);?></span></strong><?php
							}
							if(!empty($tpl['arr']['inbound_to']))
							{
								?><span><?php echo stripslashes($tpl['arr']['inbound_to']);?></span><?php
							} 
							?>
						</div><!-- /.col-md-3 col-sm-3 col-xs-12 -->
					</div><!-- /.row -->
				</blockquote>
			</li>
			<?php
		}
		if(!empty($tpl['arr']['flight_notes']))
		{
			$note_length = mb_strlen($tpl['arr']['flight_notes']);
			?>
			<li class="pjVpFlight">
				<blockquote>
					<div class="row">
						<div class="col-md-3 col-sm-3 col-xs-12">
							<p class="pjVpFlightTitle"><?php __('front_label_flight_details');?></p>
						</div><!-- /.col-md-3 col-sm-3 col-xs-12 -->
						<div class="col-md-9 col-sm-9 col-xs-12">
							<?php
							if($note_length <= 400)
							{ 
								?><div><?php echo nl2br(stripslashes($tpl['arr']['flight_notes']));?></div><?php 
							}else{
								?>
								<div id="pjVpShortNotes_<?php echo $index;?>" class="pjVpFlightNotes">
									<div><?php echo nl2br(stripslashes(pjUtil::truncateDescription($tpl['arr']['flight_notes'], 400, ' ')));?></div>
									<a class="pjVpShowFlightNotes" href="#" data-show="all"><?php __('front_label_show_all');?></a>
								</div>
								<div id="pjVpFullNotes_<?php echo $index;?>" class="pjVpFlightNotes" style="display:none;">
									<div><?php echo nl2br(stripslashes($tpl['arr']['flight_notes']));?></div>
									<a class="pjVpShowFlightNotes" href="#" data-show="lest"><?php __('front_label_show_less');?></a>
								</div>
								<?php
							}
							?>
						</div>
					</div><!-- /.row -->
				</blockquote>
			</li>
			<?php
		} 
		?>
	</ul>
</div>
<?php
$ob_flight = ob_get_contents();
ob_end_clean(); 
if (!empty($ob_flight) && $tpl['arr']['flight_included'] == 'T')
{
	?>
	<div class="panel panel-default pjVpProductSection">
		<div class="panel-heading pjVpProductSectionHead">
			<h3 class="panel-title pjVpProductSectionTitle"><?php __('front_label_flight_info'); ?></h3><!-- /.panel-title -->
		</div><!-- /.panel-heading pjVpProductSectionHead -->
		<?php echo $ob_flight;?>
	</div>
	<?php
} 
?>
							