<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Tipo de Cambio</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";
include "../../token.php";

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

//index.php?pkyExchangeRate=12&user=Luigi&token=123456
$cod_tipocambio = $_GET["pkyExchangeRate"];
//$muestra_cc = $_GET["showCC"];
//$usuario = $_GET["user"];
//$n_decimales = 6;

?>
<body>

<?php
	
// Inicio impresion tipo de cambio

$result3 = mysqli_query($link, "select a.pkyExchangeRate as cod_tc, a.fldDate as fecha, a.fldTime as hora, a.fldExclusive as exclusivo, a.sysEnabled as enabled, a.sysAuthorized as authorized, g.fldName as usuario_reg
from
actExchangeRate a, accGroup g
where 
a.sysAuthorizationGroup = g.pkyGroup and 
a.pkyExchangeRate = '$cod_tipocambio';");
	while ($row = mysqli_fetch_array($result3)) {
	$fecha_tc = $row['fecha'];
	$hora_tc = $row['hora'];
	$exclusivo = $row['exclusivo'];
	$usuario_reg = $row['usuario_reg'];
	$enabled = $row['enabled'];
	$authorized = $row['authorized'];
	}
	mysqli_free_result($result3);

if($exclusivo == 0) { 
	$nom_exclusivo = 'NO';
} else {
	$nom_exclusivo = 'SI';
}

$result6 = mysqli_query($link, "select a.pkyExchangeRateDetail as cod_tc_det, a.codBaseCurrency as cod_mon_target, b.fldName as mon_target, b.txtDescription as nom_mon_target, a.codTargetCurrency as cod_mon_base, c.fldName as mon_base, c.txtDescription as nom_mon_base, a.fldRate as tasa
from
actExchangeRateDetail a, actCurrency b, actCurrency c
where
a.codExchangeRate = '$cod_tipocambio' and 
a.codBaseCurrency = b.pkyCurrency and 
a.codTargetCurrency = c.pkyCurrency 
order by cod_mon_target, cod_mon_base;");


?>
<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>
<p><br /><center><font color="#000099" size="+1"><b>Tipo de Cambio</b></font></center></p>

<table border="1" align="center" cellpadding="2" width="90%">
 	<TR> 
 	<TD width="25%"><b>Cod. Reg.: </b><?php echo $cod_tipocambio; ?></TD>
    <TD width="25%"><b>Exclusivo: </b><?php echo $nom_exclusivo; ?></TD>
    <TD width="25%"><b>Hora de Reg.: </b><?php echo $hora_tc; ?></TD>
    <TD width="25%"><b>Fecha de Reg.: </b><?php echo $fecha_tc; ?></TD>
    </TR>
</table>
<br />
<table border="1" align="center" cellpadding="2" width="90%">
 	<TR> 
    <TD align="center"><b>Cod.</b></TD>
    <TD align="center"><b>Nombre Mon. Base</b></TD>
    <TD align="center"><b>Abrv. Mon. Base</b></TD>
    <TD align="center"><b>Nombre Mon. Objetivo</b></TD>
    <TD align="center"><b>Abrv. Mon. Objetivo</b></TD>
    <TD align="center"><b>Tasa</b></TD>
    <TD align="center"><b>Resumen</b></TD>
    </TR>
    <?php
    $color = 2;
	while ($row = mysqli_fetch_array($result6)) { //while
	
		if($color % 2 == 0) { //if color
		printf("<tr BGCOLOR='#e2e7fa'><td align='center'>%s</td>", $row['cod_tc_det']);//cod tc detalle
		} else {
		printf("<tr><td align='center'>%s</td>", $row['cod_tc_det']);//cod tc detalle
		} //cierra if color
		printf("<td align='left'>%s</td>", $row['nom_mon_base']);//nombre moneda base
		printf("<td align='left'>%s</td>", $row['mon_base']);//abreviatura moneda base
		printf("<td align='left'>%s</td>", $row['nom_mon_target']);//nombre moneda objetivo
		printf("<td align='left'>%s</td>", $row['mon_target']);//abreviatura moneda objetivo
		printf("<td align='right'>%s</td>", number_format($row['tasa'],$n_tipocambio));//tasa de cambio
		printf("<td align='left'>1 %s = %s %s</td></tr>", $row['mon_base'], number_format($row['tasa'],$n_tipocambio), $row['mon_target']);//resumen
		$color++;
	}//fin while
	mysqli_free_result($result6);
	?>
</table>
<br />
<?php
    if($enabled == 0){
				printf("<table border='0' align='center' cellpadding='2' width='600'><tr><td align='center'><font color='#FF0000' size='+1'>MOVIMIENTO ANULADO</font></td></tr></table>");
			}
	if($authorized == 0){
				printf("<table border='0' align='center' cellpadding='2' width='600'><tr><td align='center'><font color='#FF0000' size='+1'>MOVIMIENTO PENDIENTE DE AUTORIZACI&Oacute;N</font></td></tr></table>");
			}
?>


<br /><br /><br /><br /><br />
<table border="0" align="center" cellpadding="2" width="90%">
<tr>
<td align="center">----------------------------------------</td>
<td align="center">----------------------------------------</td>
<td align="center">----------------------------------------</td>
<td align="center">----------------------------------------</td>
</tr><tr>
<td align="center">Elaborado por: <?php echo $usuario_reg; ?></td>
<td align="center"><?php echo $firma_contabilidad; ?></td>
<td align="center"><?php echo $firma_gerencia; ?></td>
<td align="center"><?php echo $firma_interesado; ?></td>
</tr><tr>
<td align="left">Nombre:__________________________</td>
<td align="left">Nombre:__________________________</td>
<td align="left">Nombre:__________________________</td>
<td align="left">Nombre:__________________________</td>
</tr><tr>
<td align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C.I.:__________________________</td>
<td align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C.I.:__________________________</td>
<td align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C.I.:__________________________</td>
<td align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C.I.:__________________________</td>
</tr>
</table>

</body>
</html>
