<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Lista de Precio</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?pkyPriceList=102&user=Luigi&token=123456

$cod_listap = $_GET["pkyPriceList"];
//$muestra_precio = $_GET["showPrice"];
//$usuario = $_GET["user"];

?>
<body>

<?php

// Inicio impresion lista de precio

$result = mysqli_query($link, "select a.pkyPriceList as cod_listap, a.fldName as listap, b.fldName as tipol, c.fldName as moneda, a.txtDescription as glosa, k.fldName as usuario_reg 
from 
slsPriceList a, slsPriceListType b, actCurrency c, accGroup k
where
a.pkyPriceList = '$cod_listap' and 
a.codType = b.pkyPriceListType and 
a.codCurrency = c.pkyCurrency and
a.sysAuthorizationGroup = k.pkyGroup;");
	while ($row = mysqli_fetch_array($result)) {
		$listap = $row['listap'];
		$tipol = $row['tipol'];
		$moneda = $row['moneda'];
		$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'];
		
	}
	mysqli_free_result($result);
	
$result2 = mysqli_query($link, "select a.codItem as cod_item, b.fldName as item, a.fldPrice as precio, a.fldDiscount as descuento, b.fldFactoryKey as cod_fabrica
from 
slsPriceListDetail a, invItem b
where
a.codPriceList = '$cod_listap' and 
a.codItem = b.pkyItem 
order by b.fldName;");


?>

<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>Lista de Precio</b></font></center></p>

<table border="1" align="center" cellpadding="2" width="100%">
    <TR> 
    <TD width="25%"><b>Cod. Reg.: </b><?php echo $cod_listap; ?></TD>
    <TD width="25%"><b>Nombre: </b><?php echo $listap; ?></TD>
    <TD width="25%"><b>Tipo: </b><?php echo $tipol; ?></TD>
    <TD width="25%"><b>Moneda: </b><?php echo $moneda; ?></TD>
    </TR>
    <TR>
    <TD colspan="4"><b>Descripci&oacute;n: </b><?php echo $glosa; ?></TD>
    </tr>
</table>

<br />
<table border="1" align="center" cellpadding="2" width="100%">
    <thead>
    <TR> 
    <TD width="60" align="center"><b>Cod. Item</b></TD>
    <TD width="60" align="center"><b>Cod. Fab.</b></TD>
    <TD align="center"><b>Item</b></TD>
    <TD width="100" align="center"><b>Precio</b></TD>
    <TD width="100" align="center"><b>Desc. %</b></TD>
    </TR>
    </thead>
    <tbody class="marcafila">
    <?php
    $color = 2;
	$suma_items = 0;
    
    while ($row = mysqli_fetch_array($result2)) { //while
    
        if($color % 2 == 0) { //if color
        printf("<tr BGCOLOR='#e2e7fa'><td align='center'>%s</td>", $row['cod_item']);//cod item
        } else {
        printf("<tr><td align='center'>%s</td>", $row['cod_item']);//cod item
        } //cierra if color
		printf("<td align='center'>%s</td>", $row['cod_fabrica']);//cod fabrica
        printf("<td>%s</td>", $row['item']);//nombre item
        printf("<td align='right'>%s</td>", number_format($row['precio'],$n_decimales));//precio
        printf("<td align='right'>%s</td></tr>", number_format($row['descuento'],$n_descuento));//descuento
        $suma_items++;        
        $color++;
    }//fin while
mysqli_free_result($result2);
	
?>	
<tr BGCOLOR='#ffcccc'><td colspan="4"><b>Total Items</b></td>
<td align="right"><?php printf("<b>%s</b>", number_format($suma_items,$n_cantidad)); ?></td>
</tr>
</tbody>    
</table><br /><br />
<b>Registrado por: </b> <?php echo $usuario_reg; ?>

</body>
</html>
