<?php
if( $_GET['action'] == 'pjActionYachts' && (isset($_GET['for']) && $_GET['for'] == 'sale'))
{ 
	?>
	<div class="jumbotron">
		<div class="container">
			<h1><?php __('ws_yachts_for_sale');?></h1>
	
			<p><?php __('ws_yachts_for_sale_desc');?></p>
		</div><!-- /.container -->
	</div><!-- /.jumbotron -->
	<?php
}
if( $_GET['action'] == 'pjActionYachts' && (isset($_GET['for']) && $_GET['for'] == 'rent'))
{
	?>
	<div class="jumbotron">
		<div class="container">
			<h1><?php __('ws_yachts_for_rent');?></h1>
	
			<p><?php __('ws_yachts_for_rent_desc');?></p>
		</div><!-- /.container -->
	</div><!-- /.jumbotron -->
	<?php
}
$listing_for = __('listing_for', true);
if(!empty($tpl['arr']))
{ 
	?>
	<div class="section">
		<div class="container">
			<div class="yachts">
				<div class="row">
					<?php
					foreach($tpl['arr'] as $v)
					{ 
						$image = '';
						if(!empty($v['image']))
						{
							if(is_file(PJ_INSTALL_PATH . $v['medium_image']))
							{
								$image = PJ_INSTALL_URL . $v['medium_image'];
							}
						}
						$listing_title = pjSanitize::html(stripslashes($v['title']));
						if ($tpl['option_arr']['o_website_seo'] == 'No')
						{
							$url = $_SERVER['SCRIPT_NAME'] . '?controller=pjWebsite&amp;action=pjActionView&amp;id=' . $v['id'] .(isset($_GET['iframe']) ? '&amp;iframe' : NULL);
						} else {
							$path = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']));
							$path = $path == '/' ? '' : $path;
							$url = $path .'/'. $controller->friendlyURL($v['title']) . "-". $v['id'] . ".html";
						}
						$price = '';
						if($v['for'] == 'sale' && !empty($v['listing_price']))
						{
							$price = pjUtil::formatCurrencySign(number_format($v['listing_price'], 0, '.', ','), $tpl['option_arr']['o_currency']);
						}else{
							if($v['min_price'] != '' || $v['max_price'] != '')
							{
								if($v['min_price'] == $v['max_price'])
								{
									$price = pjUtil::formatCurrencySign(number_format($v['min_price'], 0, '.', ','), $tpl['option_arr']['o_currency']) . ' ' . __('front_per_week', true);
								}else{
									$price = pjUtil::formatCurrencySign(number_format($v['min_price'], 0, '.', ','), $tpl['option_arr']['o_currency']) . ' - ' . $price = pjUtil::formatCurrencySign(number_format($v['max_price'], 0, '.', ','), $tpl['option_arr']['o_currency']) . ' ' . __('front_per_week', true);
								}
							}
						}
						?>
						<div class="col-sm-4">
							<a href="<?php echo $url;?>" class="yacht">
								<div class="yacht-head">
									<div class="yacht-title"><?php echo $listing_title;?></div><!-- /.yacht-title -->
		
									<div class="yacht-price"><?php echo $price;?></div><!-- /.yacht-price -->
								</div><!-- /.yacht-head -->
		
								<div class="yacht-body">
									<img src="<?php echo $image;?>" alt="">
		
									<div class="yacht-body-overlay">
										<ul>
											<?php
											if(!empty($v['listing_year']))
											{ 
												?><li><span><?php __('ws_listing_year');?>:</span> <?php echo $v['listing_year'];?></li><?php
											}
											if(!empty($v['listing_loa']))
											{
												?><li><span><?php __('ws_listing_loa');?>:</span> <?php echo $v['listing_loa'];?></li><?php
											}
											if(!empty($v['listing_beam']))
											{
												?><li><span><?php __('ws_listing_beam');?>:</span> <?php echo $v['listing_beam'];?></li><?php
											}
											$enum_arr = __('enum_arr', true);
											if(!empty($v['listing_length']))
											{
												?><li><span><?php __('ws_listing_length');?>:</span> <?php echo pjSanitize::html($v['listing_length']);?> <?php echo $enum_arr[$tpl['option_arr']['o_length']];?></li><?php
											}
											if(!empty($v['listing_power']))
											{
												?><li><span><?php __('ws_listing_power');?>:</span> <?php echo pjSanitize::html($v['listing_power']);?> <?php echo $enum_arr[$tpl['option_arr']['o_power']];?></li><?php
											} 
											?>
										</ul>
									</div><!-- /.yacht-body-overlay -->
								</div><!-- /.yacht-body -->
							</a><!-- /.yacht -->
						</div><!-- /.col-sm-4 -->
						<?php
					} 
					?>
				</div><!-- /.row -->
				<?php include_once dirname(__FILE__) . '/elements/paginator.php';?>
				
			</div><!-- /.yachts -->
		</div><!-- /.container -->
	</div><!-- /.main -->
	<?php
}else{
	?>
	<div class="section">
		<div class="container">
			<div class="yachts">
				<?php __('ws_yachts_not_found');?>
			</div>
		</div>
	</div>
	<?php
} 
?>