<?php
session_start();
if($_SESSION['tipven']==""){
	$_SESSION['tipven'] = $_POST['tip_ven'];
}
include("DMMYSQLG.php");
include("DSA1000.php");
//include("DFJSISCI.inc");
include("DF30000.inc");
include("JQUERY.inc");
$f_m="";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es-es">
<link rel="stylesheet" href="css/menu.css" type="text/css"/>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Registro con AJAX</title>
<script type="text/javascript" language="JavaScript1.2" src="RSSCRIPT.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<script language="javascript" type="text/javascript">
function objetoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
  		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function enviarDatosEmpleado(){
	//donde se mostrará lo resultados
	divResultado = document.getElementById('resultado');
	divFormulario = document.getElementById('formulario');
	//valores de los inputs
	id=document.frmempleado.idempleado.value;
	nom=document.frmempleado.nombres.value;
	
	//instanciamos el objetoAjax
	ajax=objetoAjax();
	//usando del medoto POST
	//archivo que realizará la operacion
	//actualizacion.php
	ajax.open("POST", "actualizacion.php",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar los nuevos registros en esta capa
			divResultado.innerHTML = ajax.responseText
			//mostrar un mensaje de actualizacion correcta
			divFormulario.innerHTML = "<p style=\"border:1px solid red; width:400px;\">La actualizaci&oacute;n se realiz&oacute; correctamente</p>";
		}
	}
	//muy importante este encabezado ya que hacemos uso de un formulario
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	//enviando los valores
	ajax.send("idempleado="+id+"&nombres="+nom)
}

function pedirDatos(idempleado){
	//donde se mostrará el formulario con los datos
	divFormulario = document.getElementById('formulario');
	
	//instanciamos el objetoAjax
	ajax=objetoAjax();
	//uso del medotod GET
	ajax.open("POST", "MENU_ALMACEN2.php");
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			divFormulario.innerHTML = ajax.responseText
			//mostrar el formulario
			divFormulario.style.display="block";
		}
	}
	//como hacemos uso del metodo GET
	//colocamos null
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	//enviando los valores
	ajax.send("idemp="+idempleado)
}
</script>

</head>
<body onLoad = "self.focus ();">
<div align="center"><form id="form3" name="form3" method="post" action="AL10800_PR.php" >
      <table width="529" border="0" align="center">
	  <tr>
	    <th colspan="2">SALIDAS POR ORDEN DE REQUISICION</th>
	  </tr><tr>
        <tr>
          <td colspan="2">
            <div align="center">
              <input name="r1" type="radio" value="no" tabindex="3" onClick="arriba(this.value)"/>
              <span class="Estilo1">X # De Requisicion D&nbsp;Salida&nbsp;</span>&nbsp;&nbsp;&nbsp;
<input name="r1" type="radio" value="f" tabindex="5" onClick="arriba(this.value)"/>
<span class="Estilo1">X Fecha</span> </div></td>
        </tr>
        <tr> 
          <td width="57%"> <div align="right"><span class="Estilo1">Buscar.</span>
            <input name="tt" type="text" id="tt" onKeyUp="may(this)"/>
          </div></td>
          <td width="43%">
            <input name="fec" type="text" class="emplea date" id="fec" size="20" maxlength="20"
			<?php

				if(isset($_POST['fec'])){ //este es el truco
					echo 'value="' . $_POST['fec'] .  '"';
				}
			?>onkeypress="return soloNumeros(event)"
		/>
           
            <input type="submit" name="Submit32" value="Buscar" />
          </td>
        </tr>
      </table>      
  </form> 
</div>
<form name="frm1" method="post" action="" >
<div align="center">
<?php
 $vce=(isset($cla_emp))?$cla_emp:"";
	echo '<input name="txt_empresa" type="hidden" value="'.$vce.'">';
        $vu=(isset($u))?$u:"";
echo '<input name="txt_usuario" type="hidden" value="'.$vu.'">';
	//la siguiente linea va en mysql con el nombre de la base 
	//mysqli_select_db("pp");
	//@$result = mysqli_query($con ,"SELECT * FROM dgpemema where tip_ven = '".$_SESSION['tipven']."'");
	$result = mysqli_query($con ,"SELECT * FROM dgrequie");
	?>
<table width="473" border='1' bordercolor="#FFCC00" bordercolordark="#FFCC00">
      <tr>
        <th colspan="5"> 
          <div align="center">
		  <input type="submit" name="Submit6" value="Agregar" onClick="openpage('AL10800_PR2.php','_self')" class="original">
		<input type="button" name="bot12" value="Cancelar" onClick="openpage('AL10800_EL.php','_self')" class="bot_RjR"/>
          <input type="Submit" name="bot2" value="Modificar" onClick="openpage('AL10800_MO.php','_self')" class="original"/>
          <input type="button" name="bot9" value="Desplegar"  onClick="openpage('AL10800_DE.php','_self')" class="bot_WsW"/>
          <input type="button" name="bot42" value="Imprimir" onClick="openpage('AL10800_IM.php','_self')" class="original"/>
		  </div >
   		</th></tr>
		<tr>
        <th colspan="5">
		<?php
 
		$res2 = mysqli_query($con ,"SELECT * FROM dgrequie");
		$row2 = mysqli_fetch_array($res2);
                $vrdt=(isset($row2['des_tipven']))?$row2['des_tipven']:"";
		echo ' '. $vrdt;
		?></th>
      </tr>
