<?php
 
session_start();
$com = "A";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DMMYSQLG.php");
require_once("DFJQUERY.inc");
include("DF30000.inc");
?>
<html>
<link rel="stylesheet" href="css/estilo1.csss" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<style type="text/css">
<!--
.Estilo19 {font-size: 16px}
.Estilo22 {font-size: 11px}
.Estilo23 {font-size: 13px}
.Estilo24 {
	font-size: 18px;
	font-weight: bold;
}
-->
</style>
<script language="javascript">
function openWindow(dataGen,valores){
	var objDate=new Date();
	var getVars,getVarsAux,distPage;
	var idVentana;
	for(getVarsAux in valores){
		getVars +='&'+getVarsAux+'='+valores['+[a-z_]+'];
	}
	if(typeof dataGen.width=='undefined') dataGen.width='800';
	if(typeof dataGen.height=='undefined') dataGen.height='600';
	distPage='?tmr='+objDate.getHours()+objDate.getMinutes()+objDate.getSeconds()+objDate.getDay()+objDate.getMonth()+objDate.getFullYear();
	idVentana=window.open(dataGen.action+distPage+getVars,dataGen.name,'width='+dataGen.width+',height='+dataGen.height+',top=100,left=50,scrollbars=yes,menubar=yes,status=yes');
	return idVentana;
}
</script>
<script language="javascript">
$(document).ready(function(){
	function formatItem(row) {
		return " (<strong>" + row[1] + "</strong>)"+row[0];
	}
	$("#tap2").autocomplete('AL10700_AU.php',{
		minChars: 1,                 //Caracteres Minimos antes de autocompletar
		//max:3                        //maximo de resultados mostrados, se manda como limit en autosugestion
		delay: 200,                  //Retardo de autocompletar 
		width: 500,                  //ancho del cuadro de despliegue
		highlight: false,            //Resalta letras coincidentes
		autoFill: false,             //autocompleta en texto la posible palabra
		scroll: true,				 //si cuadro tiene barra scroll
		scrollHeight: 300,           //alto del cuadro para el scroll
		formatItem:formatItem,	     //formato de presentacion de las posibles busquedas
		extraParams:{tipBus:'d'}     //Parametros Extra a Mandar en autosugestion
	});
});
</script>

<script language="javascript">
function ocultaMuestra(divVent){
	if(divVent.style.display=='none'){
		divVent.style.display='';

	}else{
		divVent.style.display='none';

	}
}	
	</script>
<script language="javascript">
function sumaTex(){
	var objTex1=document.getElementById('maxe'),
		objTex2=document.getElementById('entradaf'),
		objTex9=document.getElementById('suma');
	objTex9.value=(parseFloat(objTex1.value)+parseFloat(objTex2.value)).toFixed(2);
}
function sumaTexr(){
	var objTex1=document.getElementById('d1'),
		objTex2=document.getElementById('minf'),
		objTex9=document.getElementById('f1');
	objTex9.value=((parseFloat(objTex1.value)/100)*parseFloat(objTex2.value)).toFixed(2);
}
function sumaTexa(){
	var objTex1=document.getElementById('minf'),
		objTex2=document.getElementById('maxm'),
		objTex3=document.getElementById('minm'),
		objTex4=document.getElementById('minma'),
		objTex5=document.getElementById('minj'),
		objTex6=document.getElementById('maxa'),
		objTex7=document.getElementById('minag'),
		objTex8=document.getElementById('maxs'),
		objTex9=document.getElementById('mino'),
		objTex10=document.getElementById('mins'),
		objTex11=document.getElementById('mind'),
		objTex12=document.getElementById('maxd'),
		objTex13=document.getElementById('b19'),
		objTex14=document.getElementById('b110'),
		objTex15=document.getElementById('b111'),
		objTex16=document.getElementById('b112'),
		objTex17=document.getElementById('b113'),
		objTex18=document.getElementById('b114'),
		objTex19=document.getElementById('b115'),
		objTex20=document.getElementById('b116'),
		objTex21=document.getElementById('c1');
	objTex21.value=(parseFloat(objTex1.value)+parseFloat(objTex2.value)+parseFloat(objTex3.value)+parseFloat(objTex4.value)+parseFloat(objTex5.value)+parseFloat(objTex6.value)+parseFloat(objTex7.value)+parseFloat(objTex8.value)+parseFloat(objTex9.value)+parseFloat(objTex10.value)+parseFloat(objTex11.value)+parseFloat(objTex12.value)+parseFloat(objTex13.value)+parseFloat(objTex14.value)+parseFloat(objTex15.value)+parseFloat(objTex16.value)+parseFloat(objTex17.value)+parseFloat(objTex18.value)+parseFloat(objTex19.value)+parseFloat(objTex20.value)).toFixed(2);
}
</script>	
	
