<div>
	<div class="page-hd" style="background-image: url(<?php print $site_url; ?>images/ranking.png)">
		<div class="bd-c">
			<h2 class="pre-social"><?php print $lang['ranking'].' - '.$lang['guilds']; ?></h6>
		</div>
	</div>
	<div class="content-body">
	<?php if(!$offline && $database->is_loggedin()) { ?>
<div class="btn-group d-flex justify-content-center mt-2">
	<div class="mr-1">
		<a href="<?php print $site_url; ?>ranking/players">
			<div class="btn-custom btn-content">
				<div class="btn-text-center"><?php print $lang['players']; ?></div>
			</div>
		</a>
	</div>
	<div class="ml-1">
		<a href="#">
			<div class="btn-custom btn-content">
				<div class="btn-text-center"><?php print $lang['guilds']; ?></div>
			</div>
		</a>
	</div>
</div>
<div class="d-flex justify-content-center mt-2">
	<form action="" method="POST">
		<div class="btn-group">
			<input id="search-player-input" name="search" class="form-control" style="margin-top: unset !important; width: 290px;" type="text" placeholder="<?php print $lang['guild']; ?>" value="<?php if(isset($search)) print $search; ?>">
			<button class="btn-search" type="submit" style="background: none;border: none;"><i class="fa fa-search" aria-hidden="true"></i></button>
		</div>
	</form>
</div><br>
	
	<table class="table table-responsive-md ranking">
		<thead class="thead-inverse">
			<tr>
				<th>#</th>
				<th><?php print $lang['guild']; ?></th>
				<th><?php print $lang['leader']; ?></th>
				<th><?php print $lang['empire']; ?></th>
				<th class="level-table"><?php print $lang['level']; ?></th>
				<th class="exp-table"><?php print $lang['points']; ?></th>
			</tr>
		</thead>
		<tbody>
			<?php		
				$records_per_page=10;

				if(isset($search))
				{
					$query = "SELECT id, name, master, level, ladder_point FROM guild WHERE name NOT LIKE '[%]%' AND name LIKE :search ORDER BY level DESC, ladder_point DESC, exp DESC, name ASC";
					$newquery = $paginate->paging($query,$records_per_page);
					$paginate->dataview($newquery, $search);
				} else {
					$query = "SELECT id, name, master, level, ladder_point FROM guild WHERE name NOT LIKE '[%]%' ORDER BY level DESC, ladder_point DESC, exp DESC, name ASC";
					$newquery = $paginate->paging($query,$records_per_page);
					$paginate->dataview($newquery);
				}
				
			?>
		</tbody>
	</table>
	<?php
		if(isset($search))
			$paginate->paginglink($query,$records_per_page,$lang['first-page'],$lang['last-page'],$site_url,$search);
		else
			$paginate->paginglink($query,$records_per_page,$lang['first-page'],$lang['last-page'],$site_url);
		} else print '<div class="alert alert-danger" role="alert">'.$lang['login-for-ranking'].' <strong><a href="'.$site_url.'users/login/">'.$lang['login'].'</a>.</strong></div>';
	?>
</div>
</div>