<?php
session_start();
require('45789417/ref4780.php');
if (!isset($_SESSION['userid'])) {
  echo "<script language='Javascript'> location.href='login.php';</script>";
    exit();
  };
  if ($_SESSION['type_user_live'] == "Paciente") {
   	echo "<script type='text/javascript'>  
	window.location='paci_virtual/index.php';
	</script>";
    }
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8"> 
<title>Historia Clínica, Clínica Los Robles</title>
</head>
<body>
<?php
$id = $_POST['id'];
$n_diet = $_POST['diet_paciente'];
$dieta_creada =  $_SESSION['name_live'];
$minutes_20 = $_POST['minutes_20'];
$lunch = $_POST['lunch51'];
$lunch_carnes = $_POST['lunch_carnes51a'].$_POST['lomo_res51']."<br>".$_POST['lunch_carnes51c'];
$lunchmt = $_POST['lunchmt51'];
$desamm = $_POST['desamm51'];
$cena = $_POST['cena51'];
$observacion = "";
$before_sleep = "";
$redu_ab_alto = $_POST['redu_alto51'];
$redu_ab_medio = $_POST['redu_medio51'];
$redu_ab_bajo = $_POST['redu_bajo51'];
$redu_grasa = $_POST['redu_grasa51'];
$redu_peso = $_POST['redu51'];
$redu_pesokg = $_POST['redu_kg51'];
$positivo = $_POST['positivo'];
$negativo = $_POST['negativo'];
// desayuno
		if($_POST['y_splenda51_1'] == 1){
		$y_splenda51 = $_POST['desa51_4']."<br>";	
		} else {
		$y_splenda51 = "";
		}
$desayuno = $_POST['desa51_1']."<br>".$_POST['desa51_2']."<br>".$_POST['desa51_3'].$y_splenda51;
// lunch bebida
		if($_POST['y_splenda51_2'] == 1){
		$y_splenda51_2 = $_POST['splenda51_2']."<br>";	
		} else {
		$y_splenda51_2 = "";
		}
		if($_POST['y_lot_fruta51'] == 1){
		$y_lot_fruta51 = $_POST['lot_fruta51']."<br>";	
		} else {
		$y_lot_fruta51 = "";
		}
		if($_POST['y_lot_soda51'] == 1){
		$y_lot_soda51 = $_POST['lot_soda51'];	
		} else {
		$y_lot_soda51 = "";
		}
$lunch_bebida = $_POST['lunch_bebida51'].$y_lot_fruta51.$y_splenda51_2.$y_lot_soda51;
$query = mysqli_query($con,"INSERT INTO dieta (id, n_diet, desayuno, desamm, lunch, lunch_carnes, lunch_bebida, lunchmt, cena, before_sleep, observacion, redu_ab_alto, redu_ab_medio, redu_ab_bajo, redu_grasa, redu_peso, redu_pesokg,  dieta_creada, positivo, negativo, minutes_20)
VALUES
('$id','$n_diet','$desayuno','$desamm','$lunch','$lunch_carnes','$lunch_bebida','$lunchmt','$cena','$before_sleep','$observacion','$redu_ab_alto','$redu_ab_medio','$redu_ab_bajo','$redu_grasa','$redu_peso','$redu_pesokg','$dieta_creada','$positivo','$negativo','$minutes_20');");
$proceso =  "Dieta ".$n_diet;
$last_visit = date("Y-m-d H:i:s");
$query = mysqli_query($con,"UPDATE hc_paciente SET proceso = '$proceso' WHERE id = '$id'");
$query = mysqli_query($con,"UPDATE hc_paciente SET last_visit = '$last_visit' WHERE id = '$id'");
/*** update sala de espera si es paciente virtual */
$query2 = mysqli_query($con,"UPDATE user SET sala_espera='' WHERE id_hc = '$id'");
echo "<script type='text/javascript'>  
window.location='home_diet.php?newct=1';
</script>";
?>

</body>
</html>