 <?php include_once PUBLIC_PATH. '/files_to_include/header_content.php'; ?>
<!-- =============================================== -->

  <!-- Left side column. contains the sidebar -->
  <aside class="main-sidebar" id="aside_menu" >
      <section class="sidebar">
          <ul class="sidebar-menu">
            <?php include_once PUBLIC_PATH. '/files_to_include/menu.php'; ?>
          </ul>
      </section>
  </aside>
   <!-- Content Wrapper. Contains page content -->
   <div class="content-wrapper " style="background-color: white; td{border: solid  2px #000; }">
   

    <!-- Main content -->
    <section class="content">
        <div class="row">
         <div class="col-lg-offset-1 col-lg-11">
              <div class="alert alert-danger" id="msg" style="display:none" class="col-sm-2">
                 <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              </div>
              <div id="connectheader">
                <div class="page-header">                    
                  <h3><span class="glyphicon glyphicon-th-list"></span>FICHE EPIDEMIO</h3>
                </div>
              </div>
             
           
               <table id="mytable" class="table table-striped table-bordered" cellspacing="0" width="100%">
            <thead>
                <tr>
                     <th>FORMATION</th>
                     <th>SEMAINE</th>
                    <th>NB CONSULT</th>
                    <th>NB FEBRILE</th>
                    <th>NB IRA</th>
                    <th>NB SG</th>
                    <th>ACTIONS</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                     <th>FORMATION</th>
                     <th>SEMAINE</th>
                    <th>NB CONSULT</th>
                    <th>NB FEBRILE</th>
                    <th>NB IRA</th>
                    <th>NB SG</th>
                    <th>ACTIONS</th>
                </tr>
            </tfoot>
            <tbody>
            </tbody>
        </table>
          </div>
      </div>
     

    </section>
    <!-- /.content -->
  </div>
      <div class="modal fade" id="modal-default">
          <div class="modal-dialog modal-lg">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span></button>
              </div>
              <div class="modal-body">
                  <div class="row">
                    <div class="col-lg-3">
                        <label for="formSanitaire" class="control-label">Formation Sanitaire</label>
                        <input type="text" class="form-control" id="formSanitaire" placeholder="Formation Sanitaire" disabled="">
                    </div>
                    <div class="col-lg-3">
                        <label for="semaineEpidemio" class="control-label">Semaine Epidemio</label>
                        <input type="text" class="form-control" id="semaineEpidemio" placeholder="SemaineEpi" disabled="">
                    </div>
                     <div class="col-lg-3">
                        <label for="ecouvNaso" class="control-label">Nb EcouvNaso</label>
                        <input type="text" class="form-control" id="ecouvNaso" placeholder="Nb EcouvNaso" >
                    </div>
                    <div class="col-lg-3">
                        <label for="ecouvOro" class="control-label">Nb EcouvOro</label>
                        <input type="text" class="form-control" id="ecouvOro" placeholder="Nb EcouvOro" >
                    </div>
                  </div>
                  <div class="row">
                    <div class="col-lg-3">
                        <label for="nbConsultTotal" class="control-label">Nb total Consultation</label>
                        <input type="text" class="form-control" id="nbConsultTotal" placeholder="Nb consult Total" >
                    </div>
                      <div class="col-lg-3">
                        <label for="nbAffectFebrile" class="control-label">Nb total fébrile</label>
                        <input type="text" class="form-control" id="nbAffectFebrile" placeholder="Nb total fébrile" required="">
                    </div>
                    <div class="col-lg-3">
                        <label for="nbIra" class="control-label">Nb Total IRA</label>
                        <input type="text" class="form-control" id="nbIra" placeholder="Nb Total IRA" required="">
                    </div>
                    <div class="col-lg-3">
                        <label for="nbSg" class="control-label">Nb Total SG</label>
                        <input type="text" class="form-control" id="nbSg" placeholder="Nb Total SG" required="">
                    </div>
                  </div>
                  <div class="row">
                    <div class="col-lg-3">
                        <label for="nbConsult1" class="control-label">0-11 mois nb Consultation</label>
                        <input type="text" class="form-control" id="nbConsult1" placeholder="0-11 mois nb Consultations" required="">
                    </div>
                      <div class="col-lg-3">
                        <label for="nbFebrile1" class="control-label">0-11 mois nb fébrile</label>
                        <input type="text" class="form-control" id="nbFebrile1" placeholder="0-11 mois nb fébrile" required="">
                    </div>
                      <div class="col-lg-3">
                        <label for="nbIra1" class="control-label">0-11 mois nb IRA</label>
                        <input type="text" class="form-control" id="nbIra1" placeholder="0-11 mois nb IRA" required="">
                    </div>
                    <div class="col-lg-3">
                        <label for="nbSg1" class="control-label">0-11 mois nb SG</label>
                        <input type="text" class="form-control" id="nbSg1" placeholder="0-11 mois nb SG" required="">
                    </div>  
                  </div>
                  <div class="row">
                    <div class="col-lg-3">
                        <label for="nbConsult2" class="control-label">1-4 ans nb Consultation</label>
                        <input type="text" class="form-control" id="nbConsult2" placeholder="1-4 ans nb Consultations" required="">
                    </div>
                      <div class="col-lg-3">
                        <label for="nbFebrile2" class="control-label">1-4 ans nb fébrile</label>
                        <input type="text" class="form-control" id="nbFebrile2" placeholder="1-4 ans nb fébrile" required="">
                    </div>
                      <div class="col-lg-3">
                        <label for="nbIra2" class="control-label">1-4 ans nb IRA</label>
                        <input type="text" class="form-control" id="nbIra2" placeholder="1-4 ans nb IRA" required="">
                    </div>
                    <div class="col-lg-3">
                        <label for="nbSg2" class="control-label">1-4 ans nb SG</label>
                        <input type="text" class="form-control" id="nbSg2" placeholder="1-4 ans nb SG" required="">
                    </div>  
                  </div>
                  <div class="row">
                    <div class="col-lg-3">
                        <label for="nbConsult3" class="control-label">5-14 ans nb Consultation</label>
                        <input type="text" class="form-control" id="nbConsult3" placeholder="5-14 ans nb Consultations" required="">
                    </div>
                      <div class="col-lg-3">
                        <label for="nbFebrile3" class="control-label">5-14 ans nb fébrile</label>
                        <input type="text" class="form-control" id="nbFebrile3" placeholder="5-14 ans nb fébrile" required="">
                    </div>
                      <div class="col-lg-3">
                        <label for="nbIra3" class="control-label">5-14 ans nb IRA</label>
                        <input type="text" class="form-control" id="nbIra3" placeholder="5-14 ans nb IRA" required="">
                    </div>
                    <div class="col-lg-3">
                        <label for="nbSg3" class="control-label">5-14 ans nb SG</label>
                        <input type="text" class="form-control" id="nbSg3" placeholder="5-14 ans nb SG" required="">
                    </div>  
                  </div>
                  <div class="row">
                    <div class="col-lg-3">
                        <label for="nbConsult4" class="control-label">15-49 ans nb Consultation</label>
                        <input type="text" class="form-control" id="nbConsult4" placeholder="15-49 ans nb Consultations" required="">
                    </div>
                      <div class="col-lg-3">
                        <label for="nbFebrile4" class="control-label">15-49 ans nb fébrile</label>
                        <input type="text" class="form-control" id="nbFebrile4" placeholder="15-49 ans nb fébrile" required="">
                    </div>
                      <div class="col-lg-3">
                        <label for="nbIra4" class="control-label">15-49 ans nb IRA</label>
                        <input type="text" class="form-control" id="nbIra4" placeholder="15-49 ans nb IRA" required="">
                    </div>
                    <div class="col-lg-3">
                        <label for="nbSg4" class="control-label">15-49 ans nb SG</label>
                        <input type="text" class="form-control" id="nbSg4" placeholder="15-49 ans nb SG" required="">
                    </div>  
                  </div>
                  
                  <div class="row">
                    <div class="col-lg-3">
                        <label for="nbConsult5" class="control-label">>50 ans nb Consultation</label>
                        <input type="text" class="form-control" id="nbConsult5" placeholder=">50 ans nb Consultations" required="">
                    </div>
                      <div class="col-lg-3">
                        <label for="nbFebrile5" class="control-label">>50 ans nb fébrile</label>
                        <input type="text" class="form-control" id="nbFebrile5" placeholder=">50 ans nb fébrile" required="">
                    </div>
                      <div class="col-lg-3">
                        <label for="nbIra5" class="control-label">>50 ans nb IRA</label>
                        <input type="text" class="form-control" id="nbIra5" placeholder=">50 ans nb IRA" required="">
                    </div>
                    <div class="col-lg-3">
                        <label for="nbSg5" class="control-label">>50 ans nb SG</label>
                        <input type="text" class="form-control" id="nbSg5" placeholder=">50 ans nb SG" required="">
                    </div>
                      
                  </div>
              </div>
            
              
              <div class="modal-footer">
                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">Close</button>
              </div>
            </div>
            <!-- /.modal-content -->
          </div>
          <!-- /.modal-dialog -->
        </div>
  <!-- /.content-wrapper -->
 <?php include_once PUBLIC_PATH. '/files_to_include/footer_content.php'; ?>
  
   <script src="<?php echo $this->baseUrl('script/jquery.min.js');?>"></script>
    <script src="<?php echo $this->baseUrl('script/bootstrap.min.js');?>"></script>
    <script src="<?php echo $this->baseUrl('script/sb-admin-2.js');?>"></script>
    <script src="<?php echo $this->baseUrl("script/jquery.dataTables.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/dataTables.bootstrap.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/dataTables.buttons.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/jszip.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/pdfmake.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/vfs_fonts.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/buttons.html5.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl("script/buttons.print.min.js");?>"></script>
    <script src="<?php echo $this->baseUrl('script/loadingoverlay.min.js');?>"></script>
     <script src="<?php echo $this->baseUrl('script/jquery.slimscroll.min.js');?>"></script>
      <script src="<?php echo $this->baseUrl("script/jquery-confirm.min.js");?>"></script>
      <script src="<?php echo $this->baseUrl('script/jquery.toast.min.js');?>"></script> 
