<?php
session_start();
header ('Content-type: text/html; charset=iso-8859-1');
if(!isset($_SESSION[_CUSE])) header("location: index.php");
include('../clases/clase.conexion.php');
include('../clases/clase.numeroletras.php');
include('../funciones/variables.php');
include('../funciones/funciones.php');
$var = VarServer("MYSQLI");
$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
$sql = "select date_format(C.fecha_emision,'%d/%m/%Y') AS FECHA, 
		T.nombre as TIPO, C.nro_documento as NUMERO,
		CONCAT(C.id_cliente, ' - ', UPPER(P.nombre)) as CLIENTE, upper(P.direccion) AS DIRECCION,
		C.id_vendedor as CVEN, CV.nombre AS CONDICION,	
		P.RUC, P.DNI, C.SUBTOTAL, C.IGV, C.TOTAL
		from _sv_venta C
		inner join _sv_cliente P ON C.id_Cliente = P.id_Cliente
		inner join _sv_tipo_doc_venta T ON C.id_tipo_doc = T.id_tipo_doc
		inner join _sv_tipo_condicion CV ON C.id_condicion = CV.id_condicion
		where C._estado='A'
		and C.id_tipo_doc = 3
		AND C.id_venta=$_GET[ndoc]";
$obj->AbrirConexion();
$rs = $obj->Query($sql);
$obj->CerrarConexion();
$row = $obj->FetchArray($rs);
$obj_numlet = new numerosALetras;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<title>IMPRIMIR BOLETA</title></head>
<link href="../css/boleta.css" rel="stylesheet" type="text/css" > 
<link rel="stylesheet" href="../css/boleta_epsonlx300.css" type="text/css" media="print" />
<body>
<div id="container">
    <table width="100%" border="0" class="mainContent">
      <tr>
        <td>
        <table width="100%" border="0" class="factura">
          <!--DWLayoutTable-->
      <tr>
        <td width="450" rowspan="3" align="left" valign="top"><div id="noPrint"><img src="../images/logo.jpg" width="392" height="67" /></div></td>
        <td width="182" height="18" align="center" valign="middle"><div id="noPrint"><b>R.U.C. <?php echo Config("SYSRUC")?></b></div></td>
        </tr>
      <tr>
        <td height="18" align="center" valign="middle"><div id="noPrint"><b><?php echo $row["TIPO"]; ?></b></div></td>
        </tr>
        <tr>
          <td height="18" align="center" valign="bottom"><?php echo $row["NUMERO"]; ?></td>
        </tr>
    </table>
        </td>
      </tr>
      <tr>
        <td>
    <table width="100%" border="0" class="cabecera">
      <tr>
        <td height="17" width="50" align="left"><div id="noPrint"><b>Se&ntilde;or(es)</b></div></td>
        <td width="2"><div id="noPrint"><b>:</b></div></td>
        <td align="left" colspan="3"><?php echo $row["CLIENTE"]; ?></td>
      </tr>
      <tr>
        <td height="17"><div id="noPrint"><b>Direccion</b></div></td>
        <td><div id="noPrint"><b>:</b></div></td>
        <td align="left" width="250"><?php echo $row["DIRECCION"]; ?></td>
        <td align="left" width="40">
        <div id="noPrint"><strong>Fecha:</strong></div>
        </td>
        <td align="left" width="200"><?php echo $row["FECHA"];
        ?></td>
      </tr>
      <tr>
        <td height="17"><div id="noPrint"><b>Dni</b></div></td>
        <td><div id="noPrint"><b>:</b></div></td>
        <td align="left"><?php echo $row["DNI"]; ?></td>
        <td align="left">
        <div id="noPrint"><strong>Ven.:</strong></div>
        </td>
        <td align="left"><?php echo $row["CVEN"];
        ?></td>
      </tr>    
    </table>
        </td>
      </tr>
      <tr>
        <td>
     <table width="100%" border="0" class="detalle" >
      <tr>
        <td valign="top">
      <table width="100%" border="0" class="detalle2" cellpadding="0" cellspacing="0">
      <tr>
        <td width="1%" align="center" valign="middle" class="contorno">&nbsp;</td>
        <td width="10%" align="center" valign="middle" class="contorno">
        <div id="noPrint"><strong>Cod</strong></div></td>
        <td width="10%" height="18" align="center" valign="middle" class="contorno"><div id="noPrint"><strong>Cant.</strong></div></td>
        <td width="58%" align="center" valign="middle" class="contorno" ><div id="noPrint"><b>Descripcion</b></div></td>
        <td width="11%" align="center" valign="middle" class="contorno"><div id="noPrint"><b>P. Unit.</b></div></td>
        <td width="11%" align="center" valign="middle" class="contorno"><div id="noPrint"><strong>Total</strong></div></td>
      </tr>
      <?php
        $sql = "call spQuery_Registro_Ventas_Contenido($_GET[ndoc]);";
        $obj->AbrirConexion();
        $rs = $obj->Query($sql);
        $obj->CerrarConexion();
        $j=0;
        $bgcolor1 = 'class="even_row" ';
        $bgcolor2 = 'class="odd_row" ';
        $varTotal = 0;
        while($fila = $obj->FetchArray($rs))	{
            $varTotal = $varTotal + $fila["TOTAL"]; 
        ?>
        <tr>
          <td align="center" valign="middle" class="contorno2">&nbsp;</td>
        <td align="center" valign="middle" class="contorno2"><?php echo $fila["CPRO"];?></td>
        <td align="center" valign="middle" class="contorno2"><?php echo number_format($fila["CANTIDAD"],"2",".",","); ?></td>
        <td align="left" valign="middle" class="contorno2">&nbsp;&nbsp; <?php echo substr($fila["PRODUCTO"],0,38);?></td>
        <td align="right" valign="middle" class="contorno2"><?php echo number_format($fila["PRECIO"],"5",".",","); ?></td>
        <td align="right" valign="middle" class="contorno2"><?php echo number_format($fila["TOTAL"],"2",".",","); ?></td>
      </tr>
      <?php } ?>
    </table>
        </td>
      </tr>
    </table>
        </td>
      </tr>
      <tr>
        <td>
        <table width="100%" border="0" class="resumen" cellpadding="0" cellspacing="0">
          <!--DWLayoutTable-->
      <tr>
        <td width="15%" height="20" align="center" valign="middle" class="contorno"><div id="noPrint"><strong>Son</strong></div></td>
        <td width="65%" align="left" valign="middle" class="contorno2">
		<?php echo strtoupper($obj_numlet->convertir($row["TOTAL"]));?>
        </td>
        <td width="10%" align="right" valign="middle" class="contorno"><div id="noPrint"><b>Total :</b></div></td>
        <td width="10%" align="right" valign="middle" class="contorno2"><?php echo number_format($row["TOTAL"],"2",".",",");?> </td>
      </tr>
    </table>
        </td>
      </tr>
    </table>
</div>
</body>
</html>
