<?php
include('header.php');
?>
<?php
if (!isset($_GET['id'])) {
    ?>
        <div class="col-md-12 text-center">
            <img src="<?=base_url('uploads/no_product_found.png');?>" class="img-fluid" />
        </div>
    <?php
    include('footer.php');
    
    exit;
} else {
    $product_id = $_GET['id'];
    // Check the id is valid or not
    $statement = $this->db->query("SELECT * FROM tbl_product WHERE p_id=?", array(
        $product_id
    ));
    $total     = count($statement->result_array());
    $result    = $statement->result_array();
    if ($total == 0) {
    ?>
        <div class="col-md-12 text-center">
            <img src="<?=base_url('uploads/no_product_found.png');?>" class="img-fluid" />
        </div>
    <?php
    include('footer.php');
    
    exit;
}
}
foreach ($result as $row) {
    $p_name              = $row['p_name'];
    // $p_old_price = $row['p_old_price'];
    // $p_current_price = $row['p_current_price'];
    // $p_qty = $row['p_qty'];
    $p_featured_photo    = $row['p_featured_photo'];
    $product_id                = $row['p_id'];
    $p_description       = $row['p_description'];
    $p_short_description = $row['p_short_description'];
    $p_feature           = $row['p_feature'];
    $p_condition         = $row['p_condition'];
    $p_return_policy     = $row['p_return_policy'];
    $p_total_view        = $row['p_total_view'];
    $todays_best_deal    = $row['todays_best_deal'];
    $p_is_featured       = $row['p_is_featured'];
    $p_is_active         = $row['p_is_active'];
    $ecat_id             = $row['ecat_id'];
    $tags                = $row['tags'];
}
if($p_is_active==1){ $tag = 'new'; }
if($p_is_featured==1){ $tag = 'featured'; }
if($todays_best_deal==1){ $tag = 'Best Deal'; }

// Getting all categories name for breadcrumb
$statement = $this->db->query("SELECT
t1.ecat_id,
t1.ecat_name,
t1.mcat_id,
t2.mcat_id,
t2.mcat_name,
t2.tcat_id,
t3.tcat_id,
t3.tcat_name
FROM tbl_end_category t1
JOIN tbl_mid_category t2
ON t1.mcat_id = t2.mcat_id
JOIN tbl_top_category t3
ON t2.tcat_id = t3.tcat_id
WHERE t1.ecat_id=?", array(
    $ecat_id
));
$total     = count($statement->result_array());
$result    = $statement->result_array();
foreach ($result as $row) {
    $ecat_name = $row['ecat_name'];
    $mcat_id   = $row['mcat_id'];
    $mcat_name = $row['mcat_name'];
    $tcat_id   = $row['tcat_id'];
    $tcat_name = $row['tcat_name'];
}
$p_total_view = $p_total_view + 1;
$statement    = $this->db->query("UPDATE tbl_product SET p_total_view=? WHERE p_id=?", array(
    $p_total_view,
    $product_id
));
$statement    = $this->db->query("SELECT * FROM tbl_product_size WHERE p_id=?", array(
    $product_id
));
$result       = $statement->result_array();
foreach ($result as $row) {
    $size[] = $row['size_id'];
}

if (isset($_POST['form_review'])) {
    $statement = $this->db->query("SELECT * FROM tbl_rating WHERE p_id=? AND cust_id=?", array(
        $product_id,
        $_SESSION['customer']['cust_id']
    ));
    $total     = $statement->rowCount();
    if ($total) {
        $error_message = LANG_VALUE_68;
    } else {
        $statement       = $this->db->query("INSERT INTO tbl_rating (p_id,cust_id,comment,rating) VALUES (?,?,?,?)", array(
            $product_id,
            $_SESSION['customer']['cust_id'],
            $_POST['comment'],
            $_POST['rating']
        ));
        $success_message = LANG_VALUE_163;
    }
}
// Getting the average rating for this product
$t_rating   = 0;
$statement  = $this->db->query("SELECT * FROM tbl_rating WHERE p_id=?", array(
    $product_id
));
$tot_rating = count($statement->result_array());
if ($tot_rating == 0) {
    $avg_rating = 0;
} else {
    $result = $statement->result_array();
    foreach ($result as $row) {
        $t_rating = $t_rating + $row['rating'];
    }
    $avg_rating = $t_rating / $tot_rating;
}
?>


