
<script>

$(document).ready(function(){
	$("#buynowbtn").hover(function(){
		var qty=$("#qty").val();
		///$(this).attr("qty",qty);
		$(this).attr("onclick","location.href ='https://y1electronics.in/home/checkout2/<?php echo $pro->pid;?>/"+qty+"';");
	});

	$("#addtocart").submit(function(e){e.preventDefault();



			var formdata=$(this).serialize();



			///alert(formdata);



			$.ajax({



				 type: "POST",



				 url: '<?php echo base_url();?>home/ajax_addtocart',



				 data: {formdata:formdata},



				 success: function(response){



					 //alert(response);



					 $(".mini-cart__content").html(response);



					 //swal("Product Added to your Cart.");



				 }



				 });



			setTimeout(function(){



			 $.ajax({



			 type: "POST",



			 url: '<?php echo base_url();?>home/ajax_item_total',



			 data: {id:"asdf"},



			 success: function(response){



				 //alert(response);



				 $(".mini-cart-count").html(response);
				 Swal.fire({
  icon: 'success',
  title: 'Added to cart',
})



			 }



			 });



			},1000);



		});

	$(".addbtn").click(function(e){e.preventDefault();

		<?php if($pro->prod_type=="Variant"){?>

		if($(".prod_type").val()==''){alert("Please Select Packtype");return false;}

		<?php }?>

		$("form#addtocart").trigger('submit');

	});

});

