<?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.csss" 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="AL21000_PR.php" >
      <table width="625" height="76" border="0" align="center">
	  <tr>
	    <th colspan="2">CONSULTAR ENTRADAS POR FACTURA. </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 Orden De Compra.
&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="56%"> <div align="right">BUSCAR.
              <input name="tt" type="text" id="tt" onKeyUp="may(this)"/>
          </div></td>
          <td width="44%">
            
            <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="8" nowrap>
          <div align="center">
            <input type="button" name="bot42" value="Imprimir" onClick="cargapag('AL21000_IM.php','_self')"/>
            <input type="button" name="bot9" value="Desplegar"  onClick="cargapag('AL21000_DE.php','_self')"/>
            </div></th></tr>
      <tr>
        <th colspan="9">
		<?php
 
		$res2 = mysqli_query($con ,"SELECT * FROM dgreqdev WHERE fec_ven = date('d/m/Y')");
		$row2 = mysqli_fetch_array($res2);
		echo ' '. $row2['des_tipven'];
		?></th>
      </tr>
      <tr>
        <th width="39"><div align="center">SEL.</div></th>
        <th width="61"><div align="center">FOLIO. </div></th>
		<th width="127"><div align="center">ORDEN DE COMPRA.</div></th>
		<th width="74"><div align="center">FACTURA.</div></th>
        <th><div align="center">FECHA.</div>          <div align="center"></div></th>
        <!--th width="105"><div align="center">Subtotal </div></th>
        <th width="24"><div align="center">Iva</div></th-->
        <th width="85"><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 folio_control like '".$_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']=="f"){
		$fec2 = $_POST['tt'];
		include("DF20000.php");
		echo '<input name="tbusqueda" type="hidden" value="f">';
	  	$result = mysqli_query($con ,"SELECT * FROM dgreqdev WHERE fec_ven = '$f_m'");
	}
	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 "<td> <div align='center'>" . $row['folio_control'] . "</div></td>";
		echo "<td> <div align='center'>" . $row['trefe'] . "</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>
