<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Historial</title>
<link href="../../maincss.css" rel="stylesheet" type="text/css" />
<link href="../../printcss.css" rel="stylesheet" type="text/css" media="print" />

</head>
<?php
include "../../conn.php";
//include "../../class.nroenletraver2.php";
include "../../general.php";

$rep=$_GET["rep"];
$tipo=$_GET["tipo"];

//index.php?cosRecordKey=7&cosObjectKey=203138&user=Luigi
$cod_historico = $_GET["cosRecordKey"];
$cod_modulo = $_GET["cosObjectKey"];
$usuario = $_GET["user"];
//$n_decimales = 6;

?>
<body>

<?php
	
// Inicio impresion historico

$result3 = mysqli_query($link, "select a.pkyUserLog as codigo, a.fldDate as fecha, a.fldTime as hora, a.codUser as cod_usuario, b.fldLogin as usuario, a.cosActionKey as cod_accion, c.fldName as accion, a.cosObjectKey as cod_comp, concat(d.fldModuleName,' - ',d.fldName) as comp
from 
dbaUserLog a, accUser b, srvComponentAction c, srvComponent d
where 
a.cosRecordKey = '$cod_historico' and 
a.cosObjectKey = '$cod_modulo' and 
a.codSystemObjectType = 2 and 
a.codUser = b.pkyUser and 
a.cosActionKey = c.pkyComponentAction and 
a.cosObjectKey = d.pkyComponent 
order by fecha, hora;");
$ma_his = array();
$h = 1;
while ($row = mysqli_fetch_array($result3)) {
	$ma_his [$h][1] = $row['codigo'];
	$ma_his [$h][2] = $row['fecha'];
	$ma_his [$h][3] = $row['hora'];
	$ma_his [$h][4] = $row['cod_usuario'];
	$ma_his [$h][5] = $row['usuario'];
	$ma_his [$h][6] = $row['cod_accion'];
	$ma_his [$h][7] = $row['accion'];
	$ma_his [$h][8] = $row['cod_comp'];
	$ma_his [$h][9] = $row['comp'];
	$h++;
}
mysqli_free_result($result3);
$fin_h = $h - 1;

//$numero_filas = mysqli_num_rows($result3);
?>
<table border="0" align="left" width="100%" cellpadding="5">
<tr><td><?php echo $mostrar_logo_reportes; ?>
</td><td align="right"><b>Fecha: <?php echo date("Y-m-d"); ?><br/>Hora: <?php echo date("H:i:s"); ?><br/>Usuario: <?php echo $usuario; ?></b>
</td></tr></table><br/>
<p><br /><center><font color="#000099" size="+1"><b>Historial del registro</b></font></center></p>
<table border="0" cellpadding="2" align="center" width="100%">
<tr>
<td>	
    <table border="1" align="center" cellpadding="2" width="100%">
        <TR> 
        <TD width="50%"><b>Cod. Reg.: </b><?php echo $cod_historico; ?></TD>
        <TD width="50%"><b>M&oacute;dulo - Componente: </b><?php echo $ma_his [1][9]; ?></TD>
        </TR>
    </table>

</td>
<!--
<td valign="top" width="150">

    <table border="1" align="center" cellpadding="2" width="100%">
    <tr>
    <TD><b>Tipo de Cambio:</b></TD>
    </tr><tr>
    <TD align="center"><a href="../../ModuleAccounting/VoucherExchangeRate/index.php?pkyExchangeRate=<?php echo $cod_tc; ?>&user=<?php echo $usuario; ?>" title="Tipo de Cambio"><?php echo $cod_tc; ?></a> (<?php echo $tc_fecha; ?> - <?php echo $tc_hora; ?>)<br/ >
        <table border="0" cellpadding="2" align="center">
            <?php
            for($m = 1; $m <= $fin_m; $m++) {
            printf("<tr><td align='left'>1 %s</td>", $ma_tc [$m][1]);//moneda base
            printf("<td align='center'>%s</td>", ' = ');//letra a
            printf("<td align='left'>%s %s</td></tr>", number_format($ma_tc [$m][3],$n_tipocambio), $ma_tc [$m][2]);//moneda target y tasa
            //printf("<td align='right'>%s</td></tr>", number_format($ma_tc [$m][3],$n_tipocambio));//tasa
            }
            ?>
        </table>
    </TD>
    </tr>
	</table>
    
</td>
-->
</tr>
</table>
<br />
<!--detalle historial -->
<table border="1" align="center" cellpadding="2" width="100%">
 	<thead>
    <TR> 
    <TD align="center"><b>Cod.</b></TD>
    <TD align="center"><b>Fecha</b></TD>
    <TD align="center"><b>Hora</b></TD>
    <TD align="center"><b>Usuario</b></TD>
    <TD align="center"><b>Acci&oacute;n</b></TD>
    </TR>
    </thead>
    <tbody class="marcafila">
    <?php
    $color = 2;
	$suma_reg = 0;
		
	for($i = 1; $i <= $fin_h; $i++) { //for
		
		if($color % 2 == 0) { //if color
		printf("<tr BGCOLOR='#e2e7fa'><td align='center'>%s</td>", $ma_his [$i][1]);//cod historico
		} else {
		printf("<tr><td align='center'>%s</td>", $ma_his [$i][1]);//cod historico
		} //cierra if color
		printf("<td align='right'>%s</td>", $ma_his [$i][2]);//fecha reg
		printf("<td align='right'>%s</td>", $ma_his [$i][3]);//hora reg
		printf("<td align='left'>%s</td>", $ma_his [$i][5]);//usuario
		printf("<td align='left'>%s</td></tr>", $ma_his [$i][7]);//accion
				
		$suma_reg++;
		$color++;
	}//fin for
	
	?>
	<tr BGCOLOR='#ffcccc'>
    <td colspan="4"><b>Total acciones</b></td>
    <td align="right"><b><?php echo $suma_reg; ?></b></td>
    </tr>
</tbody>
</table>

</body>
</html>
