<?php
	include('header.php');
	?>
<div id="home_slider" class="carousel slide" data-bs-ride="carousel">
	<div class="carousel-indicators d-none d-md-flex d-lg-flex">
		<?php
			if(!empty($slider)){
			    $i=0;
			    foreach($slider as $row){
			?>
		<li data-bs-target="#home_slider" data-bs-slide-to="<?=$i;?>" <?=($i==1) ? ' class="active"  aria-current="true"' : '' ;?>></li>
		<?php
			$i++;
			}
			}
			?>
	</div>
	<div class="carousel-inner">
		<?php
			if(!empty($slider)){
			    $i=0;
			    foreach($slider as $row){
			        $i++;
			?>
		<div class="carousel-item <?=($i==1) ? 'active' : '' ;?>">
			<img src="<?=base_url('uploads/shop/slider/'.$row['photo']);?>" alt="<?=$row['title'];?>" title="<?=$row['title'];?>" class="d-block w-100">
		</div>
		<?php 
			}
			}
			?>
	</div>
	<button class="carousel-control-prev" type="button" data-bs-target="#home_slider" data-bs-slide="prev">
	<i class="icofont-arrow-left bamdik2"></i>
	</button>
	<button class="carousel-control-next" type="button" data-bs-target="#home_slider" data-bs-slide="next">
	<i class="icofont-arrow-right bamdik2"></i>
	</button>
</div>

<section class="section suggest-part my-3">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <div class="section-heading mb-2">
                    <h2>Shop from Top Categories</h2>
                </div>
            </div>
        </div>
    <div class="p-3">
        <div class="row mb-10">
            <?php
                if(isset($mid_category)){
                foreach ($mid_category as $row1) {
			?>
            <div class="product-layout p-0-5-5-0 col-4 col-lg-2 col-md-2 col-sm-3">
                <!--<div class="product-thumb transition p-1">-->
                    <div class="image bg-white pt-1 shadow-sm">
                        <a href="product_special?id=<?=$row1['mcat_id']; ?>&amp;type=mid-category&amp;mid=<?=$row1['mcat_id']; ?>" class="px-3">
                            <img src="<?= base_url('uploads/shop/mid_category/'.$row1['mcat_pic']); ?>" alt="<?=$row1['mcat_name']; ?>" title="<?=$row1['mcat_name']; ?>" class="img-fluid rounded-circle w-60">
                        </a>
                        <b class="d-block w-100 text-center"><a href="product_special?id=<?=$row1['mcat_id']; ?>&amp;type=mid-category&amp;mid=<?=$row1['mcat_id']; ?>" class="text-dark"><?=$row1['mcat_name']; ?></a></b>
                    </div>
                <!--</div>-->
            </div>
            <?php
                }
                }
            ?>
        </div>
    </div>
    </div>
</section>
    
