<?php
mt_srand();
$index = mt_rand(1, 9999);
?>
<div id="pjWrapper">
	<div class="container-fluid pjYpContainer">
		<?php include_once ROOT_PATH . PJ_TEMPLATE_PATH . 'default/elements/header.php';?>
		
		<div class="pjYpBody">
			<?php include_once ROOT_PATH . PJ_TEMPLATE_PATH . 'default/elements/filter.php';?>
			
			<?php
			if(!empty($tpl['arr']))
			{ 
				?>
				<div class="row pjYpResults">
					<?php
					foreach($tpl['arr'] as $v)
					{
						$image = PJ_INSTALL_URL . PJ_IMG_PATH . 'frontend/no-image.png';
						if(!empty($v['image']))
						{
							if(is_file(PJ_INSTALL_PATH . $v['image']))
							{
								$image = PJ_INSTALL_URL . $v['image'];
							}
						}
						$listing_title = pjSanitize::html(stripslashes($v['title']));
						if ($tpl['option_arr']['o_seo_url'] == 'No')
						{
							$url = $_SERVER['SCRIPT_NAME'] . '?controller=pjListings&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";
						}
						$description = pjUtil::html2txt($v['description']);
						$description = pjUtil::truncateDescription($description, 110, ' ');						
						?>
						<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 pjYpResult">
							<a href="<?php echo $url; ?>">
								<div class="panel panel-default">
									<header class="panel-heading">
										<p class="panel-title"><?php echo $listing_title;?></p><!-- /.panel-title pjYpResultTitle -->
									</header><!-- /.panel-heading pjYpResultHead -->
								
									<div class="panel-body">
										<div class="row">
											<div class="col-lg-4 col-md-4 col-sm-5 col-xs-4 pjYpResultImage">
												<img src="<?php echo $image;?>" alt="" />
											</div><!-- /.col-lg-4 col-md-4 col-sm-5 col-xs-4 pjYpResultImage -->
								
											<div class="col-lg-8 col-md-8 col-sm-7 col-xs-8 pjYpResultContent">
												<p class="wrap"><?php echo $description;?></p>
								
												<div class="pjYpResultActions">
													<button class="btn btn-primary">
														<span class="glyphicon glyphicon-plus"></span>
														<?php __('label_view_more');?>
													</button>
												</div><!-- /.pjYpResultActions -->
											</div><!-- /.col-lg-8 col-md-8 col-sm-7 col-xs-8 pjYpResultContent -->
										</div><!-- /.row -->
									</div><!-- /.panel-body pjYpResultBody -->
								</div><!-- /.panel panel-default -->
							</a>
						</div><!-- /.col-lg-6 col-md-6 col-sm-6 col-xs-12 pjYpResult -->
						<?php
					}
					?>
				</div><!-- /.row pjYpResults -->
				<?php
			}else{
				?><p class="pjYpNoResultsText"><?php __('label_not_found');?></p><!-- /.pjYpNoResultsText --><?php
			} 
			?>
		</div><!-- /.pjYpBody -->
		<?php
		if(!empty($tpl['arr']))
		{
			include_once ROOT_PATH . PJ_TEMPLATE_PATH . 'default/elements/pagination.php';
		}
		?>
	</div><!-- /.container-fluid pjYpContainer -->
</div><!-- #pjWrapper -->