</div><div class="main-content">
<?php
if(!defined('panel'))
	die('Nope.');
if(!isset($_SESSION['user']) && !isset(Config::$_url[1])) echo '<script> location.replace("'.Config::$_PAGE_URL.'login"); </script>';
if(isset(Config::$_url[1])) $user = (int)Config::$_url[1];
else $user = $_SESSION['user'];
$q = Config::$g_con->prepare('SELECT * FROM `factions` WHERE `ID` = ?');
$q->execute(array($user));
if(!$q->rowCount()) {
	echo '
<title>Error! Invalid faction ID</title>
<div class="breadcrumbs" id="breadcrumbs">
<ul class="breadcrumb">
<li>
<i class="icon-home home-icon"></i>
<a href="../">Home</a>
</li>
<li>
<a href="../factionslist">Factions</a>
</li>
<li class="active">Invalid faction ID.</li>
</ul>

		<div class="nav-search" id="nav-search">
			<form method="POST" action="../search">
				<span class="input-icon">
					<input type="text" placeholder="Search ..." name="sname" id="username" type="submit" class="nav-search-input" autocomplete="on"> 
					<i class="ace-icon fa fa-search nav-search-icon"></i>
				</span>
			</form>
		</div> <!-- /.nav-search -->
	</div>
<div class="page-content">
	<div class="alert alert-danger">Error! Invalid faction ID.</div>';
	echo '<script> location.replace("'.Config::$_PAGE_URL.'factionslist"); </script>';
	return;
}
?>
<title>Application list - <?php echo Config::$_SITE_NAME; ?></title>

	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<ul class="breadcrumb">
			<li>
				<i class="ace-icon fa fa-home home-icon"></i>
				<a href="<?php echo Config::$_PAGE_URL; ?>">Home</a>
			</li>
			<li>
				<a href="<?php echo Config::$_PAGE_URL; ?>factionslist">Factions</a>
			</li>
			<li class="active">Faction Applications</li>
		</ul>

		<div class="nav-search" id="nav-search">
			<form method="POST" action="<?php echo Config::$_PAGE_URL; ?>search">
				<span class="input-icon">
					<input type="text" placeholder="Search ..." name="sname" id="username" type="submit" class="nav-search-input" autocomplete="on"> 
					<i class="ace-icon fa fa-search nav-search-icon"></i>
				</span>
			</form>
		</div> <!-- /.nav-search -->
	</div>
