

<?php $__env->startSection('title'); ?>
	<?php echo e(str_replace('-',' ',title_case($page))); ?>

<?php $__env->stopSection(); ?>

<?php 
	$share_url = Request::url();
	$share_title = str_replace('-',' ',title_case($page));
	$share_desc = strip_tags($data->product_content);
	$share_img = asset($storage_url.'img/products/'.$data->product_code.'/'.$data->product_image);
 ?>

<?php $__env->startSection('meta'); ?>
	<meta name="title" content="<?php echo e($share_title); ?>">
	<meta name="description" content="<?php echo e($share_desc); ?>">
<?php $__env->stopSection(); ?>

<?php $__env->startSection('sharing-meta'); ?>

<meta property="og:url" content="<?php echo e($share_url); ?>" />
<meta property="og:type" content="place" />
<meta property="og:title" content="<?php echo e($share_title); ?>" />
<meta property="og:description" content="<?php echo e($share_desc); ?>" />
<meta property="og:image" content="<?php echo e($share_img); ?>" />


<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="<?php echo e($share_url); ?>">
<meta name="twitter:title" content="<?php echo e($share_title); ?>">
<meta name="twitter:description" content="<?php echo e($share_desc); ?>">
<meta name="twitter:image:src" content="<?php echo e($share_img); ?>">


<meta itemprop="name" content="<?php echo e($share_title); ?>">
<meta itemprop="description" content="<?php echo e($share_desc); ?>">
<meta itemprop="image" content="<?php echo e($share_img); ?>">