<section class="section recent-part">
	<div class="container">
		<div class="row">
			<div class="col-lg-12">
				<div class="section-heading">
					<h2>Latest items</h2>
				</div>
			</div>
		</div>
		<div class="row row-cols-2 row-cols-md-3 row-cols-lg-4 row-cols-xl-5">
            <?php
                        $p_old_price = 0;$p_current_price = 0;$p_qty = 0;$size_id = 0;$size_name = 0;$color_name = 0;$l = 0;
                        $query11 = $this->db->query('select * from tbl_product where p_is_active=1 and p_is_featured!=1 and todays_best_deal!=1 order by p_id limit 5');
                        if(count($query11->result_array())){
                            foreach ($query11->result_array() as $row) {
                    ?>
							<div class="col mt-5  mb-10 item" loading="lazy" id="pid_2_<?=$row['p_id']; ?>">
								<div class="product-card" id="out_of_stock_<?=$row['p_id']; ?>">
									<div class="product-media">
										<div class="product-label">
											<label class="label-text new">feature</label>
										</div>
										<div class="product-label">
											<label class="label-text new"><span class="badge badge-success" <?='id="offer_' .$row[ 'p_id']. '"'; ?> >0 % OFF</span></label>
										</div>
										
										<a class="product-image" href="<?=base_url('product_view');?>?id=<?=$row['p_id']; ?>">
								    <img id="pic_<?=$row['p_id']; ?>" src="<?=base_url('uploads/shop/product/'.$row['p_featured_photo']); ?>" alt="<?=$row['p_name']; ?>">
								    <input type="hidden" id="pic2_<?=$row['p_id']; ?>" value="<?= $row['p_featured_photo']; ?>" />
								</a>
										<!--<div class="product-widget"><a title="Product Compare" href="compare.php" class="fas fa-random"></a><a title="Product Video" href="https://youtu.be/9xzcVxSBbG8" class="venobox fas fa-play" data-autoplay="true" data-vbtype="video"></a><a title="Product View" href="#" class="fas fa-eye" data-bs-toggle="modal" data-bs-target="#product-view"></a></div>--></div>
									<div class="product-content">
										<!--<div class="product-rating"><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="icofont-star"></i><a href="product-video.php">(3)</a></div>-->
										<h6 class="product-name"><a href="<?=base_url('product_view');?>?id=<?=$row['p_id']; ?>"><?=$row['p_name']; ?></a></h6>
										<?php
										
                                        $i=1;
                                        $pid=$row['p_id'];
                                        
                                        $query_product_size = $this->db->query("select * from tbl_product_size where p_id = $pid");
                                        foreach ($query_product_size->result_array() as $row2) {
                                            
                                            $size_id = $row2['size_id'];
                                            $color_id = $row2['color_id'];
                                            $p_old_price = $row2['p_old_price'];
                                            $p_current_price = $row2['p_current_price'];
                                            $p_qty = $row2['p_qty'];
                                            
                                            if(empty($color_id)){
                                                $color_id='';
                                                $color_name = '';
                                            }
                                            else
                                            {
                                                $query4 = $this->db->query("select * from tbl_color where color_id = $color_id ");
                                                if($query4->num_rows() > 0){
                                                    foreach ($query4->result_array() as $row4) {
                                                        $color_name = $row4['color_name'];
                                                    }
                                                }
                                            }
                                                    
                                            $query3 = $this->db->query("select * from tbl_size where size_id = $size_id ");
                                            if($query3->num_rows() > 0){
                                                foreach ($query3->result_array() as $row3) {
                                                        $size_name = $row3['size_name'];
                                                }
                                            }
                                            if($i==1){
                                                ?>
                                            <input type="hidden" id="p_current_price_<?=$row['p_id']; ?>" value="<?=$p_current_price; ?>">
                                            <input type="hidden" id="p_old_price_<?=$row['p_id']; ?>" value="<?=$p_old_price; ?>">
                                            <input type="hidden" id="p_name_<?=$row['p_id']; ?>" value="<?=$row['p_name']; ?>">
                                            <input type="hidden" id="size_id_<?=$row['p_id']; ?>" value="<?=$size_id; ?>">
                                            <input type="hidden" id="color_id_<?=$row['p_id']; ?>" value="<?=$color_id; ?>">
                                            <input type="hidden" id="color_name_<?=$row['p_id']; ?>" value="<?=$color_name; ?>">
                                            <input type="hidden" id="size_name_<?=$row['p_id']; ?>" value="<?=$size_name; ?>">
                                            <input type="hidden" id="p_featured_photo_<?=$row['p_id']; ?>" value="<?= $row['p_featured_photo']; ?>">
											<div class="input-group">
												<input id="size2_<?=$row['p_id']; ?>" id2="<?=$row['p_id']; ?>"
												onclick="check_size(<?=$row['p_id']; ?>);" class="form-control px-2 input-check-size" 
												value="<?=$row3['size_name'];?> (<?=$color_name;?>)" readonly>
												<div class="input-group-addon p-2 check-size-btn"> <i class="fa fa-bars"></i> </div>
											</div>
											
											<input type="hidden" id="size_<?=$row['p_id']; ?>" class="form_value" value="<?=$size_id; ?>,<?=$p_old_price;?>,<?=$p_current_price;?>,<?=$p_qty;?>,<?=$size_name;?>,<?=$row['p_id']; ?>,<?=$color_id; ?>,<?=$color_name; ?>" id2="<?=$row['p_id']; ?>" />
											<?php
											
                                                }
                                                $i++;
                                            }
                                            ?>
								<h6 class="product-price">
									<del><?php if($p_old_price!='' && $p_old_price!=$p_current_price){?><span class="regular-price"><?=$data['currency'];?><b id="price_o_<?=$row['p_id']; ?>"><?=$p_old_price; ?></b></span><?php } ?></del>
									<span><b id="price_c_<?=$row['p_id']; ?>"><?=$data['currency'];?><?php  echo $p_current_price; ?></b></span>
								</h6>
								<!--Product Size start-->
                                    <?php
                                                $count=0; 
                                                $query21 = $this->db->query("select * from tbl_product_size where p_id = $pid");
                                                foreach ($query21->result_array() as $row2) {
                                                    $primary_id=0; $count++; $primary_id = $row['p_id'].$row2['size_id'].$row2['color_id'];
                                                ?>
                                                    <button class="product-wish wish wish2" id="wish_hide_A<?=$primary_id; ?>" onclick="add_to_wishlist(<?=$row['p_id'].','.$primary_id; ?>)"><i class="fas fa-heart"></i></button>
                                                <?php
                                                    if($row2['p_qty'] != 0){
                                                ?>
                                                    <div class="product-action" id2="yes1" id3="<?=$count;?>" id="hide_A<?=$primary_id; ?>" style="display:none">
                                                        <button class="action-minus" title="Quantity Minus" onclick="minus(<?=$row['p_id'].','.$primary_id; ?>)"><i class="icofont-minus"></i></button>
                                                        <input class="action-input" title="Quantity Number" readonly name="quantity" qty_id="<?=$l;?>" id="qty_<?=$primary_id; ?>" qty="<?=$row2['p_qty']; ?>" value="1">
                                                        <button class="action-plus" title="Quantity Plus" onclick="plus(<?=$row['p_id'].','.$primary_id; ?>)"><i class="icofont-plus"></i></button>
                                                    </div>
                                                    <input id="qty2_<?=$primary_id; ?>" qty="<?=$row2['p_qty']; ?>" type="hidden" value="1" />
                                                    <button class="product-add" title="Add to Cart" id2="no1" id3="<?=$count;?>" id="hide_B<?=$primary_id; ?>" onclick="add(<?=$row['p_id'].','.$primary_id; ?>)"><i class="fas fa-shopping-basket"></i><span>add to cart</span></button>
    										<?php
                                                    }
                                                    else if($row2['p_qty'] == 0 || $row2['p_qty'] < 0)
                                                    {
                                            ?>      
                                                    <button class="product-add bg-warning" title="Out Of Stock" id2="no1" id3="<?=$count;?>" id="hide_B<?=$primary_id; ?>" onclick="sweetalert('warning','Out Of Stock')"><i class="fas fa-shopping-basket"></i><span>Out Of Stock</span></button>
    								            <?php
                                                    }
                                                }
                                                ?>
										<!--Product Size end-->
									</div>
								</div>
							</div>
							<?php }
                        } else {
                            ?>
                            </div>
        <div class="row">
			<div class="col-md-12 text-center"> <img src="<?=base_url('uploads/no_product_found.png');?>" class="img-fluid w-25" /> </div>
        		<?php
            }
            ?>
        </div>
		<div class="row">
			<div class="col-lg-12">
				<div class="section-btn-25"><a href="<?=base_url('latest');?>" class="btn btn-outline"><i class="fas fa-eye"></i><span>show more</span></a></div>
			</div>
		</div>
	</div>
