<div class="row pjVpFoot">
	<?php
	if (isset($tpl['paginator']) && $tpl['paginator']['pages'] > 1)
	{
		$page = 1 ;
		$query_string = $_SERVER['QUERY_STRING'];
		if(empty($query_string)){
			$query_string = "controller=pjListings&amp;action=pjActionListings";
		}
		if(isset($_GET['pjPage'])){
			$page = $_GET['pjPage'];
			$query_string = str_replace("&pjPage=" . $page, "", $query_string);
		}
		?>
		<div class="col-md-8 col-sm-6 col-xs-12">
			<nav class="pjVpPagination">
				<ul class="pagination">
					<?php
					$stages = 3;
					$lastpage = $tpl['paginator']['pages'];
										
					if ($page > 1)
					{
						?>
						<li>
							<a class="pjVpPaging"data-page="<?php echo $page - 1; ?>" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=<?php echo $page - 1; ?>">
								<i class="fa fa-angle-double-left"></i>
								<span class="hidden-xs"><?php __('front_paging_previous');?></span>
							</a>
						</li>
						<?php
					}else{
						?>
						<li>
							<a href="javascript:void(0);">
								<i class="fa fa-angle-double-left"></i>
								<span class="hidden-xs"><?php __('front_paging_previous');?></span>
							</a>
						</li>
						<?php
					}
					if ($lastpage < 7 + ($stages * 2))
					{
						for ($counter = 1; $counter <= $lastpage; $counter++)
						{
							if ($counter == $page)
							{
								?><li class="active"><a href="javascript:void(0);"><?php echo $counter; ?></a></li><?php
							}else{
								?><li><a class="pjVpPaging" data-page="<?php echo $counter; ?>" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=<?php echo $counter; ?>" ><?php echo $counter; ?></a></li><?php
							}
						}
					} else if ($lastpage > 5 + ($stages * 2)){
						
						if($page < 1 + ($stages * 2))		
						{
							for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
							{
								if ($counter == $page){
									?><li class="active"><a href="javascript:void(0);"><?php echo $counter; ?></a></li><?php
								}else{
									?><li><a class="pjVpPaging" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=<?php echo $counter; ?>" ><?php echo $counter; ?></a></li><?php
								}	
							}
							?>
							<li><a href="#">...</a></li>
							<li><a class="pjVpPaging" data-page="<?php echo $lastpage - 1; ?>" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=<?php echo $lastpage - 1; ?>" ><?php echo $lastpage - 1; ?></a></li>
							<li><a class="pjVpPaging" data-page="<?php echo $lastpage; ?>" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=<?php echo $lastpage; ?>" ><?php echo $lastpage; ?></a></li>
							<?php
						}else if($lastpage - ($stages * 2) > $page && $page > ($stages * 2)){
							?>
							<li><a class="pjVpPaging" data-page="1" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=1" >1</a></li>
							<li><a class="pjVpPaging" data-page="2" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=2" >2</a></li>
							<li><a href="#">...</a></li>
							<?php
							for ($counter = $page - $stages; $counter <= $page + $stages; $counter++){
								if ($counter == $page)
								{
									?><li class="active"><a href="javascript:void(0);"><?php echo $counter; ?></a></li><?php
								}else{
									?><li><a class="pjVpPaging" data-page="<?php echo $counter; ?>" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=<?php echo $counter; ?>" ><?php echo $counter; ?></a></li><?php
								}
							}
							?>
							<li><a href="#">...</a></li>
							<li><a class="pjVpPaging" data-page="<?php echo $lastpage - 1; ?>" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=<?php echo $lastpage - 1; ?>" ><?php echo $lastpage - 1; ?></a></li>
							<li><a class="pjVpPaging" data-page="<?php echo $lastpage; ?>" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=<?php echo $lastpage; ?>" ><?php echo $lastpage; ?></a></li>
							<?php
						}else{
							?>
							<li><a class="pjVpPaging" data-page="1" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=1" >1</a></li>
							<li><a class="pjVpPaging" data-page="2" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=2" >2</a></li>
							<li><a href="#">...</a></li>
							<?php
							for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
							{
								if ($counter == $page)
								{
									?><li class="active"><a href="javascript:void(0);"><?php echo $counter; ?></a></li><?php
								}else{
									?><li><a class="pjVpPaging" data-page="<?php echo $counter; ?>" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=<?php echo $counter; ?>" ><?php echo $counter; ?></a></li><?php
								}
							}
						}	
					}
					if ($page < $counter - 1){
						 ?>
						<li>
							<a class="pjVpPaging" data-page="<?php echo $page + 1; ?>" href="<?php echo $_SERVER['PHP_SELF']; ?>?<?php echo $query_string;?>&amp;pjPage=<?php echo $page + 1; ?>">
								<span class="hidden-xs"><?php __('front_paging_next');?></span>
								<i class="fa fa-angle-double-right"></i>
							</a>
						</li>
						<?php
					}else{
						?>
						<li>
							<a href="javascript:void(0);">
								<span class="hidden-xs"><?php __('front_paging_next');?></span>
								<i class="fa fa-angle-double-right"></i>
							</a>
						</li>
						<?php
					}
					?>
				</ul>
			</nav>
		</div><!-- /.col-md-8 col-sm-6 col-xs-12 -->
		<?php
	}
	$item_per_page = __('item_per_page', true);
	ksort($item_per_page);
	?>
	<div class="col-md-4 col-sm-6 col-xs-12 pull-right pjVpItemsPerPage">
		<div class="pjVpPageElements">
			<p><?php __('front_label_show');?></p>
			
			<div class="form-group">
				<select class="form-control" id="pjVpItemsPerPage_<?php echo $index?>" name="pjVpItemsPerPage">
					<?php
					if((int) $tpl['option_arr']['o_items_per_page'] < 10)
					{
						?><option value="<?php echo (int) $tpl['option_arr']['o_items_per_page'];?>" <?php echo $controller->getDefaultItemPerPage() == (int) $tpl['option_arr']['o_items_per_page'] ? 'selected="selected"' : null; ?>><?php echo $tpl['option_arr']['o_items_per_page'];?> <?php (int) $tpl['option_arr']['o_items_per_page'] == 1 ? __('package_per_page') : __('packages_per_page') ;?></option><?php
					}
					foreach($item_per_page as $k => $v)
					{
						?><option value="<?php echo $k?>" <?php echo $controller->getDefaultItemPerPage() == $k ? 'selected="selected"' : null; ?>><?php echo $v;?></option><?php
					} 
					?>
				</select>
			</div><!-- /.form-group -->
			
			<p><?php __('front_label_per_page');?></p>
		</div><!-- /.pjVpPageElements -->
	</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
		
</div><!-- /.row pjVpFoot -->