<?php
include ("conexion.php");
$folio=$_POST['folio'];

$cons4="SELECT * FROM requisiciones WHERE idRequisicion ='$folio'";
$res4=mysql_query($cons4,$conex) or die ("No se obtuvo el registro de requisicion");
$existe=mysql_num_rows($res4);

if ($folio == '')
{
	?>
          <script>
	location.href="main.php?a=33&error=2";
	    </script>
          <?php
}
if ($existe == '0')
{
	?>
          <script>
	location.href="main.php?a=33&error=3";
	    </script>
          <?php
}

$solicita=mysql_result($res4,0,'solicita');
$fecha=mysql_result($res4,0,'fecha');

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>UCA :.</title>
<link href="ucaestilos.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td><img src="img/top02.jpg" width="800" height="100" /></td>
  </tr>
  <tr>
    <td><p>&nbsp;</p>
      <table width="750" border="0" align="center">
        <tr>
          <td><table width="82%" border="0" align="center" cellspacing="0">
              <tr>
                <td width="23%"><hr /></td>
                <td width="54%" align="center"><span class="style7">Requisici&oacute;n de Compra </span></td>
                <td width="23%"><hr /></td>
              </tr>
            </table>
              <br />
              <table width="82%" border="1" align="center" cellspacing="2">
                <tr>
                  <td width="51%"><span class="style4">Solicita:</span><span class="style5"> <?php echo $solicita;?></span></td>
                  <td width="28%"><span class="style4">Fecha:</span> <span class="style5"><?php echo $fecha;?></span></td>
                  <td width="21%"><span class="style4">Folio:</span> <span class="style3"><?php echo $folio;?></span></td>
                </tr>
              </table>
            <p align="center" class="style7">
                <?php

echo "<table border=1>";
echo "<tr bgcolor='#0D3356' class='titulo' align='center'>";

echo "<td class='style4'>";
echo " Id ";
echo "</td>";


echo "<td class='style4'>";
echo "Nombre";
echo "</td>";

echo "<td class='style4'>";
echo "Descripci&oacute;n";
echo "</td>";


echo "<td class='style4'>";
echo "Presentaci&oacute;n";
echo "</td>";

echo "<td class='style4'>";
echo "Cantidad";
echo "</td>";


echo "</tr>";
include ("conexion.php");

	$cons3="SELECT clave,cantidad FROM contenido_requisicion WHERE idRequisicion='$folio'";
	$res3=mysql_query($cons3,$conex) or die ("No se realizo el barrido en la tabla contenido_requisicion");
	while($fila2 = mysql_fetch_array($res3))
	{		
			$query="SELECT clave,nombre,descripcion FROM productos Where clave='$fila2[0]'";
			$result=mysql_query($query,$conex) or die ("No se consultaron los productos");
			$numero_filas=mysql_num_rows($result);
			$numero_campos= mysql_num_fields($result);
			while($fila = mysql_fetch_array($result))
			{

         
echo "<tr align='center'>";

//CONSULTO NOMBRE DE LA PRESENTACION
$cons1="SELECT idPresentacion FROM  productos WHERE clave='".$fila[0]."'";
$res1=mysql_query($cons1,$conex) or die ("No consulto ID de presentacion");
$idpresen=mysql_result($res1,0,'idPresentacion');

$cons2="SELECT presentacion FROM presentaciones WHERE idPresentacion='$idpresen'";
$res2=mysql_query($cons2,$conex) or die ("No consulto nombre de presentacion");
$presen=mysql_result($res2,0,'presentacion');



/*
//IMPRIMO CHECKBOX
echo "<td class='style1'>";
echo "<input name='clave[]' type='checkbox' value='".$fila[0]."' >";
echo "</td>";
*/

//FOR DE LOS CAMPOS BUSCADOS
 for ($i=0;$i< $numero_campos;$i++)
 {

echo "<td class='style1'>";
echo $fila[$i];
echo "</td>";

}


//IMPRIMO PRESENTACION
echo "<td class='style1'>";
echo $presen;
echo "</td>";

//CANTIDAD
echo "<td class='titulo' bgcolor='#999999'>";
echo $fila2[1];
echo "</td>";

}

echo "</tr>";
}


echo "</table>";

?>
              </p>
            <table width="82%" height="87" border="1" align="center" cellspacing="2">
                <tr>
                  <td width="50%" align="center" valign="top"><span class="style4">AUTORIZA</span></td>
                  <td width="50%" align="center" valign="top"><span class="style4">Vo.Bo.</span></td>
                </tr>
              </table>
            <p align="center" class="style7">&nbsp;</p></td>
        </tr>
      </table>
      <table width="177" border="0" align="center" cellspacing="10">
        <tr>
          <td width="57" valign="top"><div align="center">
              <p>
                <input name="Submit" type="button" class="boton2" value="Imprimir" onClick="javascript:print()">
              </p>
          </div></td>
          <td width="109"><form id="form1" name="form1" method="post" action="main.php">
              <div align="center">
                <p>
                  <input name="Submit2" type="submit" class="boton2" value="Volver a inicio" />
                </p>
              </div>
          </form></td>
        </tr>
      </table>
      <p>&nbsp;</p>
      <table width="100%" border="0">
          <tr>
            <td height="22" bgcolor="#4E5B7B"><div align="center"><span class="style8">Universidad Cuauht&eacute;moc Plantel Aguascalientes </span></div></td>
          </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
