<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Cheque</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?pkyCheck=2&user=Luigi&token=123456
$cod_cheque = $_GET["pkyCheck"];

//$usuario = $_GET["user"];
//$n_decimales = 6;

?>
<body>

<?php
	
// Inicio impresion de cheque

$result3 = mysqli_query($link, "select a.pkyCheck as cod_cheque, a.fldNumber as numero, a.codBank as cod_banco, b.fldName as banco, a.codLocalAccount as cod_cta_loc, a.fldForeignAccount as cta_no_loc, a.codCompany as cod_empresa, a.codEmployee as cod_emp, a.fldName as a_nombre, a.fldReceived as cod_recibido, a.fldDate as fecha, a.codCurrency as cod_moneda, c.fldName as moneda, a.fldNominalTotal as total_nominal, a.fldRealTotal as total_real, a.fldLiteral as literal, a.codStatus as cod_estado, d.fldName as estado, a.txtDescription as glosa, a.sysEnabled as enabled, a.sysAuthorized as authorized, g.fldName as usuario_reg, a.fldParentComponent as papa, a.cosComponentKey as cod_papa
from 
tryCheck a, tryBank b, actCurrency c, tryCheckStatus d, accGroup g
where
a.pkyCheck = '$cod_cheque' and 
a.codBank = b.pkyBank and 
a.codCurrency = c.pkyCurrency and 
a.codStatus = d.pkyCheckStatus and 
a.sysAuthorizationGroup = g.pkyGroup;");
	while ($row = mysqli_fetch_array($result3)) {
	$numero = $row['numero'];
	$fecha = $row['fecha'];
	$cod_banco = $row['cod_banco'];
	$banco = $row['banco'];
	$cod_cuenta_loc = $row['cod_cta_loc'];
	$cuenta_no_loc = $row['cta_no_loc'];
	$cod_empresa = $row['cod_empresa'];
	$cod_empleado = $row['cod_emp'];
	$girado_para = $row['a_nombre'];
	$cod_recibido = $row['cod_recibido'];
	if($cod_recibido == 1) { 
		$recibido = 'Si'; 
	} else {
		$recibido = 'No';
	}
	$cod_moneda = $row['cod_moneda'];
	$moneda = $row['moneda'];
	$total_nominal = $row['total_nominal'];
	$total_real = $row['total_real'];
	$literal = $row['literal'];
	$cod_estado = $row['cod_estado'];
	$estado = $row['estado'];
	$glosa = $row['glosa'];
	$glosa = nl2br($glosa);
	$glosa = str_replace('\n','<br />',$glosa);
	$usuario_reg = $row['usuario_reg'];
	$enabled = $row['enabled'];
	$authorized = $row['authorized'];
	
	//para enlazar al que genero el asiento
	$papa_componente = $row['papa'];
	$papa_codigo = $row['cod_papa'];
	//$usuario = $usuario_det;
	include "../../generadopor.php";
	}
	mysqli_free_result($result3);

$resultcta = mysqli_query($link, "select pkyBankDetail as cod_cta, fldNumber as nro_cuenta
from
tryBankDetail
where
pkyBankDetail = '$cod_cuenta_loc';");
while ($row = mysqli_fetch_array($resultcta)) {
	$cuenta_loc = $row['nro_cuenta'];
}
mysqli_free_result($resultcta);

$resultemp = mysqli_query($link, "select pkyCompany as codigo, fldName as empresa
from agnCompany
where
pkyCompany = '$cod_empresa';");
while ($row = mysqli_fetch_array($resultemp)) {
	$empresa = $row['empresa'];
}
mysqli_free_result($resultemp);
	
$resultper = mysqli_query($link, "select pkyPerson as codigo, case when fldMiddleName is NULL then concat(fldLastName,', ',fldFirstName) else concat(fldLastName,' ',fldMiddleName,', ',fldFirstName) end as persona
from agnPerson
where
pkyPerson = '$cod_empleado';");
while ($row = mysqli_fetch_array($resultper)) {
	$empleado = $row['persona'];
}
mysqli_free_result($resultper);


?>
<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>Cheque</b></font></center></p>

<table border="1" align="center" cellpadding="2" width="100%">
    <TR> 
    <TD width="25%"><b>Cod. Reg.: </b><?php echo $cod_cheque; ?></TD>
    <TD width="25%"><b>Estado: </b><?php echo $estado; ?></TD>
    <TD width="25%"><b>Fecha: </b><?php echo $fecha; ?></TD>
    <TD width="25%"><b>Recibido: </b><?php echo $recibido; ?></TD>
    </TR>
    <TR> 
    <TD><b>N&uacute;mero: </b><?php echo $numero; ?></TD>
    <TD><b>Empresa: </b><?php echo $empresa; ?></TD>
    <TD><b>Empleado: </b><?php echo $empleado; ?></TD>
    <TD><b>Generado Por: </b><?php echo $papa_enlace; ?></TD>
    </TR>
    <TR> 
    <TD><b>Moneda: </b><?php echo $moneda; ?></TD>
    <TD><b>Banco: </b><?php echo $banco; ?></TD>
    <TD><b>Cuenta (Propia): </b><?php echo $cuenta_loc; ?></TD>
    <TD><b>Cuenta (Ajena): </b><?php echo $cuenta_no_loc; ?></TD>
    </TR>
    <TR>
    <TD><b>A Nombre De: </b><?php echo $girado_para; ?></TD>
    <TD><b>Total Nominal: </b><?php echo number_format($total_nominal, $n_decimales); ?></TD>
    <TD><b>Total Real: </b><?php echo number_format($total_real, $n_decimales); ?></TD>
    <TD><b>Literal: </b><?php echo $literal; ?></TD>
    </TR>
    <TR>
    <TD colspan="4"><b>Glosa: </b><?php echo $glosa; ?></TD>
    </TR>
</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'>REGISTRO 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'>REGISTRO 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>
