<?php
include("postget.php");
include_once("common.php");

$pagetitle = _LOGS;

checklevel(3,$_REQUEST['clientid']);
include("head_template.php");

$paging = new pagination;
if ($_REQUEST['orderby']) {
	$orderby = $_REQUEST['orderby'];
}else{
	$orderby ='time DESC';
}
$paging->mantenerVar('orderby');


$query="SELECT * FROM hd_history ORDER BY ".$orderby."";

$paging->agregarConsulta($query);
$paging->porPagina($config[32][1]);
$paging->paginasAntes(3, 10, 20, 50);
$paging->paginasDespues(3, 10, 20, 50);
$paging->linkSeparador('&nbsp;');
$paging->linkSeparadorEspecial('...');
$paging->linkClase('pag');
$paging->mostrarActual("<span class=\"pagthis\">{n}</span>");

$paging->ejecutar();



echo '
<div class="container">
	<div class="row">
';


if ($paging->numTotalPaginas() > 1) {
	echo "<div class='pagination'><b>".ucfirst(_PAGES)."</b>: ".$paging->fetchNavegacion()."</div>";
}

echo $paging->numTotalRegistros()." "._RECORDS;

echo '<table class="table table-striped">
';



print("<thead><tr>
<th><a href='".$serverurl."/logs.php?orderby=eventid'>".ucfirst(_LOG)."</a></th> 
<th><a href='".$serverurl."/logs.php?orderby=clientid'>".ucfirst(_CLIENT)."</a></th> 
<th><a href='".$serverurl."/logs.php?orderby=time'>".ucfirst(_DATE)."</a></th> 
<th><a href='".$serverurl."/logs.php?orderby=action'>".ucfirst(_ACTION)."</a></th> 
<th><a href='".$serverurl."/logs.php?orderby=user'>".ucfirst(_USER)."</a></th> 
</tr></thead><tbody>");

$bgc=true;

while($datos = $paging->fetchResultado()) {

	print("<tr><td align='center'>$datos[eventid]</td>");
	print("<td align='center'>");
	if ($datos[clientid]>0) {
		print("<a href='".$serverurl."/tickets.php?clientid=$datos[clientid]'>$datos[clientid]</a>");
	}else{
		print("&nbsp;");
	}
	print("$cierre</td>");
	print("<td align='left'>".date($df.' H:i',$datos[time])." (");
	print("".TimeAgo($datos[time],time()+$config[31][1]*3600).")</td>");
	print("<td align='left'>");
	if (defined($datos[action])) {
		print (constant($datos[action]));
	}else{
		print (make_clickable($datos[action]));
	}
	print("</td>");
	print("<td>$datos[user]</td></tr>");
}


echo '
		</tbody>
		</table>
</div>
</div>
';

include("foot_template.php");

?>