<?php 
$not_found = '<h5 class="search-filter-center-text"><i class="fa fa-exclamation-circle"></i> ' . $wo["lang"]["no_result"] . '</h5>';
$type_to_find = '<h5 class="search-filter-center-text"> ' . $wo["lang"]["what_are_looking_for"] . '</h5>';
?>
<div class="page-margin">
   <div class="row">
      <div class="col-md-8">
         <div class="list-group">
            <div class="list-group-item"><i class="fa fa-bars"></i> <?php echo $wo['lang']['result'];?></div>
            <div class="setting-well">
               <ul class="nav nav-tabs">
                  <li class="active"><a data-toggle="tab" href="#users"><i class="fa fa-user"></i> <?php echo $wo['lang']['users'];?></a></li>
                  <li><a data-toggle="tab" href="#pages"><i class="fa fa-flag"></i> <?php echo $wo['lang']['pages'];?></a></li>
                  <li><a data-toggle="tab" href="#groups"><i class="fa fa-users"></i> <?php echo $wo['lang']['groups'];?></a></li>
                  <li><a data-toggle="tab" href="#games"><i class="fa fa-gamepad"></i> <?php echo $wo['lang']['games'];?></a></li>
               </ul>
               <div class="tab-content">
                  <div id="users" class="tab-pane fade in active">
                     <?php
                     if (!isset($_GET['query'])) {
                        echo $type_to_find;
                     }
                     if (isset($_GET['query'])) {
                        $search_query = Wo_GetSearchFilter($_GET);
                          if (count($search_query) != 0) {
                              foreach ($search_query as $wo['result']) {
                                  echo Wo_LoadPage('search/result');
                              }
                          } else {
                              echo $not_found;
                          }
                      }
                     ?> 
                  </div>
                  <div id="pages" class="tab-pane fade">
                     <?php
                     if (!isset($_GET['query'])) {
                        echo $type_to_find;
                     }
                     if (isset($_GET['query'])) {
                        $search_query = Wo_GetSearchAdv($_GET['query'], 'pages');
                          if (count($search_query) != 0) {
                              foreach ($search_query as $wo['result']) {
                                  echo Wo_LoadPage('search/result');
                              }
                          } else {
                              echo $not_found;
                          }
                      }
                     ?> 
                  </div>
                  <div id="groups" class="tab-pane fade">
                     <?php
                     if (!isset($_GET['query'])) {
                        echo $type_to_find;
                     }
                     if (isset($_GET['query'])) {
                        $search_query = Wo_GetSearchAdv($_GET['query'], 'groups');
                          if (count($search_query) != 0) {
                              foreach ($search_query as $wo['result']) {
                                  echo Wo_LoadPage('search/result');
                              }
                          } else {
                              echo $not_found;
                          }
                      }
                     ?> 
                  </div>
                  <div id="games" class="tab-pane fade">
                     <?php
                     if (!isset($_GET['query'])) {
                        echo $type_to_find;
                     }
                     if (isset($_GET['query'])) {
                        $search_query = Wo_GetSearchAdv($_GET['query'], 'games');
                          if (count($search_query) != 0) {
                              foreach ($search_query as $wo['game']) {
                                  echo Wo_LoadPage('games/game-list');
                              }
                          } else {
                              echo $not_found;
                          }
                      }
                     ?>
                  </div>
               </div>
            </div>
            <div class="clear"></div>
         </div>
      </div>
      <div class="col-md-4">
        <div class="list-group">
            <div class="list-group-item"><i class="fa fa-search"></i> <?php echo $wo['lang']['search_filter'];?></div>
            <div class="setting-well">
         <form action="#" method="get" class="search-filter-form">
            <h5><?php echo $wo['lang']['keyword'];?></h5>
            <div class="form-group">
               <input type="text" name="query" id="query" class="form-control" value="<?php echo (isset($_GET['query'])) ? $_GET['query']: '';?>" autocomplete="off">
            </div>
            <h5><?php echo $wo['lang']['country'];?></h5>
            <div class="form-group">
               <select name="country" id="country" class="form-control">
                  <option value="all" selected><?php echo $wo['lang']['all'];?></option>
                  <?php 
                  foreach ($wo['countries_name'] as $country_ids => $country) { 
                  $selected_c = (!empty($_GET['country']) && $_GET['country'] == $country_ids) ? ' selected': '';
                  ?>
                  <option value="<?php echo $country_ids;?>" <?php echo $selected_c?>><?php echo $country;?></option>
                  <?php } ?>
               </select>
            </div>
          <div class="form-group">
             <?php 
             $selected_status_all = 'checked';
             $selected_status_on = '';
             $selected_status_off = '';
             if (!empty($_GET['status'])) {
                if ($_GET['status'] == 'on') {
                  $selected_status_on = 'checked';
                  $selected_status_all = '';
                } else if ($_GET['status'] == 'off') {
                  $selected_status_off = 'checked';
                  $selected_status_all = '';
                } 
             }
             ?>
             <h5><?php echo $wo['lang']['status'];?></h5>
               <label class="radio-inline" for="status-0">
               <input type="radio" name="status" id="status-0" value="all" <?php echo $selected_status_all;?>>
                <?php echo $wo['lang']['all']; ?>
               </label> 
               <label class="radio-inline" for="status-1">
               <input type="radio" name="status" id="status-1" value="on" <?php echo $selected_status_on;?>>
               <?php echo $wo['lang']['online']; ?>
               </label>
               <label class="radio-inline" for="status-2">
               <input type="radio" name="status" id="status-2" value="off"<?php echo $selected_status_off;?>>
               <?php echo $wo['lang']['offline']; ?>
               </label>
            <div class="clear"></div>
         </div>

          <div class="form-group">
             <?php 
             $selected_status_all_sex = 'checked';
             $selected_status_male = '';
             $selected_status_female = '';
             if (!empty($_GET['gender'])) {
                if ($_GET['gender'] == 'male') {
                  $selected_status_male = 'checked';
                  $selected_status_all = '';
                } else if ($_GET['gender'] == 'female') {
                  $selected_status_female = 'checked';
                  $selected_status_all = '';
                } 
             }
             ?>
             <h5><?php echo $wo['lang']['gender'];?></h5>
               <label class="radio-inline" for="gender-0">
               <input type="radio" name="gender" id="gender-0" value="all" <?php echo $selected_status_all_sex;?>>
                <?php echo $wo['lang']['all']; ?>
               </label> 
               <label class="radio-inline" for="gender-1">
               <input type="radio" name="gender" id="gender-1" value="male" <?php echo $selected_status_male;?>>
               <?php echo $wo['lang']['male']; ?>
               </label>
               <label class="radio-inline" for="gender-2">
               <input type="radio" name="gender" id="gender-2" value="female" <?php echo $selected_status_female;?>>
               <?php echo $wo['lang']['female']; ?>
               </label>
            <div class="clear"></div>
         </div>
         <div class="form-group">
             <?php 
             $selected_status_image_all = 'checked';
             $selected_status_image_y = '';
             $selected_status_image_n = '';
             if (!empty($_GET['image'])) {
                if ($_GET['image'] == 'yes') {
                  $selected_status_image_y = 'checked';
                  $selected_status_image_all = '';
                } else if ($_GET['image'] == 'no') {
                  $selected_status_image_n = 'checked';
                  $selected_status_image_all = '';
                } 
             }
             ?>
             <h5><?php echo $wo['lang']['profile_picture'];?></h5>
               <label class="radio-inline" for="image-0">
               <input type="radio" name="image" id="image-0" value="all" <?php echo $selected_status_image_all;?>>
                <?php echo $wo['lang']['all']; ?>
               </label>
               <label class="radio-inline" for="image-1">
               <input type="radio" name="image" id="image-1" value="yes" <?php echo $selected_status_image_y;?>>
               <?php echo $wo['lang']['yes']; ?>
               </label>
               <label class="radio-inline" for="image-2">
               <input type="radio" name="image" id="image-2" value="no" <?php echo $selected_status_image_n;?>>
               <?php echo $wo['lang']['no']; ?>
               </label>
            <div class="clear"></div>
         </div>
            <hr>
            <div class="form-group last-btn">
               <button type="submit" class="btn btn-main"><i class="fa fa-search"></i>  <?php echo $wo['lang']['search'];?></button>
            </div>
         </form>
         </div>
         </div>
      </div>
   </div>
</div>