</script>
        <div class="breadcrumb-area bg--white-6 pt--60 pb--70 pt-lg--40 pb-lg--50 pt-md--30 pb-md--40">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-12 text-center">
                        <h1 class="page-title"><?php echo $pro->title;?></h1>
                        <ul class="breadcrumb justify-content-center">
                            <li><a href="<?php echo base_url();?>" style="color:#fff;">Home&nbsp;&nbsp;&nbsp;&nbsp;/</a></li>
                            <li class="current"><span style="color:#fff;">Product Details</span></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <!-- Breadcrumb area End -->

        <!-- Main Content Wrapper Start -->
        <div id="content" class="main-content-wrapper">
            <div class="page-content-inner enable-full-width">
                <div class="container-fluid">
                    <div class="row pt--40">
                        <div class="col-md-6 product-main-image">
                            <div class="product-image">
                                <div class="product-gallery vertical-slide-nav">
                                    <div class="product-gallery__thumb">
                                        <div class="product-gallery__thumb--image">
                                            <div class="airi-element-carousel nav-slider slick-vertical" 
                                            data-slick-options='{
                                                "slidesToShow": 4,
                                                "slidesToScroll": 1,
                                                "vertical": true,
                                                "swipe": true,
                                                "verticalSwiping": true,
                                                "infinite": true,
                                                "focusOnSelect": true,
                                                "asNavFor": ".main-slider",
                                                "arrows": true, 
                                                "prevArrow": {"buttonClass": "slick-btn slick-prev", "iconClass": "fa fa-angle-up" },
                                                "nextArrow": {"buttonClass": "slick-btn slick-next", "iconClass": "fa fa-angle-down" }
                                            }'
                                            data-slick-responsive='[
                                                {
                                                    "breakpoint":992, 
                                                    "settings": {
                                                        "slidesToShow": 4,
                                                        "vertical": false,
                                                        "verticalSwiping": false
                                                    } 
                                                },
                                                {
                                                    "breakpoint":575, 
                                                    "settings": {
                                                        "slidesToShow": 3,
                                                        "vertical": false,
                                                        "verticalSwiping": false
                                                    } 
                                                },
                                                {
                                                    "breakpoint":480, 
                                                    "settings": {
                                                        "slidesToShow": 2,
                                                        "vertical": false,
                                                        "verticalSwiping": false
                                                    } 
                                                }
                                            ]'>
                                                <figure class="product-gallery__thumb--single">
                                                    <img src="<?php echo base_url().'assets/images/products/'.$pro->img;?>" alt="Products">
                                                </figure>
                                                <?php $imgs=$this->db->get_where("pgallery",array("pid"=>$pro->pid))->result();//explode(",",$pro->extimgs);
												foreach($imgs as $img){?>
                                				<figure class="product-gallery__thumb--single">
                                                    <img src="<?php echo base_url().'assets/images/products/'.$img->pg_img;?>" alt="Products">
                                                </figure><?php }?>
                                                <!--<figure class="product-gallery__thumb--single">
                                                    <img src="assets/img/products/prod-19-2-2.jpg" alt="Products">
                                                </figure>
                                                <figure class="product-gallery__thumb--single">
                                                    <img src="assets/img/products/prod-19-3-2.jpg" alt="Products">
                                                </figure>
                                                <figure class="product-gallery__thumb--single">
                                                    <img src="assets/img/products/prod-19-4-2.jpg" alt="Products">
                                                </figure>-->
                                            </div>
                                        </div>
                                    </div>
                                    <div class="product-gallery__large-image">
                                        <div class="gallery-with-thumbs">
                                            <div class="product-gallery__wrapper">
                                                <div class="airi-element-carousel main-slider product-gallery__full-image image-popup"
                                                data-slick-options='{
                                                    "slidesToShow": 1,
                                                    "slidesToScroll": 1,
                                                    "infinite": true,
                                                    "arrows": false, 
                                                    "asNavFor": ".nav-slider"
                                                }'>
                                                    <figure class="product-gallery__image zoom">
                                                    <img src="<?php echo base_url().'assets/images/products/'.$pro->img;?>" alt="Products">
                                                    </figure>
                                                    <?php foreach($imgs as $img){?>
                                				<figure class="product-gallery__image zoom">
                                                    <img src="<?php echo base_url().'assets/images/products/'.$img->pg_img;?>" alt="Products">
                                                </figure><?php }?>
                                                    <!--<figure class="product-gallery__image zoom">
                                                        <img src="assets/img/products/prod-19-2-big.jpg" alt="Product">
                                                    </figure>
                                                    <figure class="product-gallery__image zoom">
                                                        <img src="assets/img/products/prod-19-3-big.jpg" alt="Product">
                                                    </figure>
                                                    <figure class="product-gallery__image zoom">
                                                        <img src="assets/img/products/prod-19-4-big.jpg" alt="Product">
                                                    </figure>-->
                                                </div>
                                                <!--<div class="product-gallery__actions">
                                                    <button class="action-btn btn-zoom-popup"><i
                                                            class="dl-icon-zoom-in"></i></button>
                                                    <a href="https://www.youtube.com/watch?v=Rp19QD2XIGM"
                                                        class="action-btn video-popup"><i
                                                            class="dl-icon-format-video"></i></a>
                                                </div>-->
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6 product-main-details mt--40 mt-md--10 mt-sm--30">
                            <div class="product-summary">
                                <div class="product-rating float-left">
                                	<?php $totr=$this->db->get_where("order_items",array("pid"=>$pro->pid,"prating!="=>""))->num_rows();
									$avgr=0;
									if($totr>0){
									  $this->db->select_sum('prating');  
									  $this->db->where("pid",$pro->pid); 
									  $this->db->where("prating!=",""); 
									  $avg=$this->db->get('order_items')->row();
									  $avgr=$avg->prating/$totr;}?>
                                    <span>
                                    	<?php for($i=1;$i<=5;$i++){?>
                                        <i class="dl-icon-star <?php if($i<=$avgr){echo 'rated';}?>"></i>
                                        <?php }?>
                                    </span>
                                    <a href="#" class="review-link">(<?php echo $avgr.' Star Rated based on '.$totr;?> customer review)</a>
                                </div>
                                
                                <div class="clearfix"></div>
                                <h3 class="product-title"><?php echo $pro->title;?></h3>
                                <span class="product-stock in-stock float-right">
                                    <i class="dl-icon-check-circle1"></i>
                                    in stock
                                </span>
                                <div class="product-price-wrapper mb--40 mb-md--10">
                                    <span class="money">₹<?php echo $pro->oprice;?></span>
                                    <span class="product-price-old">
                                        <span class="money">₹<?php echo $pro->price;?></span>
                                    </span>
                                </div>
                                <div class="clearfix"></div>
                                <p class="product-short-description mb--45 mb-sm--20"><?php echo $pro->sdesc;?></p>
                                <form method="post" action="#" class="form--action mb--30 mb-sm--20" id="addtocart">
                                      <input type="hidden" name="pid" value="<?php echo $pro->pid;?>" />
                                    <div class="product-action flex-row align-items-center">
                                        <div class="quantity">
                                            <input type="number" class="quantity-input" name="qty" id="qty" value="1"
                                                min="1">
                                        </div>
                                        <button type="submit" class="btn btn-style-1 btn-large add-to-cart">
                                            Add To Cart
                                        </button>
                                        <button type="button" qty="1" id="buynowbtn" onclick="location.href ='<?php echo base_url().'home/buynow/'.$pro->pid;?>';" class="btn btn-style-1 btn-large">
                                            Buy Now
                                        </button>
                                        <a href="#" id="<?php echo $pro->pid;?>" class="wishlist"><i class="dl-icon-heart2"></i></a>
                                    </div>
                                </form>
                                <div class="product-extra mb--40 mb-sm--20">
                                    <a href="<?php echo base_url().'stores';?>" class="font-size-12"><i class="fa fa-map-marker"></i>Find store near
                                        you</a>
                                </div>
                                <div
                                    class="product-summary-footer d-flex justify-content-between flex-sm-row flex-column">
                                    <div class="product-meta">
                                        <span class="sku_wrapper font-size-12">SKU: <span class="sku">
                                                Y1-<?php echo $pro->pid;?></span></span>
                                        <!--<span class="posted_in font-size-12">Categories:
                                            <a href="#">Smart Watch</a>
                                        </span>-->
                                        <!--<span class="posted_in font-size-12">Tags:
                                            <a href="shop-sidebar.html">dress,</a>
                                            <a href="shop-sidebar.html">fashions,</a>
                                            <a href="shop-sidebar.html">women</a>
                                        </span>-->
                                    </div>
                                    
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row justify-content-center pt--45 pt-lg--50 pt-md--55 pt-sm--35">
                        <div class="col-12">
                            <div class="product-data-tab tab-style-1">
                                <div class="nav nav-tabs product-data-tab__head mb--40 mb-md--30" id="product-tab"
                                    role="tablist">
                                    <button type="button" class="product-data-tab__link nav-link active" id="nav-description-tab"
                                        data-bs-toggle="tab" data-bs-target="#nav-description" role="tab" aria-selected="true">
                                        <span>Description</span>
                                    </button>
                                    <button type="button" class="product-data-tab__link nav-link" id="nav-reviews-tab" data-bs-toggle="tab"
                                        data-bs-target="#nav-reviews" role="tab" aria-selected="true">
                                        <span>Reviews(<?php echo $totr;?>)</span>
                                    </button>
                                </div>
                                <div class="tab-content product-data-tab__content" id="product-tabContent">
                                    <div class="tab-pane fade show active" id="nav-description" role="tabpanel"
                                        aria-labelledby="nav-description-tab">
                                        <div class="product-description">
                                            <?php echo $pro->pdesc;?>
                                        </div>
                                    </div>
                                    <div class="tab-pane fade" id="nav-reviews" role="tabpanel" 
                                        aria-labelledby="nav-reviews-tab">
                                        <div class="product-reviews">
                                            <h3 class="review__title"><?php echo $totr;?> review</h3>
                                            <ul class="review__list">
                                            	<?php 
												$this->db->select("*");
												$this->db->from("order_items");
												$this->db->join("users","users.id=order_items.oitem_uid");
												$this->db->where("order_items.prating!=","");
												$this->db->where("order_items.pid",$pro->pid);
												$revs=$this->db->get()->result();
												foreach($revs as $rev){?>
                                                <li class="review__item">
                                                    <div class="review__container">
                                                        <img src="assets/img/others/comment-icon-2.jpg"
                                                            alt="Review Avatar" class="review__avatar">
                                                        <div class="review__text">
                                                            <div class="product-rating float-right">
                                                                <span>
                                                                    <i class="dl-icon-star rated"></i>
                                                                    <i class="dl-icon-star rated"></i>
                                                                    <i class="dl-icon-star rated"></i>
                                                                    <i class="dl-icon-star rated"></i>
                                                                    <i class="dl-icon-star rated"></i>
                                                                </span>
                                                                <?php echo $rev->prtitle;?>
                                                            </div>
                                                            <div class="review__meta">
                                                                <strong class="review__author"><?php echo $rev->first_name;?></strong>
                                                                <span class="review__dash">-</span>
                                                                <span class="review__published-date"><?php echo $rev->prdate;?></span>
                                                            </div>
                                                            <div class="clearfix"></div>
                                                            <p class="review__description"><?php echo $rev->preview;?></p>
                                                        </div>
                                                    </div>
                                                </li>
                                                <?php }?>
                                            </ul>
                                            
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row pt--65 pt-md--45 pt-sm--25 pb--35 pb-md--25 pb-sm--15">
                        <div class="col-12">
                            <div class="row mb--40 mb-md--30">
                                <div class="col-12 text-center">
                                    <h2 class="heading-secondary">Related Products</h2>
                                    <hr class="separator center mt--25 mt-md--15">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-12">
                                    <div class="airi-element-carousel product-carousel nav-vertical-center"
                                        data-slick-options='{
                                        "spaceBetween": 30,
                                        "slidesToShow": 4,
                                        "slidesToScroll": 1,
                                   		"autoplaySpeed": 1000,
                                        "arrows": true, 
                                        "autoplay": true, 
                                        "prevArrow": "dl-icon-left", 
                                        "nextArrow": "dl-icon-right" 
                                        }' data-slick-responsive='[
                                        {"breakpoint":1200, "settings": {"slidesToShow": 3} },
                                        {"breakpoint":991, "settings": {"slidesToShow": 2} },
                                        {"breakpoint":450, "settings": {"slidesToShow": 1} }
                                    ]'>
                                    <?php $this->db->select("*");

		$this->db->from('products');		

		//$this->db->join("category","products.cid=category.cid");
		
		//$this->db->join("prod_stock","prod_stock.prod_id=products.pid");
		//$this->db->join("prod_variants","prod_variants.pid=products.pid");
		//$this->db->where("prod_stock.city_id",$this->session->userdata("city"));

		//$this->db->join("subcategory","products.sid=subcategory.sid");

		$this->db->where("products.prod_slug!=",$this->uri->segment(1));

		$pros=$this->db->get()->result();foreach($pros as $pro){?> 
                                        <div class="airi-product">
                                            <div class="product-inner">
                                                <figure class="product-image">
                                                    <div class="product-image--holder">
                                                        <a href="<?php echo base_url().$pro->prod_slug;?>">
                                                            <img src="<?php echo base_url().'assets/images/products/'.$pro->img;?>"
                                                                alt="Product Image" class="primary-image">
                                                            <img src="<?php echo base_url().'assets/images/products/'.$pro->img;?>"
                                                                alt="Product Image" class="secondary-image">
                                                        </a>
                                                    </div>
                                                    
                                                </figure>
                                                <div class="product-info text-center">
                                                    <span class="product-price-wrapper">
                                                        <span class="money">₹<?php echo $pro->oprice;?></span>
                                                        <span class="product-price-old">
                                                            <span class="money">₹<?php echo $pro->price;?></span>
                                                        </span>
                                                    </span>
                                                    <h3 class="product-title">
                                                       <a style="color:#FFF;" href="<?php echo base_url().$pro->prod_slug;?>" class="btn btn-medium btn-style-1">Add To
                                                            Cart</a>
                                                    </h3>
                                                </div>
                                            </div>
                                        </div>
                                        <?php }?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                </div>
            </div>
        </div>
        