<?php echo Wo_LoadPage('forum/headers/header'); ?>
<div role="tabpanel" class="tab-pane active" id="members">
	<div class="w-100">
		<div class="page-margin mt-0">
			<div class="wow_content popular_posts_hdr flex">
				<h2>&nbsp;<?php echo $wo['lang']['list_of_users']; ?></h2>

				<div class="btnss">
					<?php foreach (range('a', 'z') as $char): ?>
						<a class="<?php if ($wo['char'] == $char) echo 'bold font20'; ?>" href="<?php echo Wo_SeoLink("index.php?link1=forum-members-byname&char=".$char); ?>">
							<?php echo strtoupper($char); ?>
						</a>
					<?php endforeach; ?>
				</div>
			</div>
		</div>
	</div>
    <div class="wow_content">
        <table class="table threads-table">
            <thead>
                <tr>
                  <th><?php echo $wo['lang']['name']; ?></th>
                  <th><?php echo $wo['lang']['joined']; ?></th>
                  <th><?php echo $wo['lang']['last_visit']; ?> </th>
                  <th><?php echo $wo['lang']['post_count']; ?></th>
                  <th><?php echo $wo['lang']['referrals']; ?></th>
                </tr>
            </thead>
            <tbody id="mbrs">
    <?php if (count($wo['members']) > 0): ?>
            <?php foreach ($wo['members'] as $wo['member']): ?>
                <tr class="forum-mbr-list" id="<?php echo $wo['member']['id']; ?>">
                    <td>
                        <p>
                            <b>
								<a href="<?php echo $wo['member']['url'] ?>" data-ajax="?link1=timeline&u=<?php echo $wo['member']['username'] ?>"><img src="<?php echo $wo['member']['avatar'] ?>" width="24" height="24"/>&nbsp;&nbsp;<?php echo $wo['member']['name'] ?></a>
								<?php if ($wo['member']['admin'] == 1): ?>
									<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18"><title><?php echo $wo['lang']['site_admin']; ?></title><path fill="currentColor" d="M12 1L21 5V11C21 16.55 17.16 21.74 12 23C6.84 21.74 3 16.55 3 11V5L12 1M16 14H8V15.5C8 15.77 8.19 15.96 8.47 16L8.57 16H15.43C15.74 16 15.95 15.84 16 15.59L16 15.5V14M17 8L17 8L14.33 10.67L12 8.34L9.67 10.67L7 8L7 8L8 13H16L17 8Z" /></svg>
								<?php else: ?>
								<?php endif; ?>
                            </b>
                        </p>
                    </td>
                    <td>
                        <span><?php echo Wo_Time_Elapsed_String($wo['member']['joined']) ?></span>
                    </td>
                    <td>
                        <span><?php echo Wo_Time_Elapsed_String($wo['member']['lastseen']) ?></span>
                        
                    </td>


                    <td><?php echo($wo['member']['forum_posts']) ?></td>
           
                    <td>
                          <span><?php echo($wo['member']['referrer']) ?></span>
                    </td>
                </tr>

            <?php endforeach; ?>
    <?php else: ?>

        <?php echo '<tr> <td colspan="7" class="text-center" style="padding:40px 40px;" >' . $wo['lang']['no_members_found'] .'</td></tr>'; ?>
    <?php endif; ?>
            </tbody>
        </table>


</div>

<div>
    <div class="posts_load">
        <?php if (count($wo['members']) >= 1): ?>
        <div class="load-more">
            <button class="btn btn-default text-center pointer" id="forum-mbrs-load" >
            <?php echo $wo['lang']['load_more_users'] ?></button>
        </div>
        <?php endif ?>
    </div>  
</div>
<br>
<div class="clear"></div>

</div>
<?php echo Wo_LoadPage('forum/headers/footer'); ?>

<script>
    jQuery(document).ready(function($) {

      var delay = (function(){
        var timer = 0;
        return function(callback, ms){
          clearTimeout (timer);
          timer = setTimeout(callback, ms);
        };
      })();


      $("#search-members").keyup(function(event) {

          delay(function(){
          if ($("#search-members").val().trim()) {
              $.ajax({
                url: Wo_Ajax_Requests_File(),
                type: 'GET',
                data: { f:"search-forum-mbrs",
                        keyword:$("#search-members").val(),
                        orderby:$("#sort_mbr_by").val()
                      },
                dataType: "json",
                success: function(data){
                  $(".posts_load").remove()
                  if (data['status'] == 200) {
                    $("#mbrs").html(data['html'])
                  }
                  else if(data['status'] == 404){
                    
                    $("#mbrs").html('<tr> <td colspan="7" class="text-center" style="padding:40px 40px;" >' + data['html'] + '</td></tr>')
                  }
                }
              })}

          }, 1000 );
      });

      $("#forum-mbrs-load").click(function () {
              
              $.ajax({
                 url: Wo_Ajax_Requests_File(),
                 type: 'GET',
                 dataType: 'json',
                 data: {
                    f:"forum-mbrs-load",
                    offset:($(".forum-mbr-list").length > 0) ? $(".forum-mbr-list:last").attr('id') : 0

                 },
                 success:function(data){
                    
                    if (data['status'] == 200) {

                        $("#mbrs").append(data['html'])
                     }
                     else{

                       $(".posts_load").remove()
                       
                     }

                 }
              });
      });

      $("#adv-mbr-search input").keyup(function(event) {
        var empty = false;
        $("#adv-mbr-search input[type=text]").each(function(index, el) {
            if ($(this).val() == '') {
              empty = true;
            }
        });

        if (empty) {
          $("#adv-mbr-search input[type=submit]").attr('disabled','disabled')
        }
        if(!empty){
          $("#adv-mbr-search input[type=submit]").removeAttr('disabled')
        }
         
      });



 });
</script>
