<!DOCTYPE html>
<html lang="en">
    
    <?php include("includes/head.php"); ?>
      
  <body>

    <div class="container-fluid">
        
        <?php include("includes/header.php"); ?>
        	
        <?php include("includes/breadcrumb.php"); ?>
        
	
        
        <div class="row">
		<div class="col-md-12">
                    <h2 class="special-title normal-title"><span><?=$pagetitle?></span></h2>
		</div>
	</div>
        
        
        <form action="<?=base_url()?>categories/<?=$current?>" id="sortresults" method="post">
        
        <div class="container">
	<div class="row main-inner-content">
            
            <?php include("includes/filter.php"); ?>
            
            
            <?            
            $sortoption = $this->session->userdata("sortoption");            
            ?>
            
            <div class="col-md-9">                
                
                <div class="sortbycont">
                <span>Sort By :</span> 
                
                    <select id="sortbyselect" name="sort">
                    <option value="recent" <? if($sortoption == "recent") echo " selected";?>>Recent Products</option>
                    <option value="pricelow" <? if($sortoption == "pricelow") echo " selected";?>>Price Low To High</option>
                    <option value="pricehigh" <? if($sortoption == "pricehigh") echo " selected";?>>Price High To Low</option>                    
                    <option value="offer" <? if($sortoption == "offer") echo " selected";?>>Special Offer</option>
                </select>    
                
                </div>
               
               
                <div class="row">
                    
                <?
                foreach($productsdetails as $row)
                {
                ?>    
                    
                    
                    
                    <div class="col-sm-4">
                    <div class="specialoffercont">          
                        <a href="<?=base_url()?>categories/<?=$current?>/<?=$row->slug?>/<?=$row->ProductID?>">
                        <div class="productoffer">        
                            <? if($row->DiscountAvailable){?>
                            <div class="percentage"><?=$row->Discount?>%</div>
                            <?}?>
                            <img src="<?=base_url()?>images/products/<?=$row->Picture?>" alt="" />     
                            <h3 class="procatlisttit"><?=$row->ProductName?></h3>
                            <div class="pricecont">
                                
                                <? if($row->DiscountAvailable){?>
                                <span class="newprice"><?=(($row->UnitPrice*$row->Discount)/100)?> AED</span>
                                <span class="oldprice"><?=$row->UnitPrice?> AED</span>
                                <?}
                                else
                                {
                                ?>
                                <span class="newprice"><?=$row->UnitPrice?> AED</span>
                                <?}?>
                            </div>
                            <? if($row->DiscountAvailable){?>
                            <div class="likecont">
                                <a href="#"><img src="images/red-heart.png" alt="" /></a>
                            </div>
                            <?}?>
                        </div>
                         </a>
                    </div>
		</div>
                    
                                                            
                    
                <?
                }
                ?>
                
               
                     
                    
                    <div class="paginationcont">
                        <? if(isset($paginationstring)) echo $paginationstring;?>                        
                    </div>   
                </div>
                
            </div>
            
            
	</div>	
        </div>
        </form>
        
        <?php include("includes/footer.php"); ?>
        
        	
        <script>
        $(document).ready(function(){
            $("#sortbyselect").change(function(){
              //var sortval = $(this).val();              
              //var pathname = window.location.pathname;                
              //var origin   = window.location.origin;               
              //var targeturl = "?sort=" + sortval;              
              //window.location.href = origin + pathname + targeturl;
              $("#sortresults").submit();                           
            });
            
            $(".filterchoices").click(function(){
                $("#sortresults").submit();                           
            });
          });    
        </script>
  </body>
</html>