<tr>
        <th width="26"><div align="center">SEL.</div></th>
        <th width="65"><div align="center"># SALIDA. </div></th>
		<th width="85"><div align="center">REQUISICION.</div></th>
        <th><div align="center">FECHA. </div>          <div align="center"></div>          <div align="center"></div>          <div align="center"></div></th>
        <th width="119"><div align="center">STATUS. </div></th>
      </tr>
	<?php
$vs=(isset($_POST['submit']))?$_POST['submit']:"";
           $vpr=(isset($_POST['r1']))?$_POST['r1']:"";
	// --->
	  	$fec = isset($_POST['fec'])?$_POST['fec']:"";
		include('DF20000.php');
		$fecha_inicial = $f_m;
		//$pdf->Cell(15,5,$fecha_inicial,1,0,'C');
//		$fec = isset($_POST['fec2'])?$_POST['fec2']:"";
//		include('DF20000.php');
//		$fecha_final = $f_m;
	  // -->
	if($vs==""&&$vpr=="na")
	{
		echo '<input name="tbusqueda" type="hidden" value="na">';
	  	$result = mysqli_query($con ,"SELECT * FROM dgrequie WHERE facturado = 0 and tip_ven = '".$_SESSION['tipven']."'");
	}elseif($vs==""&&$vpr=="a"){
		echo '<input name="tbusqueda" type="hidden" value="a">';
		if($_POST['fec']==""){
			$result = mysqli_query($con ,"SELECT * FROM dgrequie WHERE facturado = 1 and tip_ven = '".$_SESSION['tipven']."'");
		}else{
			$result = mysqli_query($con ,"SELECT * FROM dgrequie WHERE facturado = 1 and fec_ven between '$fecha_inicial' and '$fecha_final' and tip_ven = '".$_SESSION['tipven']."'");
		}
		
	}elseif($vs==""&&$vpr=="no"){
		echo '<input name="tbusqueda" type="hidden" value="no">';
	  	$result = mysqli_query($con ,"SELECT * FROM dgrequie WHERE fol_ven = '".$_POST['tt']."'");
   	}elseif($vs==""&&$vpr=="f"){
		$fec = isset($_POST['tt'])?$_POST['tt']:"";
		include("DF20000.php");
		//echo $f_m;
		echo '<input name="tbusqueda" type="hidden" value="f">';
		$result = mysqli_query($con ,"SELECT * FROM dgrequie WHERE fec_ven = '$f_m'");
   	}elseif($vs==""&&$vpr=="p"){
		echo '<input name="tbusqueda" type="hidden" value="p">';
	  	$result = mysqli_query($con ,"SELECT * FROM dgrequie WHERE cod_cli = '".$_POST['tt']."' and tip_ven = '".$_SESSION['tipven']."'");
	}
	while($row = mysqli_fetch_array($result))
	{
	  	echo "<tr>";
		if ($row['cancelado'] == 1){
			echo '<td> <div align="center"  ><input name="bot" type="radio" value="'. $row['fol_ven'].'" disabled></div></td>';
		}else{
			echo '<td> <div align="center"  ><input name="bot" type="radio" value="'. $row['fol_ven'].'"></div></td>';
		}
		echo "<td> <div align='center' style=' '>" . $row['fol_ven'] . "</div></td>";
		echo "<td> <div align='center' style=' '>" . $row['folio_control'] . "</div></td>";

		//convertir fecha
		$fec1 = $row['fec_ven'];
		include("DF20000.php");
		echo "<td> <div align='center' style=' '>" . $f_f . "</div></td>";
		//echo "<td> <div align='center'>" . '$ ' . number_format($row['sub_ven'], 2, '.', ',') . "</div></td>";
		//echo "<td> <div align='center'>" . '$ ' . number_format($row['iva_ven'], 2, '.', ',') . "</div></td>";
		//echo "<td> <div align='center'>" . '$ ' . number_format($row['tot_ven'], 2, '.', ',') . "</div></td>";
		if ($row['cancelado'] == 1){
			echo '<td  style="#FF3300"> <div align="center"  >Cancelado</div></td>';
		}else{
			echo '<td> <div align="center"  >Activo</div></td>';
		}
		echo "</tr>";
		
		//fin
	}
	mysqli_close($con);
	?>
  </table>
</div>

</form>
	

</body>
</html>