<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Poliza</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";

//index.php?pkyImportDocument=3&user=Luigi&token=123456
$rep=$_GET["rep"];
$tipo=$_GET["tipo"];

$cod_poliza = $_GET["pkyImportDocument"];
//$mostrar_asiento_cc = $_GET["showCC"];
//$usuario = $_GET["user"];

//$n_decimales = 6;
?>
<body>

<?php

// Inicio impresion Poliza

$result = mysqli_query($link, "select a.pkyImportDocument as cod_poliza, a.fldNumber as numero, a.fldPeriod as periodo, a.codSupplier as cod_prov, b.fldName as proveedor, a.fldPaymentDate as fecha_pago, a.fldImportTax as monto_import, a.fldImportValue as valor_import, a.fldGAC as gac, 
a.fldOtherExpenses as otros_gastos, a.fldTotal as total, a.fldDeductibleVAT as deducible_iva, a.fldTotalVAT as total_iva, a.fldName as nombre, a.fldNIT as nit, 
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, a.sysContext as cod_contexto, s.fldName as contexto 
from
pchImportDocument a, agnCompany b, accGroup g, srvContext s 
where
a.pkyImportDocument = '$cod_poliza' and 
a.codSupplier = b.pkyCompany and 
a.sysContext = s.pkyContext and 
a.sysAuthorizationGroup = g.pkyGroup;");
	while ($row = mysqli_fetch_array($result)) {
		$cod_poliza = $row['cod_poliza'];
		$numero = $row['numero'];
		$periodo = $row['periodo'];
		$cod_prov = $row['cod_prov'];
		$proveedor = $row['proveedor'];
		$fecha_pago = $row['fecha_pago'];
		$monto_import = $row['monto_import'];
		$valor_import = $row['valor_import'];
		$gac = $row['gac'];
		$otros_gastos = $row['otros_gastos'];
		$total = $row['total'];
		$deducible_iva = $row['deducible_iva'];
		$total_iva = $row['total_iva'];
		$nombre = $row['nombre'];
		$nit = $row['nit'];
		$glosa = $row['glosa'];
		$glosa = nl2br($glosa);//quita salto de linea 
		$glosa = str_replace('\n','<br />',$glosa);//reemplaza para salto de linea
		$usuario_reg = $row['usuario_reg'];
		$enabled = $row['enabled'];
		$authorized = $row['authorized'];
		$cod_contexto = $row['cod_contexto'];
		$contexto = $row['contexto'];
		
		//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($result);
	

	

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

<table border="1" align="center" cellpadding="2" width="80%">
    <TR> 
    <TD width="33%" colspan="2"><b>Cod. Reg.: </b><?php echo $cod_poliza; ?></TD>
    <TD width="33%" colspan="2"><b>Proveedor: </b><?php echo $proveedor; ?></TD>
    <TD width="33%" colspan="2"><b>Generado Por: </b><?php echo $papa_enlace; ?></TD>
    </TR>
    <TR>
    <TD colspan="2"><b>Nro. Doc.: </b><?php echo $numero; ?></TD>
    <TD><b>Valor Importaci&oacute;n: </b></TD><TD align="right" style="border-left:hidden"><?php echo number_format($valor_import,$n_decimales); ?></TD>
    <TD colspan="2"><b>Raz&oacute;n Social: </b><?php echo $nombre; ?></TD>
    </TR>
    <TR>
    <TD><b>Periodo: </b></TD><TD align="right" style="border-left:hidden"><?php echo substr($periodo, 0, -3); ?></TD>
    <TD><b>GAC: </b></TD><TD align="right" style="border-left:hidden"><?php echo number_format($gac,$n_decimales); ?></TD>
    <TD colspan="2"><b>NIT Ag. Desp.: </b><?php echo $nit; ?></TD>
    </TR>
    <TR>
    <TD><b>Fecha de pago: </b></TD><TD align="right" style="border-left:hidden"><?php echo $fecha_pago; ?></TD>
    <TD><b>Otros gastos: </b></TD><TD align="right" style="border-left:hidden"><?php echo number_format($otros_gastos,$n_decimales); ?></TD>
    <TD><b>Deducible IVA: </b></TD><TD align="right" style="border-left:hidden"><?php echo number_format($deducible_iva,$n_decimales); ?></TD>
    </TR>
    <TR>
    <TD><b>Imp. importaci&oacute;n: </b></TD><TD align="right" style="border-left:hidden"><?php echo number_format($monto_import,$n_decimales); ?></TD>
    <TD><b>Total: </b></TD><TD align="right" style="border-left:hidden"><?php echo number_format($total,$n_decimales); ?></TD>
    <TD><b>Total IVA: </b></TD><TD align="right" style="border-left:hidden"><?php echo number_format($total_iva,$n_decimales); ?></TD>
    </TR>
    <TR>
    <TD colspan="6"><b>Contexto: </b><?php echo $cod_contexto; ?> - <?php echo $contexto; ?></TD>
    </TR>
    <TR>
    <TD colspan="6"><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>

<?php


?>
</body>
</html>
