<?php include('meta.php') ?>
<?php $bg_header = "bg_dieta"; include('header.php') ?>
<?php
if ($_SESSION['type_user_live'] != "Admin") {
  	echo "<script language='Javascript'> location.href='home.php';</script>";
}
?>
		<script type="text/javascript">
			    function validarForm(formulario) 
			    {
			        if(formulario.palabra.value.length==0) 
			        { //¿Tiene 0 caracteres?
			            formulario.palabra.focus();  // Damos el foco al control
			            alert('Debes rellenar este campo'); //Mostramos el mensaje
			            return false; 
			         } //devolvemos el foco  
			         return true; //Si ha llegado hasta aquí, es que todo es correcto 
			     }   
			</script>
<div id="box_body" style="padding: 0px">
	<div id="wrapper" >
		<div id="row">
<!-- left -->
			<div id="tb_left" class="bg_dieta">
				<!--    <form method="POST" action="result_diet.php" onSubmit="return validarForm(this)"> 
        		<input type="text" placeholder="Buscar paciente por cedula" name="palabra" class="input-sm"><button type="submit" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-search "></span></button>
     			</form> -->

     			<script src="js/search_ajax_diet.js" language="javascript"></script>
				<input type="text" class="caja" id="valor" onkeyup="Buscar();" placeholder="Buscar por cedula o nombre" style="width: 100%" />
				<div id="resultados"></div>


			    <p><div id="line"></div></p>
			    <div class="list-group" >
			      <a href="new_hc.php" class="list-group-item list-group-item-info" style="padding: 8px 8px 8px 15px;">
			      <span class="glyphicon glyphicon-plus "> </span> Nueva historia clinica</a>
			      <a href="user.php" class="list-group-item list-group-item-info" style="padding: 8px 8px 8px 15px;">
			      <span class="glyphicon glyphicon-user "> </span> Usuarios del sistema</a>
			      <a href="allpatient2.php" class="list-group-item list-group-item-info" style="padding: 8px 8px 8px 15px;">
			      <span class="glyphicon glyphicon-list-alt "> </span>  Ver todos los registros</a>
			    </div>
			    <div class="list-group" >
			        <a href="#" class="list-group-item list-group-item-info" style="padding: 5px 8px 5px 15px; background-color: #99B3B7; border-color: #99B3B7; color: white;"> Modulos</a>
			        <a href="home.php" class="list-group-item list-group-item-info"  style="padding: 8px 8px 8px 20px;">H.C. y Controles</a>
			        <a href="<?php if($_SESSION['type_user_live']=='Admin'){echo 'home_diet.php';} else {echo '#';} ?>" class="list-group-item list-group-item-info" style="padding: 8px 8px 8px 20px;">Programa de Alimentación</a>
			        <a href="sala_espera/" class="list-group-item list-group-item-info"  style="padding: 8px 8px 8px 20px;">Sala de Espera</a>
                 </div>
                <br /><br />                       
			</div>
<!-- END left -->
			<div id="tb_col" style="padding: 10px">
				<span class="big_title dieta">Programa de Alimentación</span><div id="line"></div><br>
				Ultimas Dietas agregadas:<br>
				<?php
					$result = mysqli_query($con,"SELECT id,name,cc,age,proceso,last_visit FROM hc_paciente ORDER BY last_visit DESC LIMIT 10");  
					echo "<table class='table table-hover'> \n"; 
					echo "
					<thead>
						<tr>
						<th style='width:250px;'>Nombre</th>
						<th style='width:150px;'>Cedula</th>
						<th style='width:80px;'>Edad </th>
						<th>Ultimo Registro </th>
						<th> </th>
						</tr>
					</thead>
					<tbody>	\n"; 
					while ($row = mysqli_fetch_row($result))
					{ 
					echo "<tr> 
							<td class='last10_1'><strong>$row[1]</strong></td>
					      	<td class='last10_1'>$row[2]</td>
					      	<td class='last10_1'>$row[3] años</td>
					      	<td class='last10_1'>$row[4]</td>
					      	<td><a class='btn btn-primary btn-sm' href='result_diet.php?id=$row[0]'><span class='glyphicon glyphicon-search '> Ver</span></a>
					      	</td>
					      </tr>";
					};
					echo " \n"; 
					echo " </tbody></table> \n"; 
				?> <div align="right"><a href="allpatient2.php" class="btn btn-primary btn-xs" style="padding: 8px 8px 8px 15px;"><span class="glyphicon glyphicon-list-alt "> </span>   Ver todos los registros</a></div>
			</div>
		</div>
	</div>
</div><!-- END body center -->
<?php include('footer.php') ?>
