<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
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>
<?php
 
$ayuda = 'DH4000A_PR.php';
include("DYAYUDA.php");
if(isset($_POST['fla_bus']) && !isset($_POST['bus_pro'])){
	$dataBus=explode("|",$_POST['fla_bus']);
	$_REQUEST['r1']=$dataBus[1];
	$_REQUEST['tbus']=$dataBus[0];
}
?>
<form name="frm1"  id="frm1"method="post">
<input type="hidden" name="fla_bus" id="fla_bus" value="<? echo trim($_REQUEST['tbus']).'|'.trim($_REQUEST['r1']);?>">
<table height="35"  align="center">
  <tr>
    <th >
        <input name="r1" type="radio" tabindex="1" value="clave" checked <? if($_REQUEST['r1']=='clave') echo 'checked';?>/>
        Buscar X Clave
        <input name="r1" type="radio" value="nombre" tabindex="2" <? if($_REQUEST['r1']=='nombre') echo 'checked';?>/>
        Buscar X Nombre<br/>
        Buscar:
        <input name="tbus" type="text"  onKeyUp="may(this)" value="<? echo $_REQUEST['tbus']?>"/>
      <input type="submit" name="bus_pro" value="Buscar" />    </th>
    </tr>
</table>
<div align="center">
	<table  border='1'>
	<tr>
		<th >CONSULTA INVENTARIO </th>
	</tr>
	<tr>
<?php

$flagBus=true;
echo '<input name="txt_bus" type="hidden" value="'.$_REQUEST['tbus'].'">';
if((isset($_POST['bus_pro']) || isset($_POST['fla_bus'])) && trim($_REQUEST['tbus'])==""){
	include('DFUNCTION.php');
	msj_java("Busqueda Invalida!!",1,"tbus");
	$flagBus=false;
}elseif($_REQUEST['r1']=="clave"){
	echo '<input name="tip_bus" type="hidden" value="clave">';
	@$result = mysqli_query($con ,"SELECT * FROM dginvent WHERE  nparte1 like '".$_REQUEST['tbus']."%'");
	
}elseif($_REQUEST['r1']=="nombre"){
	echo '<input name="tip_bus" type="hidden" value="nombre">';
	@$result = mysqli_query($con ,"SELECT * FROM dginvent WHERE  np_desc1 like '%".$_REQUEST['tbus']."%'");
}else{
	$flagBus=false;
}
?>	
	  <td>Nombre:
        <select name= "m2" onChange="javascript: document.getElementById('frm1').submit()">
          <?php
 

			if($flagBus){
				$dato=mysqli_fetch_array($result);
				if($_REQUEST['fla_bus']!=trim($_REQUEST['tbus'])."|".trim($_REQUEST['r1'])){
					$selPro=$dato['nparte1'];
				}
				else{
					$selPro=$_REQUEST['m2'];
				}		
				do{ 
					if($dato['nparte1']==$selPro){
						$dataSelPro=$dato;
						echo '<option value= "' . $dato['nparte1'] . '" selected>' . $dato["nparte1"] . ' -- ' .$dato["np_desc1"] .'</option>';
					}else{
						echo '<option value= "' . $dato['nparte1'] . '">' . $dato["nparte1"] . ' -- ' .$dato["np_desc1"] .'</option>';
					} 
				}while($dato = mysqli_fetch_array ($result) );
			}
?>
        </select></td>
	  </tr>
	<tr>
	<td><input type="submit" name="Submit2" value="Acumulados" onClick="openpage('DG22000_AC.php','_self')">
		<input type="submit" name="Submit3" value="Ver X Almacen" onClick="openpage('DG22000_IN.php','_self')">		</td>
	</tr>
<?php
 
if($flagBus){ 
		$a1 = $dataSelPro['nparte1']; 
		$a2 = $dataSelPro['np_desc1']; 
		$a3 = $dataSelPro['exi_min']; 
		$a4 = $dataSelPro['exi_max']; 
		$a5 = $dataSelPro['linea']; 
		$a6 = $dataSelPro['gpo_basico']; 
		$a7 = $dataSelPro['cve_marca']; 
		$a8 = $dataSelPro['lim_vta1']; 
		$a9 = $dataSelPro['lim_vta2']; 
		$a10 = $dataSelPro['lim_vta3']; 
		$a11 = $dataSelPro['afe_inv']; 
		$a12 = $dataSelPro['cont_nser']; 
		$a13 = $dataSelPro['cve_iva']; 
		$a14 = $dataSelPro['tip_mon']; 
		$a15 = $dataSelPro['uc_fec_doc']; 
		$a16 = $dataSelPro['uc_num_doc']; 
		$a17 = $dataSelPro['uc_pre_com']; 
		$a18 = $dataSelPro['cos_prom']; 
		$a19 = $dataSelPro['cos_prom_ant']; 
		$a20 = $dataSelPro['exi_fis']; 
		$a21 = $dataSelPro['exi_dis']; 
		$a22 = $dataSelPro['fec_bck_ord']; 
		$a23 = $dataSelPro['bck_ord']; 
		$a24 = $dataSelPro['cve_uni_com']; 
		$a25 = $dataSelPro['ven_esp1']; 
		$a26 = $dataSelPro['cve_uni_vta']; 
		$a27 = $dataSelPro['cod_pro']; 
}
@$result = mysqli_query($con ,"SELECT * FROM dgbasico WHERE gpo_basico = $a6");
while(@$dato = mysqli_fetch_array ($result))
{ 
	$al1=$dato["lim_vta1"];
	$al2=$dato["lim_vta2"];
	$al3=$dato["lim_vta3"];
}
?>
	</table>
	<?php