<body>

<form name="frm1" method="post" action="">
  <table width="501"  align="center">
    <tr>
      <th colspan="4">AGREGAR ENTRADA DE ALMACEN POR FACTURAS. </th>
    </tr>
    <tr>
      <td width="77">FOLIO DE ORDEN. </td>
      <td width="408" colspan="3"><span class="Estilo19">
      <input name="codigo" type="text" id="codigo" size="15" disabled="disabled"
		  <?php
 
		if(isset($_POST['bot'])){
		echo 'value="'.$reg['codigo'].'"';
		}
		?>
		>
      </span> <input name="Submit22" type="Button" onClick="cargapag('AL10700_AC.php','_self')" value="Guardar">
      <input type="Button" name="Submit2" value="Regresar" onClick="envia1('AL10700_PR.php','_self')"></td>
    </tr>
  </table>
  <div id="divVent" style="display:">
    <table width="929"  align="center"  >
      <tr>
        <td width="74">ORDEN DE COMPRA.</td>
        <td colspan="4"><input name="tap2" id="tap2" type="text" tabindex="2" disabled="disabled"
		  onBlur="may(this)" size="60"
		<?php

			if(isset($_REQUEST['tap2'])){ 
				echo 'value="' . $_REQUEST['tap2'] .  '"';
			}
		?>></td>
        <td colspan="4">TIPO DE COMPRA:        
          <select name="select" tabindex="18">
            <option value="CONTADO"<?php
 if($_REQUEST['select']=="CONTADO") echo 'selected';?>>CONTADO</option>
            <option value="CREDITO"<?php
 if($_REQUEST['select']=="CREDITO") echo 'selected';?>>CREDITO</option>
          </select>
          <label>
          </label></td>
      </tr>
      <tr>
        <td>PROVEEDOR.</td>
        <td colspan="4"><label></label>          <label>
          <input name="p1" type="text" id="p1" tabindex="25" size="8"
	  onBlur="may(this)"
	  		<?php

				if(isset($_POST['factor'])){ //este es el truco
					echo 'value="' . $_POST['factor'] .  '"';
				}
			?>/>
          <input name="p2" type="text" id="p2" size="50">
</label>
          <label></label></td>
        <td colspan="4"><label>
        <input name="?3" type="button" value="Buscar Proveedor" onClick="
	  	openWindow(
		{
			action:'AL10700_AG3.php',
			width:700,
			height:350
		},{
			val:'p1',
			des:'p2'
		})" >
        </label></td>
      </tr>
      <tr>
        <td>FECHA. 
        <label></label></td>
        <td><input name="gfecini" type="text" class="emplea" id="gfecini" size="15" maxlength="15"
		  <?php
 
			  	echo 'value="'.date("d/m/Y").'"'; 
			  
			  ?>
		  />
          <input name="reset2" id="bot" type="image" value"Cal" src="logos/cal4.jpg" />
          <script type="text/javascript">
				  	Calendar.setup(
    					{
      						inputField  : "gfecini",        // ID of the input field
      						ifFormat    : "%d/%m/%Y",    // the date format
      						button      : "bot"      // ID of the button
    					}
  					);
				                </script></td>
        <td><label>FACTURA.</label></td>
        <td width="201"><input name="capacidad" type="text" id="capacidad" tabindex="25" size="20"
	  onBlur="may(this)"
	  		<?php

				if(isset($_POST['capacidad'])){ //este es el truco
					echo 'value="' . $_POST['capacidad'] .  '"';
				}
			?>/></td>
        <td colspan="2"><label>TOTAL DE ARTICULOS: </label></td>
        <td colspan="2"><label>
          <input type="text" name="textfield22">
        </label></td>
      </tr>
      <tr>
        <th>&nbsp;</th>
        <th>&nbsp;</th>
        <th width="69">&nbsp;</th>
        <th>TOTALES:</th>
        <th colspan="2"><label>
          <input name="c1" type="text" id="c1" size="10">
        </label></th>
        <th>&nbsp;</th>
        <th width="86" colspan="2">&nbsp;</th>
      </tr>
      <tr>
        <td colspan="9"><input name="?32" type="button" onClick="
	  	openWindow(
		{
			action:'AL10900_AG1.php',
			width:700,
			height:350
		},{
			val:'entradae',
			des:'salidae',
			por:'entradaf',
			mel:'salidaf'
		})" value="Buscar Articulo" >
        <input name="Submit222" type="Button" onClick="cargapag('AL10900_AC.php','_self')" value="Agregar">
        <input type="button" name="bot2" value="Modificar" onClick="cargapag('AL10900_MO.php','_self')"/>
        <input type="button" name="bot3" value="Quitar" onClick="cargapag('AL10900_EL.php','_self')"/></td>
      </tr>
    
      <tr>
        <th><span class="Estilo23">CODIGO.</span></th>
        <th width="216">DESCRIPCION.</th>
        <th>CANTIDAD.</th>
        <th>COSTO.        </th>
        <th colspan="2"><span class="Estilo23">IMPORTE.</span></th>
        <th>DESCUENTO.</th>
        <th colspan="2">%IMP</th>
      </tr>
      <tr>
        <td><input name="entradae" type="text" id="entradae" tabindex="25" size="12"/></td>
        <td><input name="salidae" type="text" id="salidae" tabindex="25" size="35"/></td>
        <td><input name="maxe" type="text" id="maxe" tabindex="25" size="10" onKeyUp="sumaTex()" value="0"/></td>
        <td><input name="entradaf" type="text" id="entradaf" tabindex="25" size="10" />
            <span class="Estilo24">x
              <input name="salidaf" type="text" id="salidaf" tabindex="25" size="12"/>
          </span></td>
        <td colspan="2"><input name="minf" type="text" id="minf" tabindex="25" size="10" onKeyUp="sumaTexa()" value="0" /></td>
        <td width="145"><label>
          <input name="d1" type="text" id="d1" size="6" onKeyUp="sumaTexr()" value="0">
          <input name="f1" type="text" id="f1" size="8">
        </label></td>
        <td colspan="2"><input name="e1" type="text" id="e1" size="10"></td>
      </tr>
    </table>
	  <table align="center">
