<title>Factions List - <?php echo Config::$_SITE_NAME; ?></title>
</div>
	<div class="main-content">
			<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 class="active">Factions list</li>
				</ul><!-- /.breadcrumb -->

				<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">
<div class="page-header">
<h1>Lista factiuni</h1>
</div>
<table class="table table-striped table-bordered">
	<thead>
		<tr>
			<td class="center">ID</td>
			<td>Name</td>
			<td class="hidden-480">Members</td>
			<td class="hidden-480">Options</td>
			<td class="hidden-100">Applications status</td>
			<td class="center">Minimum level</td>
		</tr>
	</thead>
	<?php
		$q = Config::$g_con->prepare('SELECT * FROM `factions` WHERE `MinLevel` > 0 ORDER BY `ID` ASC'); 
		$q->execute();
		while($row = $q->fetch(PDO::FETCH_OBJ)) {	
	?>
	<tbody>
		<tr>
			<td style="vertical-align: middle;"><center><?php echo $row->ID ?></center></td>
			<td style="vertical-align: middle;"><?php echo $row->Name ?></td>
			<td style="vertical-align: middle;"><center>
			<?php 
				$fac = Config::$g_con->prepare("SELECT * FROM `users` WHERE `Member` = ?");
				$fac->execute(array($row->ID));
			echo $fac->rowCount(); ?> / <?php echo $row->MaxMembers ?>
			</center></td>							
			<td style="vertical-align: middle;">
			<center>
				<a href="<?php echo Config::$_PAGE_URL; ?>members/<?php echo $row->ID ?>">members</a> 
				/ <a href="<?php echo Config::$_PAGE_URL; ?>logs/<?php echo $row->ID ?>">logs</a> / 
				<a href="<?php echo Config::$_PAGE_URL; ?>applications/<?php echo $row->ID ?>">applications</a>
				/ <a href="<?php echo Config::$_PAGE_URL; ?>fcomplaints/<?php echo $row->ID ?>">complaints</a>
			</center>
			</td>
			<td><center>
				<?php if(!isset($_SESSION['user'])) { ?>
					<button class="width-15 btn btn-minier btn-danger" disabled>Nu e&#351;ti logat.</button>
				<?php } else {
					if($row->Application == "0") { ?>
					<button class="width-15 btn btn-minier btn-danger" disabled>Aplica&#355;iile sunt &#238;nchise.</button>
				<?php } else if(Config::getData('users','Level',$_SESSION['user']) < $row->MinLevel) { ?>
					<button class="width-15 btn btn-minier btn-warning" disabled>Nu ai levelul necesar pentru <br />a aplica &#238;n aceast&#259; fac&#355;iune.</button>
				<?php } else { ?>
					<a href="<?php echo Config::$_PAGE_URL; ?>apply/<?php echo $row->ID ?>"><button class="width-35 btn btn-minier btn-success">Aplic&#259;</button></a>
				<?php } } ?>
			</center></td>
			<td  style="vertical-align: middle;"><center><?php echo $row->MinLevel ?></center></td>
		</tr>
		<?php } ?>
</tbody>
</table>