<?php
include("postget.php");
checklevel(1,$_REQUEST['clientid']);

if($_SESSION['hd_accesslvl']==1){
	$where=" WHERE hd_history.clientid=".$_SESSION['hd_clientid']." ";
	$showlink = 0;
}elseif ($_SESSION['hd_clientid']){
	$where=" WHERE hd_history.clientid=".$_SESSION['hd_clientid']." ";
	$showlink = 0;
}else{
	$where="";
	$showlink = 1;
}

$query="SELECT hd_history.clientid, hd_history.time, hd_history.user, hd_history.action, hd_history.eventid, hd_history.what,
hd_clients.first, hd_clients.last, hd_clients.country 
FROM hd_history 
LEFT JOIN hd_clients ON hd_history.clientid = hd_clients.clientid 
$where
ORDER BY hd_history.eventid DESC LIMIT 0,10";

$result=mysql_query($query,$db_link);

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

echo ucfirst(_LAST_10_EVENTS);

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



print("<thead><tr>
	<th>"._CLIENT."</th> 
	<th>"._DATE."</th> ");
if($_SESSION['hd_accesslvl']>1){
	print("<th>"._USER."</th> ");
}
print("<th>"._ACTION."</th>
	<th>"._ID."</th></tr></thead><tbody>");


while($row = mysql_fetch_array($result)) {

	if ($row[5]=='F') {$apertura = "<font color='red' style='text-shadow: -1px 0 white, 0 1px white, 1px 0 white, 0 -1px white'>"; $cierre = "</font>";}else{$apertura = ""; $cierre = "";}
        echo '<tr>';
	if ($row[5]=='A') {
		print("<TD>");
		print(""._ADMINISTRATOR."</TD>");
		print("<TD align='left'>".date($df.' H:i',$row[1])." (");
		print("".TimeAgo($row[1],time()+$config[31][1]*3600)." "._AGO.")</TD>");
		if($_SESSION['hd_accesslvl']>1){
			print("<TD align='left'>".$row[2]."</TD>");
		}
		print("<TD align='left'>$apertura");
		if (defined($row[3])) {
			print (constant($row[3]));
		}else{
			print (make_clickable($row[3]));
		}
		print("$cierre</TD>");
		print("<TD align='left'>".$row[4]."</TD></TR>");

	}else{
		print("<TD>");
		if ($row[0]>0) {
			bandera2($row[country]);
			print(" ".($showlink==1?"<a href='".$serverurl."/tickets.php?clientid=$row[clientid]'>[$row[0]]</a> ":"").$row[6]." ".$row[7]."");
		}
		print("&nbsp;</TD>");
		print("<TD align='left'>".date($df.' H:i',$row[1])." (");
		print("".TimeAgo($row[1],time()+$config[31][1]*3600)." "._AGO.")</TD>");
		if($_SESSION['hd_accesslvl']>1){
			print("<TD align='left'>".$row[2]."</TD>");
		}
		print("<TD align='left'>$apertura");
		if (defined($row[3])) {
			print (constant($row[3]));
		}else{
			print (make_clickable($row[3]));
		}
		print("$cierre</TD>");
		print("<TD align='left'>".$row[4]."</TD></TR>");

	}
}

print("<tr><td>");

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

?>
