<?php
@session_start();
if(isset($_SESSION['ekdhlos_userid'])){
	include_once('php/functions.php');
	require_once "pagination/Paginated.php";
	require_once "pagination/DoubleBarLayout.php";
	$results = get('','logs','','','all');
	if($results){
		$pagedResults = new Paginated($results, 5, $_SESSION['page']);
		echo '
		<h1 class="more_left_2">Τελευταίες Ενέργειες Χρήστη</h1>
		<div id="tools2">
		<a href="insert_users.php" title="Εισαγωγή χρηστών"><img alt="Εισαγωγή χρηστών" src="images/icon-insert-big.png" /></a>
		<a href="edit_users.php" title="Επεξεργασία χρηστών"><img alt="Επεξεργασία χρηστών" src="images/Write2.png" /></a>
		<a href="logs.php" title="Τελευταίες ενέργειες"><img alt="Τελευταίες ενέργειες" src="images/logs-big.png" /></a>
		</div><hr /><br />
			<table id="gradient-style">
				<thead>
				<tr>
					<th scope="col" class="width_th_u">Χρήστης</th>
					<th scope="col" class="width_th_d">Ημερομηνία</th>
					<th scope="col" class="width_th_max">Sql command</th>
				</tr>
				</thead>
				<tbody>';
		while($row = $pagedResults->fetchPagedRow()) {
		if($row['user_id']==0) {$f_name= "public"; $l_name = 'user';}
		else if($row['user_id']==-1) {$f_name= "System"; $l_name = '';}
		else {
			if($row['user_id']==$_SESSION['ekdhlos_userid']) {
				$f_name = get('f_name','users','id',$row['user_id'],'one'); $l_name = get('l_name','users','id',$row['user_id'],'one');
			}
			else {
				$f_name = '<a href="edit_users.php?edit_id='.$row['user_id'].'" title="Κάντε κλικ για να επεξεργαστείτε το χρήστη">'.get('f_name','users','id',$row['user_id'],'one'); $l_name = get('l_name','users','id',$row['user_id'],'one').'</a>';
			}
		}

		echo "
				<tr>
					<td>".$f_name." ".$l_name."</td><td>".fix_date($row['date'])."<br />".fix_hour($row['date'])."</td>
					<td><span class=\"font_s\">".$row['sql']."</span></td>
				</tr>";
		}
		echo '	
				</tbody>		
				<tfoot>';
				$pagedResults->setLayout(new DoubleBarLayout());
				echo '
				<tr>
					<td colspan="3">';
				if(sizeof($results)>5){
					echo $pagedResults->fetchPagedNavigation();
				}
				echo '
					</td>
				</tr>
				</tfoot>
			</table>';
	}
}
?>