<?php 
$this->load->view('site/templates/header');
$this->load->model('user_model');
?>
<section>
    <div class="main">
    	<ul class="breadcrumb_top">
        	<li><a href="#"><?php if($this->lang->line('header_home') != '') { echo stripslashes($this->lang->line('header_home')); } else echo "Home"; ?></a></li>
        	<li>></li>
        	<li><?php if($this->lang->line('seller_shopsearch') != '') { echo stripslashes($this->lang->line('seller_shopsearch')); } else echo "Shop Search Results"; ?></li>
        </ul>
        <div class="treasury-headline">
        	<h3><?php if($this->lang->line('seller_browsing') != '') { echo stripslashes($this->lang->line('seller_browsing')); } else echo "Browsing all Shops"; ?></h3>
        </div>
        <div class="shop_search">
            <div class="listings-title">
            	<form action="find/shop" method="get">
                    <input class="text_box" type="text" placeholder="<?php if($this->lang->line('seller_searchshops') != '') { echo stripslashes($this->lang->line('seller_searchshops')); } else echo "Search for Shops"; ?>" name="search_query" value="<?php echo $search_query; ?>" id="search_key" />
                    <input type="hidden" name="order" value="<?php if(isset($_GET['order'])){ echo $_GET['order'];}else{ echo 0; } ?>" id="order" />
            		<input class="subscribe_btn" type="submit" value="<?php if($this->lang->line('seller_srch') != '') { echo stripslashes($this->lang->line('seller_srch')); } else echo "Search"; ?>">
                </form>
                <div class="sorting-options">
                	<label> <?php if($this->lang->line('seller_sortby') != '') { echo stripslashes($this->lang->line('seller_sortby')); } else echo "Sort by"; ?>: </label>
                    <ul id="menu">
                        <li>
                            <a><?php if(isset($_GET['order'])){ if($_GET['order']==0) {echo 'Relevancy';}else if($_GET['order']==1){ echo 'Hotness'; }else { echo 'Alphabetical';}} else{ echo 'Relevancy';}?><img src="images/down_arrow.png"></a>
                            <ul class="sub-menu">
                                <span class="cursor"></span>
                                <li>
                                	<a id="Relevancy" <?php if(isset($_GET['order'])){ if($_GET['order']==0){echo 'class="active"';} }else{echo 'class="active"';}?>><?php if($this->lang->line('seller_relevancy') != '') { echo stripslashes($this->lang->line('seller_relevancy')); } else echo "Relevancy"; ?></a>
                                </li>
                                <li>
                                	<a id="Hotness" <?php if(isset($_GET['order'])){ if($_GET['order']==1){echo 'class="active"';} }?>><?php if($this->lang->line('seller_hotness') != '') { echo stripslashes($this->lang->line('seller_hotness')); } else echo "Hotness"; ?></a>
                                </li>
                                <li>
                                	<a id="Alphabetical" <?php if(isset($_GET['order'])){ if($_GET['order']==2){echo 'class="active"';} }?>><?php if($this->lang->line('seller_alphabetical') != '') { echo stripslashes($this->lang->line('seller_alphabetical')); } else echo "Alphabetical"; ?></a>
                                </li>
                            </ul>
                        </li>
                    </ul>                    
                </div>
            </div>
            <?php if($start==0){ ?>
            <?php if(!empty($shopList)){ ?>
            <?php 
				for($i=0;$i<count($shopList);$i++){
					foreach($shopList as $shopList){
			?>
            <?php if($shopList->thumbnail!=''){ $profile_pic='users/thumb/'.$shopList->thumbnail; } else { $profile_pic='default_avat.png';}?>
            <ul style="margin: 10px 0 0;display:block !important" class="seller-links">
              <li style="border: 1px solid rgb(239, 239, 239); float: left; width: 347px; margin:1px 3px 0px 0px; padding: 18px 33px 18px 10px;">
                    <a class="fav-item-name" href="shop-section/<?php echo $shopList->shop_seourl; ?>"><?php echo $shopList->shop_name; ?> </a>
                    <div class="fav-owner">
                        <a href="view-profile/<?php echo $shopList->user_name; ?>">
                        	<img class="thumbnail" width="35" height="35" src="images/<?php echo $profile_pic; ?>">
                        </a>
                    </div>
                    <div class="fav_min_text">
                    	<a href="view-profile/<?php echo $shopList->user_name; ?>"><?php echo $shopList->full_name; ?></a>
                        <br /><span><?php if($this->lang->line('user_shop_owner') != '') { echo stripslashes($this->lang->line('user_shop_owner')); } else echo "Shop Owner"; ?></span>
                    </div>
                </li>
                <?php if(count($ShopListProdDetails[$shopList->sellerid])>5){$cond=6;}else{$cond=count($ShopListProdDetails[$shopList->sellerid]);} ?>
                 <?php if($cond<6){ for($l=6-$cond;$l>0;$l--) { ?>
                        <li>
                        	
                             <div class="seller-outer" style="background-color: rgb(255, 255, 255); padding: 2px; height: 74px; width: 74px;">
<div style="background: none repeat scroll 0% 0% rgb(245, 245, 241); height: 74px;"></div>
</div>
                        </li>
                        <?php } } ?>
                <?php for($l=0;$l<$cond;$l++) {
					$img=explode(',',$ShopListProdDetails[$shopList->sellerid][$l]['image']); 
				?>
                <li>
                    <a href="products/<?php echo $ShopListProdDetails[$shopList->sellerid][$l]['seourl']; ?>">
                    <div class="seller-outer">
                        <div class="seller-inner">
                        	<img src="images/product/list-image/<?php echo $img[0]; ?>" width="75" height="75">
                        </div>
                    </div>
                    </a>
                </li>
                <?php }?>
            	<li>
                    <a href="shop-section/<?php echo $shopList->shop_seourl; ?>">
                    <div class="seller-outer count-box">
                        <div class="seller-inner">
                            <span class="count-number"><?php  echo $ShopListDetails[$shopList->sellerid]->num_rows; ?></span>
                            <?php if($this->lang->line('user_items') != '') { echo stripslashes($this->lang->line('user_items')); } else echo "items"; ?>
                        </div>
                    </div>
                    </a>
                </li>
            </ul>
            <?php } } }else{ ?>
            <div style="margin:40px 0 0 0" class="outer_tab1">
                <div class="outer_tab_2">
                    <div class="tab_content">
                    	<h1><?php if($this->lang->line('seller_noresult') != '') { echo stripslashes($this->lang->line('seller_noresult')); } else echo "No Result Found"; ?>.</h1>
                    </div>
                </div>
            </div>
            <?php } } ?>
        </div>
    </div>
<div class="clear"></div>
</section>
<script>
$(document).ready(function(e) {
    $('#Relevancy').click(function(e) {
        path='find/shop?search_query='+$('#search_key').val()+'&order=0';
		window.location = BaseURL+path;
    });
	$('#Hotness').click(function(e) {
        path='find/shop?search_query='+$('#search_key').val()+'&order=1';
		window.location = BaseURL+path;
    });
	$('#Alphabetical').click(function(e) {
        path='find/shop?search_query='+$('#search_key').val()+'&order=2';
		window.location = BaseURL+path;
    });
});
</script>
<?php 
$this->load->view('site/templates/footer');
?>
