<?php include "header.php"; 

$cjk_rck = gtOne("kmartstockprds"," purl = '$post_url' ","ksp_id");
$gt_relateds = gtAll("kmartstockprds"," ksp_id <> 0 ","RAND() LIMIT 10"); //FETCH RELATED RANDOM ITEM
$pdz = '';
if(!empty($cjk_rck)){
$sng_prd = $db_con->prepare("SELECT * FROM kmartstockprds WHERE ksp_id = '$cjk_rck' AND delete_status = 0");
$sng_prd->execute(); $pdz = $sng_prd->fetch(); $rowcount = $sng_prd->rowCount();


$gt_themn = $pdz['mn_id'];

$gt_ct_bn = getOne("ktmmenu_name"," mn_id = '$gt_themn' ","mbanner");
$prd_bnnr = (!empty($gt_ct_bn) && file_exists('prdimgs/'.$gt_ct_bn)) ? "prdimgs/".$gt_ct_bn : 'img/bn3.jpg';
}
?>

    <div class="hero-section hero-background" style="background-image:url(<?= $prd_bnnr; ?>); height:230px;">
        <div class="container"><h1 class="pg-title text-left">PRODUCT DETAILS</h1></div>
    </div>

	<div class="bcrumb">
    <div class="container">
        <nav class="biolife-nav nav-86px">
            <ul>
                <li class="nav-item"><a href="index" class="permal-link">Home</a></li>
                <li class="nav-item"><span class="current-page">Product</span></li>
            </ul>
        </nav>
    </div>
	</div>

    <div class="page-contain single-product">
        <div class="container">

            <div id="main-content" class="main-content">
                <?php
				if(!empty($pdz)){
					
					$gtctnm = gtOne("ktmmenu_name"," mn_id = $pdz[mn_id] ","mname");	//ITEM CATEGORY
					$gtcurm = gtOne("ktmmenu_name"," mn_id = $pdz[mn_id] ","murl");	
					
					$gt_relateds = gtAll("kmartstockprds"," ksp_id <> 0 AND ksp_id <> $pdz[ksp_id] AND mn_id = $pdz[mn_id] ","RAND() LIMIT 10"); //FETCH RELATED RANDOM CATEGORY ITEM
					
					$gt_imgs = gtAll("kprdw_imgs"," prd_rec = '$pdz[pqrcode]' ","kmg_id ASC"); //ITEM IMAGES
					
					
					$shw_pec = calcprcs($pdz['psell'],$pdz['pdiscount'],'spc');
					$shw_ds = calcprcs($pdz['psell'],$pdz['pdiscount'],'ssl');
					$shw_dsc = calcprcs($pdz['psell'],$pdz['pdiscount'],'sds');
					
					$chkct = getOne("my_cart"," pqrcode = '$pdz[pqrcode]' AND session_rec = '$set_sess' ","qty");
					
					$addftrs = gtAll("kprdadditional"," ksp_id = '$pdz[ksp_id]' ","ka_id ASC"); //ADDITIONAL ITEM INFOMATION
					
					$ltrand = rand();
				?>
                <div class="sumary-product single-layout">
                    <div class="media">
                        <ul class="biolife-carousel slider-for" data-slick='{"arrows":false,"dots":false,"slidesMargin":30,"slidesToShow":1,"slidesToScroll":1,"fade":true,"asNavFor":".slider-nav"}'>
							<?php
							if(!empty($gt_imgs)){
								foreach($gt_imgs as $sdc){
									$pmg = $sdc['pjm_pic'];
									echo (file_exists('prdimgs/'.$pmg)) ? '<li><img src="prdimgs/'.$pmg .'" alt="K-Mart Product Image" width="500" height="500"></li>' : '';
								}
							}
							?>
                        </ul>
                        <ul class="biolife-carousel slider-nav" data-slick='{"arrows":false,"dots":false,"centerMode":false,"focusOnSelect":true,"slidesMargin":10,"slidesToShow":4,"slidesToScroll":1,"asNavFor":".slider-for"}'>
                           <?php
							if(!empty($gt_imgs)){
								foreach($gt_imgs as $sdc){
									$pmg = $sdc['pjm_pic'];
									echo (file_exists('prdimgs/'.$pmg)) ? '<li><img src="prdimgs/'.$pmg .'" alt="K-Mart Product Image" width="88" height="88"></li>' : '';
								}
							}
							?>
                        </ul>
                    </div>
                    <div class="product-attribute">
                        <h3 class="title"><?= $pdz['pname'] ?></h3>
                        <div class="rating">
                            <p class="star-rating"><span class="width-80percent"></span></p>
                            <span class="review-count">(15 Reviews)</span>
                            <span class="qa-text"> &nbsp; </span>
                            <a href="shop?kmm=<?= $gtcurm; ?>"  class="category"><b class="rd_cl"><?= $gtctnm; ?></b></a>
                        </div>
                       <span class="sku">Sku: #<?= $pdz['kmsku']; ?></span>  <span class="sku" style="margin-left: 5rem !important;">FDA Approved</span> 
                        <p class="excerpt"><?= (!empty($pdz['pbreif'])) ? nl2br($pdz['pbreif']) : ''; ?></p>
                        <div class="price">
                            <ins><span class="price-amount"><span class="currencySymbol">GH₵</span><?= $shw_ds; ?></span></ins>
							<?= $shw_dsc; ?>
                        </div>
                        
                    </div>
                    <div class="action-form pdzkpm" data-cart="<?= $pdz['pqrcode']; ?>">
                        <div class="quantity-box">
                            <span class="title">Quantity:</span>
                            <div class="qty-input">
                                <input type="text" name="mbcrtqty" id="mbcrtqty" value="<?= (!empty($chkct)) ? $chkct : 1; ?>" data-maxvalue="20" data-subcost="<?= $shw_ds; ?>" data-min-value="1" data-step="1" data-crtque=<?= $ltrand; ?>>
                                <a href="javascript:void(0);" class="qty-btn btn-up"><i class="fa fa-caret-up" aria-hidden="true"></i></a>
                                <a href="javascript:void(0);" class="qty-btn btn-down"><i class="fa fa-caret-down" aria-hidden="true"></i></a>
                            </div>
                        </div>
                        <div class="total-price-contain" id="lpc_<?= $ltrand; ?>">
                            <span class="title">Total Price:</span>
                            <p class="price subttprc"><?= (!empty($chkct)) ? '<span class="price-amount"><span class="currencySymbol">GH₵ </span><b class="mprc">'.($shw_ds*$chkct).'</b></span>' : '<span class="price-amount"><span class="currencySymbol">GH₵</span><b class="mprc">'.$shw_ds.'</b></span>'; ?></p>
                        </div>
                        <div class="buttons">
                            <a href="javascript:void(0);" class="btn add-to-cart-btn crtadz">add to cart</a>
                        </div>
                        
                        <div class="social-media">
							<span class="title">Share To:</span>
                            <ul class="social-list">
                                <li><a href="#" class="social-link"><i class="fa fa-twitter" aria-hidden="true"></i></a></li>
                                <li><a href="#" class="social-link"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
                                <li><a href="#" class="social-link"><i class="fa fa-instagram" aria-hidden="true"></i></a></li>
                            </ul>
                        </div>
                        
                    </div>
                </div>

                <div class="product-tabs single-layout biolife-tab-contain">
                    <div class="tab-head">
                        <ul class="tabs">
                            <li class="tab-element active"><a href="#tab_description" class="tab-link">Products Descriptions</a></li>
                            <li class="tab-element" ><a href="#tab_additional" class="tab-link">Addtional information</a></li>
                            <li class="tab-element" ><a href="#tab_review" class="tab-link">Customer Reviews <sup>(15)</sup></a></li>
                        </ul>
                    </div>
                    <div class="tab-content">
                        <div id="tab_description" class="tab-contain desc-tab active">
                            <div class="desc">
								<?= $pdz['pdesc']; ?>
							</div>
                        </div>
                        <div id="tab_additional" class="tab-contain addtional-info-tab">
                            <table class="tbl_attributes">
                                <tbody>
								<?php
								if(!empty($addftrs)){
									foreach($addftrs as $vf){
								?>
                                <tr>
                                    <th><?= $vf['ka_head']; ?></th>
                                    <td><p><?= $vf['ka_info']; ?></p></td>
                                </tr>
								<?php
									}
								}else{
									echo '<tr><td colspan="2" class="text-center">No Additional Data</td></tr>';
								}
								?>
                                </tbody>
                            </table>
                        </div>
                        
                        <div id="tab_review" class="tab-contain review-tab">
                            <div class="container">
                                <div class="row">
                                    <div class="col-lg-5 col-md-5 col-sm-6 col-xs-12">
                                        <div class="rating-info">
                                            <p class="index"><strong class="rating">4.4</strong>out of 5</p>
                                            <div class="rating"><p class="star-rating"><span class="width-80percent"></span></p></div>
                                            <p class="see-all">15 Total Reviews</p>
                                            <ul class="options">
                                                <li>
                                                    <div class="detail-for">
                                                        <span class="option-name">5stars</span>
                                                        <span class="progres">
                                                            <span class="line-100percent"><span class="percent width-90percent"></span></span>
                                                        </span>
                                                        <span class="number">90</span>
                                                    </div>
                                                </li>
                                                <li>
                                                    <div class="detail-for">
                                                        <span class="option-name">4stars</span>
                                                        <span class="progres">
                                                            <span class="line-100percent"><span class="percent width-30percent"></span></span>
                                                        </span>
                                                        <span class="number">30</span>
                                                    </div>
                                                </li>
                                                <li>
                                                    <div class="detail-for">
                                                        <span class="option-name">3stars</span>
                                                        <span class="progres">
                                                            <span class="line-100percent"><span class="percent width-40percent"></span></span>
                                                        </span>
                                                        <span class="number">40</span>
                                                    </div>
                                                </li>
                                                <li>
                                                    <div class="detail-for">
                                                        <span class="option-name">2stars</span>
                                                        <span class="progres">
                                                            <span class="line-100percent"><span class="percent width-20percent"></span></span>
                                                        </span>
                                                        <span class="number">20</span>
                                                    </div>
                                                </li>
                                                <li>
                                                    <div class="detail-for">
                                                        <span class="option-name">1star</span>
                                                        <span class="progres">
                                                            <span class="line-100percent"><span class="percent width-10percent"></span></span>
                                                        </span>
                                                        <span class="number">10</span>
                                                    </div>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                    <div class="col-lg-7 col-md-7 col-sm-6 col-xs-12">
                                        <div class="review-form-wrapper">
                                            <span class="title">Submit your review</span>
                                            <form action="#" name="frm-review" method="post">
                                                <div class="comment-form-rating">
                                                    <label>1. Your rating of this products:</label>
                                                    <p class="stars">
                                                        <span>
                                                            <a class="btn-rating" data-value="star-1" href="#"><i class="fa fa-star-o" aria-hidden="true"></i></a>
                                                            <a class="btn-rating" data-value="star-2" href="#"><i class="fa fa-star-o" aria-hidden="true"></i></a>
                                                            <a class="btn-rating" data-value="star-3" href="#"><i class="fa fa-star-o" aria-hidden="true"></i></a>
                                                            <a class="btn-rating" data-value="star-4" href="#"><i class="fa fa-star-o" aria-hidden="true"></i></a>
                                                            <a class="btn-rating" data-value="star-5" href="#"><i class="fa fa-star-o" aria-hidden="true"></i></a>
                                                        </span>
                                                    </p>
                                                </div>
                                                <p class="form-row wide-half">
                                                    <input type="text" name="name" value="" placeholder="Your name">
                                                </p>
                                                <p class="form-row wide-half">
                                                    <input type="email" name="email" value="" placeholder="Email address">
                                                </p>
                                                <p class="form-row">
                                                    <textarea name="comment" id="txt-comment" cols="30" rows="10" placeholder="Write your review here..."></textarea>
                                                </p>
                                                <p class="form-row">
                                                    <button type="submit" name="submit">submit review</button>
                                                </p>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                                <div id="comments">
                                    <ol class="commentlist">
                                        <li class="review">
                                            <div class="comment-container">
                                                <div class="row">
                                                    <div class="comment-content col-lg-8 col-md-9 col-sm-8 col-xs-12 mx-auto float-none">
                                                        <p class="comment-in"><span class="post-name">By:<b>Full Name</b></span><span class="post-date">01/10/2024</span></p>
                                                        <div class="rating"><p class="star-rating"><span class="width-80percent"></span></p></div>
                                                        <p class="comment-text">Comment Content</p>
                                                    </div>
                                                </div>
                                            </div>
                                        </li>
                                    </ol>
                                    <?php /*<div class="biolife-panigations-block version-2">
                                        <ul class="panigation-contain">
                                            <li><span class="current-page">1</span></li>
                                            <li><a href="#" class="link-page">2</a></li>
                                            <li><a href="#" class="link-page">3</a></li>
                                            <li><span class="sep">....</span></li>
                                            <li><a href="#" class="link-page">20</a></li>
                                            <li><a href="#" class="link-page next"><i class="fa fa-angle-right" aria-hidden="true"></i></a></li>
                                        </ul>
                                        <div class="result-count">
                                            <p class="txt-count"><b>1-5</b> of <b>126</b> reviews</p>
                                            <a href="#" class="link-to">See all<i class="fa fa-caret-right" aria-hidden="true"></i></a>
                                        </div>
                                    </div>*/ ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
				
				<?php
				}
				else{
					?>
				<div class="row">
					<div class="col-md-8 float-none mx-auto">
					<div class="content-404 w-100">
                        <h1 class="heading"><i class="fa fa-chain-broken"></i></h1>
                        <h2 class="title">Oops! Invalid /  Broken Link</h2>
                        <p>Sorry, but the page you are looking for is not found. Please, make sure you have typed the current URL.</p>
                        <a class="button" href="shop">All Products</a>
                    </div>
                    </div>
                </div>
				<hr>
					<?php
				}
				?>
                <div class="product-related-box single-layout mb-5">
                    <div class="biolife-title-box lg-margin-bottom-26px-im">
                        <span class="subtitle"></span>
                        <h3 class="main-title"><?= (!empty($pdz)) ? "Related Products" : "Browse Other Products"; ?></h3>
                    </div>
                    <ul class="products-list biolife-carousel nav-center-02 nav-none-on-mobile" data-slick='{"rows":1,"autoplay":true,"arrows":true,"dots":false,"infinite":true,"speed":400,"slidesMargin":0,"slidesToShow":5, "responsive":[{"breakpoint":1200, "settings":{ "slidesToShow": 4}},{"breakpoint":992, "settings":{ "slidesToShow": 3, "slidesMargin":20 }},{"breakpoint":768, "settings":{ "slidesToShow": 2, "slidesMargin":10}}]}'>
					<?php
					if(!empty($gt_relateds)){
						foreach($gt_relateds as $pdz){
					
					$gtctnm = gtOne("ktmmenu_name"," mn_id = $pdz[mn_id] ","mname");
					
					$gt_imgs = gtOne("kprdw_imgs"," prd_rec = '$pdz[pqrcode]' ORDER BY kmg_id ASC","pjm_pic");
					$prd_img = (!empty($gt_imgs) && file_exists('prdimgs/'.$gt_imgs)) ? "prdimgs/".$gt_imgs : 'img/kmart-icon.png';
					
					
					$shw_pec = calcprcs($pdz['psell'],$pdz['pdiscount'],'spc');
					$shw_ds = calcprcs($pdz['psell'],$pdz['pdiscount'],'ssl');
					$shw_dsc = calcprcs($pdz['psell'],$pdz['pdiscount'],'sds');
					
					?>
						<li class="product-item">
							<div class="contain-product layout-default">
								<div class="product-thumb">
									<a href="product?kmt=<?= $pdz['purl']; ?>" class="link-to-product">
										<img src="<?= $prd_img; ?>" alt="<?= $pdz['pname'] ?>" width="270" height="270" class="product-thumnail">
									</a>
									<?= (!empty($shw_pec) && $shw_pec > 0) ? '<div class="labels"><span class="sale-label">-'.$shw_pec.'%</span></div>' : ''; ?>
								</div>
								<div class="info pdzkpm" data-cart="<?= $pdz['pqrcode']; ?>">
									<b class="categories"><?= $gtctnm; ?></b>
									<h4 class="product-title"><a href="product?kmt=<?= $pdz['purl']; ?>" class="pr-name mkells"><?= $pdz['pname']; ?></a></h4>
									<div class="price">
										<ins><span class="price-amount"><span class="currencySymbol">GH₵</span><?= $shw_ds; ?></span></ins>
										<?= $shw_dsc; ?>
									</div>
									<div class="slide-down-box">
										<p class="message">FDA Approved</p>
										<div class="buttons">
											<a href="javascript:void(0);" class="btn add-to-cart-btn crtadz"><i class="fa fa-cart-arrow-down"></i> add to cart</a>
										</div>
									</div>
								</div>
							</div>
						</li>
                       <?php
						}
					}
					   ?>
                    </ul>
                </div>
                
            </div>
        </div>
    </div>

<?php include "footer.php"; ?>