<?php
 
	$sql = mysqli_query($con ,"SELECT * FROM fextra where maxe = '0'");
	include("DE10000.php");
	?>
      <tr>
        <th colspan="19"> <div align="center">VISTA PREVIA.          <span class="Estilo24">
          <input name="loco" type="text" id="loco" tabindex="25" size="12"/>
          </span></div>
        <div align="right"></div></th>
      </tr>
      <tr>
        <th width="86" height="21"  nowrap><div align="center">SEL</div></th>
        <th width="76" colspan="1"  nowrap>ARTICULOS.</th>
        <th width="54"  nowrap>CODIGO.</th>
        <th width="124" colspan="1"  nowrap>DESCRIPCION. </th>
        <th width="72"  nowrap>CANTIDAD. </th>
		<th width="88" colspan="1"  nowrap>COSTO.</th>
		<th width="83"  nowrap>IMPORTE.</th>
		<th width="87"  nowrap>DESCUENTO. </th>
        <th width="79" colspan="2"  nowrap>I.V.A.</th>
      </tr>
	  
     <?php

	echo '<input name="txt_bus" type="hidden" value="'.$_POST['tbus'].'">';
	if($_POST['r1']=="")
	{
		echo '<input name="tip_bus" type="hidden" value="nombre">';
		@$sql = mysqli_query($con ,"SELECT * FROM fextra WHERE np_desc1 like '%".$_POST['tbus']."%'");
	}
	while($reg = mysqli_fetch_array($sql))
	{
	  	echo "<tr>";
		echo '<td> <div align="center"><input name="bot" type="radio" value="'. $reg["n_reg"].'"></div></td>';
		echo "<td> <div align='center'>" . $reg["n_reg"] . "&nbsp;</div></td>";
		echo "<td> <div align='center'>" . $reg["entradae"] . "&nbsp;</div></td>";
		echo "<td> <div align='center'>" . $reg["salidae"] . "&nbsp;</div></td>";
		echo "<td> <div align='center'>" . $reg["maxe"] . "&nbsp;</div></td>";
		echo "<td> <div align='center'>" . $reg["entradaf"] . "&nbsp;</div></td>";
		//$fec1=$reg["gfecini"];
		//include('DF20000.php');
		//echo "<td> <div align='center'>" . $f_f . "&nbsp</div></td>";
		//echo "<td> <div align='center'>" . $reg["salidaf"] . "&nbsp;</div></td>";
		echo "<td> <div align='center'>" . $reg["minf"] . "&nbsp;</div></td>";
		//echo "<td> <div align='center'>" . $reg["d1"] . "&nbsp;</div></td>";
		echo "<td> <div align='center'>" . $reg["f1"] . "&nbsp;</div></td>";
		echo "<td> <div align='center'>" . $reg["e1"] . "&nbsp;</div></td>";
		echo "</tr>";
	}
	?>
	</table>
  </div>
</form>
</body>
</html>
<?php
 mysqli_close($con);?>