if(!$flagBus)
	exit();
if($flagBus){
?>	
	<table border='1'>
      <tr>
        <th><div id="capa" align="center" style="visibility:visible">
<?php
 
if (file_exists('img_pro/'.$a1.'.JPG')){ 
	echo '<img src="img_pro/'.$a1.'.JPG" width="250" height="167">';
}
?>
<center>Imagen Actual</center>
</div> </th>
        <th colspan="3"><div align="left">Clave: <?php
 echo $a1 ?></div><br><div align="left">Descripcion: 
        <?php
 echo $a2 ?></div></th>
      </tr>
      <tr>
        <th colspan="4">EXISTENCIAS</th>
      </tr>
      <tr>
        <td>Cantidad minima: </td>
        <td><?php
 echo $a3 ?>&nbsp;</td>
        <td>Cantidad Maxima </td>
        <td><?php
 echo $a4 ?>&nbsp;</td>
      </tr>
      <tr>
        <td>Existencia Fisica: </td>
        <td><?php
 echo $a20 ?>&nbsp;</td>
        <td>Existencia Disponible: </td>
        <td><?php
 echo $a21 ?>&nbsp;</td>
      </tr>
      <tr>
        <th colspan="4">PRECIOS DE VENTA X CANTIDAD </th>
      </tr>
      <tr>
        <td>Venta de 1 a 
		<?php
 echo $al1 ?>		</td>
        <td><?php
 echo '$' . number_format($a8, 2, '.', ','); ?>&nbsp;</td>
        <td>Venta de <?php
 echo $al1 + 1 ?> a <?php
 echo $al2 + 1 ?></td>
        <td><?php
 echo '$' . number_format($a9, 2, '.', ','); ?>&nbsp;</td>
      </tr>
      <tr>
        <td>Venta de <?php
 echo $al2 + 1 ?> a <?php
 echo $al3 + 1 ?></td>
        <td><?php
 echo '$' . number_format($a10, 2, '.', ','); ?>&nbsp;</td>
        <td>Venta distribuidor: </td>
        <td><?php
 echo '$' . number_format($a25, 2, '.', ','); ?>&nbsp;</td>
      </tr>
      
      
      
      <tr>
        <th colspan="4">PEDIDOS PENDIENTES </th>
      </tr>
      <tr>
        <td>Back Order </td>
        <td><?php
 echo $a23 ?>&nbsp;</td>
        <td>Fecha Back Order </td>
        <td><?php
 
		$fec1= $a22;
		include("DF20000.php");
		echo  $f_f;
		?>&nbsp;</td>
      </tr>
      <tr>
        <th colspan="4">DATOS DE VENTA Y COMPRA </th>
      </tr>
      <tr>
        <td>Iva:</td>
        <td><?php
 
		@$result = mysqli_query($con ,"SELECT * FROM dxtasiva WHERE cve_iva = $a13");
		while(@$dato = mysqli_fetch_array ($result))
		{ 
			$a1313=$dato["conc_iva"];
		}
		echo $a1313;
		 ?>&nbsp;</td>
        <td>Moneda:</td>
        <td><?php
 
		if ($a14 == "N" || $a14 == "1"){
			echo 'NACIONAL';
		}elseif($a14 == "E" || $a14 == "E"){
			echo 'EXTRANJERA';
		}
		?>&nbsp;
		<?php
 echo $a14 ?>
		</td>
      </tr>
      
      <tr>
        <td>Fecha de la ultima venta </td>
        <td>&nbsp;</td>
        <td>precio de la ultima venta </td>
        <td>&nbsp;</td>
      </tr>

<?php

mysqli_close($con);
?>
</table>
</div>
<?php

}
?>
</form>
</body>
</html>