<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
  <main id="mainContent" class="container-fluid">
    <div class="col-xs-12 col-md-12 col-md-offset-0 col-lg-10 col-lg-offset-1">
			
		<section class="row">
			<aside class="col-xs-12">
				<ol class="breadcrumb">
					<li><a href="<?php echo e(route('home')); ?>"><i class="fa fa-home" aria-hidden="true"></i></a></li>
					<li><a href="<?php echo e(route('categories')); ?>"><?php echo e(ucwords($page_product)); ?></a></li>
					<li><a href="<?php echo e(route('category',['id'=>$data->product_category,'category'=>$category])); ?>"><?php echo e(ucwords(str_replace('-',' ',$category))); ?></a></li>
					<?php 
						$get = $data->locales()->where('locale',config('app.locale'))->first();
					 ?>
					<li class="active"><?php echo e(ucwords( isset($get)? $get->product_name : $data->product_name )); ?></li>
				</ol>
			</aside>
		</section>

		<section class="row product-list">

			<figure class="col-xs-12 col-sm-4">
				<div class="row">
					<?php 
						$image = $data->details()->first();
					 ?>
					<div class="col-xs-3 products-thumbs js-img-zoom-wrapper">
						<ul class="thumbnails">
							<?php $__currentLoopData = $data_detail; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
								<li class="<?php echo e($loop->first ? 'active' : ''); ?>">
									<img src="<?php echo e(asset($storage_url.'img/products/'.$val->detail_code.'/'.$val->detail_image)); ?>" alt="<?php echo e(isset($data->alt) ? $data->alt : ''); ?>"
										data-zoom="<?php echo e(asset($storage_url.'img/products/'.$val->detail_code.'/'.($val->detail_image_big ? $val->detail_image_big : $val->detail_image))); ?>"
										class="img-responsive thumb js-zoom-thumb">
								</li>
							<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
						</ul>
					</div>

	          		<div class="col-xs-9">
	            		<img
	              			src="<?php echo e(asset($storage_url.'img/products/'.$image->detail_code.'/'.$image->detail_image)); ?>"
						data-zoom="<?php echo e(asset($storage_url.'img/products/'.$image->detail_code.'/'.($image->detail_image_big ? $image->detail_image_big : $image->detail_image))); ?>"
						alt="<?php echo e(isset($data->alt) ? $data->alt : ''); ?>"
						class="thumb-preview js-img-zoom-trigger">
					</div>
    	    	</div>
					
				</figure>

				<article class="col-xs-12 col-sm-8">
					<div class="card product-detail js-img-zoom-preview">
						<header class="row">
							<span class="col-xs-12 col-sm-6">
								<?php 
									$get = $data->locales()->where('locale',config('app.locale'))->first();
								 ?>
								<h2><?php echo e(ucfirst( isset($get)? $get->product_name : $data->product_name )); ?></h2>
								<?php 
									$currency = explode('|',$data->product_currency);
								 ?>
								<?php 
									if( $masterCurrency == "USD" ){
										$price = number_format($data->product_price,2,".",",");
									}elseif( $masterCurrency == "EUR" ){
										$price = number_format($data->product_price,2,",",".");
									}else{
										$price = number_format($data->product_price,0,",",".");
									}
								 ?>
								<p class="product-price"><span id="currency"><?php echo e($masterCurrency); ?></span> <span id="price"><?php echo e($price); ?></span></p>
							</span>
							<span class="col-xs-12 col-sm-6 top-share-button">
								<button class="btn btn-default" data-toggle="modal" data-target="#shareLinks">
									<i class="fa fa-share-alt-square" aria-hidden="true"></i> <?php echo app('translator')->getFromJson('frontend.share'); ?>
								</button>
							</span>
						</header>
						<div class="product-spec">
							<?php echo isset($get)? $get->product_content : $data->product_content; ?>

						</div>
					</div>

					<aside class="share">
						

						<div class="modal fade" id="addToCart" role="dialog">
							<div class="modal-dialog" role="document">
    						<div class="modal-content">
									<header class="modal-header text-center">
										<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
										<h2><i class="fa fa-cart-plus" aria-hidden="true"></i> <?php echo app('translator')->getFromJson('frontend.add_to_cart'); ?></h2>
									</header>
									<div class="modal-body row">
										<div class="col-xs-12 col-sm-5">
											<?php $__currentLoopData = $data_detail; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
												<img alt="" class="img img-responsive" src="<?php echo e(asset($storage_url.'img/products/'.$val->detail_code.'/'.$val->detail_image)); ?>" style="border:5px solid #<?php echo e($btnColor[0]); ?>"/>
												<?php 
													break;
												 ?>
											<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
										</div>
										<div class="col-xs-12 col-sm-7">
											<h3 class="text-capitalize"><?php echo e(isset($get->product_name) ? $get->product_name : $data->product_name); ?></h3>
											<?php 
												$currency = explode('|',$data->product_currency);
											 ?>
											<?php 
												if( $masterCurrency == "USD" ){
													$price = number_format($data->product_price,2,".",",");
												}elseif( $masterCurrency == "EUR" ){
													$price = number_format($data->product_price,2,",",".");
												}else{
													$price = number_format($data->product_price,0,",",".");
												}
											 ?>
											<p class="product-price lead"><span><?php echo e($masterCurrency); ?></span> <span><?php echo e($price); ?></span></p>
											<div class="form-group row">
												<div class="col-xs-12 col-sm-2">
													<?php echo Form::label('options',__('frontend.notes'),['class'=>'control-label','style'=>'padding-top:5px']); ?>

												</div>
												<div class="col-xs-12 col-sm-10">
													<?php echo Form::textarea('options','',['class'=>'form-control','rows'=>2]); ?>

												</div>
											</div>

											<div class="form-group row">
												<div class="col-xs-12 col-sm-2">
													<?php echo Form::label('qty',__('frontend.qty'),['class'=>'control-label','style'=>'padding-top:5px']); ?>

												</div>
												<div class="col-xs-12 col-sm-5">
													<?php echo Form::number('qty',1,['class'=>'form-control','min'=>1, 'max' => $data->product_stock]); ?>

												</div>
												<div class="col-xs-12 col-sm-5 text-center">
													<label for="remain" style="margin: 0;">Current Stock :</label> <br>
													<span name="remain"><?php echo e(isset($data->product_stock) ? $data->product_stock : 0); ?></span>
													
												</div>
											</div>

											<div class="form-group row">
												<div class="col-xs-12 col-sm-2">
													<?php echo Form::label('total',__('frontend.total'),['class'=>'control-label']); ?>

												</div>
												<div class="col-xs-12 col-sm-10">
													<p class="lead">
														<?php 
															if( $masterCurrency == "USD" ){
																$price = number_format($data->product_price,2,".",",");
															}elseif( $masterCurrency == "EUR" ){
																$price = number_format($data->product_price,2,",",".");
															}else{
																$price = number_format($data->product_price,0,",",".");
															}
														 ?>
														<span><?php echo e($masterCurrency); ?></span> <strong><span id="cal_total"><?php echo e($price); ?></span></strong>
													</p>
												</div>
											</div>

											<div class="form-group row">
												<div class="col-xs-12 col-sm-12">
													<label class="control-label"><?php echo app('translator')->getFromJson('frontend.average-production-time'); ?> : <?php echo e(isset($data->production_time) ? $data->production_time : 0); ?> <?php echo app('translator')->getFromJson('frontend.'.($data->production_time > 1 ? 'days' : 'day')); ?></label>
												</div>
											</div>

										</div>
										<div class="col-xs-12">
											<br/>
											<div id="statusItem" class=""></div>
										</div>
									</div>
									<div class="panel-footer text-center">
										<a id="addtocart" class="btn btn-default"><i class="fa fa-plus" aria-hidden="true"></i> <?php echo app('translator')->getFromJson('frontend.add_to_cart'); ?></a>
									</div>
								</div>
							</div>
						</div>

						<button id="shareButton" class="btn btn-default" data-toggle="modal" data-target="#shareLinks">
							<i class="fa fa-share-alt-square" aria-hidden="true"></i> <?php echo app('translator')->getFromJson('frontend.share'); ?>
						</button>
						<div class="modal fade" id="shareLinks" role="dialog">
							<div class="modal-dialog" role="document">
    						<div class="modal-content">
									<header class="modal-header text-center">
										<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
										<h3><?php echo app('translator')->getFromJson('frontend.share'); ?></h3>
									</header>
									<div class="modal-body text-center">
										<div class="addthis_inline_share_toolbox"></div>
									</div>
								</div>
							</div>
						</div>
					</aside>
				</article>


			</section>
			<section class="row m-md-15 product-list item-single">
				<header class="col-xs-12">
					<h2>
						<?php echo app('translator')->getFromJson('frontend.you_may_also_like'); ?>
					</h3>
					<br />
				</header>

				<div>
					<?php $__currentLoopData = $other_product; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
						<?php 
							if($key == 4):
								break;
							endif;
						 ?>
						<?php 
							$get = $val->locales()->where('locale',config('app.locale'))->first();
						 ?>
						<article class="col-xs-12 col-sm-6 col-md-3 p-l-5 p-r-5">
							<div class="card">
								<figure class="card-img">
									<img alt="" src="<?php echo e(asset($storage_url.'img/products/'.$val->product_code.'/'.$val->product_image)); ?>"/>
								</figure>
								<div class="text-center card-content">
									<header class="card-header">
											<h2 class="text-capitalize h-58"><?php echo e(isset($get->product_name) ? $get->product_name : $val->product_name); ?></h2>
											<p class="product-price"><?php 
                
                if($masterCurrency === 'USD' ){
                  echo ($masterCurrency.' '.number_format($val->product_price,2,'.',','));
                }elseif($masterCurrency === 'EUR' ){
                  echo ($masterCurrency.' '.number_format($val->product_price,2,',','.'));
                }else{
                  echo ($masterCurrency.' '.number_format($val->product_price,0,',','.'));
                } 
              
              ?></p>
									</header>
									<div class="card-footer">
										<?php 
											$name = str_slug($val->product_name ? $val->product_name : 'no-name');
										 ?>
										<a href="<?php echo e(route('productDetail',['category'=>$category,'id'=>$val->product_code,'slug'=>$name])); ?>" class="btn btn-default"><?php echo app('translator')->getFromJson('frontend.detail'); ?></a>
									</div>
								</div>
							</div>
						</article>
					<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
				</div>
			</section>
		</div>
  </main>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
	<script>
		function resize_card(){
			var $highest = 0;
			$(".product-list.item-single .card").each(function(){
				var $h = $($(this)).height();
				if($h > $highest){
					$highest = $h;
				}
			});

			$(".product-list.item-single .card").each(function(){
				$($(this)).css("height",$highest+"px");
			});
		};

		$(document).ready(function(){
			resize_card();
		});

		$(window).resize(function(){
			resize_card();
		});

		$(document).ready(function(){
			var $price = <?php echo e($data->product_price); ?>;

			$("input[name='qty']").change(function() {
				var $qty = $(this).val();
				var $remain = <?php echo e(isset($data->product_stock) ? $data->product_stock : 0); ?>

				if ($qty > $remain) {
					$("input[name='qty']").val($remain)
					$qty = $remain
				}
				$("span[name='remain']").text($remain - $qty)

				var $total = $qty*$price;

				$.ajax({
			        type: 'post',
			        url: '<?php echo e(route('formatNumber')); ?>',
			        data: {
			            '_token': '<?php echo e(csrf_token()); ?>',
			            'total': $total,
			        },
			        success: function(data) {
								var obj = jQuery.parseJSON(data);
								$("#cal_total").html(obj.formatted_price);
			        },
			    });
			});

			$('#addToCart').on('shown.bs.modal', function () {
				var $qty = $("input[name='qty']").val();
				var $total = $qty*$price;
				$.ajax({
			        type: 'post',
			        url: '<?php echo e(route('formatNumber')); ?>',
			        data: {
			            '_token': '<?php echo e(csrf_token()); ?>',
			            'total': $total,
			        },
			        success: function(data) {
								var obj = jQuery.parseJSON(data);
								$("#cal_total").html(obj.formatted_price);
			        },
			    });
	    });

			$('#addToCart').on('hidden.bs.modal', function () {
				$("#statusItem").removeClass('alert alert-info').html('');
	    });

			$("#addtocart").click(function(){
				$("#statusItem").addClass('alert alert-info')
				.html('<i class="fa fa-spinner fa-spin fa-lg" aria-hidden="true"></i> Adding item');

				$.ajax({
			        type: 'post',
			        url: '<?php echo e(route('addToCart')); ?>',
			        data: {
			            '_token': '<?php echo e(csrf_token()); ?>',
			            'id': '<?php echo e($data->product_code); ?>',
									'name': '<?php echo e($data->product_name); ?>',
									'qty': $("input[name='qty']").val(),
									'price': '<?php echo e($data->product_price); ?>',
									'options': {
										notes: $("textarea[name='options']").val(),
										product: <?php echo e($data->id); ?>

									}
			        },
			        success: function(data) {
								$.get( '<?php echo e(route('updateBubble')); ?>', function( data ) {
					        if(data == 0){
					          $("#show_cart span.label").hide();
					        }else{
					          $("#show_cart span.label").show().html(data);
					        }
					      });
								$("#statusItem").removeClass('alert alert-info').addClass('alert alert-success')
								.html('<i class="fa fa-check fa-lg" aria-hidden="true"></i> Item added');
			        },
			    });
			});
		});
	</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>