<?php 
    session_start();
    include '../validacion.php';
    include '../siguientedia.php';
    include "../conexion/conexion.php";
if (isset($_SESSION['start'])) {
?>
<!DOCTYPE html>
<html lang="en">
   <head>
   <title>Solicitudes - Recursos Humanos</title>
   <?php 
   include '../layout/header.php'; 
   ?>  
   </head>
   <body class="inner_page tables_page">
      <div class="full_container">
         <div class="inner_container">
            <!-- MENÚ  -->
            <?php include '../layout/menu.php'; ?>
            <!-- FIN DEL MENÚ -->
            <!-- right content -->
            <div id="content">
               <!-- SUB-MENÚ -->
               <?php include '../layout/submenu.php'; ?>
               <!-- FIN DEL SUB-MENÚ -->
               <!-- dashboard inner -->
               <div class="midde_cont">
                  <div class="container-fluid">
                     <div class="row column_title">
                        <div class="col-md-12">
                           <div class="page_title">
                              <h2>Solicitudes de Registro</h2>
                           </div>
                        </div>
                     </div>
                     <!-- row -->
                     <div class="row">
                        <!-- table section -->
                        <div class="col-md-12">
                           <div class="white_shd full margin_bottom_30">
                              <div class="full graph_head">
                                 <div class="heading1 margin_0">
                                    <h2>Usuarios Pendientes de Aprobación</h2>
                                 </div>
                              </div>
                              <div class="table_section padding_infor_info">
                                 <div class="table-responsive-sm">
                                    <table class="table table-hover">
                                       <thead>
                                          <tr style="text-align: center;">
                                             <th>COLABORADOR</th>
                                             <th>DNI</th>
                                             <th>CORREO</th>
                                             <th>SEDE</th>
                                             <th>ACCIÓN</th>
                                          </tr>
                                       </thead>
                                          <?php
                                             if($idrol_sesion == 4){
                                                 $sql = "SELECT * FROM usuario WHERE estado=1 ORDER BY idusuario";
                                             }
                                             else{
                                                 $sql = "SELECT * FROM usuario WHERE sede = '$sede_sesion' and estado=1 ORDER BY idusuario";
                                             }
                                             
                                             $consulta = $pdo->prepare($sql);
                                             $consulta->execute();
                                             $usuarios = $consulta->fetchAll(PDO::FETCH_ASSOC);

                                             foreach ($usuarios as $gousuario) {
                                                $idusuario = $gousuario['idusuario'];
                                                $nombreusuario = $gousuario['nombreusuario'];
                                                $dni = $gousuario['dni'];
                                                $correo = $gousuario['correo'];
                                                $sede = $gousuario['sede'];                                          
                                          ?>
                                       <tbody>
                                          <tr style="text-align: center;">
                                             <th><?php echo $nombreusuario; ?></th>
                                             <th><?php echo $dni; ?></th>
                                             <th><?php echo $correo; ?></th>
                                             <th><?php echo $sede; ?></th>
                                             <th>
                                                <div class="dropdown_section">
                                                   <div class="dropdown" style="align-items:center;">
                                                      <a style="font-size:16pt; cursor: pointer;" class="fas fa-edit" data-toggle="dropdown"></a>
                                                      <div class="dropdown-menu" style="padding:0;">
                                                         <a class="dropdown-item" style="background-color:#5CB51D; color:white;" href="validarusuariospendientes.php?opcion=1&usuario=<?php echo $idusuario; ?>"><i class="fa-solid fa-check"></i> ACEPTAR</a>
                                                         <a class="dropdown-item" style="background-color:#C22626; color:white;" href="validarusuariospendientes.php?opcion=2&usuario=<?php echo $idusuario; ?>"><i class="fa-solid fa-x"></i> RECHAZAR</a>
                                                      </div>
                                                   </div>
                                                </div>
                                             </th>
                                          </tr>
                                       </tbody> 
                                    <?php } ?>                                            
                                    </table>
                                 </div>
                              </div>
                           </div>
                        </div>
                        <!-- table section -->
                     </div>
                     <!-- end row -->
                  </div>
                                  
                  <!-- FOOTER -->
                  <?php include '../layout/footer.php' ?>
                  <!-- FIN DEL FOOTER -->
               </div>
               <!-- end dashboard inner -->
            </div>
         </div>
         <!-- model popup -->
         <!-- The Modal -->
         <div class="modal fade" id="myModal">
            <div class="modal-dialog">
               <div class="modal-content">
                  <!-- Modal Header -->
                  <div class="modal-header">
                     <h4 class="modal-title">Modal Heading</h4>
                     <button type="button" class="close" data-dismiss="modal">&times;</button>
                  </div>
                  <!-- Modal body -->
                  <div class="modal-body">
                     Modal body..
                  </div>
                  <!-- Modal footer -->
                  <div class="modal-footer">
                     <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                  </div>
               </div>
            </div>
         </div>
         <!-- end model popup -->
      </div>
      <!-- INCLUYENDO JS. -->
   <?php include '../layout/pie.php' ?>
   </body>
</html>

<?php
} else {
  echo'<script type="text/javascript">alert("Inicie Sesión Nuevamente");window.location.href="../login/login.php";</script>';
}
?>