</section>

<div class="section promo-part">
	<div class="container">
		<div class="row">
		    <?php
                    $u=0;
                    $query = $this->db->query("SELECT * FROM tbl_ad_slider ORDER BY RAND() limit 2");
                    foreach ($query->result_array() as $row) {
        		?>
			<div class="col-sm-12 col-md-6 col-lg-6 px-xl-3 <?php if($u==0){echo 'd-none d-lg-block d-md-block d-sm-block';}?>">
				<div class="promo-img"><a href="<?=$row['link']; ?>"><img src="<?= base_url('uploads/shop/ad_slider/'.$row['img']); ?>" class="w-100" alt="<?=$row['title']; ?>"></a></div>
			</div>
			<?php
			        $u++;
                        }
			?>
		</div>
	</div>
</div>

<section class="section newitem-part">
	<div class="container">
		<div class="row">
			<div class="col">
				<div class="section-heading">
					<h2>Featured new items</h2>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col">
				<ul class="new-slider slider-arrow">
					<?php
                        $p_old_price = 0;$p_current_price = 0;$p_qty = 0;$size_id = 0;$size_name = 0;$color_name = 0;$l = 0;
                        $query11 = $this->db->query('select * from tbl_product where p_is_active=1 and  p_is_featured=1 order by p_id limit 8');
                        if(count($query11->result_array())){
                            foreach ($query11->result_array() as $row) {
                    ?>
							<li loading="lazy" id="pid_2_<?=$row['p_id']; ?>">
								<div class="product-card" id="out_of_stock_<?=$row['p_id']; ?>">
									<div class="product-media">
										<div class="product-label">
											<label class="label-text new">feature</label>
										</div>
										<div class="product-label">
											<label class="label-text new"><span class="badge badge-success" <?='id="offer_' .$row[ 'p_id']. '"'; ?> >0 % OFF</span></label>
										</div>
										<button class="product-wish wish"><i class="fas fa-heart"></i></button> <a class="product-image" href="<?=base_url('product_view');?>?id=<?=$row['p_id']; ?>">
								    <img id="pic_<?=$row['p_id']; ?>" src="<?=base_url('uploads/shop/product/'.$row['p_featured_photo']); ?>" alt="<?=$row['p_name']; ?>">
								    <input type="hidden" id="pic2_<?=$row['p_id']; ?>" value="<?= $row['p_featured_photo']; ?>" />
								</a>
										<!--<div class="product-widget"><a title="Product Compare" href="compare.php" class="fas fa-random"></a><a title="Product Video" href="https://youtu.be/9xzcVxSBbG8" class="venobox fas fa-play" data-autoplay="true" data-vbtype="video"></a><a title="Product View" href="#" class="fas fa-eye" data-bs-toggle="modal" data-bs-target="#product-view"></a></div>--></div>
									<div class="product-content">
										<!--<div class="product-rating"><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="icofont-star"></i><a href="product-video.php">(3)</a></div>-->
										<h6 class="product-name"><a href="<?=base_url('product_view');?>?id=<?=$row['p_id']; ?>"><?=$row['p_name']; ?></a></h6>
										<?php
										
                                        $i=1;
                                        $pid=$row['p_id'];
                                        
                                        $query_product_size = $this->db->query("select * from tbl_product_size where p_id = $pid");
                                        foreach ($query_product_size->result_array() as $row2) {
                                            
                                            $size_id = $row2['size_id'];
                                            $color_id = $row2['color_id'];
                                            $p_old_price = $row2['p_old_price'];
                                            $p_current_price = $row2['p_current_price'];
                                            $p_qty = $row2['p_qty'];
                                            
                                            if(empty($color_id)){
                                                $color_id='';
                                                $color_name = '';
                                            }
                                            else
                                            {
                                                $query4 = $this->db->query("select * from tbl_color where color_id = $color_id ");
                                                if($query4->num_rows() > 0){
                                                    foreach ($query4->result_array() as $row4) {
                                                        $color_name = $row4['color_name'];
                                                    }
                                                }
                                            }
                                                    
                                            $query3 = $this->db->query("select * from tbl_size where size_id = $size_id ");
                                            if($query3->num_rows() > 0){
                                                foreach ($query3->result_array() as $row3) {
                                                        $size_name = $row3['size_name'];
                                                }
                                            }
                                            if($i==1){
                                                ?>
                                            <input type="hidden" id="p_current_price_<?=$row['p_id']; ?>" value="<?=$p_current_price; ?>">
                                            <input type="hidden" id="p_old_price_<?=$row['p_id']; ?>" value="<?=$p_old_price; ?>">
                                            <input type="hidden" id="p_name_<?=$row['p_id']; ?>" value="<?=$row['p_name']; ?>">
                                            <input type="hidden" id="size_id_<?=$row['p_id']; ?>" value="<?=$size_id; ?>">
                                            <input type="hidden" id="color_id_<?=$row['p_id']; ?>" value="<?=$color_id; ?>">
                                            <input type="hidden" id="color_name_<?=$row['p_id']; ?>" value="<?=$color_name; ?>">
                                            <input type="hidden" id="size_name_<?=$row['p_id']; ?>" value="<?=$size_name; ?>">
                                            <input type="hidden" id="p_featured_photo_<?=$row['p_id']; ?>" value="<?= $row['p_featured_photo']; ?>">
											<div class="input-group">
												<input id="size2_<?=$row['p_id']; ?>" id2="<?=$row['p_id']; ?>"
												onclick="check_size(<?=$row['p_id']; ?>);" class="form-control px-2 input-check-size" 
												value="<?=$row3['size_name'];?> (<?=$color_name;?>)" readonly>
												<div class="input-group-addon p-2 check-size-btn"> <i class="fa fa-bars"></i> </div>
											</div>
											
											<input type="hidden" id="size_<?=$row['p_id']; ?>" class="form_value" value="<?=$size_id; ?>,<?=$p_old_price;?>,<?=$p_current_price;?>,<?=$p_qty;?>,<?=$size_name;?>,<?=$row['p_id']; ?>,<?=$color_id; ?>,<?=$color_name; ?>" id2="<?=$row['p_id']; ?>" />
											<?php
											
                                                }
                                                $i++;
                                            }
                                            ?>
								<h6 class="product-price">
									<del><?php if($p_old_price!='' && $p_old_price!=$p_current_price){?><span class="regular-price"><?=$data['currency'];?><b id="price_o_<?=$row['p_id']; ?>"><?=$p_old_price; ?></b></span><?php } ?></del>
									<span><b id="price_c_<?=$row['p_id']; ?>"><?=$data['currency'];?><?php  echo $p_current_price; ?></b></span>
								</h6>
								<!--Product Size start-->
                                    <?php
                                                $count=0; 
                                                $query21 = $this->db->query("select * from tbl_product_size where p_id = $pid");
                                                foreach ($query21->result_array() as $row2) {
                                                    $primary_id=0; $count++; $primary_id = $row['p_id'].$row2['size_id'].$row2['color_id'];
                                                    
                                                    if($row2['p_qty'] != 0){
                                                ?>
                                                
                                                    <div class="product-action" id2="yes1" id3="<?=$count;?>" id="hide_A<?=$primary_id; ?>" style="display:none">
                                                        <button class="action-minus" title="Quantity Minus" onclick="minus(<?=$row['p_id'].','.$primary_id; ?>)"><i class="icofont-minus"></i></button>
                                                        <input class="action-input" title="Quantity Number" readonly name="quantity" qty_id="<?=$l;?>" id="qty_<?=$primary_id; ?>" qty="<?=$row2['p_qty']; ?>" value="1">
                                                        <button class="action-plus" title="Quantity Plus" onclick="plus(<?=$row['p_id'].','.$primary_id; ?>)"><i class="icofont-plus"></i></button>
                                                    </div>
                                                    <input id="qty2_<?=$primary_id; ?>" qty="<?=$row2['p_qty']; ?>" type="hidden" value="1" />
                                                    <button class="product-add" title="Add to Cart" id2="no1" id3="<?=$count;?>" id="hide_B<?=$primary_id; ?>" onclick="add(<?=$row['p_id'].','.$primary_id; ?>)"><i class="fas fa-shopping-basket"></i><span>add to cart</span></button>
    										<?php
                                                    }
                                                    else if($row2['p_qty'] == 0 || $row2['p_qty'] < 0)
                                                    {
                                            ?>
                                                    <button class="product-add bg-warning" title="Out Of Stock" id2="no1" id3="<?=$count;?>" id="hide_B<?=$primary_id; ?>" onclick="sweetalert('warning','Out Of Stock')"><i class="fas fa-shopping-basket"></i><span>Out Of Stock</span></button>
    								            <?php
                                                    }
                                                }
                                                ?>
										<!--Product Size end-->
									</div>
								</div>
							</li>
							<?php }
                        } else {
                            ?>
								<div class="col-md-12 text-center"> <img src="<?=base_url('uploads/no_product_found.png');?>" class="img-fluid" /> </div>
								<?php
                        }
                        ?>
				</ul>
			</div>
		</div>
		<div class="row">
			<div class="col">
				<div class="section-btn-25"><a href="<?=base_url('featured');?>" class="btn btn-outline"><i class="fas fa-eye"></i><span>show more</span></a></div>
			</div>
		</div>
	</div>
