<?php
 
session_start();
if($_SESSION['tipven']==""){
	$_SESSION['tipven'] = $_POST['tip_ven'];
}
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
?>
<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 = 'DI3200A_PR.php';
include("DYAYUDA.php");
?>
	<form id="form3" name="form3" method="post" action="DI32000_PR.php" >
      <table width="714" border="0" align="center">
	  <tr>
	    <th colspan="2">ENTRADAS VARIAS </th>
	  </tr><tr>
        <tr>
          <td colspan="2">
            <div align="center">
              <input name="r1" type="radio" value="no" tabindex="3" onClick="arriba(this.value)"/>
X # de Requisicion Entrada
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="r1" type="radio" value="f" tabindex="5" onClick="arriba(this.value)"/>
X Fecha </div></td>
        </tr>
        <tr>
          <td width="29%"> Buscar:
              <input name="tt" type="text" id="tt" onKeyUp="may(this)"/>
          </td>
          <td width="71%">De:
             
            <input name="fec" type="text" class="emplea" id="fec" size="20" maxlength="20"
			<?php

				if(isset($_POST['fec'])){ //este es el truco
					echo 'value="' . $_POST['fec'] .  '"';
				}
			?>onkeypress="return soloNumeros(event)"//solo fechas
		/>
            <input name="bot" id="bot" type="image" value="Cal" src="logos/cal4.jpg" />
            <script type="text/javascript">
  Calendar.setup(
    {
      inputField  : "fec",        // ID of the input field
      ifFormat    : "%d/%m/%Y",    // the date format
      button      : "bot"      // ID of the button
    }
  );
            </script>

            A:
            
            <input name="fec2" type="text" class="emplea" id="fec2" size="20" maxlength="20"
			<?php

				if(isset($_POST['fec2'])){ //este es el truco
					echo 'value="' . $_POST['fec2'] .  '"';
				}
			?>onkeypress="return soloNumeros(event)"//solo fechas
		/>
            <input name="bot1" id="bot1" type="image" value="Cal" src="logos/cal4.jpg"/>
            <script type="text/javascript">
  Calendar.setup(
    {
      inputField  : "fec2",        // ID of the input field
      ifFormat    : "%d/%m/%Y",    // the date format
      button      : "bot1"      // ID of the button
    }
  );
            </script>
            <input type="submit" name="Submit32" value="Buscar" />
          </td>
        </tr>
      </table>
       
  </form>
<div align="center">
  <form name="frm1" id="frm1" method="post" action="">

    <?php
 
echo '<input name="txt_empresa" type="hidden" value="'.$cla_emp.'">';
echo '<input name="txt_usuario" type="hidden" value="'.$u.'">';
	//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 dgreqdev");
	?>
<table border='1'>
      <tr>
        <th colspan="9" nowrap><div align="left">
          
          <input type="submit" name="Submit6" value="Agregar" onClick="openpage('DI32000_PR2.php','_self')">
		  <input type="button" name="bot12" value="Cancelar" onClick="openpage('DI32000_EL.php','_self')"/>
          <input type="Submit" name="bot2" value="Modificar" onClick="openpage('DI32000_MO.php','_self')"/>
          <input type="button" name="bot9" value="Desplegar"  onClick="openpage('DI32000_DE.php','_self')"/>
          <input type="button" name="bot42" value="Imprimir" onClick="openpage('DI32000_IM.php','_self')"/>
        </div></th>
      </tr>
      <tr>
        <th colspan="9">
		<?php
 
		$res2 = mysqli_query($con ,"SELECT * FROM dgreqdev");
		$row2 = mysqli_fetch_array($res2);
		echo ' '. $row2['des_tipven'];
		?></th>
      </tr>
      <tr>
        <th><div align="center">Sel</div></th>
        <th><div align="center">N&uacute;m. Ent. </div></th>
		<th><div align="center">Tipo Entrada</div></th>
		<th><div align="center">Fecha Entrada</div></th>
        <th><div align="center">Fecha</div></th>
        <th><div align="center">Subtotal </div></th>
        <th><div align="center">Iva</div></th>
        <th><div align="center">Total </div></th>
		<th><div align="center">Status </div></th>
      </tr>
      <?php

	  // --->
	  	$fec = $_POST['fec'];
		include('DF20000.php');
		$fecha_inicial = $f_m;
		//$pdf->Cell(15,5,$fecha_inicial,1,0,'C');
		$fec = $_POST['fec2'];
		include('DF20000.php');
		$fecha_final = $f_m;
	  // -->
	if($_POST['r1']=="na")
	{
		echo '<input name="tbusqueda" type="hidden" value="na">';
	  	$result = mysqli_query($con ,"SELECT * FROM dgreqdev WHERE facturado = 0 and tip_ven = '".$_SESSION['tipven']."'");
	}elseif($_POST['r1']=="a"){
		echo '<input name="tbusqueda" type="hidden" value="a">';
		if($_POST['fec']==""){
			$result = mysqli_query($con ,"SELECT * FROM dgreqdev WHERE facturado = 1 and tip_ven = '".$_SESSION['tipven']."'");
		}else{
			$result = mysqli_query($con ,"SELECT * FROM dgreqdev WHERE facturado = 1 and fec_ven between '$fecha_inicial' and '$fecha_final' and tip_ven = '".$_SESSION['tipven']."'");
		}
		
	}elseif($_POST['r1']=="no"){
		echo '<input name="tbusqueda" type="hidden" value="no">';
	  	$result = mysqli_query($con ,"SELECT * FROM dgreqdev WHERE fol_ven = '".$_POST['tt']."'");
   	}elseif($_POST['r1']=="f"){
		$fec = $_POST['tt'];
		include("DF20000.php");
		//echo $f_m;
		echo '<input name="tbusqueda" type="hidden" value="f">';
		$result = mysqli_query($con ,"SELECT * FROM dgreqdev WHERE fec_ven = '$f_m'");
   	}elseif($_POST['r1']=="p"){
		echo '<input name="tbusqueda" type="hidden" value="p">';
	  	$result = mysqli_query($con ,"SELECT * FROM dgreqdev 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'>" . $row['fol_ven'] . "</div></td>";
		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'];
		
		echo "<td> <div align='center'>" . $registro['des_tipcar'] . "</div></td>";
		echo "<td> <div align='center'>" . $row['fec_ven'] . "</div></td>";
		//convertir fecha
		$fec1 = $row['fec_ven'];
		include("DF20000.php");
		echo "<td> <div align='center'>" . $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>
  </form>
</div>
</body>
</html>
