<?php include('meta.php'); ?>	
<?php $bg_header = "bg_hc"; 
include('header.php') 
?>
<?php
	if ($_GET['notbe'] == 1){
       		 echo "<div id='alert' class='alert alert-warning'>No se encuentra el paciente</div>";
            };
    if ($_GET['newhc'] == 1){
       		 echo "<div id='alert' class='alert alert-success'>Paciente creado <b>Gracias</b></div>";
            };
    if ($_GET['updatehc'] == 1){
       		 echo "<div id='alert' class='alert alert-success'>Historía clinica actualizada <b>Gracias</b></div>";
            };

    if ($_GET['newct'] == 1){
       		 echo "<div id='alert' class='alert alert-success'>Control creado <b>Gracias ".$_SESSION['name_live']."</b></div>";
            };
   if ($_GET['newct'] == 2){
       		 echo "<div id='alert' class='alert alert-success'>Control modificado <b>Gracias ".$_SESSION['name_live']."</b></div>";
            };
     if ($_GET['delpaciente'] == 1){
       		 echo "<div id='alert' class='alert alert-success'>Registro Eliminado <b>Gracias ".$_SESSION['name_live']."</b></div>";
            };
	if ($_GET['login2'] == 1){
		$t = date("H");
		if ($t < "12") {
			echo "<div id='alert' class='alert alert-info'><strong>Buenos Días!</strong> ".$_SESSION['name_live']."
 			 </div>";
		} elseif ($t < "18") {
			echo "<div id='alert' class='alert alert-info'><strong>Buenas Tardes!</strong> ".$_SESSION['name_live']."</div>";
		} else {
			echo "<div id='alert' class='alert alert-info'<strong>Buenas Noches!</strong> ".$_SESSION['name_live']."</div>";
		}
	}
?> 
			<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">
			<div id="tb_left" class="bg_hc">
			<!-- 
			    <form method="POST" action="result.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><br>
		     -->
				<script src="js/search_ajax.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="allpatient.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 />
		                        <!-- 
		                        <a href="#" >control medico</a>     <br />
		                        control de peso
		                        dietas
		                        administra users
		                        inventario
		                        facturacion
		                        Opciones master
		      crear usuario
		      editar usuario
		      eliminar
		      opcion como se entero
		      editar contraseña
		      editar info
		                        opcion
		      editar contraseña
		      editar info
		                        -->

			</div>
			<div id="tb_col" style="padding: 10px">
				<span class="big_title">H.C y Controles</span><div id="line"></div><br>
				Ultimos H.C. agregadas:<br>
				<?php
				        mysqli_select_db($con,DB_NAME) or  die('Could not connect3333: ' . mysqli_error());
					$result = mysqli_query($con,"SELECT id,name,cc,age,proceso,last_visit FROM hc_paciente ORDER BY last_visit DESC LIMIT 10");    
				/* 	$result = mysqli_query($con,"SELECT id,name,cc,age FROM hc_paciente  ORDER BY id 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-info btn-sm' href='result.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="allpatient.php" class="btn btn-info 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') ?>