</section>

<div class="section promo-part">
	<div class="container">
		<div class="row">
		    <?php
                    $u=0;
                    $query = $this->db->query("SELECT * FROM tbl_ad_slider ORDER BY RAND() limit 2");
                    foreach ($query->result_array() as $row) {
        		?>
			<div class="col-sm-12 col-md-6 col-lg-6 px-xl-3 <?php if($u==0){echo 'd-none d-lg-block d-md-block d-sm-block';}?>">
				<div class="promo-img"><a href="<?=$row['link']; ?>"><img src="<?= base_url('uploads/shop/ad_slider/'.$row['img']); ?>" class="w-100" alt="<?=$row['title']; ?>"></a></div>
			</div>
			<?php
			        $u++;
                        }
			?>
		</div>
	</div>
</div>


<section class="section newitem-part">
	<div class="container">
		<div class="row">
			<div class="col">
				<div class="section-heading">
					<h2>todays Best Deal</h2>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col">
				<ul class="new-slider slider-arrow">
					<?php
                        $p_old_price = 0;$p_current_price = 0;$p_qty = 0;$size_id = 0;$size_name = 0;$color_name = 0;$l = 0;
                        $query11 = $this->db->query('select * from tbl_product where p_is_active=1 and  todays_best_deal=1 order by p_id limit 8');
                        if(count($query11->result_array())){
                            foreach ($query11->result_array() as $row) {
                    ?>
							<li loading="lazy" id="pid_2_<?=$row['p_id']; ?>">
								<div class="product-card" id="out_of_stock_<?=$row['p_id']; ?>">
									<div class="product-media">
										<div class="product-label">
											<label class="label-text new">feature</label>
										</div>
										<div class="product-label">
											<label class="label-text new"><span class="badge badge-success" <?='id="offer_' .$row[ 'p_id']. '"'; ?> >0 % OFF</span></label>
										</div>
										<button class="product-wish wish"><i class="fas fa-heart"></i></button> <a class="product-image" href="<?=base_url('product_view');?>?id=<?=$row['p_id']; ?>">
								    <img id="pic_<?=$row['p_id']; ?>" src="<?=base_url('uploads/shop/product/'.$row['p_featured_photo']); ?>" alt="<?=$row['p_name']; ?>">
								    <input type="hidden" id="pic2_<?=$row['p_id']; ?>" value="<?= $row['p_featured_photo']; ?>" />
								</a>
										<!--<div class="product-widget"><a title="Product Compare" href="compare.php" class="fas fa-random"></a><a title="Product Video" href="https://youtu.be/9xzcVxSBbG8" class="venobox fas fa-play" data-autoplay="true" data-vbtype="video"></a><a title="Product View" href="#" class="fas fa-eye" data-bs-toggle="modal" data-bs-target="#product-view"></a></div>--></div>
									<div class="product-content">
										<!--<div class="product-rating"><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="icofont-star"></i><a href="product-video.php">(3)</a></div>-->
										<h6 class="product-name"><a href="<?=base_url('product_view');?>?id=<?=$row['p_id']; ?>"><?=$row['p_name']; ?></a></h6>
										<?php
										
                                        $i=1;
                                        $pid=$row['p_id'];
                                        
                                        $query_product_size = $this->db->query("select * from tbl_product_size where p_id = $pid");
                                        foreach ($query_product_size->result_array() as $row2) {
                                            
                                            $size_id = $row2['size_id'];
                                            $color_id = $row2['color_id'];
                                            $p_old_price = $row2['p_old_price'];
                                            $p_current_price = $row2['p_current_price'];
                                            $p_qty = $row2['p_qty'];
                                            
                                            if(empty($color_id)){
                                                $color_id='';
                                                $color_name = '';
                                            }
                                            else
                                            {
                                                $query4 = $this->db->query("select * from tbl_color where color_id = $color_id ");
                                                if($query4->num_rows() > 0){
                                                    foreach ($query4->result_array() as $row4) {
                                                        $color_name = $row4['color_name'];
                                                    }
                                                }
                                            }
                                                    
                                            $query3 = $this->db->query("select * from tbl_size where size_id = $size_id ");
                                            if($query3->num_rows() > 0){
                                                foreach ($query3->result_array() as $row3) {
                                                        $size_name = $row3['size_name'];
                                                }
                                            }
                                            if($i==1){
                                                ?>
                                            <input type="hidden" id="p_current_price_<?=$row['p_id']; ?>" value="<?=$p_current_price; ?>">
                                            <input type="hidden" id="p_old_price_<?=$row['p_id']; ?>" value="<?=$p_old_price; ?>">
                                            <input type="hidden" id="p_name_<?=$row['p_id']; ?>" value="<?=$row['p_name']; ?>">
                                            <input type="hidden" id="size_id_<?=$row['p_id']; ?>" value="<?=$size_id; ?>">
                                            <input type="hidden" id="color_id_<?=$row['p_id']; ?>" value="<?=$color_id; ?>">
                                            <input type="hidden" id="color_name_<?=$row['p_id']; ?>" value="<?=$color_name; ?>">
                                            <input type="hidden" id="size_name_<?=$row['p_id']; ?>" value="<?=$size_name; ?>">
                                            <input type="hidden" id="p_featured_photo_<?=$row['p_id']; ?>" value="<?= $row['p_featured_photo']; ?>">
											<div class="input-group">
												<input id="size2_<?=$row['p_id']; ?>" id2="<?=$row['p_id']; ?>"
												onclick="check_size(<?=$row['p_id']; ?>);" class="form-control px-2 input-check-size" 
												value="<?=$row3['size_name'];?> (<?=$color_name;?>)" readonly>
												<div class="input-group-addon p-2 check-size-btn"> <i class="fa fa-bars"></i> </div>
											</div>
											
											<input type="hidden" id="size_<?=$row['p_id']; ?>" class="form_value" value="<?=$size_id; ?>,<?=$p_old_price;?>,<?=$p_current_price;?>,<?=$p_qty;?>,<?=$size_name;?>,<?=$row['p_id']; ?>,<?=$color_id; ?>,<?=$color_name; ?>" id2="<?=$row['p_id']; ?>" />
											<?php
											
                                                }
                                                $i++;
                                            }
                                            ?>
								<h6 class="product-price">
									<del><?php if($p_old_price!='' && $p_old_price!=$p_current_price){?><span class="regular-price"><?=$data['currency'];?><b id="price_o_<?=$row['p_id']; ?>"><?=$p_old_price; ?></b></span><?php } ?></del>
									<span><b id="price_c_<?=$row['p_id']; ?>"><?=$data['currency'];?><?php  echo $p_current_price; ?></b></span>
								</h6>
								<!--Product Size start-->
                                    <?php
                                                $count=0; 
                                                $query21 = $this->db->query("select * from tbl_product_size where p_id = $pid");
                                                foreach ($query21->result_array() as $row2) {
                                                    $primary_id=0; $count++; $primary_id = $row['p_id'].$row2['size_id'].$row2['color_id'];
                                                    
                                                    if($row2['p_qty'] != 0){
                                                ?>
                                                
                                                    <div class="product-action" id2="yes1" id3="<?=$count;?>" id="hide_A<?=$primary_id; ?>" style="display:none">
                                                        <button class="action-minus" title="Quantity Minus" onclick="minus(<?=$row['p_id'].','.$primary_id; ?>)"><i class="icofont-minus"></i></button>
                                                        <input class="action-input" title="Quantity Number" readonly name="quantity" qty_id="<?=$l;?>" id="qty_<?=$primary_id; ?>" qty="<?=$row2['p_qty']; ?>" value="1">
                                                        <button class="action-plus" title="Quantity Plus" onclick="plus(<?=$row['p_id'].','.$primary_id; ?>)"><i class="icofont-plus"></i></button>
                                                    </div>
                                                    <input id="qty2_<?=$primary_id; ?>" qty="<?=$row2['p_qty']; ?>" type="hidden" value="1" />
                                                    <button class="product-add" title="Add to Cart" id2="no1" id3="<?=$count;?>" id="hide_B<?=$primary_id; ?>" onclick="add(<?=$row['p_id'].','.$primary_id; ?>)"><i class="fas fa-shopping-basket"></i><span>add to cart</span></button>
    										<?php
                                                    }
                                                    else if($row2['p_qty'] == 0 || $row2['p_qty'] < 0)
                                                    {
                                            ?>
                                                    <button class="product-add bg-warning" title="Out Of Stock" id2="no1" id3="<?=$count;?>" id="hide_B<?=$primary_id; ?>" onclick="sweetalert('warning','Out Of Stock')"><i class="fas fa-shopping-basket"></i><span>Out Of Stock</span></button>
    								            <?php
                                                    }
                                                }
                                                ?>
										<!--Product Size end-->
									</div>
								</div>
							</li>
							<?php }
                        } else {
                            ?>
								<div class="col-md-12 text-center"> <img src="<?=base_url('uploads/no_product_found.png');?>" class="img-fluid" /> </div>
								<?php
                        }
                        ?>
				</ul>
			</div>
		</div>
		<div class="row">
			<div class="col">
				<div class="section-btn-25"><a href="<?=base_url('today_deal');?>" class="btn btn-outline"><i class="fas fa-eye"></i><span>show more</span></a></div>
			</div>
		</div>
	</div>
