<?php   session_start(); include 'xyz.php';
 $webPID = substr($_REQUEST['param'],-7,7); 
if(QueryDB("SELECT count(*) FROM products where item_pid='$webPID' ")->fetchColumn()<1){
	header('location:index'); die();
}
$selProduct =getProductWithPID($webPID);
$img1 = explode(',',$selProduct['item_img'])[0];
$prodName = str_replace('-',' ',prodName($selProduct['id'],$selProduct['item_pid']));
$Selitem_category=$selProduct['brand'];

$metalink =$sized_by[$selProduct['size']].$colored_by[$selProduct['color']].' '.$selProduct['item_name'].' '.$company[$selProduct['company']].' '.$brand[$selProduct['brand']].' -'.$selProduct['item_offer'].'% OFF';
$single_img =explode(',',$selProduct['item_img'])[0];
if(file_exists($single_img)){
	$metaImg = $single_img;
}else{ $metaImg = $getApp['comp_logo'];  }




?>

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1">
</style>
		<?php  include 'inc/outl_toplinks.php'; ?>
		<link rel="stylesheet" type="text/css" href="css/outl_ulib.css">



<meta name="keywords" content="<?php  echo $metalink;  ?>">

 
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:description" content="<?php echo $metalink; ?>"/>
<meta name="twitter:title" content="<?php echo $selProduct['item_desc'];  ?>"/>
<meta name="twitter:site" content="@brainpalsClass"/>
<meta name="twitter:domain" content="<?php echo $selProduct['item_desc'];  ?>"/>
<meta name="twitter:image:src" content="https://www.sholarindeelectronics.com.ng/<?php echo $metaImg; ?>"/>
<meta name="twitter:creator" content="@brainpalscode"/>

<meta property="og:locale" content="en_US" />
<meta property="og:type" content="article" />
<meta property="og:title" content="<?php echo $metalink; ?>" />
<meta property="og:description" content="<?php echo $selProduct['item_desc'];  ?>" />
<meta property="og:url" content="https://www.brainpals.com.ng/" />
<meta property="og:site_name" content="brainpals" />
<meta property="article:publisher" content="" />
<meta property="og:image" content="https://www.sholarindeelectronics.com.ng/<?php echo $metaImg; ?>" />











</head>
<body><?php include 'inc/outl_header.php';  include 'inc/outl_nav.php'; include 'process.php'; ?>
	


		
		<!-- BREADCRUMB -->
		<div id="breadcrumb" class="section">
			<!-- container -->
			<div class="container">
				<!-- row -->
				<div class="row">
					<div class="col-md-12">
						<ul class="breadcrumb-tree">
							<li><a href="#">Home</a></li>
							<li><a href="../company/<?php echo $company[$selProduct['company']]; ?>"><?php echo $company[$selProduct['company']];  ?></a></li>
							<li><a href="../<?php echo $brand[$selProduct['brand']]; ?>"><?php echo $brand[$selProduct['brand']]; ?></a></li>
							<li><a href="#"><?php echo $selProduct['item_name']; ?></a></li>
							
						</ul>
					</div>
				</div>
				<!-- /row -->
			</div>
			<!-- /container -->
		</div>
		<!-- /BREADCRUMB -->

<?php 




