<?php
session_start();
require('../45789417/ref4780.php');
if (!isset($_SESSION['userid'])) {
  echo "<script language='Javascript'> location.href='../login.php';</script>";
    exit();
  };
/* Values received via ajax */
$id = $_GET['id'];
$servicio = $_GET['ser'];
$update_status = $_GET['st'];
$cc = $_GET['cc'];

// connection to the database
require_once('4798945.php');
 // update the records
$sql = "UPDATE se_evenement SET $servicio=? WHERE id=?";
$q = $bdd->prepare($sql);
$q->execute(array($update_status,$id));
	if ($update_status == 1 AND $servicio == "CMD" || $servicio == "CMA" || $servicio == "CPA" ){
		$go_cmd= mysqli_query($con,"SELECT id,cc FROM hc_paciente WHERE cc = '$cc'");
			if ($reg = mysqli_fetch_assoc($go_cmd)){
				$id = $reg['id'];
				echo "<script type='text/javascript'>  
						window.location='../result.php?id=$id';
						</script>";			 
			} else { 
				echo "<script> window.history.back(); </script>"; /* cumple pero no es la misma cedula */
				};
	} else {
		echo "<script> window.history.back(); </script>";
	}
?>
