<?php
if (isset($_SESSION['usuario'])){
$user=$_SESSION['usuario'];
}
else{
?>
<script>
location.href="index.php?errorusuario=3";
</script>
<?php }
?>
<!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>Untitled Document</title>
<script>
function nuevo()
{window.open ('nvousuario.php');}
</script>


<link href="ucaestilos.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="950" border="0" align="center">
  <tr>
    <td><p class="style4">USUARIOS :. </p></td>
  </tr>
  <tr>
    <td><table width="100%" height="0" border="0" cellpadding="0" cellspacing="5">
      <tr>
        <td width="8%" valign="top">
          <form id="form2" name="form2" method="post" action="main.php?a=81">
            <input name="Submit" type="submit" class="boton2" value="Nuevo">
                    </form>          </td>
        <td width="2%" valign="top"><form id="form3" name="form3" method="post" action="main.php?a=82">
          <input name="Submit2" type="submit" class="boton2" value="Bitacora" />
        </form>
        </td>
        <td width="90%" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="3" align="center" valign="top"><hr width="100%" size="1" noshade="noshade" color="#0D3356"></td>
        </tr>
    </table></td>
  </tr>
</table>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><form action="svusuario.php" method="post" name="form1">
		  <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td><p class="style4">Selecciona Usuario:</p>
                <div align="center">
                  <?php if (isset($_GET['error']))
      $error=$_GET['error'];
 {

if (isset ($error))
 {
			  $error=$_GET['error'];
			  
			  if($error==1)
			  {
			  echo "<p class='style3'>ˇEl usuario seleccionado esta en uso! <br>Cierre sesión y cambie de cuenta para eliminar.</p>";
			  }
			  		  			  
}
else
{

}

}
  ?>
                </div>
                <div align="center">
	              <?php
echo "<table border=1>";
echo "<tr bgcolor='#0D3356' class='titulo' align='center'>";

echo "<td>";
echo "Usuario";
echo "</td>";

echo "<td>";
echo "Nombre";
echo "</td>";

echo "<td>";
echo "Tipo";
echo "</td>";

echo "<td>";
echo "Correo";
echo "</td>";

echo "<td>";
echo "Clinica";
echo "</td>";

echo "<td>";
echo "Editar";
echo "</td>";

echo "<td>";
echo "Eliminar";
echo "</td>";

echo "</tr>";
include ("conexion.php");
$cons="SELECT idUsuario,nombre,tipo,correo FROM usuarios" ;
$res=mysql_query($cons,$conex) or die ("No se realizo con exito la consulta de Equipos");
$numero_filas=mysql_num_rows($res);
$numero_campos= mysql_num_fields($res);
    while ($fila=mysql_fetch_row($res)){				  
         
echo "<tr align='center'>";
 for ($i=0;$i< $numero_campos;$i++){

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

}
//impresion de la clinica
$cons2="SELECT idClinica FROM usuarios Where idUsuario = '".$fila[0]."'" ;
$res2=mysql_query($cons2,$conex) or die ("No se realizo con exito la consulta de numero de clinica");
$idcli=mysql_result($res2,0,'idClinica');

$cons3="SELECT clinica FROM clinicas WHERE idClinica = '$idcli'" ;
$res3=mysql_query($cons3,$conex) or die ("No se realizo con exito la consulta de clinica");
$clinica=mysql_result($res3,0,'clinica');

echo "<td class='style1'>";
echo $clinica;
echo "</td>";

//Editar
echo "<td class='style4'>";
echo "<a href='main.php?a=84&usua="; echo $fila[0]; echo "'> <img src='img/icon_edit.jpg' border='0' ALT='Editar usuario'> </a>";
echo "</td>";
//Eliminar
echo "<td class='style4'>";
echo "<a href='deleteusuario.php?usua="; echo $fila[0]; echo "'> <img src='img/icon_delete.jpg' border='0' ALT='Eliminar usuario'> </a>";

echo "</td>";

echo "</tr>";
}
echo "</table>";
mysql_free_result($res);

?>
                </div>
                <p class="style4"></p>
                <p></p></td>
            </tr>
          </table>
		  </form></td>
  </tr>
</table>

</body>
</html>
