<?php
session_start();
if (!isset($_SESSION['rol']) || $_SESSION['rol'] !== 'admin') {
  header('Location: ../../index.php');
  exit;
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="UTF-8">
  <title>Autorizaciones de RRHH</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
  <link href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/6.4.0/mdb.min.css" rel="stylesheet">
  <link href="../../assets/css/recruiter.css" rel="stylesheet">

</head>
<body class="bg-light">
  <div class="d-flex">
  <?php include '../../includes/sidebar.php'; ?>

  <div class="main-content w-100" id="mainContent">
    <?php include '../../includes/topbar.php'; ?>

  <div class="container py-4">
    <h3 class="mb-4">Solicitudes Pendientes de Autorización</h3>
    <div class="mb-3">
  <input type="text" id="buscador-autorizaciones" class="form-control" placeholder="Buscar por CURP o nombre completo...">
</div>

    <div id="contenedor-autorizaciones" class="table-responsive">
      <table class="table table-hover table-bordered">
        <thead class="table">
           <tr>
            <th>Nombre</th>
            <th>CURP</th>
            <th>Movimiento</th>
            <th>Temporalidad</th>
            <th>PDV Actual</th>
            <th>Observaciones</th>
            <th>Acciones</th>
          </tr>
        </thead>
        <tbody id="tabla-autorizaciones">
          <!-- Aquí se cargará con JS -->
        </tbody>
      </table>
      <div class="d-flex justify-content-center mt-3" id="paginacion-autorizaciones"></div>
    </div>
  </div>

  <!-- Modal de Detalles -->
<div class="modal fade" id="modalDetalles" tabindex="-1" aria-labelledby="modalDetallesLabel" aria-hidden="true">
  <div class="modal-dialog modal-xl modal-dialog-centered">
    <div class="modal-content border-primary">
      <div class="modal-header bg-primary text-white">
        <h5 class="modal-title" id="modalDetallesLabel">Detalle de Solicitud</h5>
        <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Cerrar"></button>
      </div>
      <div class="modal-body">
        <div class="container-fluid">
          <div class="row row-cols-1 row-cols-md-2 g-4" id="contenido-detalles">
            <!-- Aquí se carga el contenido dinámico -->
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button class="btn btn-secondary" data-bs-dismiss="modal">Cerrar</button>
        <button class="btn btn-success" id="btnAutorizarDesdeDetalle">
          <i class="fas fa-check-circle me-2"></i>Autorizar Solicitud
        </button>
      </div>
    </div>
  </div>
</div>
<!-- Modal de Confirmación -->
<div class="modal fade" id="modalConfirmar" tabindex="-1" aria-labelledby="modalConfirmarLabel" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered">
    <div class="modal-content border-success">
      <div class="modal-header bg-success text-white">
        <h5 class="modal-title" id="modalConfirmarLabel">Confirmar Autorización</h5>
        <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Cerrar"></button>
      </div>
      <div class="modal-body">
        ¿Estás seguro de autorizar esta solicitud?
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancelar</button>
        <button type="button" class="btn btn-success" id="btnConfirmarAutorizacion">
          Sí, autorizar
        </button>
      </div>
    </div>
  </div>
</div>


  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
  <script src="../../assets/js/autorizaciones/autorizaciones.js"></script>
</body>
</html>