</section>


<!--<section class="section niche-part">
	<div class="container">
		<div class="row">
			<div class="col-lg-12">
				<div class="section-heading">
					<h2>Browse by Top Niche</h2>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-lg-12">
				<ul class="nav nav-tabs">
					<li><a href="#top-order" class="tab-link active" data-bs-toggle="tab"><i class="icofont-price"></i><span>top order</span></a></li>
					<li><a href="#top-rate" class="tab-link" data-bs-toggle="tab"><i class="icofont-star"></i><span>top rating</span></a></li>
					<li><a href="#top-disc" class="tab-link" data-bs-toggle="tab"><i class="icofont-sale-discount"></i><span>top discount</span></a></li>
				</ul>
			</div>
		</div>
		<div class="tab-pane active" id="top-order">
			<div class="row row-cols-2 row-cols-md-3 row-cols-lg-4 row-cols-xl-5">
				<div class="col">
					<div class="product-card">
						<div class="product-media">
							<div class="product-label"><label class="label-text order">314</label></div>
							<button class="product-wish wish"><i class="fas fa-heart"></i></button><a class="product-image" href="product-video.php"><img src="<?=base_url('site_assets/');?>images/product/01.jpg" alt="product"></a>
							<div class="product-widget"><a title="Product Compare" href="compare.php" class="fas fa-random"></a><a title="Product Video" href="https://youtu.be/9xzcVxSBbG8" class="venobox fas fa-play" data-autoplay="true" data-vbtype="video"></a><a title="Product View" href="#" class="fas fa-eye" data-bs-toggle="modal" data-bs-target="#product-view"></a></div>
						</div>
						<div class="product-content">
							<div class="product-rating"><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="icofont-star"></i><a href="product-video.php">(3)</a></div>
							<h6 class="product-name"><a href="product-video.php">fresh green chilis</a>
							</h6>
							<h6 class="product-price"><del>$34</del><span>$28<small>/piece</small></span>
							</h6>
							<button class="product-add" title="Add to Cart"><i class="fas fa-shopping-basket"></i><span>add</span></button>
							<div class="product-action"><button class="action-minus" title="Quantity Minus"><i class="icofont-minus"></i></button><input class="action-input" title="Quantity Number" type="text" name="quantity" value="1"><button class="action-plus" title="Quantity Plus"><i class="icofont-plus"></i></button></div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="tab-pane" id="top-rate">
			<div class="row row-cols-2 row-cols-md-3 row-cols-lg-4 row-cols-xl-5">
				<div class="col">
					<div class="product-card">
						<div class="product-media">
							<div class="product-label"><label class="label-text rate">4.8</label></div>
							<button class="product-wish wish"><i class="fas fa-heart"></i></button><a class="product-image" href="product-video.php"><img src="<?=base_url('site_assets/');?>images/product/11.jpg" alt="product"></a>
							<div class="product-widget"><a title="Product Compare" href="compare.php" class="fas fa-random"></a><a title="Product Video" href="https://youtu.be/9xzcVxSBbG8" class="venobox fas fa-play" data-autoplay="true" data-vbtype="video"></a><a title="Product View" href="#" class="fas fa-eye" data-bs-toggle="modal" data-bs-target="#product-view"></a></div>
						</div>
						<div class="product-content">
							<div class="product-rating"><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="icofont-star"></i><a href="product-video.php">(3)</a></div>
							<h6 class="product-name"><a href="product-video.php">fresh green chilis</a>
							</h6>
							<h6 class="product-price"><del>$34</del><span>$28<small>/piece</small></span>
							</h6>
							<button class="product-add" title="Add to Cart"><i class="fas fa-shopping-basket"></i><span>add</span></button>
							<div class="product-action"><button class="action-minus" title="Quantity Minus"><i class="icofont-minus"></i></button><input class="action-input" title="Quantity Number" type="text" name="quantity" value="1"><button class="action-plus" title="Quantity Plus"><i class="icofont-plus"></i></button></div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="tab-pane" id="top-disc">
			<div class="row row-cols-2 row-cols-md-3 row-cols-lg-4 row-cols-xl-5">
				<div class="col">
					<div class="product-card">
						<div class="product-media">
							<div class="product-label"><label class="label-text off">-10%</label></div>
							<button class="product-wish wish"><i class="fas fa-heart"></i></button><a class="product-image" href="product-video.php"><img src="<?=base_url('site_assets/');?>images/product/06.jpg" alt="product"></a>
							<div class="product-widget"><a title="Product Compare" href="compare.php" class="fas fa-random"></a><a title="Product Video" href="https://youtu.be/9xzcVxSBbG8" class="venobox fas fa-play" data-autoplay="true" data-vbtype="video"></a><a title="Product View" href="#" class="fas fa-eye" data-bs-toggle="modal" data-bs-target="#product-view"></a></div>
						</div>
						<div class="product-content">
							<div class="product-rating"><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="active icofont-star"></i><i class="icofont-star"></i><a href="product-video.php">(3)</a></div>
							<h6 class="product-name"><a href="product-video.php">fresh green chilis</a>
							</h6>
							<h6 class="product-price"><del>$34</del><span>$28<small>/piece</small></span>
							</h6>
							<button class="product-add" title="Add to Cart"><i class="fas fa-shopping-basket"></i><span>add</span></button>
							<div class="product-action"><button class="action-minus" title="Quantity Minus"><i class="icofont-minus"></i></button><input class="action-input" title="Quantity Number" type="text" name="quantity" value="1"><button class="action-plus" title="Quantity Plus"><i class="icofont-plus"></i></button></div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-lg-12">
				<div class="section-btn-25"><a href="#<?=base_url('trending');?>" class="btn btn-outline"><i class="fas fa-eye"></i><span>show more</span></a></div>
			</div>
		</div>
	</div>
