<title>Wars log - <?php echo Config::$_SITE_NAME; ?></title>
<?php
if(!defined('panel'))
	die('Nope.');
?>
</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>
						<a href="<?php echo Config::$_PAGE_URL; ?>factionslist">Factions</a>
					</li>					
					<li class="active">Wars</li>
				</ul><!-- /.breadcrumb -->

				<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="table-responsive">
	<table id="login-table" class="table table-striped table-hover table-bordered">
		<thead>
		<tr>			
			<td><b>War Date</b></td>
			<td><b>Attacker - Defender</b></td>
			<td><b>Score</b></td>
			<td><b>Result</b></td>			
			<td><b>Logs</b></td>			
		</tr>
		</thead>
		<tbody>
			<?php
				$q = Config::$g_con->prepare('SELECT * FROM `wars` ORDER BY `id` DESC '.Pagination::limit());
				$q->execute();
				while($row = $q->fetch(PDO::FETCH_OBJ)) {
					if($row->Result == 1) {
						$result = "".Config::$factions[$row->Attacker]." won";
					} else if($row->Result == 2) {
						$result = "".Config::$factions[$row->Defender]." won";
					} else if($row->Result == 3) {
						$result = "".Config::$factions[$row->Defender]." won  (".Config::$factions[$row->Attacker]." left the turf)";
					}
					?>
					<tr>
						<td><?php echo $row->Time ?></td>
						<td><?php echo Config::$factions[$row->Attacker]; ?> - <?php echo Config::$factions[$row->Defender] ?></td>
						<td><?php echo $row->Atscore ?> - <?php echo $row->Defscore ?></td>
						<td><?php echo $result ?></td>
						<td><a href="<?php echo Config::$_PAGE_URL ?>war/<?php echo $row->id ?>">View logs</a></td>
					</tr>
		<?php } ?>
		</tbody>
	</table>
</div>
<?php
echo Pagination::create(Config::rows('wars'));
?>
<link href="<?php echo Config::$_PAGE_URL; ?>assets/css/sort.min.css" media="all" type="text/css" rel="stylesheet">
<script src="<?php echo Config::$_PAGE_URL; ?>assets/js/jquery.tablesorter.min.js" async></script>
