 <?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>COVID 19</h3>
                </div>
              </div>

              <div class="row">
                <dir class="col-lg-8">
                  
                </dir>
                <div class="col-lg-2">
                    <button  type="button" class="btn btn-microsoft" id="sendSMSMultiple"><i class="fa fa-envelope fa-3x"></i></button>
                   
                </div>
                <div class="col-lg-offset-1 col-lg-1">
                     <button  type="button" class="btn btn-microsoft" id="printMultiple"><i class="fa fa-print fa-3x"></i></button>
                </div>
                
              </div>
           
               <table id="mytable" class="table table-striped table-bordered" cellspacing="0" width="100%">
            <thead style="border-radius: 10px; highlight-color: #EAF3F3;background-color: #167F92;border: 1px solid #FFF;">
                <tr>
                     <th>LABORATOIRE</th>
                     <th>PATIENT</th>
                    <th>SEXE</th>
                    <th>RESULTAT</th>
                    <th>IDENTIFIANT</th>
                    <th>TELEPHONE</th>
                    <th>DATE PRELEVEMENT</th>
                    <th>ACTIONS</th>
                </tr>
            </thead>
            <tfoot style="border-radius: 10px; highlight-color: #EAF3F3;background-color: #167F92;border: 1px solid #FFF;">
                <tr>
                     <th>LABORATOIRE</th>
                     <th>PATIENT</th>
                    <th>SEXE</th>
                    <th>RESULTAT</th>
                    <th>IDENTIFIANT</th>
                    <th>TELEPHONE</th>
                    <th>DATE PRELEVEMENT</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" id="modifier" class="btn btn-microsoft enreg">Modifier</button>
                 <button type="button" id="valider" class="btn btn-microsoft enreg">Valider</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.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");
        });
        $("#modifier").hide();
        $("#valider").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' => 'Covid', 'action' => 'datatable')); ?>",
                                         type : "POST",
                                           beforeSend:function(){
                 $("#mytable").LoadingOverlay("show");
            },
            complete:function(){
                 $("#mytable").LoadingOverlay("hide");
            },
                                },
                               
                                "createdRow": function( row, data, dataIndex ) {
                                    console.log(JSON.stringify(data))
                                      $(row).css("background-color" ,data[8]);
                                      $(row).css("color" ,"#FFF");
                                 }
                              });



     

      function send () {
        var donnee = {
                    outboundSMSMessageRequest: {
                address : "tel:"+"237696993837", 
                    senderAddress : "tel:"+"237696993837",
                outboundSMSTextMessage: {
                    message : "Bonjour Docteur Landry Messanga"   
            }
            }}


               $.ajax({
                  url: 'https://api.orange.com/smsmessaging/v1/outbound/tel:+237696993837/requests',
                   contentType: 'application/json',
                   async: false,
                   xhrFields: {
                withCredentials: true,
                crossDomain: true,
                
            },
            headers:{
              'Authorization': "Bearer efYImzg65FsRnGkuq8rYT83F8mhi"
            },
                 type: "POST",
                 dataType: "json",
                
                 
                 data: JSON.stringify(donnee),
                success: function(data){
                  alert(JSON.stringify(data));
                },
                error: function () {
                  alert("Echec"); // Get a specific response header
                }
        });
             }
              //send()

       

        $("#sendSMSMultiple").click(function(e){
             var tabResultat = [];
             var objet = {};
              $( ".cocher" ).each(function( index ) {
                    if ($(this).prop("checked")) {
                      objet = {};
                      var sexe ="";
                     sexe= $(this).siblings("a.sendSMS").attr("sexe");
                     var labo = "";
                     var labo = $(this).siblings("a.sendSMS").attr("labo");
                     var tel = "";
                     tel=$(this).siblings("a.sendSMS").attr("tel");
                     var datePrelev = "";

                     datePrelev=$(this).siblings("a.sendSMS").attr("datePrelev");
                     var nom = ""
                     nom=$(this).siblings("a.sendSMS").attr("nom");
                      var resultat = ""
                     resultat=$(this).siblings("a.sendSMS").attr("resultat");
                     var id = "";
                      id=$(this).siblings("a.sendSMS").attr("id");
                      
                      objet = {"sexe": sexe,"labo":labo,"tel":tel,"datePrelev":datePrelev,"nom":nom,"id":id,"resultat":resultat};
                      tabResultat.push(objet);
                    }
              });

             $.ajax({
                        url: "<?php echo $this->url(array('controller' => 'covid', 'action' => 'sendsms')); ?>",
                        type: "POST",
                        dataType: "json",
                        data:{"parametres":tabResultat},
                    beforeSend:function(){
                        $("#modal-default").LoadingOverlay("show");
                         },
                    complete:function(){
                         $("#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'
                     });
                     
                 }else{
                     $.toast({
                         heading : "erreur",
                         text : data.message,
                         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'
                            });
                        }
                    });
        })

        //Envoi de message par cliquer sur le boutton
      $("body").on("click",".sendSMS",function(e){
         var sexe ="";
         sexe= $(this).attr("sexe");
         var labo = "";
         var labo = $(this).attr("labo");
         var tel = "";
         tel=$(this).attr("tel");
         var datePrelev = "";

         datePrelev=$(this).attr("datePrelev");
         var nom = ""
         nom=$(this).attr("nom");
          var resultat = ""
         resultat=$(this).attr("resultat");
         var id = "";
          id=$(this).attr("id");
          var tabParams = [];
           var params = {"sexe": sexe,"labo":labo,"tel":tel,"datePrelev":datePrelev,"nom":nom,"id":id,"resultat":resultat};
           tabParams.push(params)

            $.ajax({
                        url: "<?php echo $this->url(array('controller' => 'covid', 'action' => 'sendsms')); ?>",
                        type: "POST",
                        dataType: "json",
                         data:{"parametres":tabParams},
                    beforeSend:function(){
                        $("#modal-default").LoadingOverlay("show");
                         },
                    complete:function(){
                         $("#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'
                     });
                     
                 }else{
                     $.toast({
                         heading : "erreur",
                         text : data.message,
                         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",".validerHeb",function(e){
           e.preventDefault();
          $("#modifier").hide();
          $("#valider").show();
           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' => 'Sms', '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'
                            });
                        }
                    });
        });
  
        
       
         
    </script>

</body>

</html>