<?php
include "header.php";
include "includes/pagination_products.php";

$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"><?php if(!empty($pdserch)){ echo 'Shop - Search Results' ; } else { echo (!empty($drenm)) ? $drenm : 'Shop -  All Products';} ?></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">Shop</span></li>
				<?= (!empty($drenm)) ? ' <li class="nav-item"><span class="current-page">'.$drenm .'</span></li>': ''; ?>
            </ul>
        </nav>
    </div>
	</div>
	
	
	

    <div class="page-contain category-page no-sidebar">
        <div class="container">
            <div class="row">
                <div id="main-content" class="main-content col-lg-12 col-md-12 col-sm-12 col-xs-12">
					<?php
					if(!empty($gt_shopfeature) && empty($kpchk)){
						
					?>
					<h3 class="title text-start" style="font-weight:bold">SELECTED FOR YOU</h3>
                    <div class="block-item recently-products-cat md-margin-bottom-39">
                        <ul class="products-list biolife-carousel nav-center-02 nav-none-on-mobile" data-slick='{"autoplay": true, "rows":1,"arrows":true,"dots":false,"infinite":false,"speed":400,"slidesMargin":0,"slidesToShow":5, "responsive":[{"breakpoint":1200, "settings":{ "slidesToShow": 3}},{"breakpoint":992, "settings":{ "slidesToShow": 3, "slidesMargin":30}},{"breakpoint":768, "settings":{ "slidesToShow": 2, "slidesMargin":10}}]}' >
                            <?php
							foreach($gt_shopfeature as $pds){
								$ft_pdi = $pds['rec_id'];
								
								$gt_prds = gtOne("kmartstockprds","  ksp_id = '$ft_pdi' ",'ksp_id');
								if(!empty($gt_prds)){
								$chk_prdz = $db_con->prepare("SELECT * FROM kmartstockprds WHERE ksp_id = '$gt_prds' ");
								$chk_prdz->execute(); $pdz = $chk_prdz->fetch();	
								
								$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-02">
									<div class="product-thumb">
										<a href="product?kmt=<?= $pdz['purl']; ?>" class="link-to-product">
											<img src="<?= $prd_img; ?>" alt="<?= $pdz['pname'] ?>" class="product-thumnail">
										</a>
									</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"><?= $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>
								</div>
							</li>
							<?php
								}
							}
							?>
                        </ul>
                    </div>
					
					<hr>
					<?php
					}
					if(!empty($gt_shopcategory) && !empty($kpchk)){
					?>
					<h3 class="title text-start" style="font-weight:bold">CATEGORY MATCHED CHOICE</h3>
                    <div class="block-item recently-products-cat md-margin-bottom-39">
                        <ul class="products-list biolife-carousel nav-center-02 nav-none-on-mobile" data-slick='{"autoplay": true, "rows":1,"arrows":true,"dots":false,"infinite":false,"speed":400,"slidesMargin":0,"slidesToShow":5, "responsive":[{"breakpoint":1200, "settings":{ "slidesToShow": 3}},{"breakpoint":992, "settings":{ "slidesToShow": 3, "slidesMargin":30}},{"breakpoint":768, "settings":{ "slidesToShow": 2, "slidesMargin":10}}]}' >
                            <?php
							foreach($gt_shopcategory as $pds){
								$ft_pdi = $pds['rec_id'];
								
								$gt_prds = gtOne("kmartstockprds","  ksp_id = '$ft_pdi' ".$drecv,'ksp_id');
								if(!empty($gt_prds)){
									
								$chk_prdz = $db_con->prepare("SELECT * FROM kmartstockprds WHERE ksp_id = '$gt_prds' ");
								$chk_prdz->execute(); $pdz = $chk_prdz->fetch();	
								
								$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-02">
									<div class="product-thumb">
										<a href="product?kmt=<?= $pdz['purl']; ?>" class="link-to-product">
											<img src="<?= $prd_img; ?>" alt="<?= $pdz['pname'] ?>" class="product-thumnail">
										</a>
									</div>
									<div class="info pdzkpm" data-cart="<?= $pdz['pqrcode']; ?>">
										<b class="categories"><?= $gtctnm; ?></b>
										<h4 class="product-title mkells"><a href="product?kmt=<?= $pdz['purl']; ?>" class="pr-name"><?= $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>
								</div>
							</li>
							<?php
								}
								
							}
							?>
                        </ul>
                    </div>
					<hr>
					<?php
					}
					?>
                    <div class="product-category grid-style">

                        <?php /*<div id="top-functions-area" class="top-functions-area" >
                            <div class="flt-item to-left group-on-mobile">
                                <span class="flt-title">Refine</span>
                                <a href="#" class="icon-for-mobile">
                                    <span></span>
                                    <span></span>
                                    <span></span>
                                </a>
                                <div class="wrap-selectors">
                                    <form action="#" name="frm-refine" method="get">
                                        <span class="title-for-mobile">Refine Products By</span>
                                        <div data-title="Price:" class="selector-item">
                                            <select name="price" class="selector">
                                                <option value="all">Price</option>
                                                <option value="class-1st">Less than 5$</option>
                                                <option value="class-2nd">$5-10$</option>
                                                <option value="class-3rd">$10-20$</option>
                                                <option value="class-4th">$20-45$</option>
                                                <option value="class-5th">$45-100$</option>
                                                <option value="class-6th">$100-150$</option>
                                                <option value="class-7th">More than 150$</option>
                                            </select>
                                        </div>
                                        <div data-title="Brand:" class="selector-item">
                                            <select name="brad" class="selector">
                                                <option value="all">Top brands</option>
                                                <option value="br2">Brand first</option>
                                                <option value="br3">Brand second</option>
                                                <option value="br4">Brand third</option>
                                                <option value="br5">Brand fourth</option>
                                                <option value="br6">Brand fiveth</option>
                                            </select>
                                        </div>
                                        <div data-title="Avalability:" class="selector-item">
                                            <select name="ability" class="selector">
                                                <option value="all">Availability</option>
                                                <option value="vl2">Availability 1</option>
                                                <option value="vl3">Availability 2</option>
                                                <option value="vl4">Availability 3</option>
                                                <option value="vl5">Availability 4</option>
                                                <option value="vl6">Availability 5</option>
                                            </select>
                                        </div>
                                        <p class="btn-for-mobile"><button type="submit" class="btn-submit">Go</button></p>
                                    </form>
                                </div>
                            </div>
                            <div class="flt-item to-right">
                                <span class="flt-title">Sort</span>
                                <div class="wrap-selectors">
                                    <div class="selector-item orderby-selector">
                                        <select name="orderby" class="orderby" aria-label="Shop order">
                                            <option value="menu_order" selected="selected">Default sorting</option>
                                            <option value="popularity">popularity</option>
                                            <option value="rating">average rating</option>
                                            <option value="date">newness</option>
                                            <option value="price">price: low to high</option>
                                            <option value="price-desc">price: high to low</option>
                                        </select>
                                    </div>
                                    <div class="selector-item viewmode-selector">
                                        <a href="category-grid-left-sidebar.html" class="viewmode grid-mode active"><i class="biolife-icon icon-grid"></i></a>
                                        <a href="category-list-left-sidebar.html" class="viewmode detail-mode"><i class="biolife-icon icon-list"></i></a>
                                    </div>
                                </div>
                            </div>
                        </div>*/ ?>

						<?php
						
						if(!empty($nquery))
						{
						?>
                        <div class="row">
                            <ul class="products-list">
							<?php
							foreach($nquery 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 col-lg-3 col-md-3 col-sm-4 col-xs-6">
                                    <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'] ?>"  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>
						<?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>
							<?php
						}
						?>

                        <div class="biolife-panigations-block">
                            <ul class="panigation-contain">
								<?= $paginationCtrls; ?>
                            </ul>
                        </div>

                    </div>

                </div>

            </div>
        </div>
    </div>

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