<?php
 
session_start();
include("DMMYSQLG.php");
?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<body>
<form name="frm1" id="frm1" method="post" action="">

<?php
 
if ($_POST['bot']==""){
	echo '<h2>!!! Selecciona un Registro !!!</h2>';
	echo '<meta content="1; url=DI32000_PR.php"  HTTP-EQUIV="REFRESH">';
}else{
?>
  <input name="ver" type="hidden" value="1">
 <table   align="center">
   <tr>
     <td colspan="4" class="men">
<?php
  
	@$result = mysqli_query($con ,"SELECT * FROM dgreqdev WHERE fol_ven = '".$_POST['bot']."'");	
	@$row = mysqli_fetch_array($result);
	$op3=$row["alm_gen"];

?>
     </td>
   </tr>
   <tr>
     <th colspan="4" class=\"titulo\">Datos de la Entrada </th>
   </tr>
   <tr>
     <td width="117">Tipo de Entrada:</td>
     <td width="267"><?php
 
		//echo $op1.'<br>';
		@$resultado=mysqli_query($con ,"select * from dgtipcar where tip_car = '".$row['tip_ven']."'");
		@$registro=mysqli_fetch_array($resultado);
		echo $registro['des_tipcar'];
		
	?>
       &nbsp;</td>
     <td colspan="2">Fecha de Entrada :
       <?php
 
			$fec1=$row["fec_ven"];
			include("DF20000.php");
			echo $f_f;
		}
	?>
     </td>
   </tr>
 </table>
 </div>
<table border='1' align="center">
    <tr>
      <th><div align="center">Sel</div></th>
      <th><div align="center">Clave Producto</div></th>
      <th><div align="center">Descripcion</div></th>
      <th><div align="center">Precio Base</div></th>
      <th><div align="center">% Descuento</div></th>
      <th><div align="center">Descuento</div></th>
      <th><div align="center">Precio Unitario</div></th>
      <th><div align="center">Cantidad</div></th>
      <th><div align="center">Sub - total</div></th>
      <th><div align="center">Iva</div></th>
      <th><div align="center">Total</div></th>
    </tr>
    <?php

	//saca el numero de producto
	@$res=mysqli_query($con ,"select * from dgreqded where cons_ven = '".$_POST['bot']."'");
	while($row = mysqli_fetch_array($res))
	{
		$npr[]=$row["nparte1"];	
		$nrx[]=$row["fol_ven1"];	
	}
	//contar cuantos registros
	$num_elementos=count($npr);
	//saca la descripcion del producto
	for($j=0;$j<=$num_elementos-1;$j++)
	{
		@$res=mysqli_query($con ,"SELECT * FROM dginvent WHERE dginvent.modulo='".$_SESSION['mod_sis']."' AND   nparte1 = '$npr[$j]'");
		while($row = mysqli_fetch_array($res))
		{
			$dpr[]=$row["np_desc1"];	
		}
	}
	$num_elementos1=count($npr);
	for($y=0;$y<=$num_elementos1-1;$y++)
	{	
		//mostrar datos encontrados en dgrefodd
		@$res=mysqli_query($con ,"select * from dgreqded where cons_ven = '".$_POST['bot']."' and nparte1 = '$npr[$y]'");
		while($row = mysqli_fetch_array($res)){
			echo '<tr><td>';
			echo '<div align="center"><input name="r5" type="radio" value="'.$row['fol_ven1'].'"/></div></td>';
			echo '<input name="nu_re1'.$y.'" type="hidden" value="'.$nrx[$y].'">';
			echo '<input name="nu_re2'.$y.'" type="hidden" value="'. $npr[$y].'">';
			echo '<td><div align="center">' . $npr[$y] . '</div></td>';
			echo '<td><div align="center">' . $dpr[$y] . '</div></td>';
			$pbas=$row['pre_uni'];
			echo '<td><div align="center">$ ' . number_format($row['pre_uni'], 4, '.', ',') . '</div></td>';
			$pbase =  $pbase + $pbas;
			$c = $c + $row['can_ref'];
			echo '<td><div align="center">' . number_format($row['por_des'], 4, '.', ',') . '  %</div></td>';
			echo '<td><div align="center">$ ' . number_format($row['des'], 4, '.', ',') . '</div></td>';
			$d = $d + $row['des'];
			$pre_u = $pbas - $row['des'];
			echo '<td><div align="center">$ ' . number_format($pre_u, 4, '.', ',') . '</div></td>';
			$p = $p + $pre_u;
			//sacra el iva
			$sbt = $pre_u * $row['can_ref'];
			echo '<td><div align="center">' . $row['can_ref'] . '</div></td>';
			echo '<td><div align="center">$ ' . number_format($sbt, 2, '.', ',') . '</div></td>';
			$s = $s + $sbt;
			//$ti = $sbt
			$ivpp = $row['iva_pre'] ;
			echo '<td><div align="center">$ ' . number_format($ivpp, 2, '.', ',') . '</div></td>';
			$iv = $iv + $ivpp;
			$t = $ivpp + $sbt;
			echo '<td><div align="center">$ ' . number_format($t, 2, '.', ',') . '</div></td>';
			$tot = $tot + $t;
			echo '</tr>'; 
		}
	}
 
 mysqli_close($con);
?>
  <th colspan="2">Totales</th>
      <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th> <?php
 
	echo '<input name="txt_s" type="hidden" value="'.$s.'">';
	echo '$' . number_format($s, 2, '.', ',');
	?>      </th>
    <th> <?php
 
	echo '<input name="txt_iv" type="hidden" value="'.$iv.'">';
	echo '$' . number_format($iv, 2, '.', ',');
	?>      </th>
    <th> <?php
 
	echo '<input name="txt_to" type="hidden" value="'.$tot.'">';
	echo '$' . number_format($tot, 2, '.', ',');
	?>      </th>
  </table>
  <div align="center">
    <input name="Submit5" type="Submit" value="Regresar" onClick="openpage('DI32000_PR.php','_self')">
  </div>
</form>
</body>
</html>