<div class="page-content">

	<?php	
		$q = Config::$g_con->prepare('SELECT * FROM `factions` WHERE `ID` = ?'); 
		$q->execute(array(Config::$_url[1]));
		while($row = $q->fetch(PDO::FETCH_OBJ)) {	
	?>

<div class="page-header">
<h1>Aplica&#355;ii pentru <?php echo Config::$factions[$row->ID] ?></h1>
</div>

	<?php } 	
		$q = Config::$g_con->prepare('SELECT * FROM `aplications` WHERE `factionid` = ?'); 
		$q->execute(array(Config::$_url[1]));
		while($row = $q->fetch(PDO::FETCH_OBJ)) {	
	?>

<h4 class="blue">
<i class="icon-sun"></i>
	<?php 
		$q = Config::$g_con->prepare('SELECT * FROM `aplications` WHERE `factionid` = ? AND `status` = 0');
		$q->execute(array(Config::$_url[1]));
	?>
Aplica&#355;ii noi (<?php echo $q->rowCount(); ?>)
</h4>
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th class="center">ID</th>
<th>Player</th>
<th class="hidden-100">Date</th>
<th class="hidden-480">View</th>
</tr>
</thead>
<tbody>
<?php
	$q = Config::$g_con->prepare('SELECT * FROM `aplications` WHERE `factionid` = ? AND `status` = 0'); 
	$q->execute(array(Config::$_url[1])); 
	while($new = $q->fetch(PDO::FETCH_OBJ)) { ?>	  
<tr>
<td class="center"><?php echo $new->id; ?></td>
<?php
	$s = Config::$g_con->prepare('SELECT * FROM `users` WHERE `Name` = ?');
	$s->execute(array($new->name));
	while($data = $s->fetch(PDO::FETCH_OBJ)) 
	{
?>
<td>	
<a href="<?php echo Config::$_PAGE_URL; ?>profile/<?php echo Config::getData('users','id',$data->id) ?>"><?php echo $new->name; ?></a>
</td>
<?php } ?>
<td class="hidden-100">
<i class="icon-time blue"></i> <?php echo $new->time; ?>
</td>
<td class="hidden-480"><a href="<?php echo Config::$_PAGE_URL; ?>viewapplication/<?php echo $new->id; ?>" class="">Cite&#351;te aplica&#355;ie</a></td>
</tr>
<?php } ?>
</tbody>
</table>


<h4 class="purple">
<i class="icon-list-ul"></i>
	<?php 
		$q = Config::$g_con->prepare('SELECT * FROM `aplications` WHERE `factionid` = ? AND `status` = 1');
		$q->execute(array(Config::$_url[1]));
	?>
Aplica&#355;iile playerilor accepta&#355;i pentru teste (<?php echo $q->rowCount(); ?>)
</h4>
<div class="table-responsive">
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th class="center">ID</th>
<th>Player</th>
<th class="hidden-100">Date</th>
<th class="hidden-480">View</th>
</tr>
</thead>
<tbody>
<?php
	$q = Config::$g_con->prepare('SELECT * FROM `aplications` WHERE `factionid` = ? AND `status` = 1'); 
	$q->execute(array(Config::$_url[1])); 
	while($acceptedfortests = $q->fetch(PDO::FETCH_OBJ)) { ?>	  
<tr>
<td class="center"><?php echo $acceptedfortests->id; ?></td>
<?php
	$s = Config::$g_con->prepare('SELECT * FROM `users` WHERE `Name` = ?');
	$s->execute(array($acceptedfortests->name));
	while($data = $s->fetch(PDO::FETCH_OBJ)) 
	{
?>
<td>	
<a href="<?php echo Config::$_PAGE_URL; ?>profile/<?php echo Config::getData('users','id',$data->id) ?>"><?php echo $acceptedfortests->name; ?></a>
</td>
<?php } ?>
<td class="hidden-100">
<i class="icon-time purple"></i> <?php echo $acceptedfortests->time; ?>
</td>
<td class="hidden-480"><a href="<?php echo Config::$_PAGE_URL; ?>viewapplication/<?php echo $acceptedfortests->id; ?>" class="">Cite&#351;te aplica&#355;ie</a></td>
</tr>
<?php } ?>

</tbody>
</table>
</div>


<h4 class="green">
<i class="icon-thumbs-up"></i>
	<?php 
		$q = Config::$g_con->prepare('SELECT * FROM `aplications` WHERE `factionid` = ? AND `status` = 2');
		$q->execute(array(Config::$_url[1]));
	?>
Aplica&#355;iile playerilor accepta&#355;i (<?php echo $q->rowCount(); ?>)
</h4>
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th class="center">ID</th>
<th>Player</th>
<th class="hidden-100">Date</th>
<th class="hidden-480">View</th>
</tr>
</thead>
<tbody>
<?php
	$q = Config::$g_con->prepare('SELECT * FROM `aplications` WHERE `factionid` = ? AND `status` = 2'); 
	$q->execute(array(Config::$_url[1])); 
	while($accepted = $q->fetch(PDO::FETCH_OBJ)) { ?>	  
<tr>
<td class="center"><?php echo $accepted->id; ?></td>
<?php
	$s = Config::$g_con->prepare('SELECT * FROM `users` WHERE `Name` = ?');
	$s->execute(array($accepted->name));
	while($data = $s->fetch(PDO::FETCH_OBJ)) 
	{
?>
<td>	
<a href="<?php echo Config::$_PAGE_URL; ?>profile/<?php echo Config::getData('users','id',$data->id) ?>"><?php echo $accepted->name; ?></a>
</td>
<?php } ?>
<td class="hidden-100">
<i class="icon-time green"></i> <?php echo $accepted->time; ?>
</td>
<td class="hidden-480"><a href="<?php echo Config::$_PAGE_URL; ?>viewapplication/<?php echo $accepted->id; ?>" class="">Cite&#351;te aplica&#355;ie</a></td>
</tr>
<?php } ?>
</tbody>
</table>


<h4 class="red">
<i class="icon-thumbs-down"></i>
	<?php 
		$q = Config::$g_con->prepare('SELECT * FROM `aplications` WHERE `factionid` = ? AND `status` = 3');
		$q->execute(array(Config::$_url[1]));
	?>
Aplica&#355;iile playerilor respin&#351;i (<?php echo $q->rowCount(); ?>)
</h4>
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th class="center">ID</th>
<th>Player</th>
<th class="hidden-100">Date</th>
<th class="hidden-480">View</th>
</tr>
</thead>
<tbody>
<?php
	$q = Config::$g_con->prepare('SELECT * FROM `aplications` WHERE `factionid` = ? AND `status` = 3'); 
	$q->execute(array(Config::$_url[1])); 
	while($rejected = $q->fetch(PDO::FETCH_OBJ)) { ?>	  
<tr>
<td class="center"><?php echo $rejected->id; ?></td>
<?php
	$s = Config::$g_con->prepare('SELECT * FROM `users` WHERE `Name` = ?');
	$s->execute(array($rejected->name));
	while($data = $s->fetch(PDO::FETCH_OBJ)) 
	{
?>
<td>	
<a href="<?php echo Config::$_PAGE_URL; ?>profile/<?php echo Config::getData('users','id',$data->id) ?>"><?php echo $rejected->name; ?></a>
</td>
<?php } ?>
<td class="hidden-100">
<i class="icon-time red"></i> <?php echo $rejected->time; ?>
</td>
<td class="hidden-480"><a href="<?php echo Config::$_PAGE_URL; ?>viewapplication/<?php echo $rejected->id; ?>" class="">Cite&#351;te aplica&#355;ie</a></td>
</tr>
<?php } ?>
</tbody>
</table>

<?php } ?>
 
</div>
</div>
</div>
</div>
