<?php
session_start();
include("include/db.conn.php");
include("include/admin.class.php");
include("include/config.class.php");
if(isset($_GET['item_id']) && $_GET['item_id']!=NULL)
{  
	$item_id=$cartCustomerCore->md5_base64_decode($_GET['item_id']);
	$fetch_item_details=$cartCustomerAdminMain->fetch_catagory_product_details_by_item_id($item_id);
	$fetch_product_details=$cartCustomerAdminMain->fetch_product_details_by_product_id($fetch_item_details['PRODUCT_ID']);
	$fetch_company_details=$cartCustomerAdminMain->fetch_company_details_by_company_id($fetch_item_details['COMPANY_ID']);
	$fetch_catagory_details=$cartCustomerAdminMain->fetch_catagory_details_by_catagory_id($fetch_item_details['CATAGORY_ID']);
	
if(isset($_POST['SEND']))
{
	$cartCustomerCore->add_reviews($_GET['item_id']);
}
if(isset($_POST['BUY_PRODUCT'])){
	$_SESSION['ITEM_ID']=$_POST['ITEM_ID'];
	$_SESSION['ONE_BACK_ID']=$_POST['ITEM_ID'][0];
	$_SESSION['QUANTITY_VALUE']=$_POST['QUANTITY_VALUE'];
	$_SESSION['CURRENCY']=$_POST['CURRENCY'];
	$_SESSION['CHECKOUT']="CHECKOUT";
	$_SESSION['GLOBAL_ID_FOR_TAX_SHIPPING']=$fetch_company_details['GLOBAL_ID'];
	header("location:../admin/form_wizards.php?bk=".$_POST['ITEM_ID'][0]);
}
	?>
<!DOCTYPE HTML>
<html>
<head>
<?=$cartCustomerCore->get_header($fetch_item_details,$fetch_company_details);?>
<script>
// Can also be used with $(document).ready()
$(window).load(function() {
  $('.flexslider').flexslider({
    animation: "slide",
    controlNav: "thumbnails"
  });
});
</script>

  <!--mycart-->
  <!--start-rate-->
<script src="js/jstarbox.js"></script>
	<link rel="stylesheet" href="css/jstarbox.css" type="text/css" media="screen" charset="utf-8" />
		<script type="text/javascript">
			jQuery(function() {
			jQuery('.starbox').each(function() {
				var starbox = jQuery(this);
					starbox.starbox({
					average: starbox.attr('data-start-value'),
					changeable: starbox.hasClass('unchangeable') ? false : starbox.hasClass('clickonce') ? 'once' : true,
					ghosting: starbox.hasClass('ghosting'),
					autoUpdateAverage: starbox.hasClass('autoupdate'),
					buttons: starbox.hasClass('smooth') ? false : starbox.attr('data-button-count') || 5,
					stars: starbox.attr('data-star-count') || 5
					}).bind('starbox-value-changed', function(event, value) {
					if(starbox.hasClass('random')) {
					var val = Math.random();
					starbox.next().text(' '+val);
					return val;
					} 
				})
			});
		});
		</script>
<!--//End-rate-->
<link href="css/owl.carousel.css" rel="stylesheet">
<script src="js/owl.carousel.js"></script>
	<script>
		$(document).ready(function() {
		$("#owl-demo").owlCarousel({
			items : 1,
			lazyLoad : true,
			autoPlay : true,
			navigation : false,
			navigationText :  false,
			pagination : true,
		});
		});
	</script>

</head>
<body>
	<!--header-->
		<div class="header">
			<div class="header-top">
				<div class="container">
					 <div class="top-left">
						<a href="#"> Help  <i class="glyphicon glyphicon-phone" aria-hidden="true"></i> <?=$cartCustomerAdminMain->get_company_hotline($fetch_item_details['COMPANY_ID'])?></a>
					</div>
					<div class="top-right">
					<ul>
                    <?php
					if(isset($_SESSION['tkusernameCART']))
					{
						echo '<li><a href="../admin/customer_order.php?token_id='.$_SESSION['token'].'&bk='.$_GET['item_id'].'">View Order</a></li><li><a href="#">Logout</a></li>';
					}
					else
					{
						echo '<li><a href="../admin/login.php?customer=y&bk='.$_GET['item_id'].'">Login</a></li>';
					}
					?>
						
					</ul>
					</div>
					<div class="clearfix"></div>
				</div>
			</div>
            

		<!--header-->
		<!--banner-->
		<div class="banner1">
			<div class="container">
				
			</div>
		</div>
	<!--banner-->

	<!--content-->
		<div class="content">
			<!--single-->
			<div class="single-wl3">
				<div class="container">
					<div class="single-grids">
						<div class="col-md-9 single-grid">
							<div clas="single-top">
								<div class="single-left">
									<div class="flexslider">
										<ul class="slides">
                                        
                                        <?=$cartCustomerAdminMain->view_product_images($fetch_item_details['ID'])?>
											
										 </ul>
                                          
									</div>
                                   
								</div>
                                
								<div class="single-right simpleCart_shelfItem">
                                
									<h4><?=$fetch_product_details['PRODUCT_NAME']?><br><span class="size"><?=$fetch_catagory_details['CATAGORY_NAME']?> </span></h4>
                                    
									<div class="block">
                                    
                                    <?php
									if($fetch_item_details['OLD_PRICE']!="0")
									{
									?>
										<strike><?=$cartCustomerAdminMain->get_selected_currencySymbol($fetch_company_details['COMPANY_CURRENCY_ID'])?> <?=$fetch_item_details['OLD_PRICE']?> <?=$cartCustomerAdminMain->get_selected_currencyValue($fetch_company_details['COMPANY_CURRENCY_ID'])
									?>	</strike>	<?php } ?>					
									</div>
									<p class="price item_price"><?=$cartCustomerAdminMain->get_selected_currencySymbol($fetch_company_details['COMPANY_CURRENCY_ID'])?> <?=$fetch_item_details['PRICE']?> <?=$cartCustomerAdminMain->get_selected_currencyValue($fetch_company_details['COMPANY_CURRENCY_ID'])?></p>
									<div class="description">
										<p align="justify"><span>Quick Overview : </span> <?=$fetch_item_details['QUICK_OVERVIEW']?></p>
									</div>
                                    <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" name="myform" onSubmit="document.myform.quantity_value.value = $('#quantity_id').html()">
                                    <input type="hidden" name="ITEM_ID[]" value="<?=$_GET['item_id']?>">
                                    <input type="hidden" id="quantity_value" name="QUANTITY_VALUE[]">
                                    <input type="hidden" name="CURRENCY" value="<?=$cartCustomerAdminMain->get_selected_currencySymbol($fetch_company_details['COMPANY_CURRENCY_ID'])?>">
									<div class="color-quality">
										<h6>Quantity :</h6>
											<div class="quantity"> 
												<div class="quantity-select">                           
													<div class="entry value-minus1">&nbsp;</div>
													<div class="entry value1" id="quantity_id"><span>1</span></div>
													<div class="entry value-plus1 active">&nbsp;</div>
                                                    
												</div>
											</div>
												<!--quantity-->
														<script>
														var num=<?=$fetch_item_details['MAX_QUANTITY']?>;
														$('.value-plus1').on('click', function(){
															
															
															var divUpd = $(this).parent().find('.value1'), newVal = parseInt(divUpd.text(), 10)+1;
															if(newVal<=num) divUpd.text(newVal);
														});

														$('.value-minus1').on('click', function(){
															var divUpd = $(this).parent().find('.value1'), newVal = parseInt(divUpd.text(), 10)-1;
															if(newVal>=1) divUpd.text(newVal);
														});
														</script>
													<!--quantity-->
									</div>
									<div class="women">
                                    <?php
									if($fetch_item_details['OUTOF_STOCK']==true)
									{
										echo '<a href="#" data-text="Out of Stock" class="my-cart-b item_add">Out of Stock</a>';
									}
									else
									{
										echo '<input type="submit" name="BUY_PRODUCT" class="buy_product" value="Buy This Product"> <input type="submit" class="add_product" name="CART_PRODUCT" value="Add to Cart">';
									}
									?>	
									</div>
                                    </form>
									<div class="social-icon">
									<?php 
									if($fetch_item_details['FACEBOOK_LINK']!=NULL){echo '<a href="'.$fetch_item_details['FACEBOOK_LINK'].'"><i class="icon"></i></a>';}
									if($fetch_item_details['TWITER_LINK']!=NULL){echo '<a href="'.$fetch_item_details['TWITER_LINK'].'"><i class="icon1"></i></a>';}
									if($fetch_item_details['GOOGLE_PLUS_LINK']!=NULL){echo '<a href="'.$fetch_item_details['GOOGLE_PLUS_LINK'].'"><i class="icon2"></i></a>';}
									?>
									</div>
								</div>
								<div class="clearfix"> </div>
							</div>
						</div>
						<div class="col-md-3 single-grid1">
							<h3>Catagories</h3>
                            <?=$cartCustomerAdminMain->get_catagory_by_product_id($fetch_item_details['PRODUCT_ID'],$fetch_company_details['COMPANY_CURRENCY_ID']);?>
							
						</div>
						<div class="clearfix"> </div>
					</div>
					<!--Product Description-->
						<div class="product-w3agile">
							<h3 class="tittle1">Product Description</h3>
							<div class="product-grids">
                            <h3>Other Products of <?=$fetch_company_details['TITLE_NAME']?></h3>
								<div class="col-md-4 product-grid">
                                
									<div id="owl-demo" class="owl-carousel">
										
                                        
                                      <?=$cartCustomerAdminMain->get_company_items($fetch_item_details['COMPANY_ID'],$fetch_company_details['COMPANY_CURRENCY_ID']);?>  
                                        
											
									</div>	
									<img class="img-responsive " src="images/woo2.jpg" alt="">
								</div>
								<div class="col-md-8 product-grid1">
									<div class="tab-wl3">
										<div class="bs-example bs-example-tabs" role="tabpanel" data-example-id="togglable-tabs">
											<ul id="myTab" class="nav nav-tabs left-tab" role="tablist">
												<li role="presentation" class="active"><a href="#home" id="home-tab" role="tab" data-toggle="tab" aria-controls="home" aria-expanded="true">Description</a></li>
												<li role="presentation"><a href="#reviews" role="tab" id="reviews-tab" data-toggle="tab" aria-controls="reviews">Reviews (<?=$cartCustomerAdminMain->count_reviews($fetch_item_details['ID'])?>)</a></li>

											</ul>
											<div id="myTabContent" class="tab-content">
												<div role="tabpanel" class="tab-pane fade in active" id="home" aria-labelledby="home-tab">
													<div class="descr">
														<h4><?=$fetch_product_details['PRODUCT_NAME']?> <span class="size"><?=$fetch_catagory_details['CATAGORY_NAME']?> </span> </h4>
														
                                                       <?php if($fetch_item_details['PRODUCT_DESCRIPTION']!=""){echo '<p align="justify">'.$fetch_item_details['PRODUCT_DESCRIPTION'].'</p>'; }else {echo '<p align="justify">No any description</p>';}  ?>
                                                        
														<p class="quote">
														<?php if($fetch_item_details['PRODUCT_FUNCTION']!=NULL){echo $cartCustomerAdminMain->view_product_function($fetch_item_details['PRODUCT_FUNCTION']); }?>
														</p>
                                                        
                                                        
															<div class="video">
                                                            <?php if($fetch_item_details['YOUTUBE_LINK']!=NULL){ echo '<iframe src="'.$fetch_item_details['YOUTUBE_LINK'].'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';} ?>
															
															</div>
														
														

													</div>
												</div>
												<div role="tabpanel" class="tab-pane fade" id="reviews" aria-labelledby="reviews-tab">
													<div class="descr">
														<div class="reviews-top">
															<div class="reviews-left">
																<img src="images/men3.jpg" alt=" " class="img-responsive">
															</div>
															<div class="reviews-right">
																<ul>
																	<li><a href="#">Admin</a></li>
																	
																</ul>
																<p>Hi I'm administrator, your review section is currently modifing</p>
															</div>
															<div class="clearfix"></div>
														</div>
														<div class="reviews-bottom">
															<h4>Add Reviews</h4>
															<p>Your email address will not be published. Required fields are marked *</p>
															<p>Your Rating</p>
															<div class="block">
																<div class="starbox small ghosting"><div class="positioner"><div class="stars"><div class="ghost" style="width: 42.5px; display: none;"></div><div class="colorbar" style="width: 42.5px;"></div><div class="star_holder"><div class="star star-0"></div><div class="star star-1"></div><div class="star star-2"></div><div class="star star-3"></div><div class="star star-4"></div></div></div></div></div>
															</div>
                                                           <?php
			if(isset($_SESSION['success']))
			{ ?>
            
            <script type="text/javascript"> 
       $(document).ready(function(){
           $('#myModal3').modal('show');
       });
      </script>
			<?php 
			unset($_SESSION['success']);
			}
			?> 
															<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
																<label>Your Review </label>
																<textarea type="text" Name="MESSAGE" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Message...';}" required>Message...</textarea>
																<div class="row">
																	<div class="col-md-6 row-grid">
																		<label>Name</label>
																		<input type="text" Name="NAME" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Name';}" required>
																	</div>
																	<div class="col-md-6 row-grid">
																		<label>Email</label>
																		<input type="email" Name="EMAIL" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email';}" required>
																	</div>
																	<div class="clearfix"></div>
																</div>
																<input type="submit" name="SEND" value="SEND">
															</form>
														</div>
													</div>
												</div>
												<div role="tabpanel" class="tab-pane fade" id="custom" aria-labelledby="custom-tab">
													
												</div>
											</div>
										</div>
									</div>
								</div>
								<div class="clearfix"> </div>
							</div>
						</div>
					<!--Product Description-->
				</div>
			</div>
			<!--single-->
		</div>
		<!--content-->
		<!---footer--->
					<div class="footer-w3l">
						<div class="container">
							<div class="footer-grids">
								<div class="col-md-3 footer-grid">
									<h4>About </h4>
									<p></p>
									<div class="social-icon">
										<a href="<?=$fetch_company_details['FACEBOOK_LINK']?>"><i class="icon"></i></a>
										<a href="<?=$fetch_company_details['TWITTER_LINK']?>"><i class="icon1"></i></a>
										<a href="<?=$fetch_company_details['GOOGLE_LINK']?>"><i class="icon2"></i></a>
										<a href="<?=$fetch_company_details['LKD_LINK']?>"><i class="icon3"></i></a>
									</div>
								</div>
								
								
								<div class="col-md-3 footer-grid foot">
									<h4>Contacts</h4>
									<ul>
										<li><i class="glyphicon glyphicon-map-marker" aria-hidden="true"></i><a href="#"><?=$fetch_company_details['COMPANY_NAME']?><BR> <?=$fetch_company_details['COMPANY_ADDRESS_01']?>, <?=$fetch_company_details['COMPANY_CITY']?>, <?=$fetch_company_details['COMPANY_COUNTRY']?>, <?=$fetch_company_details['COMPANY_POST_CODE']?></a></li>
										<li><i class="glyphicon glyphicon-earphone" aria-hidden="true"></i><a href="#"><?=$fetch_company_details['COMPANY_TELEPHONE_01']?>, <?=$fetch_company_details['COMPANY_MOBILE']?></a></li>
										<li><i class="glyphicon glyphicon-envelope" aria-hidden="true"></i><a href="mailto:<?=$fetch_company_details['COMPANY_EMAIL_01']?>"> <?=$fetch_company_details['COMPANY_EMAIL_01']?></a></li>
										
									</ul>
								</div>
							<div class="clearfix"> </div>
							</div>
							
						</div>
					</div>
					<!---footer--->
					<!--copy-->
					<div class="copy-section">
						<div class="container">
							<div class="copy-left">
								
							</div>
							<div class="copy-right">
								<img src="images/card.png" alt=""/>
							</div>
							<div class="clearfix"></div>
						</div>
					</div>
				<!--copy-->
                
                <div class="modal fade" id="myModal3" tabindex="-1" role="dialog">
				<div class="modal-dialog" role="document">
					<div class="modal-content modal-info">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>						
						</div>
						<div class="modal-body">
							<div class="news-gr">
									<div class="col-md-7 new-grid">
										<h5>Review has been Successfully submitted</h5>
										<span>Only registered user reviews have been published</span>
									
									</div>
                                    <div class="add">
                                    <a href="http://google.lk" data-text="Out of Stock" class="my-cart-b item_add">Register Now</a>
                                    </div>
							</div>
							<div class="clearfix"></div>
						</div>
					</div>
				</div>
			</div>
			
				
</body>
</html>
<?php } ?>