<div class="container">
	<div class="page-hd" style="background-image: url(<?php print $site_url; ?>images/ranking.png)">
		<div class="bd-c">
			<div id='page_title'><?php print $lang['ranking']; ?> - VIPs</div>
		</div>
	</div>
	<div id="page_content">
		<div class="jumbotron jumbotron-fluid" style="padding: 1rem 2rem;margin-left: 24%;">
			<form action="" method="POST" id="search-form">
				<div class="row">
					<div class="col-lg-7">
						<input type="text" name="search" class="form-control" placeholder="<?php print $lang['name']; ?>" value="<?php if(isset($search)) print $search; ?>">
					</div>
					<div class="col-lg-5">
						<button style="margin-left: 10px;" type="submit" class="btn btn-primary"><i class="fa fa-search fa-1" aria-hidden="true"></i> <?php print $lang['search']; ?></button>
					</div>
				</div>
			</form>
		</div>
		<table class="table table-striped table-hover">
			<thead class="thead-inverse">
				<tr>
					<th>#</th>
					<th><?php print $lang['class']; ?></th>
					<th><?php print $lang['name']; ?></th>
					<th><?php print $lang['level']; ?></th>
					<th><?php print $lang['guild']; ?></th>
					<th><?php print $lang['empire']; ?></th>
				</tr>
			</thead>
			<tbody>
				<?php 
					$banned_ids = getBannedAccounts();
					$records_per_page=20;
					
					if(isset($search))
					{
						if($banned_ids)
							$query = "SELECT id, name, account_id, level, exp, hp, mp, job FROM player WHERE (name LIKE '[YT]%' OR name LIKE '[VIP]%' OR name LIKE '[MVP]%' OR name LIKE '[MR]%' OR name LIKE '[MISS]%' OR name LIKE '[PVP]%' OR name LIKE '[TEAMPVP]%') AND account_id NOT IN (".$banned_ids.") AND name LIKE :search ORDER BY level DESC, exp DESC, playtime DESC, name ASC";
						else
							$query = "SELECT id, name, account_id, level, exp, hp, mp, job FROM player WHERE (name LIKE '[YT]%' OR name LIKE '[VIP]%' OR name LIKE '[MVP]%' OR name LIKE '[MR]%' OR name LIKE '[MISS]%' OR name LIKE '[PVP]%' OR name LIKE '[TEAMPVP]%') AND name LIKE :search ORDER BY level DESC, exp DESC, playtime DESC, name ASC";
						$newquery = $paginate->paging($query,$records_per_page);
						$paginate->dataview($newquery, $search);
					} else {
						if($banned_ids)
							$query = "SELECT id, name, account_id, level, exp, hp, mp, job FROM player WHERE (name LIKE '[YT]%' OR name LIKE '[VIP]%' OR name LIKE '[MVP]%' OR name LIKE '[MR]%' OR name LIKE '[MISS]%' OR name LIKE '[PVP]%' OR name LIKE '[TEAMPVP]%') AND account_id NOT IN (".$banned_ids.") ORDER BY level DESC, exp DESC, playtime DESC, name ASC";
						else
							$query = "SELECT id, name, account_id, level, exp, hp, mp, job FROM player WHERE (name LIKE '[YT]%' OR name LIKE '[VIP]%' OR name LIKE '[MVP]%' OR name LIKE '[MR]%' OR name LIKE '[MISS]%' OR name LIKE '[PVP]%' OR name LIKE '[TEAMPVP]%') ORDER BY level DESC, exp DESC, playtime 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);
		?>
	</div>
</div>