<?php
session_start();
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}

?>
<!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=euc-jp">
<style type="text/css">
.cs0{
	font-size:12px; 
	font-family:Arial, Helvetica, sans-serif; 
	font-weight:bold;
}
.cs1{
	font-size:14px; 
	font-family:Arial, Helvetica, sans-serif; 
	font-weight:bold;
}
.cs2{
	font-size:22px; 
	font-family:Arial, Helvetica, sans-serif; 
	font-weight:bold;
	margin-top:2px;	
}
.cs3{
	font-size:12px; 
	font-family:Arial, Helvetica, sans-serif; 	
}
.cs4{
	font-size:20px; 
	font-family:Arial, Helvetica, sans-serif; 
	font-weight:bold;
	margin-top:2px;	
}
</style>

<?php
function tu($s){
	$s=trim(strtoupper($s));
	return $s;
}
	
$SER="";
$NUM="";
$CLI=tu(V($_GET['CLI']));
$DIR=tu(V($_GET['DIR']));
$DNI=tu(V($_GET['DNI']));
$RUC=tu(V($_GET['RUC']));
$TDP=tu(V($_GET['TDP']));
$FEC=tu(V($_GET['FEC']));
$USU=gs("nom","usuarios","id_usuario=".vbval(V($_SESSION['SYS_USER_ID'])));
$VEN=tu(V($_GET['VEN']));
$ENV=vbval(V($_GET['ENV']));
$HWN=V($_SESSION['SYS_USER_ID']."_V");
//ZYZ_USER_ID
if(strlen($CLI)==0)$CLI="-";
if(strlen($DIR)==0)$DIR="-";
if(strlen($DNI)==0)$DNI="-";
if(strlen($USU)==0)$USU="-";
if(strlen($VEN)==0)$VEN="-";

?>
<title>Ventas vista previa</title>
</head>
<body onload=" window.print() ;">
<center>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" style="max-width:950px;" >
      <tr>
        <td width="1%">&nbsp;</td>
        <td width="98%">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" >
            <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>            
            </tr>
            <tr>
            <td width="40%">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" style="min-width:220px">
            <tr>
            <td align="center">
            <span  class="cs1">INVERSIONES</span>
            </td>
            </tr>
            <tr>
            <td align="center">
            <div  class="cs2">SOUND UNIVERSAL</div>
            </td>
            </tr>
            <tr>
            <td align="center">
            <div  class="cs0">JR. CUZCO 686 - LIMA</div>
            </td>
            </tr>
            <tr>
            <td align="center">
            <div  class="cs0">TELF. 428-3617</div>
            </td>
            </tr>
            </table>
            </td>
            <td width="30%">&nbsp;</td>
            <td  width="30%">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" style="min-width:220px">
            <tr>
            <td align="center">&nbsp;
            
            </td>
            </tr>
            <tr>
            <td align="center">
            <div  class="cs2">-</div>
            </td>
            </tr>
            <tr>
            <td align="center">
            <div  class="cs4">-</div>
            </td>
            </tr>
            <tr>
            <td align="center">
            <div  class="cs0">&nbsp;</div>
            </td>
            </tr>
            </table>
            </td>
            </tr>
            </table>
        </td>
        <td width="1%">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="cs3" style="min-width:800px;">
          <tr>
            <td width="14%">Señores</td>
            <td width="1%">:</td>
            <td colspan="2"><?php echo $CLI;?></td>
            <td width="16%">&nbsp;</td>
          </tr>
          <tr>
            <td>Direccion</td>
            <td>:</td>
            <td colspan="2"><?php echo $DIR;?></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>Dni</td>
            <td>:</td>
            <td colspan="2"><?php echo $DNI;?></td>
            <td>&nbsp;</td>
          </tr>
          <?php
		  if(strlen($RUC)>0){
		  ?>
          <tr>
            <td>Ruc</td>
            <td>:</td>
            <td colspan="2"><?php echo $RUC;?></td>
            <td>&nbsp;</td>
          </tr>
          <?php
		  }
		  ?>
          <tr>
            <td>Medio de pago</td>
            <td>:</td>
            <td colspan="2"><?php echo $TDP;?></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>Fecha de emision</td>
            <td>:</td>
            <td colspan="2"><?php echo $FEC;?></td>
            <td>&nbsp;</td>
          </tr>
          
          <tr>
            <td>Vendedor</td>
            <td>:</td>
            <td colspan="2"><?php echo $VEN;?></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>Usuario</td>
            <td>:</td>
            <td colspan="2"><?php echo $USU;?></td>
            <td>&nbsp;</td>
          </tr>
          
            <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td colspan="2">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
         
         
        </table>
        </td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>
        
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="cs3">
            <tr>
            <td colspan="11"><hr></td>
            </tr>
            <tr>
            <td width="4%">&nbsp;</td>
            <td width="4%">&nbsp;</td>
            <td width="3%" align="right"><b>CANT</b></td>
            <td width="1%">&nbsp;</td>
            <td width="58%"><b>DESCRIPCION</b></td>
            <td width="3%">&nbsp;</td>
            <td width="9%" align="right"><b>PRECIO</b></td> 
            <td width="6%">&nbsp;</td>
            <td width="12%" align="right"><b>IMPORTE</b></td>
            </tr>
            <tr>
            <td colspan="9"><hr></td>
            </tr>
            <?php
			$CX=0;
			$TOT=0;
			$s="SELECT * FROM temp_compras WHERE cod_temc='$HWN' ORDER BY temc_index";
			$rs=grs($s);
			while($r=$rs->fetch_assoc()){
				$CX++;
				$TOT=$TOT+$r['temc_imp'];
			?>
            
            <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td align="right"><?php echo $r['temc_cant'];?></td>
            <td>&nbsp;</td>
            <td><?php echo $r['des'];?></td>
            <td>&nbsp;</td>
            <td align="right"><?php echo $r['temc_precio'];?></td>
            <td>&nbsp;</td>
            <td align="right"><?php echo $r['temc_imp'];?></td>
            </tr>
            <tr>
            <td colspan="9"><hr></td>
            </tr>
            <?php
			}
			$TOT=round($TOT,1);
			?>           
            <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td colspan="2">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                <td><b>TOTAL IMPORTE</b></td>
                <td align="right">:</td>
                </tr>
                </table>
            </td>
            <td align="right"><b>S/ <?php echo NF2($TOT,2)?></b></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td colspan="2">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                    <td><b>COSTO DE ENVIO</b></td>
                    <td align="right">:</td>
                    </tr>
                    </table>
              </td>
              <td align="right"><b>S/ <?php echo NF2($ENV,2)?></b></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td colspan="2">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                <td><b>TOTAL FINAL</b></td>
                <td align="right">:</td>
                </tr>
                </table>              
              </td>
              <td align="right"><b>S/ <?php echo NF2(round($TOT + $ENV,1),2)?></b></td>
            </tr>
            </table>
            
            
        </td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
</center>
</body>
</html>