<?php session_start();
if(!empty($_SESSION['user_connect_id']))
{ require('../../config.php');

date_default_timezone_set('Africa/Algiers');
$d_aj=date('Y-m-d H:i:s');

if(isset($_POST['fns'])){$fns=1;}else{$fns=0;}
if(isset($_POST['feritne'])){$feritne=1;}else{$feritne=0;}
if(isset($_POST['groupage_sanguin'])){$groupage_sanguin=1;}else{$groupage_sanguin=0;}
if(isset($_POST['glecemie'])){$glecemie=1;}else{$glecemie=0;}
if(isset($_POST['hba1c'])){$hba1c=1;}else{$hba1c=0;}
if(isset($_POST['hgpo'])){$hgpo=1;}else{$hgpo=0;}
if(isset($_POST['uree_creatinemie'])){$uree_creatinemie=1;}else{$uree_creatinemie=0;}
if(isset($_POST['ecbu'])){$ecbu=1;}else{$ecbu=0;}
if(isset($_POST['proteinurie'])){$proteinurie=1;}else{$proteinurie=0;}
if(isset($_POST['microalbuminurie'])){$microalbuminurie=1;}else{$microalbuminurie=0;}
if(isset($_POST['vs'])){$vs=1;}else{$vs=0;}
if(isset($_POST['crp'])){$crp=1;}else{$crp=0;}
if(isset($_POST['fibrinogene'])){$fibrinogene=1;}else{$fibrinogene=0;}
if(isset($_POST['tgo_tgp'])){$tgo_tgp=1;}else{$tgo_tgp=0;}
if(isset($_POST['phosphatase_alcalines'])){$phosphatase_alcalines=1;}else{$phosphatase_alcalines=0;}
if(isset($_POST['gamma_gt'])){$gamma_gt=1;}else{$gamma_gt=0;}
if(isset($_POST['bilirubinemie_total'])){$bilirubinemie_total=1;}else{$bilirubinemie_total=0;}
if(isset($_POST['bilirubinemie_conjugue'])){$bilirubinemie_conjugue=1;}else{$bilirubinemie_conjugue=0;}
if(isset($_POST['bilirubinemie_non_conjugue'])){$bilirubinemie_non_conjugue=1;}else{$bilirubinemie_non_conjugue	=0;}
if(isset($_POST['cholesterol'])){$cholesterol=1;}else{$cholesterol=0;}
if(isset($_POST['hdl_cholesterol'])){$hdl_cholesterol=1;}else{$hdl_cholesterol=0;}
if(isset($_POST['ldl_cholesterol'])){$ldl_cholesterol=1;}else{$ldl_cholesterol=0;}
if(isset($_POST['triglyceride'])){$triglyceride=1;}else{$triglyceride=0;}
if(isset($_POST['tp'])){$tp=1;}else{$tp=0;}
if(isset($_POST['tck'])){$tck=1;}else{$tck=0;}
if(isset($_POST['kaltemie_natremie'])){$kaltemie_natremie=1;}else{$kaltemie_natremie=0;}
if(isset($_POST['calcemie_phosphoremie'])){$calcemie_phosphoremie=1;}else{$calcemie_phosphoremie=0;}
$autres_bilans=mysqli_real_escape_string($con,htmlspecialchars(trim($_POST['autres_bilans']))) ;

$id_bilan=mysqli_real_escape_string($con,htmlspecialchars(trim($_POST['id_bilan']))) ;
$id_consult=mysqli_real_escape_string($con,htmlspecialchars(trim($_POST['id_consult']))) ;

$sql1 = "UPDATE bilans SET
         fns='$fns',
         feritne='$feritne',
         groupage_sanguin='$groupage_sanguin',
         glecemie='$glecemie',
         hba1c='$hba1c',
         hgpo='$hgpo',
         uree_creatinemie='$uree_creatinemie',
         ecbu='$ecbu',
         proteinurie='$proteinurie',
         microalbuminurie='$microalbuminurie',
         vs='$vs',
         crp='$crp',
         fibrinogene='$fibrinogene',
         tgo_tgp='$tgo_tgp',
         phosphatase_alcalines='$phosphatase_alcalines',
         gamma_gt='$gamma_gt',
         bilirubinemie_total='$bilirubinemie_total',
         bilirubinemie_conjugue='$bilirubinemie_conjugue',
         bilirubinemie_non_conjugue='$bilirubinemie_non_conjugue',
         cholesterol='$cholesterol',
         hdl_cholesterol='$hdl_cholesterol',
         ldl_cholesterol='$ldl_cholesterol',
         triglyceride='$triglyceride',
         tp='$tp',
         tck='$tck',
         kaltemie_natremie='$kaltemie_natremie',
         calcemie_phosphoremie='$calcemie_phosphoremie',
         autres_bilans='$autres_bilans',


        date_creation='$d_aj'
        where id_bilan='$id_bilan'";
 $result1= mysqli_query($con,$sql1) or die('Query privacy_stars failed: ' . mysqli_error($con));       
$sql2 = "INSERT INTO consultation_bilan (id_consult,id_bilan) VALUES ('$id_consult','$id_bilan')";
 
$result2= mysqli_query($con,$sql2) or die('Query privacy_stars failed: ' . mysqli_error($con));

 if($result1){
  echo 1;
  } else {
echo 0;
 }

    }

?>