<?php 
if(!empty($_SESSION['user_connect_id']))
{ 

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

if(isset($_GET['id_consult'])){
  

  $id_consult=$_GET['id_consult'];

$sql0 = "INSERT INTO bilans (date_creation) VALUES ('$d_aj')";
 
$result0= mysqli_query($con,$sql0) or die('Query privacy_stars failed: ' . mysqli_error($con));
$id_bilan = mysqli_insert_id($con);

  $req_get_p="SELECT *  FROM patients as p, consultations as c where c.id_patient=p.id and c.id='$id_consult' ";}
  $query_get_p=mysqli_query($con,$req_get_p);

  $row_p= mysqli_fetch_array($query_get_p);

 ?>

 <h4 class="title"><i class="fa fa-building"></i> Ajouter Bilan "<span class="title-name"><?php echo $row_p['nom']." ".$row_p['prenom']; ?><span>"</h4>
 	<div class="row">
          		<div class="col-lg-12">
                  <div class="form-panel">
                   	<form id="add-form" method="" class="form-horizontal" action=""  enctype="multipart/form-data">
              	     <div class="form-group">
                      <div class="col-sm-3 col-xs-12">
                      <label>patient</label>
        
                    
                       
                     
              <select name="id_patient" class="form-control" disabled>
                 <?php 
                 
             ?>


                <option value="<?php echo $row_p['id'] ?>" ><?php echo $row_p['nom']." ".$row_p['prenom'] ; ?></option>
                </select>


               
                                    </div>
                                    </div> 

            <div class="col-sm-2 col-xs-12">
             <div class="col-sm-12 col-xs-12">

                    <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="fns">FNS</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="fns" name="fns" value="FNS" >
                           </div>
                    </div>  
                   <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="feritne">FERRITINE</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="feritne" name="feritne" value="FERRITINE" >
                           </div>
                   </div> 
             
                  

                        <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="groupage_sanguin">Groupage Sanguin</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="groupage_sanguin" name="groupage_sanguin" value="Groupage Sanguin" >
                           </div>
                   </div> 
             
                   <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="fns">Glycémie</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="glecemie" name="glecemie" value="Glycémie" >
                           </div>
                    </div>
                    
                     <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="fns">HBA1C</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="hba1c" name="hba1c" value="HBA1C">
                           </div>
                    </div>  
                     <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="fns">HGPO</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="hgpo" name="hgpo" value="hgpo" >
                           </div>
                    </div>  
                     <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="fns">Urée Créatinémie</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="uree_creatinemie" name="uree_creatinemie" value="Urée Créatinémie" >
                           </div>
                    </div> 



             </div>          
             </div> 

     <div class="col-sm-2 col-xs-12">
             <div class="col-sm-12 col-xs-12">

                    <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="fns">ECBU</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="ecbu" name="ecbu" value="ECBU" >
                           </div>
                    </div>  
                   <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="feritne">Protéinurie</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="proteinurie" name="proteinurie" value="Protéinurie" >
                           </div>
                   </div> 
             
                  

                        <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="groupage_sanguin">Microalbuminurie</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="	microalbuminurie" name="microalbuminurie" value="Microalbuminurie" >
                           </div>
                   </div> 
             
                   <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="fns">vs</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="vs" name="vs" value="vs" >
                           </div>
                    </div>
                    
                     <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="fns">CRP</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="crp" name="crp" value="CRP">
                           </div>
                    </div>  
                     <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="fns">Fibrinogène</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="fibrinogene" name="fibrinogene" value="Fibrinogène" >
                           </div>
                    </div>  
                     <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="tgo_tgp">TGO-TGP</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="tgo_tgp" name="tgo_tgp" value="TGO-TGP" >
                           </div>
                    </div> 



             </div> 
             </div> 

              <div class="col-sm-2 col-xs-12">
             <div class="col-sm-12 col-xs-12">

                    <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="phosphatase_alcalines">Phosphatases alcalines</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="phosphatase_alcalines" name="phosphatase_alcalines" value="Phosphatases alcalines" >
                           </div>
                    </div>  
                   <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="gamma_gt">Gamma GT</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="gamma_gt" name="gamma_gt" value="Gamma GT" >
                           </div>
                   </div> 
             
                  

                        <div class="form-group">    

                          <label class="form-check-label" >Bilirubine</label>


                         <div class="col-sm-12 col-xs-12">
                            <div class="form-check form-check-inline">
                               <label class="form-check-label" for="bilirubinemie_total">Totale</label>
                               <input class="form-check-input checkbox1" type="checkbox" id="bilirubinemie_total" name="bilirubinemie_total" value="Bilirubine totale" >
                            </div>
                   
                  
                             <div class="form-check form-check-inline">
                      
                               <label class="form-check-label" for="bilirubinemie_conjugue">Conjuguée</label>
                                <input class="form-check-input checkbox1" type="checkbox" id="bilirubinemie_conjugue" name="bilirubinemie_conjugue" value="Bilirubine conjuguée" >
                            </div>
                                      
                            <div class="form-check form-check-inline">
                      
                               <label class="form-check-label" for="bilirubinemie_non_conjugue">Non conjuguée </label>
                                <input class="form-check-input checkbox1" type="checkbox" id="bilirubinemie_non_conjugue" name="bilirubinemie_non_conjugue" value="Bilirubine non conjuguée">
                            </div>
                          </div>
                     </div> 
                    
                       <div class="form-group">    

                          <label class="form-check-label" >Cholestérol</label>


                         <div class="col-sm-12 col-xs-12">
                            <div class="form-check form-check-inline">
                               <label class="form-check-label" for="hdl_cholesterol"> HDL Cholestérol</label>
                               <input class="form-check-input checkbox1" type="checkbox" id="hdl_cholesterol" name="hdl_cholesterol" value="HDL Cholestérol" >
                            </div>
                   
                  
                             <div class="form-check form-check-inline">
                      
                               <label class="form-check-label" for="ldl_cholesterol">LDL Cholestérol </label>
                                <input class="form-check-input checkbox1" type="checkbox" id="ldl_cholesterol" name="ldl_cholesterol" value="LDL Cholestérol" >
                            </div>
                                      
                          
                          </div>
                     </div> 



             </div> 
             </div> 
              <div class="col-sm-2 col-xs-12">
             <div class="col-sm-12 col-xs-12">

                    <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="triglyceride">Triglycérides</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="triglyceride" name="triglyceride" value="Triglycerides" >
                           </div>
                    </div>  
                   <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="tp">TP</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="tp" name="tp" value="TP" >
                           </div>
                   </div> 
                    <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="tck">TCK</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="tck" name="tck" value="TCK" >
                           </div>
                   </div> 
                   <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="kaltemie_natremie">Kaliémie</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="kaltemie_natremie" name="kaltemie_natremie" value="Kaliemie" >
                           </div>
                   </div> 
                   <div class="form-group">                      
                       <div class="form-check form-check-inline">
                      
                           <label class="form-check-label" for="calcemie_phosphoremie">Calcémie-Phosphorémie</label>
                            <input class="form-check-input checkbox1" type="checkbox" id="calcemie_phosphoremie" name="calcemie_phosphoremie" value="Calcemie-Phosphoremie" >
                           </div>
                   </div> 
                     <div class="form-group">                      
                   
                      <label>Autres bilans</label>
                      <textarea class="form-control" id="autres_bilans" name="autres_bilans" rows="2" aria-invalid="false">        
                      </textarea> 
                        
                   </div> 
</div></div>

 <div class="col-sm-2 col-xs-12">
                  </div> 
              <div class="form-group">
                        
              <input type="hidden"   class="form-control"  id="id_consult" name="id_consult" value="<?php echo $id_consult; ?>">
                <input type="hidden" id="id_bilan" name="id_bilan" value="<?php echo $id_bilan; ?>"> 
                <div class="col-sm-12 col-xs-12">
                 <div class="col-sm-1 col-xs-12">
                          <input type="button"  class="btn btn-secondary btn-block" value="back" onclick="history.go(-1)" style="padding: 12px 12px !important;margin: 30px 0px;">
                          </div>
                 <div class="col-sm-1 col-xs-12">
              <input type="submit" id="Ajouter" class="btn btn-primary btn-block"  value="Ajouter">
                       </div>
                 <div class="col-sm-1 col-xs-12">
		<a href="pages/bilan/bilan.php?id_bilan=<?php echo $id_bilan;?>&id_patient=<?php echo $row_p['id_patient'] ;?>" class="btn btn-info btn-block print">Print</a>


            

                 </div>
                            
                 
                     </div>
             </div>

                <div class="input-group message col-sm-6" id="mess">

              </div>
              	</form>



<script type="text/javascript" src="assets/js/jquery.validate.js"></script>
<script type="text/javascript">
$(document).ready( function () {
//$("#g_unite").addClass("active");
document.title = 'Ajouter Bilan';
jQuery.validator.addMethod('selectcheck', function (value) {
    return (value != '0');

    }, "type required");

$("#add-form").validate({
submitHandler: function(form) {
$.ajax({
 url: 'actions/bilan/ajouter.php',
 type: "POST",
 data: new FormData(form),
 contentType: false,
 cache: false,
 processData: false,
 success: function(data){


 if(data == 1){
          $("#mess").html('<div class="alert alert-success">  <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>   <strong>Insertion avec succès </strong> </div>')  ;
              $("#add-form")[0].reset();
               setTimeout(function() {
                     //  window.history.back();
               }, 2000);
    } else  {
   /*  $("#mess").html('<div class="alert alert-danger">  <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>   <strong>Erreur.</strong> </div>')  ;*/
$("#mess").html(data);
     }
},
 error: function(){}
 });
  } ,
                rules: {
               nom: "required",
               nomar: "required",



                               },
                messages: {
                        nom: "Entrez le nom ",
                        nomar: "Entrez le nom en arab",
                           },
                errorElement: "em",
                errorPlacement: function ( error, element ) {

                    error.addClass( "help-block" );

                    element.parents( ".col-sm-6" ).addClass( "has-feedback" );

                    if ( element.prop( "type" ) === "checkbox" ) {
                        error.insertAfter( element.parent( "label" ) );
                    } else {
                        error.insertAfter( element );
                    }

                },

                highlight: function ( element, errorClass, validClass ) {
                    $( element ).parents( ".col-sm-6" ).addClass( "has-error" ).removeClass( "has-success" );
                    $( element ).next( "span" ).addClass( "glyphicon-remove" ).removeClass( "glyphicon-ok" );
                },
                unhighlight: function ( element, errorClass, validClass ) {
                    $( element ).parents( ".col-sm-6" ).addClass( "has-success" ).removeClass( "has-error" );
                    $( element ).next( "span" ).addClass( "glyphicon-ok" ).removeClass( "glyphicon-remove" );
                }
            } );
        } );


</script>
<?php }else{   include("404.php");  } ?>