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


 ?>
 <h4 class="title"><i class="fa fa-users"></i> Fiche Patient</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="col-sm-12 col-xs-12 part_div"> 
                 

                   <div  id="titre_glob1" class="col-sm-4 col-xs-12 titre_glob"> 
                     <div class="col-sm-12 col-xs-12 part_div">
                    <h4 id="sous_title1" class="sous_title"> Informations patient</h4>

                     
                    

                     <div class="form-group">
                      <div class="col-sm-12 col-xs-12">
                      <label>Nom(*) </label>
                      <input type="text" required="required"  class="form-control"  id="nom" name="nom">
                      </div>
                      </div> 
                      
                       <div class="form-group">
                      <div class="col-sm-12 col-xs-12">
                      <label>Prénom(*) </label>
                      <input type="text" required="required"  class="form-control"  id="prenom" name="prenom">
                      </div>
                      </div> 
                       <div class="form-group">
                     <div class="col-sm-12 col-xs-12">
                      <label for="date">Date de naissance(*)</label> 
                      <input class="form-control" type="date" id="date_naissance" name="date_naissance">
                      </div>
                      </div>
                     <div class="form-group">
                      <div class="col-sm-12 col-xs-12">
                      <label>Sexe </label>
                      <select name="sexe" class="form-control" >
                         
                        <option value="0">Sélectionnez Sexe</option>
                        <option value="F" >F</option>
                        <option value="M" >M</option>
                       
                      </select>
                      </div>
                      </div> 
                       

                       <div class="form-group">
                      <div class="col-sm-12 col-xs-12">
                      <label>Groupe Sanguin</label>
        
                      <select name="groupe_sanguin" class="form-control" >
                         
                        <option value="0">Sélectionnez Groupe Sanguin</option>
                        <option value="O-" >O-</option>
                        <option value="O+" >O+</option>
                        <option value="B-" >B-</option>
                         <option value="B+" >B+</option>
                        <option value="A-" >A-</option>
                        <option value="A+" >A+</option>
                        <option value="AB-" >AB-</option>
                        <option value="AB+" >AB+</option>
                      </select>
                      </div>
                      </div>

                       <div class="form-group">
                      <div class="col-sm-12 col-xs-12">
                      <label>Situation familiale</label>
        
                      <select name="situation_familiale" class="form-control" >
                         
                        <option value="0">sélectionnez la situation familiale</option>
                        <option value="Célibataire" >Célibataire</option>
                        <option value="Marié(e)" >Marié(e)</option>
                        <option value="Divorcé(e)" >Divorcé(e)</option>
                      </select>
                      </div>
                      </div>

                   
                      </div> 
</div> 
                      
                      <div id="titre_glob2" class="col-sm-4 col-xs-12 titre_glob">
                           <div class="col-sm-12 col-xs-12 part_div"> 
                         <h4 id="sous_title2" class="sous_title">Coordonnées</h4>
                      <div class="form-group">
                      <div class="col-sm-12 col-xs-12">
                      <label>Email</label>
                      <input type="mail"  class="form-control"  id="mail" name="mail">
                      </div>
                      </div> 

                      <div class="form-group">
                      <div class="col-sm-12 col-xs-12">
                      <label>Tel</label>
                      <input type="text"  class="form-control"  id="tel" name="tel">
                      </div>
                      </div> 
                     
                      <div class="form-group">
                     <div class="col-sm-12 col-xs-12">
                      <label>Adresse</label>
                      <textarea  class="form-control"  id="adresse" name="adresse" rows="4">
                        
                      </textarea> 
                      </div>
                      </div> 
                      <div class="form-group">
                      <div class="col-sm-12 col-xs-12">
                      <label>Note</label>
                      <textarea  class="form-control"  id="note" name="note" rows="4">        
                      </textarea> 
                      </div>
                      </div> 
                      </div>
                      </div>
                     
                          <div  id="titre_glob3" class="col-sm-4 col-xs-12 titre_glob">
                               <div class="col-sm-12 col-xs-12 part_div"> 
                       <h4  id="sous_title3" class="sous_title"> Antécédents</h4>
                      <div class="form-group">
                      <div class="col-sm-12 col-xs-12">
                      <label>Antécédents médicaux</label>
                      <textarea  class="form-control"  id="antecedents_med" name="antecedents_med" rows="2">        
                      </textarea> 
                      </div>
                      </div> 
                       <div class="form-group">
                      <div class="col-sm-12 col-xs-12">
                      <label>Antécédents chirurgicaux</label>
                      <textarea  class="form-control"  id="antecedents_chirur" name="antecedents_chirur" rows="2">        
                      </textarea> 
                      </div>
                      </div>                       
                      <div class="form-group">
                      <div class="col-sm-12 col-xs-12">
                      <label>Antécédents Familiales</label>
                      <textarea  class="form-control"  id="antecedents_famil" name="antecedents_famil" rows="2">        
                      </textarea> 
                      </div>
                      </div> 

                      <div class="form-group">
                      <div class="col-sm-12 col-xs-12">
                      <label>Autres antécédents</label>
                      <textarea  class="form-control"  id="antecedents_autres" name="antecedents_autres" rows="4">
                        
                      </textarea> 
                      </div>
                      </div> 
                      </div> 
                      </div> 
 </div> 

              <div class="form-group">
                         <div class="col-sm-3 col-xs-12">
              <input type="submit" id="Ajouter" class="btn btn-primary btn-block" value="Ajouter"></input>
                     </div>
                    <div class="input-group message col-sm-6" id="mess">    
                     </div>
             

              </div>
                </form>

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


<script type="text/javascript" src="assets/js/jquery.validate.js"></script>
<script type="text/javascript">
$(document).ready( function () {
$("#g_patients").addClass("active");
document.title = 'Ajouter Patient';

   jQuery.validator.addMethod('selectcheck', function (value) {
    return (value != '0');

    }, "type required");
$("#add-form").validate({
submitHandler: function(form) {
$.ajax({
 url: 'actions/patient/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() {
                location.href="index.php?&p=patient";
               }, 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>')  ;

     }
},
 error: function(){}
 });
  } ,
                rules: {
               nom: "required",
               prenom: "required",
               date_naissance: "required"


                               },
                messages: {
                        nom: "Entrez le nom ",
                        prenom: "Entrez le prenom",
                       date_naissance: "Entrez la date de naissance"
                                                 },
                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");  } ?>