<!-- start main -->
<section class="single-banner inner-section">
	<div class="container">
		<h2><?= $p_name; ?></h2>
		<ol class="breadcrumb">
			<li class="breadcrumb-item"><a href="<?= base_url(); ?>">Home</a></li>
			<li class="breadcrumb-item"><a href="#"><?= $tcat_name; ?></a></li>
			<li class="breadcrumb-item"><a href="#"><?= $mcat_name; ?></a></li>
			<li class="breadcrumb-item"><a href="#"><?= $ecat_name; ?></a></li>
			<li class="breadcrumb-item active" aria-current="page"><?= $p_name; ?></li>
		</ol>
	</div>
</section>

<section class="inner-section">
	<div class="container">
		<div class="row">
         <div class="col-md-6">
             <div class="details-gallery">
					<div class="details-label-group"><label class="details-label new"><?=(isset($tag)) ? $tag : '' ;?></label><label class="details-label off" <?= 'id="offer_' . $product_id . '"'; ?> >1 % OFF</label></div>
					<ul class="details-preview">
					    <li><img id="pic_<?= $product_id; ?>" src="<?=base_url('uploads/shop/product/');?><?= $p_featured_photo; ?>" alt="<?= $p_name; ?>" class="img-fluid img-center"></li>
					    <?php
                            $statement = $this->db->query("SELECT * FROM tbl_product_photo WHERE p_id=?", array($product_id));
                            $result    = $statement->result_array();
                            foreach ($result as $row) {
                        ?>
                        <li><img src="<?=base_url('uploads/shop/product/');?>more/<?= $row['photo']; ?>" alt="<?= $p_name; ?>" class="img-fluid img-center"></li>
                        <?php
                            }
                        ?>
					</ul>
					<input type="hidden" id="pic2_<?= $product_id; ?>" value="<?= $p_featured_photo; ?>" />
					<ul class="details-thumb">
					    <li><img src="<?=base_url('uploads/shop/product/');?><?= $p_featured_photo; ?>" alt="<?= $p_name; ?>" class="img-fluid img-center"></li>
					    <?php
                            $statement = $this->db->query("SELECT * FROM tbl_product_photo WHERE p_id=?", array($product_id));
                            $result    = $statement->result_array();
                            foreach ($result as $row) {
                        ?>
                        <li><img src="<?=base_url('uploads/shop/product/');?>more/<?= $row['photo']; ?>" alt="<?= $p_name; ?>" class="img-fluid img-center"></li>
                        <?php
                            }
                        ?>
					</ul>
				</div>
			</div>
			<div class="col-lg-6">
            	<div class="details-content">
            	    <h3 class="details-name"><a href="#"><?= $p_name; ?></a></h3>
            	    <!--<div class="details-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="#">(3
							reviews)</a></div>-->
            	    <?php
                        $i=1;
                        $query_product_size = $this->db->query("select * from tbl_product_size where p_id = $product_id");
                        foreach ($query_product_size->result_array() as $row2) {
                            
                            $p_pv = $row2['p_pv'];
                            $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="<?=$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="p_pv_<?=$row['p_id']; ?>" value="<?=$p_pv; ?>">
                            <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="<?= $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'];?> <?php if(empty($color_name)){}else{?>(<?=$color_name;?>)<?php } ?>" 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; ?>,<?=$p_pv;?>" id2="<?=$row['p_id']; ?>" />
							<?php
							
                                }
                                $i++;
                            }
                    ?>
                    <h3 class="details-price pt-2">
							<del><?php if($p_old_price!='' && $p_old_price!=$p_current_price){?><?=$data['currency'];?><b id="price_o_<?=$row['p_id']; ?>"><?=$p_old_price; ?></b><?php } ?></del>
							<span><?=LANG_VALUE_1;?><b id="price_c_<?=$row['p_id']; ?>"><?=$data['currency'];?><?php  echo $p_current_price; ?></b></span>
							<b class="pv d-none">(<b id="p_pv2_<?=$row['p_id']; ?>"><?=$p_pv;?></b> PV)</b>
					</h3>
					<p class="details-desc">
					    <?= $p_short_description; ?>
					</p>
					<div class="details-list-group"><label class="details-list-title">tags:</label>
						<ul class="details-tag-list">
						    <?php 
						    $array1 = explode(',',$tags);
						    foreach($array1 as $tag){
					        ?>
					        <li><a href="#"><?=$tag;?></a></li>
					        <?php
						    }
						    ?>
						</ul>
					</div>
					<script type='text/javascript' src='https://platform-api.sharethis.com/js/sharethis.js#property=60dad47e2b1ad10012445e5a&product=sop' async='async'></script>
					<div class="details-list-group"><label class="details-list-title">Share:</label>
						<!--<ul class="details-share-list">-->
						<!--	<li><a href="#" class="icofont-facebook" title="Facebook"></a></li>-->
						<!--	<li><a href="#" class="icofont-twitter" title="Twitter"></a></li>-->
						<!--	<li><a href="#" class="icofont-linkedin" title="Linkedin"></a></li>-->
						<!--	<li><a href="#" class="icofont-instagram" title="Instagram"></a></li>-->
						<!--</ul>-->
						<!-- ShareThis BEGIN --><div class="sharethis-inline-share-buttons"></div><!-- ShareThis END -->
					</div>
					<div class="details-add-group">
					    <!--Product Size start-->
                                <?php
                                $count=0; 
                                $query21 = $this->db->query("select * from tbl_product_size where p_id = $product_id");
                                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>
			</div>
		</div>
	</div>