?>


		<!-- SECTION -->
		<div class="section">
			<!-- container -->
			<div class="container">
				<!-- row -->
				<div class="row">
					<!-- Product main img -->
					<div class="col-md-5 col-md-push-2">
						<div id="product-main-img">
		<?php foreach(explode(',',$selProduct['item_img']) as $img){

echo '<div class="product-preview"><img src="'.str_replace('../','',$img).'" alt="'.$prodName.'">
							</div>';}?></div></div>
					<!-- /Product main img -->

					<!-- Product thumb imgs -->
					<div class="col-md-2  col-md-pull-5">
						<div id="product-imgs">
<?php foreach(explode(',',$selProduct['item_img']) as $img){?>					
<div class="product-preview"><img src="<?php echo str_replace('../','',$img); ?>" alt=""></div> <?php } ?>
						</div>
					</div>
					<!-- /Product thumb imgs -->

					<!-- Product details -->
					<div class="col-md-5">
						<div class="product-details">
							<h2 class="product-name"><?php echo $prodName;  ?></h2>
							<div>
								<div class="product-rating">
									<i class="fa fa-star"></i>
									<i class="fa fa-star"></i>
									<i class="fa fa-star"></i>
									<i class="fa fa-star"></i>
									<i class="fa fa-star-o"></i>
								</div>
<a class="review-link" href="#">
	<?php echo QueryDB("SELECT COUNT(*) FROM reviews where pid='$webPID' and status=1 ")->fetchColumn(); ?> Review(s)</a>
							</div>
							<div>
								<h3 class="product-price myPrs" id="<?php echo calcDiscount($selProduct['item_cost'],$selProduct['item_offer']); ?>">&#8358;<span id="addPrice"><?php echo number_format(calcDiscount($selProduct['item_cost'],$selProduct['item_offer'])); ?></span><del class="product-old-price">&#8358;<?php echo $selProduct['item_cost'];  ?></del></h3>
								<span class="product-available">
<?php $inStock =  totalStock($selProduct['id'],'','')-getQuantity($selProduct['id'],'','');
if($inStock>0){  echo $inStock.' In Stock'; }else{ echo 'Out Stock'; }
?>
<span style="display:none;" id="itemCounts" class="<?php echo $inStock; ?>"></span>

							</span>
							</div>
							<p><?php echo substr($selProduct['item_desc'],0,160).'...';  ?></p>

							<div class="product-options">
								<label>
									Size
									<select class="input-select">
						<option value="0"><?php echo $sized_by[$selProduct['size']]; ?></option>
									</select>
								</label>
								<label>
									Color
									<select class="input-select">
										<option value="0"><?php echo $colored_by[$selProduct['color']]; ?></option>
									</select>
								</label>
							</div>
<span style="display:none;" id="item" class="<?php echo $selProduct['id'];//$webPID; ?>"></span>
<span style="display:none;" id="discount" class="<?php echo $selProduct['item_offer']; ?>"></span>

							<div class="add-to-cart">
								<div class="qty-label">
									Qty
									<div class="input-number">
										<input type="number" required value="1" id="growNumb" readonly>
										<span class="qty-up" id="grow">+</span>
										<span class="qty-down" id="grDown">-</span>
									</div>
								</div>
<?php  if(isset($_SESSION['mycus'])){ if($inStock>0){?>
<button class="btn btn-danger addCart"><i class="fa fa-shopping-cart"></i> add to cart</button>
	<?php } }else{ $_SESSION['directory']=$_REQUEST['param'];   ?><a href="login" class="btn btn-primary">Sign In</a> &nbsp; <a href="register" class="btn btn-info">Sign Up</a> <?php  } ?>
							</div>

							<!-- <ul class="product-btns">
								<li><a href="#"><i class="fa fa-heart-o"></i> add to wishlist</a></li>
								<li><a href="#"><i class="fa fa-exchange"></i> add to compare</a></li>
							</ul> -->

							<ul class="product-links">
								<li>Category:</li>
								<li><a href="#"><?php echo $brand[$selProduct['brand']];  ?></a></li>
								<!-- <li><a href="#">Accessories</a></li> -->
							</ul>

							<ul class="product-links">
								<li>Share:</li>
								<li>
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $_REQUEST['param']; ?>.html" target="_blank">
    <i class="fa fa-facebook"></i>
</a></li>
<li><a href="https://api.whatsapp.com/send?text=<?php echo $_REQUEST['param']; ?>.html"><i class="fa fa-whatsapp"></i></a></li>
<li><a href="https://www.instagram.com/sharer.php?u=<?php echo $_REQUEST['param']; ?>.html"><i class="fa fa-instagram"></i></a></li>
								<!-- <li><a href="#"><i class="fa fa-twitter"></i></a></li>
								<li><a href="#"><i class="fa fa-google-plus"></i></a></li>
								<li><a href="#"><i class="fa fa-envelope"></i></a></li> -->
							</ul>

						</div>
					</div>
					<!-- /Product details -->

					<!-- Product tab -->
					<div class="col-md-12">
						<div id="product-tab">
							<!-- product tab nav -->
							<ul class="tab-nav">
								<li class="active"><a data-toggle="tab" href="#tab1">Description</a></li>
								<li><a data-toggle="tab" href="#tab2">Details</a></li>
								<li><a data-toggle="tab" href="#tab3">Reviews (<?php echo QueryDB("SELECT COUNT(*) FROM reviews where pid='$webPID' and status=1 ")->fetchColumn(); ?>)</a></li>
							</ul>
							<!-- /product tab nav -->

							<!-- product tab content -->
							<div class="tab-content">
								<!-- tab1  -->
								<div id="tab1" class="tab-pane fade in active">
									<div class="row">
										<div class="col-md-12">
											<p><?php echo $selProduct['item_desc']; ?></p>
										</div>
									</div>
								</div>
								<!-- /tab1  -->

								<!-- tab2  -->
								<div id="tab2" class="tab-pane fade in">
									<div class="row">
										<div class="col-md-12">
											<p><?php echo $selProduct['item_details']; ?></p>
										</div>
									</div>
								</div>
								<!-- /tab2  -->

								<!-- tab3  -->
								<div id="tab3" class="tab-pane fade in">
									<div class="row">
										<!-- Rating -->
										<div class="col-md-3">
											<div id="rating">
												<div class="rating-avg">
													<span>4.5</span>
													<div class="rating-stars">
														<i class="fa fa-star"></i>
														<i class="fa fa-star"></i>
														<i class="fa fa-star"></i>
														<i class="fa fa-star"></i>
														<i class="fa fa-star-o"></i>
													</div>
												</div>
												<ul class="rating">
													<li>
														<div class="rating-stars">
															<i class="fa fa-star"></i>
															<i class="fa fa-star"></i>
															<i class="fa fa-star"></i>
															<i class="fa fa-star"></i>
															<i class="fa fa-star"></i>
														</div>
														<div class="rating-progress">
															<div style="width: 80%;"></div>
														</div>
														<span class="sum">3</span>
													</li>
													<li>
														<div class="rating-stars">
															<i class="fa fa-star"></i>
															<i class="fa fa-star"></i>
															<i class="fa fa-star"></i>
															<i class="fa fa-star"></i>
															<i class="fa fa-star-o"></i>
														</div>
														<div class="rating-progress">
															<div style="width: 60%;"></div>
														</div>
														<span class="sum">2</span>
													</li>
													<li>
														<div class="rating-stars">
															<i class="fa fa-star"></i>
															<i class="fa fa-star"></i>
															<i class="fa fa-star"></i>
															<i class="fa fa-star-o"></i>
															<i class="fa fa-star-o"></i>
														</div>
														<div class="rating-progress">
															<div></div>
														</div>
														<span class="sum">0</span>
													</li>
													<li>
														<div class="rating-stars">
															<i class="fa fa-star"></i>
															<i class="fa fa-star"></i>
															<i class="fa fa-star-o"></i>
															<i class="fa fa-star-o"></i>
															<i class="fa fa-star-o"></i>
														</div>
														<div class="rating-progress">
															<div></div>
														</div>
														<span class="sum">0</span>
													</li>
													<li>
														<div class="rating-stars">
															<i class="fa fa-star"></i>
															<i class="fa fa-star-o"></i>
															<i class="fa fa-star-o"></i>
															<i class="fa fa-star-o"></i>
															<i class="fa fa-star-o"></i>
														</div>
														<div class="rating-progress">
															<div></div>
														</div>
														<span class="sum">0</span>
													</li>
												</ul>
											</div>
										</div>
										<!-- /Rating -->

										<!-- Reviews -->
										<div class="col-md-6">
											<div id="reviews">
												<ul class="reviews">
					<?php  foreach(QueryDB("SELECT * FROM reviews where pid='$webPID' ")as $myRev){?>
													<li>
														<div class="review-heading">
															<h5 class="name">John</h5>
															<p class="date">
<?php  echo date('D M Y, h:i A',$myRev['date_rev']); ?></p>
															<div class="review-rating">
														<?php  echo $myRev['stars'].'/5'; ?>
															</div>
														</div>
														<div class="review-body">
															<p><?php echo $myRev['reviews']; ?></p>
														</div>
													</li>
							<?php  } ?>
													
												</ul>
												<ul class="reviews-pagination">
													<li class="active">1</li>
													<li><a href="#">2</a></li>
													<li><a href="#">3</a></li>
													<li><a href="#">4</a></li>
													<li><a href="#"><i class="fa fa-angle-right"></i></a></li>
												</ul>
											</div>
										</div>
										<!-- /Reviews -->

										<!-- Review Form -->
										<div class="col-md-3">
											<div id="review-form">
						<form class="review-form" action="" method="POST">
													<!-- <input class="input" type="text" placeholder="Your Name">
													<input class="input" type="email" placeholder="Your Email"> -->
													<textarea class="input" placeholder="Your Review" name="textMsg" maxlength="160" minlength="10" required></textarea>
													<div class="input-rating">
														<span>Your Rating: </span>
						<select class="form-control" required name="rating">
							<option value="5">Excellent</option>
							<option value="4">Great</option>
							<option value="3">Satisfactory</option>
							<option value="2">Average</option>
							<option value="1">Poor</option>

						</select>
													</div>
						<input type="submit" name="sendreviews" value="Submit Review" class="btn btn-info">
													
												</form>
											</div>
										</div>
										<!-- /Review Form -->
									</div>
								</div>
								<!-- /tab3  -->
							</div>
							<!-- /product tab content  -->
						</div>
					</div>
					<!-- /product tab -->
				</div>
				<!-- /row -->
			</div>
			<!-- /container -->
		</div>
		<!-- /SECTION -->

		<!-- Section -->
		<div class="section">
			<!-- container -->
			<div class="container">
				<!-- row -->
				<div class="row">

					<div class="col-md-12">
						<div class="section-title text-center">
							<h3 class="title">Related Products</h3>
						</div>
					</div>

					<!-- product -->
<?php    foreach(QueryDB("SELECT * FROM products where brand='$Selitem_category' and tm_status=1 ORDER BY RAND() ")as $listProd){?><div class="col-md-3 col-xs-6"><div class="product">
<div class="product-img"><img src="<?php 
echo explode(',',str_replace('../','',$listProd['item_img']))[0];  ?>" alt="">
<div class="product-label"><?php  if($listProd['item_offer']!=0){  echo '<span class="sale">-'.$listProd['item_offer'].'%</span>';  }  ?><span class="new">Original</span></div></div>
							<div class="product-body">
								<p class="product-category"><?php echo $brand[$listProd['brand']]; ?></p>
								<h3 class="product-name"><a href="#"><?php  echo $company[$listProd['company']].','.$listProd['item_name'].' '.$brand[$listProd['brand']] ?></a></h3>
		<p><?php echo '<b>Size:</b> '.$sized_by[$listProd['size']].' <b>Colour:</b> '.$colored_by[$listProd['color']];  ?></p>
	<h4 class="product-price">
&#8358;<?php  echo number_format(calcDiscount($listProd['item_cost'],$listProd['item_offer']));   ?>
<?php  if($listProd['item_offer']!=''){?>
	<del class="product-old-price">&#8358;<?php  echo number_format($listProd['item_cost']);  ?></del><?php  } ?></h4>
	<span class="small"><?php $inStock =  totalStock($listProd['id'],'','')-getQuantity($listProd['id'],'','');if($inStock>0){  echo $inStock.' In Stock'; }else{ echo 'Out Stock'; }?></span>
								<div class="product-rating">
								</div>
								<div class="product-btns">
								
									<a  href="<?php echo getItemLink($listProd['id'],$listProd['item_pid']);  ?>" class="quick-view btn btn-success btn-xs"><i class="fa fa-eye"></i><span class="tooltipp"> view</span></a>
								</div>
							</div>
							<!-- <div class="add-to-cart">
								<button class="add-to-cart-btn"><i class="fa fa-shopping-cart"></i> add to cart</button>
							</div> -->
						</div>
					</div>
				<?php  } ?>
					<!-- /product -->


					
				</div>
				<!-- /row -->
			</div>
			<!-- /container -->
		</div>
		<!-- /Section -->

	<?php include 'inc/outl_newsbottom.php'; include 'inc/outl_footer.php';  include 'js/outl_footlinks.php'; ?>
<script type="text/javascript">
$('#grow').click(function(e){ getNumb = parseInt($('#growNumb').val());
	// alert($('#itemCounts').attr('class'));
	if($('#growNumb').val() > parseInt($('#itemCounts').attr('class'))-1){
	$('#growNumb').val(parseInt($('#itemCounts').attr('class')));
}else{
	$('#growNumb').val(getNumb++);
}


  getPrice =$('.myPrs').attr('id');

$('#addPrice').html($('#growNumb').val()*getPrice);






})
$('#grDown').click(function(e){ 
	getNumb = parseInt($('#growNumb').val());
	$('#growNumb').val(getNumb--);
if(getNumb<1){ $('#growNumb').val(1) }
getPrice =$('.myPrs').attr('id');
$('#addPrice').html($('#growNumb').val()*getPrice);
})

//Add to Cart
$('.addCart').click(function(){ pid =$('#item').attr('class'); qty =$('#growNumb').val();
discount =$('#discount').attr('class');
$.ajax({data: {myPID:pid,myQTY:qty,myDiscount:discount},type: "post",url: "ajaxpage",success: function(data){
 if(data==1){
swal({text:'Item Added to Cart',type:'success',title:'Updated'},function(){ window.location = '';});
 }else if(data==2){
 	swal({text:'Cart Updated',type:'success',title:'Added'},function(){ window.location = '';});
 }else{
 	alert(data);
 }

},error: function(jqXHR, textStatus, errorThrown) { 
$(function(){ setTimeout(function() { alert('There was an Error');}, 5000);})}
});





})





</script>
	</body>
</html>
