<?php
 
session_start();
include("DMMYSQLG.php");
@$resultado2=mysqli_fetch_array(mysqli_query($con ,"SELECT nparte1,np_desc1 FROM ctarea WHERE ctarea.modulo='".$_SESSION['mod_sis']."' AND   nparte1 like '".$_POST['bot']."'"));
?>
<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" method="post" action="">
  <table border='1' align="center">
    <tr>
      <th colspan="13">CARDEX DE <?php echo $resultado2['nparte1'].'-'.$resultado2['np_desc1']?></th>
    </tr>
    <tr>
	  <th><div align="center">Producto</div></th>
	  <th><div align="center">Fecha</div></th>
      <th><div align="center">Tipo de Mov</div></th>
      <th><div align="center">Documento</div></th>
      <th><div align="center">Almacen</div></th>
	  <th><div align="center">Existencia Inicial</div></th>
	  <th><div align="center">Entradas</div></th>
	  <th><div align="center">Salidas</div></th>
	  <th><div align="center">Costo Promedio</div></th>
      <th><div align="center">Existencia Final</div></th>
    </tr>
<?php
 
//echo $_POST['bot'];
@$result = mysqli_query($con ,"SELECT * FROM dginvacu WHERE n_reg = '".$_POST['bot1']."' order by n_reg");
while(@$dato = mysqli_fetch_array ($result))
{ 
	$npa2 = $dato["nparte1"];
	$axo2 = $dato["axo"];
	$mes2 = $dato["mes"];
	$ini2 = $dato["exi_ini"];
	$fin2 = $dato["exi_fin"];
}	
$exiIni=$ini2;

$fecha1 = date("m/d/Y",mktime(0,0,0,$mes2,1,$axo2));
$a = substr($fecha1,6);
$m = substr($fecha1,0,2);
$d = substr($fecha1,3,2);
$date = $a . "-" . $m . "-" . $d;
$date1 = date("Y-m-d" , strtotime($date));
$fecha1 = $date1;
$fecha2 = date("m/d/Y",mktime(0,0,0,$mes2+1,1-1,$axo2));
$a = substr($fecha2,6);
$m = substr($fecha2,0,2);
$d = substr($fecha2,3,2);
$date = $a . "-" . $m . "-" . $d;
$date1 = date("Y-m-d" , strtotime($date));
$fecha2 = $date1;
//echo $fecha1.'<br>';
//echo $fecha2.'<br>';
@$result = mysqli_query($con ,"SELECT * FROM dgcardex WHERE nparte1 like '$npa2' && fec_mov BETWEEN '$fecha1' AND '$fecha2' order by n_reg");
while(@$row = mysqli_fetch_array($result))
	{	
	echo '<tr>';
		  echo "<td><div align='center'>" . $row["nparte1"]  . "&nbsp;</div></td>";
		  echo "<td><div align='center'>" . $row["fec_mov"] . "&nbsp;</div></td>";
		  echo "<td><div align='center'>" . $row["tip_mov"] . "&nbsp;</div></td>";
		  echo "<td><div align='center'>" . $row["num_fol"]  . "&nbsp;</div></td>";
		  echo "<td><div align='center'>" . $row["almacen"] . "&nbsp;</div></td>";
		  echo "<td><div align='center'>" .  $exiIni . "&nbsp;</div></td>";
		  echo "<td><div align='center'>" . $row["mov_ent"] . "&nbsp;</div></td>";
		  echo "<td><div align='center'>" . $row["mov_sal"]  . "&nbsp;</div></td>";
		  echo "<td><div align='center'>" . $row["cos_pro_mov"] . "&nbsp;</div></td>";
		  echo "<td><div align='center'>" . ($exiIni +=($row["mov_ent"]-$row["mov_sal"])) . "&nbsp;</div></td>";
	echo '</tr>';
	}
	mysqli_close($con);
	echo '<input name="m2" type="hidden" value="' . $_POST['bot'] . '"/>';
?>
  </table>
  <div align="center">
    <input type="submit" name="Submit2" value="Regresar" onClick="openpage('cat_areas_AC1.php','_self')">
  </div>
</form>

</body>
</html>
