<input type="hidden" id="baseurl" value="<?php echo base_url(); ?>" >
<!----Banner Start---->
	<div class="fd_bread_wrapper">
		<div class="container">
			<div class="row">
				<div class="col-lg-12">
					<div class="fd_bread">
						<h1 class="fd_page_title"><span><?php if(!empty($productdetails)){ echo $productdetails[0]->prod_name; } ?></span></h1>
						<nav aria-label="breadcrumb">
						  <ol class="breadcrumb">
							<li class="breadcrumb-item"><a href="<?php echo base_url(); ?>">Home</a></li>
							<li class="breadcrumb-item active" aria-current="page"><?php if(!empty($productdetails)){ echo $productdetails[0]->prod_name; } ?></li>
						  </ol>
						</nav>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!----Shop Single Section Start---->
	<?php if(!empty($productdetails)){ ?> 
	<div class="fd_shop_single_wrapper">
		<div class="container">
			<div class="row">
				<div class="col-lg-6">
					<div class="fd_single_pro_slider">
						<img src="<?php echo base_url().$productdetails[0]->prod_singleimg; ?>" alt="image" class="img-responsive" />
					</div>				
				</div>
				<div class="col-lg-6">
					<div class="fd_pro_single_data">
						<h2><?php echo $productdetails[0]->prod_name; ?></h2>
						 <?php if(!empty($productdetails)){ if(!empty($productdetails[0]->prod_id)){ $prodid = $productdetails[0]->prod_id; } } 
								
										$get_sum = $this->Data_access_model->get_sum_of_column('rating_star','hs_rating',array('rating_prod_id' =>$prodid,)); 
										if(!empty($get_sum)){									
											$total_sum = $get_sum->row();
										} 
										 
										$get_rating_count = $this->hs->count_table_column('rating_star','hs_rating',array('rating_prod_id' =>$prodid));
									 
										if($get_rating_count != 0){
											$rating_average = $total_sum->rating_star/$get_rating_count; 
										}else{
											$rating_average = 0;
										}							 			
									?>
						<div class="fd_pro_rating">
							<span class="rating_no"><?php echo round($rating_average,2); ?></span>
							<ul class="fd_rating">
								<li><i class="fa fa-star <?php if(!empty($rating_average)){ if($rating_average >=1){ echo "average"; } } ?>" aria-hidden="true"></i></li>
								<li><i class="fa fa-star <?php if(!empty($rating_average)){ if($rating_average >=2){ echo "average"; } } ?>" aria-hidden="true"></i></li>
								<li><i class="fa fa-star <?php if(!empty($rating_average)){ if($rating_average >=3){ echo "average"; } } ?>" aria-hidden="true"></i></li>
								<li><i class="fa fa-star <?php if(!empty($rating_average)){ if($rating_average >=4){ echo "average"; } } ?>" aria-hidden="true"></i></li>
								<li><i class="fa fa-star <?php if(!empty($rating_average)){ if($rating_average >=5){ echo "average"; } } ?>" aria-hidden="true"></i></li>
							</ul>
								<span class="fd_reviews"><?php echo $this->hs->count_table_column('rating_review','hs_rating',array('rating_prod_id' =>$prodid,)); ?> reviews</span>
						</div>	
							<div class="fd_pro_availability"> 
								<p>Product Code: <?php echo $productdetails[0]->prod_code; ?> </p>
								<p class="pro_available">Availability:   <?php if($productdetails[0]->prod_quantity ==''){ ?><span class="color1"> In Stock</span>
								<?php }else{ if($productdetails[0]->prod_quantity > 0){?>
										<span class="color1"> In Stock</span>
								<?php }else{ ?>
										<span class="color1 color_red"> Out Of Stock</span>
								<?php 
										}
									}									
								?>
								</p>
							</div>
							<p class="fd_pro_descrip">
								<?php echo $productdetails[0]->prod_description; ?>
							</p>
							<div class="fd_pro_prices">
								<h2><?php echo $this->hs->getwebsettings('currency_symbol'); ?> <?php echo $productdetails[0]->prod_price; ?></h2>
							</div>
							 <div class="fd_pro_quantity">
								<div class="quantity_wrapper">
									<div class="input-group">
											<span class="input-group-btn">
												<button type="button" class="quantity-left-minus btn btn-number" data-type="minus" data-field="">
													<i class="fa fa-minus" aria-hidden="true"></i>
												</button>
											</span>
											<input type="text" id="quantity" name="quantity" class="form-control input-number quantity" value="1">
											<span class="input-group-btn">
												<button type="button" class="quantity-right-plus btn btn-number" data-type="plus" data-field="">
													<i class="fa fa-plus" aria-hidden="true"></i>
												</button>
											</span>
									</div>
								</div>
							</div>
							<div class="fd_pro_add_btn">
								<a onclick="add_to_cart(<?php echo $productdetails[0]->prod_id; ?>,null)" class="fd_btn">add to cart</a>
							</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<?php } ?>
	<!----Products Details ---->
	<div class="fd_product_details">
		<div class="container">
			<div class="row">
				<div class="col-lg-12">
					<div class="fd_product_tab">
					<h1>Product Details <span class="dot_border"></span></h1>
					  <ul class="nav nav-tabs">
					  <?php if(!empty($productdetails)){ if(!empty($productdetails[0]->prod_longdescription)){  ?>
						<li><a data-toggle="tab"  class="active" href="#description">Description</a></li>
					  <?php }
					    }					
					  ?>
						<li><a data-toggle="tab" href="#review">Review</a></li>
					  </ul>
					  <div class="tab-content">
					  <?php if(!empty($productdetails)){   ?>
						<div id="description" class="tab-pane fade show active">
							<p><?php echo $productdetails[0]->prod_longdescription; ?></p>
						</div>
					 <?php } ?>
						
						<?php if(!empty($productdetails)){ ?> 
						<div id="review" class="tab-pane fade">
						  <div class="fd_review_wrapper">
							<div class="row">
								<div class="col-lg-2 col-md-6">
									<div class="rating_review">
										<div class="progress_circle progress_70">
										<?php if(!empty($productdetails[0]->prod_id)){ $prodid = $productdetails[0]->prod_id; }  
								
										$get_sum = $this->Data_access_model->get_sum_of_column('rating_star','hs_rating',array('rating_prod_id' =>$prodid,)); 
										if(!empty($get_sum)){									
											$total_sum = $get_sum->row();
										} 
										 
										$get_rating_count = $this->hs->count_table_column('rating_star','hs_rating',array('rating_prod_id' =>$prodid));
									 
										if($get_rating_count != 0){
										$rating_average = $total_sum->rating_star/$get_rating_count; 
										}else{
											$rating_average = 0;
										}							 			
									?>
										 <div class="progress__number"><?php echo round($rating_average,2); ?></div>
										</div>
								
										 <span><?php if(!empty($total_sum->rating_star)){ echo $total_sum->rating_star; }else{ echo 0;} ?> Rating and <br><?php echo $this->hs->count_table_column('rating_review','hs_rating',array('rating_prod_id' =>$prodid,)); ?>  Review</span> 
									</div>
								</div>
								<div class="col-lg-4 col-md-6">
									<div class="rating_star">
										<ul>
											<li><i class="fa fa-star" aria-hidden="true"></i></li>
											<li>5 star</li>
											<li>
												<div class="fd-progress">
													<div class="progress-bar">
													</div>
												</div>
											</li>
											<li>
											 <span class="rating_no"><?php echo $this->hs->count_table_column('rating_uid','hs_rating',array('rating_prod_id' =>$prodid,'rating_star' =>5)); ?></span>
											</li>
										</ul>
										<ul>
											<li><i class="fa fa-star" aria-hidden="true"></i></li>
											<li>4 star</li>
											<li>
												  <div class="fd-progress">
													<div class="progress-bar progress-bar1">
													</div>
												  </div>
											</li>
											<li>
												<span class="rating_no"><?php echo $this->hs->count_table_column('rating_uid','hs_rating',array('rating_prod_id' =>$prodid,'rating_star' =>4)); ?></span>
											</li>
										</ul>
										<ul>
											<li><i class="fa fa-star" aria-hidden="true"></i></li>
											<li>3 star</li>
											<li>
												  <div class="fd-progress">
													<div class="progress-bar progress-bar2">
													</div>
												  </div>
											</li>
											<li>
												<span class="rating_no"><?php echo $this->hs->count_table_column('rating_uid','hs_rating',array('rating_prod_id' =>$prodid,'rating_star' =>3)); ?></span>
											</li>
										</ul>
										<ul>
											<li class="star_color1"><i class="fa fa-star" aria-hidden="true"></i></li>
											<li>2 star</li>
											<li>
												  <div class="fd-progress">
													<div class="progress-bar progress-bar3">
													</div>
												  </div>
											</li>
											<li>
												<span class="rating_no"><?php echo $this->hs->count_table_column('rating_uid','hs_rating',array('rating_prod_id' =>$prodid,'rating_star' =>2)); ?></span>
											</li>
										</ul>
										<ul>
											<li class="star_color2"><i class="fa fa-star" aria-hidden="true"></i></li>
											<li>1 star</li>
											<li>
												  <div class="fd-progress">
													<div class="progress-bar progress-bar4">
													</div>
												  </div>
											</li>
											<li>
												<span class="rating_no"><?php echo $this->hs->count_table_column('rating_uid','hs_rating',array('rating_prod_id' =>$prodid,'rating_star' =>1)); ?></span>
											</li>
										</ul>
									</div>
								</div>
								<?php if(isset($_SESSION['userid'])){ 
								   $check_rating = $this->Data_access_model->select_data('rating_star,rating_review','hs_rating',array('rating_uid' =>$_SESSION['userid'],'rating_prod_id' =>$prodid));   
									if($check_rating->num_rows() > 0){
										$login_user_rating = $check_rating->row_array();
										$current_user_rating = $login_user_rating['rating_star'];
										$current_user_review = $login_user_rating['rating_review'];
									}	
								?>
								
								<div class="col-lg-3 col-md-6">
									<div class="rating_pro_used">
										<ul class="fd_rating">
                                            <li class="current"><i class="fa fa-star star_rating <?php if(!empty($current_user_rating)){ if($current_user_rating >=1){ echo "selected"; } } ?>" id="star1" aria-hidden="true" data-rating="1"></i></li>
											<li class="current"><i class="fa fa-star star_rating <?php if(!empty($current_user_rating)){ if($current_user_rating >=2){ echo "selected"; } } ?>" id="star2" aria-hidden="true" data-rating="2"></i></li>
											<li class="current"><i class="fa fa-star star_rating <?php if(!empty($current_user_rating)){ if($current_user_rating >=3){ echo "selected"; } } ?>" id="star3" aria-hidden="true" data-rating="3"></i></li>
											<li class="current"><i class="fa fa-star star_rating <?php if(!empty($current_user_rating)){ if($current_user_rating >=4){ echo "selected"; } } ?>" id="star4" aria-hidden="true" data-rating="4"></i></li>
											<li class="current"><i class="fa fa-star star_rating <?php if(!empty($current_user_rating)){ if($current_user_rating >=5){ echo "selected"; } } ?>" id="star5"  aria-hidden="true" data-rating="5"></i></li>
										</ul>
										<?php if(!empty($current_user_rating)){
											  echo 'you rated '.$current_user_rating.' stars this product'; }else{ ?>
											  <p>Have you used this product?</p>
										<?php } ?>	
									</div>
								</div>
								<div class="col-lg-3 col-md-6">
									<div class="rating_review_form">
										<form method="post" id="rating_form">
										<input type="hidden" name="rating_stars" id="rating_stars" value="<?php if(!empty($current_user_rating)){ echo $current_user_rating; } ?>"> 
										<input type="hidden" name="rating_userid" id="rating_userid" value="<?php if(isset($_SESSION['userid'])){ echo $_SESSION['userid']; } ?>">
 
										<input type="hidden" name="rating_prodid" id="rating_prodid" value="<?php if(!empty($productdetails)){ echo $productdetails[0]->prod_id; } ?>">
										<textarea id="comment" name="comment" class="form-control" placeholder="Write Your Review"><?php if(!empty($current_user_review)){ echo $current_user_review; } ?></textarea>
										<input name="submit" type="submit" id="comment-submit" class="submit fd_btn" value="<?php if(!empty($current_user_review)){ echo 'Update'; }else{ echo 'Review'; } ?>">
										</form>
									</div>
								</div>
								<?php 
								 }							
								?>
							</div>	
						  </div>
						</div>
						<?php } ?>
					  </div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!----Product Comment Section ----->
	<?php if(!empty($ratingdetails)){ ?> 
	<div class="fd_pro_cmnt_wrapper">
		<div class="container">
			<div class="row">
				<div class="col-lg-12">
					<div class="fd_cmnt_list">
							<ul class="commentlist">
							<?php
                              $review_counter=0;

							foreach($ratingdetails as $rating){  
							$review_counter++;
							?>
								<li class="comment blogBox moreBox" <?Php if($review_counter >3){ echo "style='display:none'"; } ?> >
									<div class="fd_cmnt_img">
									<?php  $user_pic =$this->hs->get_userdetails('user_image',$rating->rating_uid); 
									 
									if(!empty($user_pic)){ ?>
									<img src="<?php echo base_url().$user_pic; ?>" alt="" width="50" height="50">	
								<?php }else{ ?>
									<img src="<?php echo base_url(); ?>themeassets/images/blog/author1.png" alt="">
								<?php } ?>	
									</div>
									<div class="fd_cmnt_data">
										<div class="fd_cmnt_info">
											<h3><a href="javascript:;"><?php echo $this->hs->get_userdetails('user_name',$rating->rating_uid); ?></a></h3>
											<?php $reviewdate = strtotime($rating->rating_date);
														 $day = date('d', $reviewdate);
														 $month = date('M', $reviewdate);
														 $year =date('Y',$reviewdate);
											?>
											<span class="fd_cmnt_date"><a href="javascript:;"><?php echo  $day.' '.$month.' '.$year; ?></a></span>
										</div>
										<div class="fd_cmnt_para">
											<?php echo $rating->rating_review; ?>
										</div>
									</div>
									<div class="fd_cmnt_likes">
										 <ul>
											<li><i class="fa fa-star <?php if($rating->rating_star >=1){echo "selected";} ?>" aria-hidden="true" data-rating="1"></i></li>
											<li><i class="fa fa-star <?php if($rating->rating_star >=2){echo "selected";} ?>" aria-hidden="true" data-rating="2"></i></li>
											<li><i class="fa fa-star <?php if($rating->rating_star >=3){echo "selected";} ?>" aria-hidden="true" data-rating="2"></i></li>
											<li><i class="fa fa-star <?php if($rating->rating_star >=4){echo "selected";} ?>" aria-hidden="true" data-rating="3"></i></li>
											<li><i class="fa fa-star <?php if($rating->rating_star >=5){echo "selected";} ?>" aria-hidden="true" data-rating="4"></i></li>
										</ul>
									</div>
								</li>
							<?php } ?>
								 
							</ul>
							<div class="fd_more_cmnt" id="loadMore">
								<a href="javascript:;" class="fd_btn">more review</a>
							</div>
						</div>
				</div>
			</div>
		</div>
	</div>
	<?php } ?>
	<!----Recently Viewed Section---->
	<?php 
	 if(!empty($randproduct)){
	?>
	<div class="fd_sol_wrapper fd_inner_sol_wrapper">
		<div class="container">
			<div class="row">
				<div class="col-lg-12">
					<div class="fd_heading text-center btm_marger50">
						<?php if($this->hs->getwebsettings('relatedprodheading_show') == 1){  ?>
						<h2><?php echo $this->hs->getwebsettings('relatedprodheading_text'); ?></h2>
					 <?php } ?>
					 <?php if($this->hs->getwebsettings('relatedprodtitle_show') == 1){  ?>
						<h1><?php echo $this->hs->getwebsettings('relatedprodtitle_text'); ?></h1>
					 <?php } ?>
					</div>
				</div>
				<div class="col-lg-12">
					<div class="fd_recent_menu">
									 <div class=" fd_recent_slider swiper-container">
										<div class="swiper-wrapper">
										<?php foreach($randproduct as $randprod){ ?>
										  <div class="swiper-slide">
											<div class="fd_food_box">
												<div class="fd_food_img">
													<img src="<?php echo base_url().$randprod->prod_image; ?>" alt="">
												</div>
												 
												<div class="fd_food_name">
													<h3><a href="<?php echo base_url().'product/'.$randprod->prod_slug.'/'.$randprod->prod_code; ?>"><?php echo $randprod->prod_name; ?></a></h3>
													<span class="food_price"><?php echo $this->hs->getwebsettings('currency_symbol'); ?><?php echo $randprod->prod_price; ?></span>
													<span class="food_name_arrow"><img src="<?php echo base_url(); ?>themeassets/images/svg/up_arrow.svg" alt=""></span>
												</div>
												<div class="fd_food_detail">
													<h3><a href="<?php echo base_url().'product/'.$randprod->prod_slug.'/'.$randprod->prod_code; ?>"><?php echo $randprod->prod_name; ?></a></h3>
													<span class="food_price"><?php echo $this->hs->getwebsettings('currency_symbol'); ?><?php echo $randprod->prod_price; ?></span>
													<div class="add_to_cart"><a href="javascript:;" onclick="add_to_cart(<?php echo $randprod->prod_id; ?>,1)">add to cart <span class="add_crt_icon"><img src="<?php echo base_url(); ?>themeassets/images/svg/basket1.svg" alt=""></span></a></div>
												</div>
												<div class="fd_food_overlay"></div>
										</div>
									</div>
										<?php } ?>
										</div>
									 </div>
									  <!-- Add Pagination -->
									<div class="swiper-button-next14 slider_nav_next"><span class="slider_icon_next"></span></div>
									<div class="swiper-button-prev14 slider_nav_prev"><span class="slider_icon_prev"></span></div>
					</div>
				</div>
			</div>
		</div>
		<div class="fd_overlay"></div>
	</div>
	 <?php } ?> 
	 
	 
	 									