<!DOCTYPE html>

<html lang="es" dir="ltr">


<head>
    <meta charset="UTF-8">

    <link rel="stylesheet" href="bootstrap-4.4.1-dist/css/bootstrap.min.css" >
    <link rel="stylesheet" href="DataTable/css/dataTables.bootstrap4.min.css" >
    <link rel="stylesheet" href="toast/src/jquery.toast.css" type="text/css">
    <link rel="stylesheet" href="css/estilos.css" >


    <title>SURA</title>

</head>

<body id="cuerpo">



<?php
    include_once('conection.php');

 ini_set('date.timezone','America/Bogota');            
 //$fecha_actual = date('Y-m-d H:i:s');
 $hora = date('H:i:s');

 $fecha_quiz = date('Y-m-d');


@$cedula = $_SESSION['cedula'];
    



if(empty($_SESSION['usuario'])||empty($_SESSION['clave'])){        

?>

            <script language="JavaScript">
                 window.location="index.php";
            </script>

<?php 

}else{






      if($_SESSION['rol']==3){
  ?>

   <ul class="nav nav-pills">
        <li class="nav-item">
          <a class="nav-link active" href="index.php">Inicio</a>
        </li>
         <li class="nav-item">
          <a class="nav-link" href="consultar_am.php">Consultar AM</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="consultar_pm.php">Consultar PM</a>
        </li>
         <li class="nav-item">
          <a class="nav-link" href="faltan_am.php">Faltan AM</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="faltan_pm.php">Faltan PM</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="auditoria.php">Auditoria</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="registro_preg.php">Crear preguntas</a>
        </li>        
    </ul>

<?php 
      }//if($_SESSION['rol']==3){
  
 ?>



 <div class="container-fluid">

    <br>

<div class="row justify-content-md-center">

    <div class="col-lg-8">    

   





<?php 




    //if($hora> '03:00:00' && $hora< '10:46:00' || $_SESSION['rol']==5){
    if($hora> '03:00:00' && $hora< '07:46:00' || $_SESSION['rol']==5){

   


        $sql = $connection->prepare("SELECT a.pregunta, a.cons,  a.orden FROM preguntas a
            WHERE NOT EXISTS 
            (select * from det_pre_fun c WHERE c.cons_pre = a.cons and cedula_fun = '$cedula' AND c.fecha_quiz = '$fecha_quiz' and jornada = 'am') 
            ORDER BY orden ASC");
        $sql->execute();
        $encuesta = $sql->fetchAll(PDO::FETCH_ASSOC);






        ?>

   
                 <h1 class="centrar">Evaluacion de sintomas de Covid-19</h1>
                 <h1 class="centrar text-primary font-weight-bold">JORNADA MAÑANA</h1>
                 


                    <br>
                    <br>
                    
                        <form id="form_sura">



                        
                <?php
                                
                        $c=0;

                        if(count($encuesta)>0){
                            //$_SESSION['jornada'] = 'am';
                        foreach ($encuesta as $value) {

                ?>

                            <div class="card col-12" >

                            <div class=" btn-group-toggle" data-toggle="buttons" >    
                <?php

                            $preg = $value['pregunta'];
                            $orden = $value['orden'];
                            $c++;
                            $cons = $value['cons'];

                            
                            $sql2 = $connection->prepare("SELECT cons FROM posibilidades WHERE cons_preg = $cons 
                                GROUP BY cons_preg ORDER BY cons ASC LIMIT 1");
                            $sql2->execute();
                            $resul2 = $sql2->fetch(PDO::FETCH_ASSOC);

                            $pos = $resul2['cons'];



                            $si2 = '';
                            if($orden == 10){

                                $si2 = 'si2';
                            }

                            echo "<h1>".$orden.". ".$preg."</h1>"; 


                        echo'<div class="row">';
                            
                        echo"<label class='btn btn-light col ancho si $si2'>";
                ?>
                              <input type="radio" class="radio " name="p<?php echo $c;?>" autocomplete="off" value="<?php echo $pos;?>" required> SI
                            </label>

                            <label class="col-1"></label>

                            <label class="btn btn-light col ancho no">
                              <input type="radio" class="radio " name="p<?php echo $c;?>" autocomplete="off" value="<?php echo $pos+1;?>" > NO
                            </label>

                          </div>
                </div>

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

                <?php
                                }//foreach ($encuesta as $value)
                   
                ?>
                          
                        


                          <div class=" centrar" >  
                            <button type="button" class="btn btn-dark" id="enviar">Enviar</button>
                          </div>

                        </form>
                        </div> <!-- <div class="col-sm"> -->
                       
                    </div> <!-- <div class="row"> -->
                    </div>  <!-- <div class="container"> -->
                <?php
                              
                    } //if(count($encuesta)>0)           
                    else{
                        echo "<h1 class='centrar'>encuesta jornada mañana completa </h1>";
                        echo "<h1 class='centrar'>Por favor ingresa en la tarde</h1>";

                    }









    }elseif ($hora> '11:45:00' && $hora< '16:45:00' || $_SESSION['rol']==5){

    


        $sql = $connection->prepare("SELECT a.pregunta, a.cons,  a.orden FROM preguntas a
            WHERE NOT EXISTS 
            (select * from det_pre_fun c WHERE c.cons_pre = a.cons and cedula_fun = '$cedula' AND c.fecha_quiz = '$fecha_quiz' and jornada = 'pm') 
            ORDER BY orden ASC");
        $sql->execute();
        $encuesta = $sql->fetchAll(PDO::FETCH_ASSOC);





            ?>

   
                 <h1 class="centrar">Evaluacion de sintomas de Covid-19</h1>
                 <h1 class="centrar text-danger font-weight-bold">JORNADA TARDE</h1>

                    <br>
                    <br>
                    
                        <form id="form_sura">



                        
                <?php
                                
                        $c=0;

                        if(count($encuesta)>0){
                             //$_SESSION['jornada'] = 'pm';
                        foreach ($encuesta as $value) {

                ?>

                            <div class="card col-12" >

                            <div class=" btn-group-toggle" data-toggle="buttons" >    
                <?php

                            $preg = $value['pregunta'];
                            $orden = $value['orden'];
                            $c++;
                            $cons = $value['cons'];

                            
                            $sql2 = $connection->prepare("SELECT cons FROM posibilidades WHERE cons_preg = $cons 
                                GROUP BY cons_preg ORDER BY cons ASC LIMIT 1");
                            $sql2->execute();
                            $resul2 = $sql2->fetch(PDO::FETCH_ASSOC);

                            $pos = $resul2['cons'];



                            $si2 = '';
                            if($orden == 10){

                                $si2 = 'si2';
                            }

                            echo "<h1>".$orden.". ".$preg."</h1>"; 


                        echo'<div class="row">';
                            
                        echo"<label class='btn btn-light col ancho si $si2'>";
                ?>
                              <input type="radio" class="radio " name="p<?php echo $c;?>" autocomplete="off" value="<?php echo $pos;?>" required> SI
                            </label>

                            <label class="col-1"></label>

                            <label class="btn btn-light col ancho no">
                              <input type="radio" class="radio " name="p<?php echo $c;?>" autocomplete="off" value="<?php echo $pos+1;?>" > NO
                            </label>

                          </div>
                </div>

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

                <?php
                                }//foreach ($encuesta as $value)
                   
                ?>
                          
                        


                          <div class=" centrar" >  
                            <button type="button" class="btn btn-dark" id="enviar">Enviar</button>
                          </div>

                        </form>
                        </div> <!-- <div class="col-sm"> -->
                       
                    </div> <!-- <div class="row"> -->
                    </div>  <!-- <div class="container"> -->
                <?php
                              
                    } //if(count($encuesta)>0)           
                    else{
                        echo "<h1 class='centrar'>Encuesta jornada tarde completa</h1>";
                        echo "<h1 class='centrar'>Por favor ingresa mañana</h1>";

                    }







        
    }else{
?>


    

     <div class="centrar">   
        <h1>COOPSERP</h1>
        <br>
        <h2>AUTO EVALUACION DE SINTOMAS DE COVID-19</h2>
        <br>
        <p id="limite"><b>ESTÁS FUERA DEL RANGO DE HORARIOS DE LA ENCUESTA</b></p>

        <p id="limite"><b>Lunes a Viernes</b></p>
        
        <p id="limite" class="text-primary font-weight-bold">JORNADA MAÑANA: 3:00 AM - 7:45 AM</p>
        <p id="limite" class="text-danger font-weight-bold">JORNADA TARDE: 3:00 PM - 4:30 PM</p>

        <br>
        <br>
        
        <p id="limite"><b>Sábados</b></p>
        
        <p id="limite" class="text-primary font-weight-bold">JORNADA MAÑANA: 3:00 AM - 7:45 AM</p>
        <p id="limite" class="text-danger font-weight-bold">JORNADA TARDE: 12:00 PM - 1:00 PM</p>
       
     </div> 



<?php
    }//else{


}//if(empty($_SESSION['usuario'])||empty($_SESSION['clave'])){      
















?>

        <!--ventana emergente no_wsp-->
        <div id="vaciar">    
      <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                  <div class="modal-content">
                    <div class="modal-header">
                      <h1 class="modal-title" id="myModalLabel"><strong>Registro:</strong></h1>
                    <button type="button" class="close listo" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cerrar</span></button>
                    
                    </div>
                    
                        <div id="muestra" class="modal-body" style="text-align: center;">

                            <h1 id="mensaje"></h1>
                            <br>
                            <div class="d-flex align-items-center justify-content-center h-100">
                              <button type='button'  class='btn btn-primary listo'>Listo</button>&nbsp; &nbsp; &nbsp; &nbsp;
                            <!-- <button type='button' id="no" class='btn btn-dark' >no</button> -->
                            </div>

                             <!-- ocultos -->
                            <input type="hidden" id="cons2" name="cons2" >
                            <input type="hidden" id="cel" name="cel" >                          

                        </div>
                    
                    
                    <div class="modal-footer">
                   <!-- <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                    <button type="button" class="btn btn-default fa fa-print" onClick="forward('formato_pdf.php?id='+$('#fmtid').val())" data-dismiss="modal">Imprimir</button>
                    <a target="_blank" href="javascript:imprSelec('muestra')" id="imp" rel="" class="btn btn-default fa fa-print">Imprimir</a>-->
                    </div>
                  </div>
                </div>
            </div> 
             </div> 


            <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                  <div class="modal-content">
                    <div class="modal-header">
                      <h1 class="modal-title" id="myModalLabel"><strong>Error:</strong></h1>
                    <button type="button" class="close listo" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cerrar</span></button>
                    
                    </div>
                    
                        <div id="muestra" class="modal-body" style="text-align: center;">

                            <h1 id="mensaje2"></h1>
                            <br>
                            <div class="d-flex align-items-center justify-content-center h-100">
                              <button type='button' id="listo2" class='btn btn-danger listo'>Listo</button>&nbsp; &nbsp; &nbsp; &nbsp;
                            <!-- <button type='button' id="no" class='btn btn-dark' >no</button> -->
                            </div>

                             <!-- ocultos -->
                            <input type="hidden" id="cons2" name="cons2" >
                            <input type="hidden" id="cel" name="cel" >                          

                        </div>
                    
                    
                    <div class="modal-footer">
                   <!-- <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                    <button type="button" class="btn btn-default fa fa-print" onClick="forward('formato_pdf.php?id='+$('#fmtid').val())" data-dismiss="modal">Imprimir</button>
                    <a target="_blank" href="javascript:imprSelec('muestra')" id="imp" rel="" class="btn btn-default fa fa-print">Imprimir</a>-->
                    </div>
                  </div>
                </div>
            </div> 





               <!--ventana emergente no_wsp-->
          
      <div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                  <div class="modal-content">
                    <div class="modal-header">
                      <h1 class="modal-title" id="myModalLabel"><strong>Registro:</strong></h1>
                    <button type="button" class="close listo" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cerrar</span></button>
                    
                    </div>
                    
                        <div id="muestra" class="modal-body" style="text-align: center;">

                            <h1 id="mensaje3"></h1>
                            <br>
                            <div class="d-flex align-items-center justify-content-center h-100">
                              <button type='button' id="listo" class='btn btn-primary listo'>Listo</button>&nbsp; &nbsp; &nbsp; &nbsp;
                            <!-- <button type='button' id="no" class='btn btn-dark' >no</button> -->
                            </div>

                             <!-- ocultos -->
                            <input type="hidden" id="cons2" name="cons2" >
                            <input type="hidden" id="cel" name="cel" >                          

                        </div>
                    
                    
                    <div class="modal-footer">
                   <!-- <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                    <button type="button" class="btn btn-default fa fa-print" onClick="forward('formato_pdf.php?id='+$('#fmtid').val())" data-dismiss="modal">Imprimir</button>
                    <a target="_blank" href="javascript:imprSelec('muestra')" id="imp" rel="" class="btn btn-default fa fa-print">Imprimir</a>-->
                    </div>
                  </div>
                </div>
            </div> 






		


</body>


	<script src="jquery-3.4.1/jquery-3.4.1.min.js" ></script>
    <script src="popper-1.12.9/popper-1.12.9.min.js" ></script>
    <script src="bootstrap-4.4.1-dist/js/bootstrap.min.js" ></script>
    <script src="DataTable/js/dataTables.bootstrap4.min.js"></script>
    <script src="DataTable/js/jquery.dataTables.min.js"></script>
    <script src="toast/src/jquery.toast.js"></script>
    <script src="jquery_validator_1.10.0/jquery.validate.min.js" ></script>
    <script src="jquery_validator_1.10.0/messages_es.js" ></script>    


    <!-- <script type="text/javascript">var toas = '<?php //echo json_encode($_SESSION['toas']);?>'; </script> -->
    <script src="js/quiz7.js"></script>



    <script>
          $(document).ready(function(){
              $("#myButton").click(function(){
                  $(this).button('toggle');

              });
          });

    </script>



</html>