<?
session_start();
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = 'index.php';
		</script>
		<? 
		exit();
		}
$id_empresa = $_SESSION['ss_empresa'];      //     22/12/10  
$id_user = $_SESSION['ss_user'];

$id_nv=$_POST["txt_nv"];

include("../conex.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Ver Traspaso</title>

<?
$sql_nv = "SELECT * FROM salida WHERE tipo_dcto = 17 AND num_dcto=$id_nv  AND empresa = $id_empresa";

$res_nv = mysql_query($sql_nv,$enlace);
$nv_cont = 0;
$sqlnv_ivar='';
while(mysql_fetch_object($res_nv)){
	
	$id_bodega_origen=mysql_result($res_nv, $nv_cont, "bodega");
	$id_bodega_destino= mysql_result($res_nv, $nv_cont, "observacion");
	$id_sucursal=mysql_result($res_nv, $nv_cont, "id_sucursal");
	$sqlnv_nv=mysql_result($res_nv, $nv_cont, "num_dcto");
	$rut=mysql_result($res_nv, $nv_cont, "rut_cliente");
	$fecha=mysql_result($res_nv, $nv_cont, "fecha_emision");
	
	$sql_neto=mysql_result($res_nv, $nv_cont, "neto");   // neto parte final
	
		$id_soe=mysql_result($res_nv, $nv_cont, "id");
	$nv_cont += 1;
	}
$id_dcto = 17;                                //traspaso
$num_dcto = $txtndcto;

	
//******************************** Datos Empresa ******** seleccionar cual empresa  es el ingreso  en sesion******/
	$sql_empresa = "SELECT * FROM empresa WHERE id=$id_empresa;";
	$res_empresa = mysql_query($sql_empresa,$enlace);
	
	$empresa_nombre=mysql_result($res_empresa, 0, "nombre");
		
$sql_vendedor = "SELECT * FROM bodega WHERE id=$id_bodega_origen";
	$res_vendedor = mysql_query($sql_vendedor,$enlace);
        $origen=mysql_result($res_vendedor, 0, "descripcion");
$sql_vendedor = "SELECT * FROM bodega WHERE id=$id_bodega_destino";
	$res_vendedor = mysql_query($sql_vendedor,$enlace);
        $destino=mysql_result($res_vendedor, 0, "descripcion");	


	$dia = substr ($fecha, 8, 2);
	$mes = substr ($fecha, 5, 2);
	$ano = substr ($fecha, 0, 4); 
    $fecha = "$dia-$mes-$ano";	
	
	
?>
<style type="text/css">
<!--
.Estilo1 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;}
.Estilo2 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color:#FF0000}
-->
</style>
</head>
<body LINK="#000000" VLINK="#000000" ALINK="#000000">

  <div align="center">


<table width="503" align="center" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="63"><div align="center"><img src="../Images/logo.gif" width="60px" height="60px"></div></td>
	<td width="75"><div align="left"><font size="1"><?=$empresa_nombre?></font></div>	</td>
    <td width="141"> <div align="center"><strong> Traspaso N&ordm; <?=$sqlnv_nv;?>  </strong> </div>   </td>
    <td width="224"> <div align="center"> Fecha:  <?=$fecha;?> <?=$hora;?>  </div>     </td>
  </tr>
</table>

<table width="550" height="30" border="1" align="center"  cellpadding="0" cellspacing="0">
  <tr>
   <td><div align="left"><strong>Bodega Origen:  <?=$origen;?> </strong></div></td>
   <td><div align="left"><strong>Bodega Destino:  <?=$destino;?> </strong></div></td>
   
    <td> <div align="center"> Usuario:  <?=$usuario;?>   </div>   </td>
  </tr>  
 </table>
 
<table width="550" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr bgcolor="#000000"> 
 <td width="5%"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">Codigo</font></strong></div></td>
  <td width="50%"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">Detalle</font></strong></div></td>
	  <td width="5%"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">Cant.</font></strong></div></td>
	 
     <td width="5%"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">Peso</font></strong></div></td>
    
  </tr>

<? 
                     //*********************
$sql_pnv = "SELECT * FROM movimiento AS m, productos AS p WHERE m.id_soe= $id_soe AND m.cod_producto = p.codigo AND m.entrada_salida_traspaso='S'";
	$res_pnv = mysql_query($sql_pnv,$enlace);
	$pnv_cont = 0;
	$totalkilos = 0;
	
	while(mysql_fetch_object($res_pnv))
	{
		$cod_producto = mysql_result($res_pnv, $pnv_cont, "m.cod_producto");
		$cantidad = mysql_result($res_pnv, $pnv_cont, "m.cantidad");
		$detalle = mysql_result($res_pnv, $pnv_cont, "p.descripcion");
		
		$peso = mysql_result($res_pnv, $pnv_cont, "p.peso");
		
		
	
		$totalkilos+= $cantidad*$peso;

	?>
	
   <tr> 
	 <td width="9%">		  	
<div align="center"><?=$cod_producto;?></div>  </td> 	
    <td width="42%"><div align="center"><?=$detalle;?>
	 </strong></div>  </td>
	<td width="9%"><div align="center"><?=$cantidad;?></strong></div></td>	    
      <td width="9%">		  	
<div align="center"><strong><?=$peso;?></strong></div>  </td> 
	
  </tr> 
   <?  
			
		$pnv_cont+=1;
   }
   ?>
 <tr> 
    <td width="9%">  </td> 	
    <td width="42%">  </td>
	<td width="9%">Total kilos</td>	    
      <td width="9%">		  	
<div align="center"><strong><font color="#333333" face="Arial, Helvetica, sans-serif"><?=$totalkilos;?></font></strong></div>  </td> 
	
  </tr> 


     </table> 

<form name="form1" method="post" action="">
  <input type="button" name="imprimir" id="imprimir" value="Imprimir" onClick="fun_imprimir();">
  <input type="button" name="Salir" id="Salir" value="Salir" onClick="fun_salir();"> 
 </form>

</div>
 
<script language="Javascript">

function fun_salir()
	{		
	window.top.open('','_parent','');window.top.close();
	}
function fun_imprimir()
	{	
	document.getElementById('Imprimir').style.display = "none";
	document.getElementById('Salir').style.display = "none";
	window.print();
	//document.getElementById('Imprimir').style.display = "block";
	document.getElementById('Salir').style.display = "block";
	}	

 </script>

