<?php
echo '<!-- left list -->
    <div class="col-lg-3 col-md-3 hidden-sm hidden-xs" >
        <div class="left-list">';
include "includes/e-shop-left-list.php";
echo    '</div>
    </div>
    <!-- end left list -->';
      
echo '<!-- products page support -->
        <div  role="tabpanel" class="tab-pane active col-lg-8 col-md-9 col-sm-12 col-xs-12" id="products">
        <div class="page-bar col-lg-12 col-md-12 col-sm-12 col-xs-12" style="margin-top: 20px;">
            <!-- Breadcrumb -->
			<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="padding:0px 0px">
            <ol class="breadcrumb" style="display: inline;">
                <li class="text-primary-color dark-primary">
                    <a href="e-shop.php">
                        All Products
                    </a>
                </li>
                
                <li class="active">
                    '.@str_replace('_',' ',$_GET['ategory']).@str_replace('_',' ',$_GET['belong']).@$_SESSION["search"].'
                </li>
            </ol>
			</div>
            <!-- end Breadcrumb -->
            
            <!-- Number of Items Ori -->
			<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="padding:0px 0px">
            <div class="shop-setting-section" ng-controller="ProductsFetchController">
                <div class="shop-setting-wrapper">
					<form action="includes/sort.php" method="post">
                    <select name="sort" class="shop-setting" onchange="submit()" >
                        <option value="New-Arrival" ';if(@$_SESSION["sort"]==' ORDER BY created desc'){echo 'selected="selected"';} echo ' >
                            New Arrival
                        </option>
                        
                        <option value="price-HTL" ';if(@$_SESSION["sort"]==' ORDER BY price DESC'){echo 'selected="selected"';} echo ' >
                            Price(High to Low)
                        </option>
                        
                        <option value="price-LTH" ';if(@$_SESSION["sort"]==' ORDER BY price'){echo 'selected="selected"';} echo ' >
                            Price(Low to High)
                        </option>
                    </select>
                    </form>
					
                    <!-- Makes select bar match search bar -->
                    <button class="pull-right" style="height: 27x; opacity: 0;">
                        <i class="fa fa-search"></i>
                    </button>
                    <!-- end Makes select bar match search bar -->
                </div>
            </div>
			</div>
            <!-- end Number of Items Ori -->
        </div>
        </div>
        <!-- end porducts page support -->';
echo '<div  role="tabpanel" class="tab-pane active col-lg-8 col-md-9 col-sm-12 col-xs-12" id="products">  
';
if(isset($_SESSION["sort"])){$sort = $_SESSION["sort"];
}else{
$sort = " ORDER BY created desc";}
unset($_SESSION["sort"]);

if(isset($_GET['ategory'])){$ategory = " where ategory ='".str_replace('_',' ',$_GET['ategory'])."'";}
elseif(isset($_GET['belong'])){$ategory = " where belong ='".str_replace('_',' ',$_GET['belong'])."'";}
else{$ategory='';}

$query = "select * from products".$ategory.$sort;
if(@$_GET["search"]){$query = "SELECT * FROM  `products` WHERE  `name` LIKE  '%".$_SESSION["search"]."%'".$sort; unset($_SESSION["search"]);}
$result=mysqli_query($conn,$query);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)) {
echo '<!-- main products page -->
                <a href="includes/product_select.php?id='.$row["id"].'">
                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 product-li-img"> 
					<div class="hovereffect">
					<img class="img-responsive" src="../timthumb/timthumb.php?src='.$row["image"].'&h=500&w=500&zc=1" style="width:100%">
					<div class="overlay">
					<h2>
					'.$row["name"].'
					</h2>
					<p> 
					DETAIL
					</p> 
					</div>
					</div>
					
					<div class="product-li-text">
						<div style="height:38px;overflow:hidden">
						'.$row["name"].'</div>
						
						<div style="height:16px;color: #9D9D9D; text-decoration: line-through; margin:5px 0px;">';
						
						if(!$row["original price"]==null){echo '
						Original Price  HK$'.$row["original price"];}
						
						echo '</div>
						
						<div style="color: #0E9BAD;height:35px">';
						if(!$row["original price"]==null){echo 'Promotional';echo '&nbsp;Price HK$'.$row["price"];}
						else{echo '&nbsp;Price HK$'.$row["price"];}
						echo '</div>
					</div>
                </div>
                </a>';
}}		
echo '</div> 
    <!-- end main products page -->';
?>