<?php
mt_srand();
$index = mt_rand(1, 9999);
?>
<div id="pjWrapper" style="display:none;">
	<div class="container-fluid pjVpContainer">
		<?php 
		include_once ROOT_PATH . PJ_TEMPLATE_PATH . 'default/elements/header.php';
		
		$has_filter = false;
		?>
		<form id="pjVpFilterForm_<?php echo $index;?>" action="<?php echo $_SERVER['PHP_SELF'];?>?controller=pjListings&amp;action=pjActionListings" method="get">
			<input type="hidden" name="controller" value="pjListings"/>
			<input type="hidden" name="action" value="pjActionListings"/>
			<input type="hidden" name="listing_search" value="1"/>
			<input type="hidden" name="view" value="<?php echo isset($_GET['view']) && in_array($_GET['view'], array('list', 'grid', 'map')) ? $_GET['view'] : 'list';?>"/>
			<?php
			if(isset($_GET['column']) && in_array($_GET['column'], array('min', 'listing_rating')))
			{
				?><input type="hidden" name="column" value="<?php echo $_GET['column'];?>"/><?php
			}
			if(isset($_GET['direction']) && in_array(strtoupper($_GET['direction']), array('ASC', 'DESC')))
			{
				?><input type="hidden" name="direction" value="<?php echo $_GET['direction'];?>"/><?php
			}
			if(isset($_GET['season']) && (int) $_GET['season'] > 0)
			{
				?><input type="hidden" name="season" value="<?php echo $_GET['season'];?>"/><?php
				$has_filter = true;
			}
			if(isset($_GET['type']) && (int) $_GET['type'] > 0)
			{
				?><input type="hidden" name="type" value="<?php echo $_GET['type'];?>"/><?php
				$has_filter = true;
			}
			if(isset($_GET['price_from']) && (int) $_GET['price_from'] > 0)
			{
				?><input type="hidden" name="price_from" value="<?php echo $_GET['price_from'];?>"/><?php
				$has_filter = true;
			}
			if(isset($_GET['price_to']) && (int) $_GET['price_to'] > 0)
			{
				?><input type="hidden" name="price_to" value="<?php echo $_GET['price_to'];?>"/><?php
				$has_filter = true;
			}
			if(isset($_GET['rating_from']) && (int) $_GET['rating_from'] > 0)
			{
				?><input type="hidden" name="rating_from" value="<?php echo $_GET['rating_from'];?>"/><?php
				$has_filter = true;
			}
			if(isset($_GET['rating_to']) && (int) $_GET['rating_to'] > 0)
			{
				?><input type="hidden" name="rating_to" value="<?php echo $_GET['rating_to'];?>"/><?php
				$has_filter = true;
			}
			if(isset($_GET['location']))
			{
				?><input type="hidden" name="location" value="<?php echo $_GET['location'];?>"/><?php
				$has_filter = true;
			}
			if(isset($_GET['item_per_page']) && (int) $_GET['item_per_page'] > 0)
			{
				?><input type="hidden" name="item_per_page" value="<?php echo $_GET['item_per_page'];?>"/><?php
			} 
			?>
		</form>
		<?php
		include_once ROOT_PATH . PJ_TEMPLATE_PATH . 'default/elements/filter.php';
		?>
		
		<div class="row pjVpFiltersBottom">
			<div class="col-md-6 col-sm-6 col-xs-12">
				<?php
				if($controller->getDefaultView() != 'map')
				{
					?>
					<span class="sort-by"><?php __('front_label_sort_by');?>:</span>
					<div class="btn-group">
						<div class="btn-group" role="group">
							<button type="button" class="btn btn-default dropdown-toggle" data-pj-toggle="dropdown" aria-expanded="false"><?php __('front_label_price');?> <span class="caret"></span></button>
					
							<ul class="dropdown-menu" role="menu">
								<li><a href="#" class="pjVpSortLink" data-column="min" data-direction="DESC"><?php __('front_highest_to_lowest');?></a></li>
								<li><a href="#" class="pjVpSortLink" data-column="min" data-direction="ASC"><?php __('front_lowest_to_highest');?></a></li>
							</ul>
						</div>
					
						<div class="btn-group" role="group">
							<button type="button" class="btn btn-default dropdown-toggle" data-pj-toggle="dropdown" aria-expanded="false"><?php __('front_sortby_start');?> <span class="caret"></span></button>
					
							<ul class="dropdown-menu" role="menu">
								<li><a href="#" class="pjVpSortLink" data-column="listing_rating" data-direction="DESC"><?php __('front_highest_to_lowest');?></a></li>
								<li><a href="#" class="pjVpSortLink" data-column="listing_rating" data-direction="ASC"><?php __('front_lowest_to_highest');?></a></li>
							</ul>
						</div>
					
					</div><!-- /.btn-group -->
					<?php
				} 
				?>
			</div><!-- /.col-md-6 col-sm-6 col-xs-12 -->
						
			<div class="col-md-6 col-sm-6 col-xs-6 hidden-xs">
				<ul class="list-inline pull-right pjVpLayouts">
					<li class="pjVpLayout<?php echo $controller->getDefaultView() == 'list' ? ' pjVpLayoutActive' : null;?>">
						<a href="#" data-view="list" class="btn btn-default pjVpBtn pjVpBtnPrimary pjVpBtnView<?php echo $controller->getDefaultView() == 'list' ? ' pjVpBtnActive' : null;?>">
							<i class="fa fa-bars"></i>
						</a>
					</li>
					
					<li class="pjVpLayout<?php echo $controller->getDefaultView() == 'grid' ? ' pjVpLayoutActive' : null;?>">
						<a href="#" data-view="grid" class="btn btn-default pjVpBtn pjVpBtnPrimary pjVpBtnView<?php echo $controller->getDefaultView() == 'grid' ? ' pjVpBtnActive' : null;?>">
							<i class="fa fa-th"></i>
						</a>
					</li>
					
					<li class="pjVpLayout<?php echo $controller->getDefaultView() == 'map' ? ' pjVpLayoutActive' : null;?>">
						<a href="#" data-view="map" class="btn btn-default pjVpBtn pjVpBtnPrimary pjVpBtnView<?php echo $controller->getDefaultView() == 'map' ? ' pjVpBtnActive' : null;?>">
							<i class="fa fa-map-marker"></i>
						</a>
					</li>
				</ul><!-- /.list-inline pull-right pjVpLayouts -->
			</div><!-- /.col-md-6 col-sm-6 col-xs-6 -->
		</div><!-- /.row pjVpFiltersBottom -->
		
		<div class="pjVpBody">
			<?php
			if(!empty($tpl['arr']))
			{
				switch ($controller->getDefaultView()) 
				{
					case 'list':
						include_once ROOT_PATH . PJ_TEMPLATE_PATH . 'default/elements/_list.php';
						break;
					case 'grid':
						include_once ROOT_PATH . PJ_TEMPLATE_PATH . 'default/elements/_grid.php';
						break;
					case 'map':
						include_once ROOT_PATH . PJ_TEMPLATE_PATH . 'default/elements/_map.php';
						break;
					default:
						include_once ROOT_PATH . PJ_TEMPLATE_PATH . 'default/elements/_list.php';
						break;
				}	
			} else {
				__('front_label_not_found');
			} 
			?>
		</div><!-- /.pjVpBody -->
		
		<?php
		if(!empty($tpl['arr']))
		{ 
			include_once ROOT_PATH . PJ_TEMPLATE_PATH . 'default/elements/pagination.php';
		}
		?>
		<div class="pjVpScrollSection"><a id="pjVpScrollToTop_<?php echo $index;?>" class="btn btn-default pjVpScrollToTop" href="#"><i class="fa fa-chevron-up"></i>&nbsp;<span><?php __('front_label_top');?></span></a></div>
	</div><!--  /.container-fluid pjVpContainer  -->
</div><!-- /.pjWrapper -->

<?php include_once ROOT_PATH . PJ_TEMPLATE_PATH . 'default/elements/loadjs.php';?>