<?php 
include('header.php');

if(isset($arr_cart_p_id2)){$arr_cart_p_id2=$arr_cart_p_id2;}else{$arr_cart_p_id2=array();}
if(isset($arr_cart_size_id2)){$arr_cart_size_id2=$arr_cart_size_id2;}else{$arr_cart_size_id2=array();}
$f=0;
?>
      <section class="carousel-slider-main text-center border-top border-bottom bg-white">
         <div class="owl-carousel owl-carousel-slider">
              <?php
                if(!empty($slider)){
                    foreach($slider as $row){
            ?>
                <div class="item">
                   <a target='blank' href="<?=$row['button_url'];?>"><img class="img-fluid" loading="lazy" src="<?=base_url('uploads/shop/slider/'.$row['photo']);?>" alt="<?=$row['title'];?>" title="<?=$row['title'];?>"></a>
                </div>
            <?php 
                    }
                }
            ?>
         </div>
      </section>

      
    <section>
             <div class="container">
                 
                <div class="p-0-16">
                <div class="row mb-10">
                    <div class="col-12 ptb-1">
                        <h4 class="font-20 mb-0">Shop from Top Categories</h4>
                    </div>
                    <?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 shadow-sm">
                                    <a href="product_special?id=<?=$row1['mcat_id']; ?>&amp;type=mid-category&amp;mid=<?=$row1['mcat_id']; ?>">
                                        <img src="<?= base_url('uploads/shop/mid_category/'.$row1['mcat_pic']); ?>" alt="<?=$row1['mcat_name']; ?>" title="<?=$row1['mcat_name']; ?>" class="img-responsive w-60">
                                    </a>
                                    <!--<h5><a href="product_special?id=<?=$row1['mcat_id']; ?>&amp;type=mid-category&amp;mid=<?=$row1['mcat_id']; ?>"><?=$row1['mcat_name']; ?></a></h5>-->
                                </div>
                            <!--</div>-->
                        </div>
                         
    				<?php
    					}
    					}
    				?>
                    
                    
                    </div>
                    </div>
                 </div>
          </section>
      
        <section class="offer-product">
         <div class="container">
            <div class="row no-gutters">
                <?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-md-6 <?php if($u==0){echo 'd-none d-lg-block d-md-block d-sm-block';}?>">
                  <a href="<?=$row['link']; ?>"><img class="img-fluid" src="<?= base_url('uploads/shop/ad_slider/'.$row['img']); ?>" alt="<?=$row['link']; ?>"></a>
               </div>
               <?php $u++;  } ?>
            </div>
         </div>
        </section>
        
        <section class="product-items-slider section-padding">
             <div class="container">
                <div class="section-header">
                   <h5 class="heading-design-h5 text-center">Latest Product <!--<span class="badge badge-success">20% OFF</span>-->
                      <a class="float-right text-secondary" href="latest">View All</a>
                   </h5>
                </div>
                <?php
                    $query11 = $this->db->query('select * from tbl_product where p_is_active=1 and p_is_featured=0 order by p_id limit 10');
                    if(count($query11->result_array())){
                ?>
                <div class="owl-carousel owl-carousel-featured">
                    <?php
                        foreach ($query11->result_array() as $row) {
                    ?>
                        <div class="item" id="pid_2_<?=$row['p_id']; ?>">
                          <div class="product">
                              <a href="<?=base_url('product_view');?>?id=<?=$row['p_id']; ?>">
                                <div class="product-header">
                                    <span class="badge badge-success" <?='id="offer_'.$row['p_id'].'"'; ?> >0 % OFF</span>
                                   
                                   <img class="img-fluid" 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']; ?>" />
                                   <span class="veg text-success mdi mdi-circle"></span>
                                   <!--<span class="non-veg text-danger mdi mdi-circle"></span>-->
                                </div>
                                <div class="product-body">
                                   <h5 class="text-inline"><?=$row['p_name']; ?></h5>
                                   <h6><strong><span class="mdi mdi-approval"></span> Available in</strong> - </h6>
                                </div>
                                </a>
                                <div class="product-footer">
                                    <p>
                                    <?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'];
                                            $query3 = $this->db->query("select * from tbl_size where size_id = $size_id ");
                                            if($query3->num_rows()>0){
                                            foreach ($query3->result_array() as $row3) {
                                                if($i==1){
                                                    $p_old_price = $row2['p_old_price'];
                                                    $p_current_price = $row2['p_current_price'];
                                                    $p_qty = $row2['p_qty'];
                                                    $size_id = $row3['size_id'];
                                                    $size_name = $row3['size_name'];
                                                ?>
                                                    <div class="input-group">
                                                      <input id="size2_<?=$row['p_id']; ?>"  id2="<?=$row['p_id']; ?>" onclick="check_size(<?=$row['p_id']; ?>);" class="form-control input-sm" value='<?=$row3['size_name'];?>' readonly>
                                                      <div class="input-group-addon" style="background: #ddd;padding: 5px;">
                                                        <i class="mdi mdi-view-module"></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']; ?>"
                                                    id2="<?=$row['p_id']; ?>" />
                                           <?php
                                                }
                                                
                                                $i++;
                                            }
                                            }
                                            else{
                                                ?>
                                                <script>
                                                    $('#pid_2_<?=$row['p_id']; ?>').remove();
                                                </script>
                                                <?php
                                            }
                                        }
                                    ?>
                                    </p>
                                   <p class="offer-price mb-0">
                                       &#8377;<b id="price_c_<?=$row['p_id']; ?>"><?php  echo $p_current_price; ?></b>
                                       <i class="mdi mdi-tag-outline"></i> 
                                       <?php if($p_old_price!='' && $p_old_price!=$p_current_price){?><span class="regular-price">&#8377;<b id="price_o_<?=$row['p_id']; ?>"><?=$p_old_price; ?></b></span><?php } ?>
                                   
                                   </p>
                                        <!--Product Size start-->
                                    <?php 
                                        if($p_qty >= 1){
                                    ?>
                                        <input type="hidden" name="p_current_price" id="p_current_price_<?=$row['p_id']; ?>" value="<?=$p_current_price; ?>">
                                        <input type="hidden" name="p_old_price" id="p_old_price_<?=$row['p_id']; ?>" value="<?=$p_old_price; ?>">
                                        <input type="hidden" name="p_name" id="p_name_<?=$row['p_id']; ?>" value="<?=$row['p_name']; ?>">
                                        <input type="hidden" name="size_id" id="size_id_<?=$row['p_id']; ?>" value="<?=$size_id; ?>">
                                        <input type="hidden" name="size_name" id="size_name_<?=$row['p_id']; ?>" value="<?=$size_name; ?>">
                                        <input type="hidden" name="p_featured_photo" id="p_featured_photo_<?=$row['p_id']; ?>" value="<?= $row['p_featured_photo']; ?>">
                                        
                                        <?php  
                                            $count=0; 
                                            $query21 = $this->db->query("select * from tbl_product_size where p_id = $pid");
                                            foreach ($query21->result_array() as $row2) {
                                                $pid_search=0;
                                                $size_id_search=0;
                                                $primary_id=0;
                                                $ok=0;
                                                $count++;
                                                
                                                for($l=1;$l<=count($arr_cart_p_id2);$l++){
                                                    $size_id_search = array_search($row2['size_id'],$arr_cart_size_id2);
                                                    if($row['p_id'] == $arr_cart_p_id2[$l] && $row2['size_id'] == $arr_cart_size_id2[$l]){
                                                        $size_id_search=$l;
                                                        $ok=1;
                                                        break;
                                                    }
                                                }
                                                $primary_id = $row['p_id'].$row2['size_id'];
                                                if($ok){
                                            ?>
                                                <div class="col-xs-12 col-sm-12 input-group" id2="yes" id3="<?=$count;?>" id="hide_A<?=$primary_id; ?>">
                                                    <button class="btn btn-md input-group-btn bg-theme-color" onclick="minus(<?=$row['p_id'].','.$primary_id; ?>)">-</button>
                                                    <input type="text" name="quantity" class="form-control input-type text-center" qty_id="<?=$l;?>" id="qty_<?=$primary_id; ?>"
                                                    qty="<?=$row2['p_qty']; ?>" readonly value="<?=$arr_cart_p_qty2[$l];?>" >
                                                    <button class="btn btn-md input-group-btn bg-theme-color" onclick="plus(<?=$row['p_id'].','.$primary_id; ?>)">+</button>
                                                </div>
                                                
                                                <input id="qty2_<?=$primary_id; ?>"  qty="<?=$row2['p_qty']; ?>" type="hidden" value="1"/>
                                                <button type="button" id2="no" id3="<?=$count;?>" id="hide_B<?=$primary_id; ?>" style="display:none" class="btn  btn-secondary btn-sm" onclick="add(<?=$row['p_id'].','.$primary_id; ?>)"><i class="mdi mdi-cart-outline"></i> Add To Cart</button>
                                            <?php
                                                } else {
                                            ?>
                                                <div class="col-xs-12 col-sm-12 input-group" id2="yes1" id3="<?=$count;?>" id="hide_A<?=$primary_id; ?>" style="display:none">
                                                <button class="btn btn-md input-group-btn bg-theme-color" onclick="minus(<?=$row['p_id'].','.$primary_id; ?>)">-</button>
                                                <input type="text" readonly name="quantity" class="form-control input-type text-center " qty_id="<?=$l;?>" id="qty_<?=$primary_id; ?>"
                                                qty="<?=$row2['p_qty']; ?>"  value="1" >
                                                <button class="btn btn-md input-group-btn bg-theme-color " onclick="plus(<?=$row['p_id'].','.$primary_id; ?>)">+</button>
                                                </div>
                                                <input id="qty2_<?=$primary_id; ?>"  qty="<?=$row2['p_qty']; ?>" type="hidden" value="1" />
                                                <button type="button" id2="no1" id3="<?=$count;?>" id="hide_B<?=$primary_id; ?>" class="btn btn-secondary btn-sm" onclick="add(<?=$row['p_id'].','.$primary_id; ?>)"><i class="mdi mdi-cart-outline"></i> Add To Cart</button>
                                            <?php
                                                }
                                            }
                                        }
                                        elseif($p_qty <= 0){ ?>
                                        <button type="button" class="btn btn-secondary btn-sm"><i class="mdi mdi-cart-outline"></i> Out Of Stock</button>
                                        <?php } ?>
                                        <!--Product Size end-->
                                </div>
                          </div>
                       </div>
                        <?php } ?>
                </div>
                <?php 
                    }
                    else
                    {
                            ?>
                            <div class="col-md-12 text-center">
                                <img src="<?=base_url('uploads/no_product_found.png');?>" class="img-fluid" />
                            </div>
                            <?php
                        }
                ?>
             </div>
          </section>
          
        <section class="product-items-slider section-padding">
             <div class="container">
                <div class="section-header">
                   <h5 class="heading-design-h5 text-center">Featured Product <!--<span class="badge badge-success">20% OFF</span>-->
                      <a class="float-right text-secondary" href="featured">View All</a>
                   </h5>
                </div>
                <?php
                    $query11 = $this->db->query('select * from tbl_product where p_is_active=1 and p_is_featured=1 order by p_id limit 10');
                    if(count($query11->result_array())){
                ?>
                <div class="owl-carousel owl-carousel-featured">
                    <?php
                        foreach ($query11->result_array() as $row) {
                    ?>
                        <div class="item" id="pid_2_<?=$row['p_id']; ?>">
                          <div class="product">
                              <a href="<?=base_url('product_view');?>?id=<?=$row['p_id']; ?>">
                                <div class="product-header">
                                    <span class="badge badge-success" <?='id="offer_'.$row['p_id'].'"'; ?> >0 % OFF</span>
                                   
                                   <img class="img-fluid" 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']; ?>" />
                                   <span class="veg text-success mdi mdi-circle"></span>
                                   <!--<span class="non-veg text-danger mdi mdi-circle"></span>-->
                                </div>
                                <div class="product-body">
                                   <h5 class="text-inline"><?=$row['p_name']; ?></h5>
                                   <h6><strong><span class="mdi mdi-approval"></span> Available in</strong> - </h6>
                                </div>
                                </a>
                                <div class="product-footer">
                                    <p>
                                    <?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'];
                                            $query3 = $this->db->query("select * from tbl_size where size_id = $size_id ");
                                            if($query3->num_rows()>0){
                                            foreach ($query3->result_array() as $row3) {
                                                if($i==1){
                                                    $p_old_price = $row2['p_old_price'];
                                                    $p_current_price = $row2['p_current_price'];
                                                    $p_qty = $row2['p_qty'];
                                                    $size_id = $row3['size_id'];
                                                    $size_name = $row3['size_name'];
                                                ?>
                                                    <div class="input-group">
                                                      <input id="size2_<?=$row['p_id']; ?>"  id2="<?=$row['p_id']; ?>" onclick="check_size(<?=$row['p_id']; ?>);" class="form-control input-sm" value='<?=$row3['size_name'];?>' readonly>
                                                      <div class="input-group-addon" style="background: #ddd;padding: 5px;">
                                                        <i class="mdi mdi-view-module"></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']; ?>"
                                                    id2="<?=$row['p_id']; ?>" />
                                           <?php
                                                }
                                                
                                                $i++;
                                            }
                                            }
                                            else{
                                                ?>
                                                <script>
                                                    $('#pid_2_<?=$row['p_id']; ?>').remove();
                                                </script>
                                                <?php
                                            }
                                        }
                                    ?>
                                    </p>
                                   <p class="offer-price mb-0">
                                       &#8377;<b id="price_c_<?=$row['p_id']; ?>"><?php  echo $p_current_price; ?></b>
                                       <i class="mdi mdi-tag-outline"></i> 
                                       <?php if($p_old_price!='' && $p_old_price!=$p_current_price){?><span class="regular-price">&#8377;<b id="price_o_<?=$row['p_id']; ?>"><?=$p_old_price; ?></b></span><?php } ?>
                                   
                                   </p>
                                        <!--Product Size start-->
                                    <?php 
                                        if($p_qty >= 1){
                                    ?>
                                        <input type="hidden" name="p_current_price" id="p_current_price_<?=$row['p_id']; ?>" value="<?=$p_current_price; ?>">
                                        <input type="hidden" name="p_old_price" id="p_old_price_<?=$row['p_id']; ?>" value="<?=$p_old_price; ?>">
                                        <input type="hidden" name="p_name" id="p_name_<?=$row['p_id']; ?>" value="<?=$row['p_name']; ?>">
                                        <input type="hidden" name="size_id" id="size_id_<?=$row['p_id']; ?>" value="<?=$size_id; ?>">
                                        <input type="hidden" name="size_name" id="size_name_<?=$row['p_id']; ?>" value="<?=$size_name; ?>">
                                        <input type="hidden" name="p_featured_photo" id="p_featured_photo_<?=$row['p_id']; ?>" value="<?= $row['p_featured_photo']; ?>">
                                        
                                        <?php  
                                            $count=0; 
                                            $query21 = $this->db->query("select * from tbl_product_size where p_id = $pid");
                                            foreach ($query21->result_array() as $row2) {
                                                $pid_search=0;
                                                $size_id_search=0;
                                                $primary_id=0;
                                                $ok=0;
                                                $count++;
                                                
                                                for($l=1;$l<=count($arr_cart_p_id2);$l++){
                                                    $size_id_search = array_search($row2['size_id'],$arr_cart_size_id2);
                                                    if($row['p_id'] == $arr_cart_p_id2[$l] && $row2['size_id'] == $arr_cart_size_id2[$l]){
                                                        $size_id_search=$l;
                                                        $ok=1;
                                                        break;
                                                    }
                                                }
                                                $primary_id = $row['p_id'].$row2['size_id'];
                                                if($ok){
                                            ?>
                                                <div class="col-xs-12 col-sm-12 input-group" id2="yes" id3="<?=$count;?>" id="hide_A<?=$primary_id; ?>">
                                                    <button class="btn btn-md input-group-btn bg-theme-color" onclick="minus(<?=$row['p_id'].','.$primary_id; ?>)">-</button>
                                                    <input type="text" name="quantity" class="form-control input-type text-center" qty_id="<?=$l;?>" id="qty_<?=$primary_id; ?>"
                                                    qty="<?=$row2['p_qty']; ?>" readonly value="<?=$arr_cart_p_qty2[$l];?>" >
                                                    <button class="btn btn-md input-group-btn bg-theme-color" onclick="plus(<?=$row['p_id'].','.$primary_id; ?>)">+</button>
                                                </div>
                                                
                                                <input id="qty2_<?=$primary_id; ?>"  qty="<?=$row2['p_qty']; ?>" type="hidden" value="1"/>
                                                <button type="button" id2="no" id3="<?=$count;?>" id="hide_B<?=$primary_id; ?>" style="display:none" class="btn  btn-secondary btn-sm" onclick="add(<?=$row['p_id'].','.$primary_id; ?>)"><i class="mdi mdi-cart-outline"></i> Add To Cart</button>
                                            <?php
                                                } else {
                                            ?>
                                                <div class="col-xs-12 col-sm-12 input-group" id2="yes1" id3="<?=$count;?>" id="hide_A<?=$primary_id; ?>" style="display:none">
                                                <button class="btn btn-md input-group-btn bg-theme-color" onclick="minus(<?=$row['p_id'].','.$primary_id; ?>)">-</button>
                                                <input type="text" readonly name="quantity" class="form-control input-type text-center " qty_id="<?=$l;?>" id="qty_<?=$primary_id; ?>"
                                                qty="<?=$row2['p_qty']; ?>"  value="1" >
                                                <button class="btn btn-md input-group-btn bg-theme-color " onclick="plus(<?=$row['p_id'].','.$primary_id; ?>)">+</button>
                                                </div>
                                                <input id="qty2_<?=$primary_id; ?>"  qty="<?=$row2['p_qty']; ?>" type="hidden" value="1" />
                                                <button type="button" id2="no1" id3="<?=$count;?>" id="hide_B<?=$primary_id; ?>" class="btn btn-secondary btn-sm" onclick="add(<?=$row['p_id'].','.$primary_id; ?>)"><i class="mdi mdi-cart-outline"></i> Add To Cart</button>
                                            <?php
                                                }
                                            }
                                        }
                                        elseif($p_qty <= 0){ ?>
                                        <button type="button" class="btn btn-secondary btn-sm"><i class="mdi mdi-cart-outline"></i> Out Of Stock</button>
                                        <?php } ?>
                                        <!--Product Size end-->
                                </div>
                          </div>
                       </div>
                        <?php } ?>
                </div>
                <?php 
                    }
                    else
                    {
                            ?>
                            <div class="col-md-12 text-center">
                                <img src="<?=base_url('uploads/no_product_found.png');?>" class="img-fluid" />
                            </div>
                            <?php
                        }
                ?>
             </div>
          </section>
        
        <section class="product-items-slider section-padding">
             <div class="container">
                <div class="section-header">
                   <h5 class="heading-design-h5 text-center">Today's Best Deal Product <!--<span class="badge badge-success">20% OFF</span>-->
                      <a class="float-right text-secondary" href="today_deal">View All</a>
                   </h5>
                </div>
                <?php
                    $query11 = $this->db->query('select * from tbl_product where p_is_active=1 and todays_best_deal=1 order by p_id limit 10');
                    if(count($query11->result_array())){
                ?>
                <div class="owl-carousel owl-carousel-featured">
                    <?php
                        foreach ($query11->result_array() as $row) {
                    ?>
                        <div class="item" id="pid_2_<?=$row['p_id']; ?>">
                          <div class="product">
                              <a href="<?=base_url('product_view');?>?id=<?=$row['p_id']; ?>">
                                <div class="product-header">
                                    <span class="badge badge-success" <?='id="offer_'.$row['p_id'].'"'; ?> >0 % OFF</span>
                                   
                                   <img class="img-fluid" 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']; ?>" />
                                   <span class="veg text-success mdi mdi-circle"></span>
                                   <!--<span class="non-veg text-danger mdi mdi-circle"></span>-->
                                </div>
                                <div class="product-body">
                                   <h5 class="text-inline"><?=$row['p_name']; ?></h5>
                                   <h6><strong><span class="mdi mdi-approval"></span> Available in</strong> - </h6>
                                </div>
                                </a>
                                <div class="product-footer">
                                    <p>
                                    <?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'];
                                            $query3 = $this->db->query("select * from tbl_size where size_id = $size_id ");
                                            if($query3->num_rows()>0){
                                            foreach ($query3->result_array() as $row3) {
                                                if($i==1){
                                                    $p_old_price = $row2['p_old_price'];
                                                    $p_current_price = $row2['p_current_price'];
                                                    $p_qty = $row2['p_qty'];
                                                    $size_id = $row3['size_id'];
                                                    $size_name = $row3['size_name'];
                                                ?>
                                                    <div class="input-group">
                                                      <input id="size2_<?=$row['p_id']; ?>"  id2="<?=$row['p_id']; ?>" onclick="check_size(<?=$row['p_id']; ?>);" class="form-control input-sm" value='<?=$row3['size_name'];?>' readonly>
                                                      <div class="input-group-addon" style="background: #ddd;padding: 5px;">
                                                        <i class="mdi mdi-view-module"></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']; ?>"
                                                    id2="<?=$row['p_id']; ?>" />
                                           <?php
                                                }
                                                
                                                $i++;
                                            }
                                            }
                                            else{
                                                ?>
                                                <script>
                                                    $('#pid_2_<?=$row['p_id']; ?>').remove();
                                                </script>
                                                <?php
                                            }
                                        }
                                    ?>
                                    </p>
                                   <p class="offer-price mb-0">
                                       &#8377;<b id="price_c_<?=$row['p_id']; ?>"><?php  echo $p_current_price; ?></b>
                                       <i class="mdi mdi-tag-outline"></i> 
                                       <?php if($p_old_price!='' && $p_old_price!=$p_current_price){?><span class="regular-price">&#8377;<b id="price_o_<?=$row['p_id']; ?>"><?=$p_old_price; ?></b></span><?php } ?>
                                   
                                   </p>
                                        <!--Product Size start-->
                                    <?php 
                                        if($p_qty >= 1){
                                    ?>
                                        <input type="hidden" name="p_current_price" id="p_current_price_<?=$row['p_id']; ?>" value="<?=$p_current_price; ?>">
                                        <input type="hidden" name="p_old_price" id="p_old_price_<?=$row['p_id']; ?>" value="<?=$p_old_price; ?>">
                                        <input type="hidden" name="p_name" id="p_name_<?=$row['p_id']; ?>" value="<?=$row['p_name']; ?>">
                                        <input type="hidden" name="size_id" id="size_id_<?=$row['p_id']; ?>" value="<?=$size_id; ?>">
                                        <input type="hidden" name="size_name" id="size_name_<?=$row['p_id']; ?>" value="<?=$size_name; ?>">
                                        <input type="hidden" name="p_featured_photo" id="p_featured_photo_<?=$row['p_id']; ?>" value="<?= $row['p_featured_photo']; ?>">
                                        
                                        <?php  
                                            $count=0; 
                                            $query21 = $this->db->query("select * from tbl_product_size where p_id = $pid");
                                            foreach ($query21->result_array() as $row2) {
                                                $pid_search=0;
                                                $size_id_search=0;
                                                $primary_id=0;
                                                $ok=0;
                                                $count++;
                                                
                                                for($l=1;$l<=count($arr_cart_p_id2);$l++){
                                                    $size_id_search = array_search($row2['size_id'],$arr_cart_size_id2);
                                                    if($row['p_id'] == $arr_cart_p_id2[$l] && $row2['size_id'] == $arr_cart_size_id2[$l]){
                                                        $size_id_search=$l;
                                                        $ok=1;
                                                        break;
                                                    }
                                                }
                                                $primary_id = $row['p_id'].$row2['size_id'];
                                                if($ok){
                                            ?>
                                                <div class="col-xs-12 col-sm-12 input-group" id2="yes" id3="<?=$count;?>" id="hide_A<?=$primary_id; ?>">
                                                    <button class="btn btn-md input-group-btn bg-theme-color" onclick="minus(<?=$row['p_id'].','.$primary_id; ?>)">-</button>
                                                    <input type="text" name="quantity" class="form-control input-type text-center" qty_id="<?=$l;?>" id="qty_<?=$primary_id; ?>"
                                                    qty="<?=$row2['p_qty']; ?>" readonly value="<?=$arr_cart_p_qty2[$l];?>" >
                                                    <button class="btn btn-md input-group-btn bg-theme-color" onclick="plus(<?=$row['p_id'].','.$primary_id; ?>)">+</button>
                                                </div>
                                                
                                                <input id="qty2_<?=$primary_id; ?>"  qty="<?=$row2['p_qty']; ?>" type="hidden" value="1"/>
                                                <button type="button" id2="no" id3="<?=$count;?>" id="hide_B<?=$primary_id; ?>" style="display:none" class="btn  btn-secondary btn-sm" onclick="add(<?=$row['p_id'].','.$primary_id; ?>)"><i class="mdi mdi-cart-outline"></i> Add To Cart</button>
                                            <?php
                                                } else {
                                            ?>
                                                <div class="col-xs-12 col-sm-12 input-group" id2="yes1" id3="<?=$count;?>" id="hide_A<?=$primary_id; ?>" style="display:none">
                                                <button class="btn btn-md input-group-btn bg-theme-color" onclick="minus(<?=$row['p_id'].','.$primary_id; ?>)">-</button>
                                                <input type="text" readonly name="quantity" class="form-control input-type text-center " qty_id="<?=$l;?>" id="qty_<?=$primary_id; ?>"
                                                qty="<?=$row2['p_qty']; ?>"  value="1" >
                                                <button class="btn btn-md input-group-btn bg-theme-color " onclick="plus(<?=$row['p_id'].','.$primary_id; ?>)">+</button>
                                                </div>
                                                <input id="qty2_<?=$primary_id; ?>"  qty="<?=$row2['p_qty']; ?>" type="hidden" value="1" />
                                                <button type="button" id2="no1" id3="<?=$count;?>" id="hide_B<?=$primary_id; ?>" class="btn btn-secondary btn-sm" onclick="add(<?=$row['p_id'].','.$primary_id; ?>)"><i class="mdi mdi-cart-outline"></i> Add To Cart</button>
                                            <?php
                                                }
                                            }
                                        }
                                        elseif($p_qty <= 0){ ?>
                                        <button type="button" class="btn btn-secondary btn-sm"><i class="mdi mdi-cart-outline"></i> Out Of Stock</button>
                                        <?php } ?>
                                        <!--Product Size end-->
                                </div>
                          </div>
                       </div>
                        <?php } ?>
                </div>
                <?php 
                    }
                    else
                    {
                            ?>
                            <div class="col-md-12 text-center">
                                <img src="<?=base_url('uploads/no_product_found.png');?>" class="img-fluid" />
                            </div>
                            <?php
                        }
                ?>
             </div>
          </section>
        
        <section class="offer-product">
         <div class="container">
            <div class="row no-gutters">
                <?php
                $y=0;
                    $query = $this->db->query("SELECT * FROM tbl_ad_slider ORDER BY RAND() limit 2");
                    foreach ($query->result_array() as $row) {
        		?>
               <div class="col-md-6 <?php if($y==0){echo 'd-none d-lg-block d-md-block d-sm-block';}?>">
                  <a href="<?=$row['link']; ?>"><img class="img-fluid" src="<?= base_url('uploads/shop/ad_slider/'.$row['img']); ?>" alt="<?=$row['link']; ?>"></a>
               </div>
               <?php $y++; } ?>
            </div>
         </div>
        </section>
      
        <section class="hidden-md hidden-lg">
             <div class="container">
                <div class="row ">
                    <?php
        				$statement = $this->db->query("SELECT * FROM tbl_mid_category order by mcat_id desc");
        				$result = $statement->result_array();
        				foreach ($result as $row1) {
        					?>
        				<div class="col-md-12 col-12 col-lg-12 mb-10">			
                            <div class="item2" id="mdi_<?=$row1['mcat_id'];?>" onclick="$('#Display_id_<?=$row1['mcat_id'];?>').toggle();$(this).toggleClass('mycolor');$('#mdi_<?=$row1['mcat_id'];?> .category-item2 .icon i').toggleClass('mdi-chevron-up');">
                                    <div class="category-item2">
                                        <div class="row">
                                        <div class="col-md-4  col-sm-4 col-4 "><img class="img-fluidx" style="height: auto;" src="<?=base_url('uploads/shop/mid_category/'.$row1['mcat_pic']); ?>" alt=""></div>
                                        <div class="col-md-6  col-sm-6 col-6 ">
                                            <div class="content">
                                                <span> <?=$row1['mcat_name']; ?></span>
                                                <p class="text2">
                                                    <?php
                                                        $mcatid = $row1['mcat_id'];
                										$statement = $this->db->query("SELECT * FROM tbl_end_category WHERE mcat_id=$mcatid");
                                                        $result2 = $statement->result_array();
                                                        foreach ($result2 as $row2) {
                											?>
                											<?=$row2['ecat_name']; ?>,
                                                    	<?php
                										}
                										?>
                                                </p>
                                        </div></div>
                                        <div class="col-md-2 col-sm-2 col-2 "><div class="icon"><i class="mdi mdi-chevron-right"></i></div></div>
                                        </div>
                                    </div>
                                    <div class="p-10 p-102" id="Display_id_<?=$row1['mcat_id'];?>" style="display:none;">
                                        <div class="row cat-all" >
                                            <div class="col-md-4 col-lg-3 col-xl-2 no-padding col-sm-4 col-4 text-center">
                                                <a href="product_special?id=<?=$row1['mcat_id']; ?>&type=mid-category&mid=<?=$row1['mcat_id']; ?>">
                                                <div class="category-item3">
                                                    <img class="img-fluid" src="<?=base_url('uploads/shop/mid_category/'.$row1['mcat_pic']); ?>" alt=""><br>All <?=$row1['mcat_name']; ?>
                                                </div>
                                                </a>
                                            </div>
                                        <?php
                										$mcat2id = $row1['mcat_id'];
                										$statement = $this->db->query("SELECT * FROM tbl_end_category WHERE mcat_id=$mcat2id");
                                                        $result2 = $statement->result_array();
                                                        foreach ($result2 as $row2) {
                                                            $pic='';
                                                            $arr_pic='';
                                                            $arr_pic = explode('.',$row2['ecat_pic']);
                                                            if(empty($arr_pic[1]) || !file_exists('uploads/shop/end_category/'.$row2['ecat_pic'])){
                                                            $pic='../../no-image.png';
                                                            }
                                                            else
                                                            {
                                                                $pic = $row2['ecat_pic'];
                                                            }
                											?>
                                                            <div class="col-md-4 col-lg-3 col-xl-2 no-padding col-sm-4 col-4 text-center">
                                                                <a href="product_special?id=<?=$row2['ecat_id']; ?>&type=end-category&mid=<?=$row1['mcat_id']; ?>">
                                                                <div class="category-item3">
                                                                    <img class="img-fluid" src="<?=base_url('uploads/shop/end_category/'.$pic); ?>" alt=""><br><?=$row2['ecat_name']; ?>
                                                                </div>
                                                                </a>
                                                            </div>
                                                    	<?php
                										}
                										?>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
        			<?php
        				}
        			?>
                    
                    
                    </div>
                 </div>
          </section>
      
<?php include('footer.php');?>