<?php include('inc/header.php'); ?>
<h1>Listen - Letzte Registrationen</h1>
<div class="container">
<?php
		odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['web'] . ']');
	
	echo '<div id="pageinc">';
	
		if(!isset($_GET['page'])) {$_GET['page'] = 1;}
		$page = $_GET['page'];
		$perpage = 20;
		$select = odbc_exec($odbc_connect, 'SELECT * FROM [VALIDATE] ORDER BY timestamp DESC');
		$resultset = array();
		$counter = 0;
		while($row = odbc_fetch_array($select)) {$resultset[$counter++] = $row;}
		$all = odbc_exec($odbc_connect, 'SELECT COUNT(*) as count FROM [VALIDATE]');
		$count = odbc_result($all, 'count');
		$countpages = $count / $perpage;
		echo '<table id="table" style="width: 100%;">
				<tr>
					<td width="5%" id="key">Nr.</td>
					<td width="10%" id="key">Typ</td>
					<td width="20%" id="key">Account</td>
					<td width="20%" id="key">E-Mail</td>
					<td width="20%" id="key" style="text-align: center;"><table align="center"><tr><td><img src="img/date.png" /></td><td>Datum / Uhrzeit</td></tr></table></td>
					<td width="5%" id="key" colspan="2">Aktionen</td>
				</tr>';
		for($i = $perpage * ($page-1);$i < $perpage*$page;$i++) {
			if(isset($resultset[$i])) {			
				echo '
				<tr id="regid_'.$i.'" class="row">
					<td style="line-height:20px;">#'.$i.'</td>
					<td>'.$resultset[$i]['type'].'</td>
					<td>'.$resultset[$i]['account'].'</td>
					<td>'.$resultset[$i]['fieldAlfa'].'</td>
					<td align="center">'.date('d.m.Y, H:i', $resultset[$i]['timestamp']).' Uhr</td>
					<td align="center"><a href="javascript:acceptValidation(\''.$i.'\',\''.$resultset[$i]['key'].'\');" title="Validieren" rel="tooltip"><img src="../images/add.png" alt="" /></a></td>
					<td align="center"><a href="javascript:denyValidation(\''.$i.'\',\''.$resultset[$i]['key'].'\');" title="Anfrage verwerfen" rel="tooltip"><img src="../images/delete.png" alt="" /></a></td>
				</tr>';
			}
		}
		echo '</table><br/>';
		for($i=0; $i < $countpages; $i++) {
			$k = $i + 1;
			if(strlen($k) == 1) {$k = '0'.$k;} if($k == 51) {echo '<br /><br />';}
			if($page == $k) {echo '<span id="page"><b>'.$k.'</b></span>';} 
			else {echo '<span id="page"><a href="database.php?NeusteAccounts=Latest+Accounts&page='.$k.'">'.$k.'</a></span>';}
		}
		echo '</div><br/>';
?>
</div>
<?php include('inc/footer.php'); ?>