</section>-->

<!--<div class="section promo-part">
	<div class="container">
		<div class="row">
		    <?php
                    $u=0;
                    $query = $this->db->query("SELECT * FROM tbl_ad_slider ORDER BY RAND() limit 2");
                    foreach ($query->result_array() as $row) {
        		?>
			<div class="col-sm-12 col-md-6 col-lg-6 px-xl-3 <?php if($u==0){echo 'd-none d-lg-block d-md-block d-sm-block';}?>">
				<div class="promo-img"><a href="<?=$row['link']; ?>"><img src="<?= base_url('uploads/shop/ad_slider/'.$row['img']); ?>" class="w-100 alt="<?=$row['title']; ?>"></a></div>
			</div>
			<?php
			        $u++;
                        }
			?>
		</div>
	</div>
</div>-->

<!--<section class="section brand-part">
	<div class="container">
		<div class="row">
			<div class="col-12">
				<div class="section-heading">
					<h2>shop by brands</h2>
				</div>
			</div>
		</div>
		<div class="brand-slider slider-arrow">
			<div class="brand-wrap">
				<div class="brand-media">
					<img src="<?=base_url('site_assets/');?>images/brand/01.jpg" alt="brand">
					<div class="brand-overlay"><a href="#"><i class="fas fa-link"></i></a></div>
				</div>
				<div class="brand-meta">
					<h4>natural organe</h4>
					<p>(45 items)</p>
				</div>
			</div>
		</div>
	</div>
</section>-->

<!-- end main -->
<?php
	include('footer.php');
	?>