</section>
<section class="inner-section">
	<div class="container">
		<div class="row">
			<div class="col-lg-12">
				<ul class="nav nav-tabs">
					<!--<li><a href="#tab-short-desc" class="tab-link active" data-bs-toggle="tab">Quick Overview</a></li>-->
					<li><a href="#tab-desc" class="tab-link " data-bs-toggle="tab">descriptions</a></li>
					<li><a href="#tab-spec" class="tab-link" data-bs-toggle="tab">Specifications</a></li>
					<li><a href="#tab-cond" class="tab-link" data-bs-toggle="tab">Condition</a></li>
					<li><a href="#tab-retu" class="tab-link" data-bs-toggle="tab">Return Policy</a></li>
					<!--<li><a href="#tab-reve" class="tab-link" data-bs-toggle="tab">reviews (2)</a></li>-->
				</ul>
			</div>
		</div>
		<!--<div class="tab-pane active" id="tab-short-desc">
			<div class="row">
				<div class="col-lg-12">
					<div class="product-details-frame">
						<div class="tab-descrip">
							<?= $p_short_description; ?>
						</div>
					</div>
				</div>
			</div>
		</div>-->
		<div class="tab-pane active" id="tab-desc">
			<div class="row">
				<div class="col-lg-12">
					<div class="product-details-frame">
					    <?= $p_description; ?>
					</div>
				</div>
			</div>
		</div>
		<div class="tab-pane" id="tab-spec">
			<div class="row">
				<div class="col-lg-12">
					<div class="product-details-frame">
					    <?= $p_feature; ?>
					</div>
				</div>
			</div>
		</div>
		<div class="tab-pane" id="tab-cond">
			<div class="row">
				<div class="col-lg-12">
					<div class="product-details-frame">
					    <?= $p_condition; ?>
					</div>
				</div>
			</div>
		</div>
		<div class="tab-pane" id="tab-retu">
			<div class="row">
				<div class="col-lg-12">
					<div class="product-details-frame">
					    <?= $p_return_policy; ?>
					</div>
				</div>
			</div>
		</div>
		<div class="tab-pane" id="tab-reve">
			<div class="row">
				<div class="col-lg-12">
					<div class="product-details-frame">
						<ul class="review-list">
							<li class="review-item">
								<div class="review-media"><a class="review-avatar" href="#"><img src="<?=base_url('site_assets/');?>images/avatar/01.jpg" alt="review"></a>
									<h5 class="review-meta"><a href="#">miron mahmud</a><span>June 02,
											2020</span></h5>
								</div>
								<ul class="review-rating">
									<li class="icofont-ui-rating"></li>
									<li class="icofont-ui-rating"></li>
									<li class="icofont-ui-rating"></li>
									<li class="icofont-ui-rating"></li>
									<li class="icofont-ui-rate-blank"></li>
								</ul>
								<p class="review-desc">Lorem ipsum dolor sit amet consectetur adipisicing
									elit. Ducimus hic amet qui velit, molestiae suscipit perferendis,
									autem doloremque blanditiis dolores nulla excepturi ea nobis!</p>
								<form class="review-reply"><input type="text" placeholder="reply your thoughts"><button><i class="icofont-reply"></i>reply</button></form>
								<ul class="review-reply-list">
									<li class="review-reply-item">
										<div class="review-media"><a class="review-avatar" href="#"><img src="<?=base_url('site_assets/');?>images/avatar/02.jpg" alt="review"></a>
											<h5 class="review-meta"><a href="#">labonno
													khan</a><span><b>author -</b>June 02, 2020</span>
											</h5>
										</div>
										<p class="review-desc">Lorem ipsum dolor sit amet consectetur
											adipisicing elit. Ducimus hic amet qui velit, molestiae
											suscipit perferendis, autem doloremque blanditiis dolores
											nulla excepturi ea nobis!</p>
										<form class="review-reply"><input type="text" placeholder="reply your thoughts"><button><i class="icofont-reply"></i>reply</button></form>
									</li>
									<li class="review-reply-item">
										<div class="review-media"><a class="review-avatar" href="#"><img src="<?=base_url('site_assets/');?>images/avatar/03.jpg" alt="review"></a>
											<h5 class="review-meta"><a href="#">tahmina
													bonny</a><span>June 02, 2020</span></h5>
										</div>
										<p class="review-desc">Lorem ipsum dolor sit amet consectetur
											adipisicing elit. Ducimus hic amet qui velit, molestiae
											suscipit perferendis, autem doloremque blanditiis dolores
											nulla excepturi ea nobis!</p>
										<form class="review-reply"><input type="text" placeholder="reply your thoughts"><button><i class="icofont-reply"></i>reply</button></form>
									</li>
								</ul>
							</li>
							<li class="review-item">
								<div class="review-media"><a class="review-avatar" href="#"><img src="<?=base_url('site_assets/');?>images/avatar/04.jpg" alt="review"></a>
									<h5 class="review-meta"><a href="#">shipu shikdar</a><span>June 02,
											2020</span></h5>
								</div>
								<ul class="review-rating">
									<li class="icofont-ui-rating"></li>
									<li class="icofont-ui-rating"></li>
									<li class="icofont-ui-rating"></li>
									<li class="icofont-ui-rating"></li>
									<li class="icofont-ui-rate-blank"></li>
								</ul>
								<p class="review-desc">Lorem ipsum dolor sit amet consectetur adipisicing
									elit. Ducimus hic amet qui velit, molestiae suscipit perferendis,
									autem doloremque blanditiis dolores nulla excepturi ea nobis!</p>
								<form class="review-reply"><input type="text" placeholder="reply your thoughts"><button><i class="icofont-reply"></i>reply</button></form>
							</li>
						</ul>
					</div>
					<div class="product-details-frame">
						<h3 class="frame-title">add your review</h3>
						<form class="review-form">
							<div class="row">
								<div class="col-lg-12">
									<div class="star-rating"><input type="radio" name="rating" id="star-1"><label for="star-1"></label><input type="radio" name="rating" id="star-2"><label for="star-2"></label><input type="radio" name="rating" id="star-3"><label for="star-3"></label><input type="radio" name="rating" id="star-4"><label for="star-4"></label><input type="radio" name="rating" id="star-5"><label for="star-5"></label></div>
								</div>
								<div class="col-lg-12">
									<div class="form-group"><textarea class="form-control" placeholder="Describe"></textarea></div>
								</div>
								<div class="col-lg-6">
									<div class="form-group"><input type="text" class="form-control" placeholder="Name"></div>
								</div>
								<div class="col-lg-6">
									<div class="form-group"><input type="email" class="form-control" placeholder="Email"></div>
								</div>
								<div class="col-lg-12"><button class="btn btn-inline"><i class="icofont-water-drop"></i><span>drop your
											review</span></button></div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>
<section class="section newitem-part">
	<div class="container">
		<div class="row">
			<div class="col">
				<div class="section-heading">
					<h2>Related this 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=?  AND ecat_id=?   AND p_id !=? ORDER BY p_id DESC", array(1,$ecat_id,$product_id));
                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"><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) {
                                            
                                            $p_pv = $row2['p_pv'];
                                            $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="p_pv_<?=$row['p_id']; ?>" value="<?=$p_pv; ?>">
                                            <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'];?> <?php if(empty($color_name)){}else{?>(<?=$color_name;?>)<?php } ?>" 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; ?>,<?=$p_pv;?>" 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'];?><?=$p_current_price; ?></b> <b class="pv">(<b id="p_pv2_<?=$row['p_id']; ?>"><?=$p_pv;?></b> PV)</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 class="col-md-12 text-center"> <img src="<?=base_url('uploads/no_product_found.png');?>" class="img-fluid" /> </div>
						<?php
                }
                ?>
				
		</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>View All</span></a></div>
			</div>
		</div>
	</div>
</section>

<?php
include('footer.php');
?>