<!-- FastClick -->
<script src="<?php echo $this->baseUrl('script/fastclick.js');?>"></script>
<!-- AdminLTE App -->
<script src="<?php echo $this->baseUrl('script/adminlte.min.js');?>"></script>
<script src="<?php echo $this->baseUrl('script/demo.js');?>"></script>
    <script type="text/javascript">
          $(document).ajaxSend(function(event, jqxhr, settings){
            $.LoadingOverlay("show");
        });
        
        $(document).ajaxComplete(function(event, jqxhr, settings){
            $.LoadingOverlay("hide");
        });
     $('.sidebar-menu').tree();
      var numCurrentPage = 0;
      var $myTable = $("#mytable").DataTable({
                                "language": {
                                    "zeroRecords": " aucune donnée disponible ",
                                    "infoEmpty": "Aucune donnée disponible",
                                    "search": "recherche",
                                    "infoFiltered": ""
                                },
                                "bLengthChange": false,
                                "destroy" : true,
                                dom: 'Bfrtip',
                                buttons: [
                                  'copy', 'csv', 'excel', 'pdf', 'print'
                                ],
                                "processing" : true,
                                "serverSide" : true,
                                "ajax" : {
                                         url : "<?php echo $this->url(array('controller' => 'Fiche', 'action' => 'datatable')); ?>",
                                         type : "POST"
                                }
                              });
    
  
         $("body").on("click",".elementHeb",function(e){
           e.preventDefault();
          
           var idElement = $(this).attr("id");
          numCurrentPage = $myTable.page();
         
           console.log(idElement);
           var formSanitaire = idElement.substr(0, idElement.search("_"));
      var semaineEpidemio = idElement.substr(idElement.search("_")+1, idElement.length+1);
           var params = {formSanitaire: formSanitaire,semaineEpidemio:semaineEpidemio};
           console.log(JSON.stringify(params));
                    $.ajax({
                        url: "<?php echo $this->url(array('controller' => 'Fiche', 'action' => 'information')); ?>",
                        type: "POST",
                        dataType: "json",
                        data: params,
                    beforeSend:function(){
                        $("#modal-default").LoadingOverlay("show");
                         },
                    complete:function(){
                         $("#modal-default").LoadingOverlay("hide");
                    },
                        success: function(data) {
                           if ( data.type === "success"){
                               
                    var resultat   = data.data;
                    $("#formSanitaire").val(resultat.formSanitaire);
                    $("#semaineEpidemio").val(resultat.semaineEpidemio);
                    $("#ecouvNaso").val(resultat.nbecouvnano);
                    $("#ecouvOro").val(resultat.nbecouvbucco);
                    $("#nbConsultTotal").val(resultat.nbconsulttotal);
                    $("#nbAffectFebrile").val(resultat.nbaffectfebrile);
                    $("#nbIra").val(resultat.nbira);
                    $("#nbSg").val(resultat.nbsg);
                    //Consultation 
                    $("#nbConsult1").val(resultat.nbconsultants1);
                    $("#nbConsult2").val(resultat.nbconsultants2);
                    $("#nbConsult3").val(resultat.nbconsultants3);
                    $("#nbConsult4").val(resultat.nbconsultants4);
                    $("#nbConsult5").val(resultat.nbconsultants5);
                    //Fébrile
                    $("#nbFebrile1").val(resultat.nbfebrile1);
                    $("#nbFebrile2").val(resultat.nbfebrile2);
                    $("#nbFebrile3").val(resultat.nbfebrile3);
                    $("#nbFebrile4").val(resultat.nbfebrile4);
                    $("#nbFebrile5").val(resultat.nbfebrile5);
                    //IRA
                    $("#nbIra1").val(resultat.nbira1);
                    $("#nbIra2").val(resultat.nbira2);
                    $("#nbIra3").val(resultat.nbira3);
                    $("#nbIra4").val(resultat.nbira4);
                    $("#nbIra5").val(resultat.nbira5);
                    //SG
                    $("#nbSg1").val(resultat.nbsg1);
                    $("#nbSg2").val(resultat.nbsg2);
                    $("#nbSg3").val(resultat.nbsg3);
                    $("#nbSg4").val(resultat.nbsg4);
                    $("#nbSg5").val(resultat.nbsg5);
                 }else{
                     $.toast({
                         heading : "erreur",
                         text : data.data,
                         icon : "error",
                         hideAfter : false,
                         stack : false,
                         position : 'mid-center'
                     });
                 }
                        },
                        error: function() {
                            $.toast({
                                    heading: "serveut inactif",
                                    text: "AsideSMS n'arrive pas à accéder au serveur , si cela persiste veuillez contacter l'administrateur ",
                                    icon: "error",
                                    hideAfter: false,
                                    stack: false,
                                    position: 'mid-center'
                            });
                        }
                    });
        });
        
        $("body").on("click","#save",function(e){
           e.preventDefault();
           
           var params = {formSanitaire: $("#formSanitaire").val(),semaineEpidemio:$("#semaineEpidemio").val(),nbEcouvnano:$("#ecouvNaso").val(),nbEcouvbucco:$("#ecouvOro").val(),
           nbConsultTotal:$("#nbConsultTotal").val(),nbAffectFebrile:$("#nbAffectFebrile").val(),nbIra:$("#nbIra").val(),nbSg:$("#nbSg").val(),
       nbConsultants1:$("#nbConsult1").val(),nbConsultants2:$("#nbConsult2").val(),nbConsultants3:$("#nbConsult3").val(),nbConsultants4:$("#nbConsult4").val(),nbConsultants5:$("#nbConsult5").val(),
    nbfebrile1:$("#nbFebrile1").val(),nbfebrile2:$("#nbFebrile2").val(),nbfebrile3:$("#nbFebrile3").val(),nbfebrile4:$("#nbFebrile4").val(),nbfebrile5:$("#nbFebrile5").val(),
    nbIra1:$("#nbIra1").val(),nbIra2:$("#nbIra2").val(),nbIra3:$("#nbIra3").val(),nbIra4:$("#nbIra4").val(),nbIra5:$("#nbIra5").val(),
    nbSg1:$("#nbSg1").val(), nbSg2:$("#nbSg2").val(), nbSg3:$("#nbSg3").val(), nbSg4:$("#nbSg4").val(), nbSg5:$("#nbSg5").val()};
    
           console.log(JSON.stringify(params));
                    $.ajax({
                        url: "<?php echo $this->url(array('controller' => 'Fiche', 'action' => 'editer')); ?>",
                        type: "POST",
                        dataType: "json",
                        data: params,
                    beforeSend:function(){
                        $("#modal-default").LoadingOverlay("show");
                         },
                    complete:function(){
                        console.log(numCurrentPage);
                        $myTable.page(numCurrentPage).draw("page");
                         $("#modal-default").LoadingOverlay("hide");
                         
                    },
                        success: function(data) {
                           if ( data.type === "success"){
                               $.toast({
                         heading : "success",
                         text : data.message,
                         icon : "success",
                         hideAfter : false,
                         stack : false,
                         position : 'mid-center'
                     });
                     console.log(numCurrentPage);
               
                              $myTable.page(numCurrentPage).draw("page"); 
                              console.log($myTable.page());
                     $("button.close").click();
                 }else{
                     $.toast({
                         heading : "erreur",
                         text : data.data,
                         icon : "error",
                         hideAfter : false,
                         stack : false,
                         position : 'mid-center'
                     });
                 }
                        },
                        error: function() {
                            $.toast({
                                    heading: "serveut inactif",
                                    text: "AsideSMS n'arrive pas à accéder au serveur , si cela persiste veuillez contacter l'administrateur ",
                                    icon: "error",
                                    hideAfter: false,
                                    stack: false,
                                    position: 'mid-center'
                            });
                        }
                    });
        });
    </script>

</body>

</html>