<?php
  session_start();
  if(!(isset($_SESSION["k_name"]))){
        header("location:index.php");
        }
        else{  
 include("includes/conect.php");
 include("includes/timezone.php");

?>

<!DOCTYPE html>
<html lang="es">


<head>
<?php include('head.php'); ?>
</head>

<body>
  <div class="loader"></div>
  <div id="app">
    <div class="main-wrapper main-wrapper-1">
      <div class="navbar-bg"></div>
      
      <?php include('navbar.php')?>

      <?php include('sidebar.php')?>
      <!-- Main Content -->

          <div class="main-content">
            <section class="section">


               <div class="col-xl-12 col-lg-12 col-md-12">
                <?php
                if (isset($_GET['full'])) {
                ?>

                    <div class="alert alert-danger alert-dismissible fade show" role="alert">
                        <strong>No disponible!</strong> Capacidad llena para esta Área.
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>

                <?php
                }
 


                   if (isset($_GET['succ'])) {
                ?>

                    <div class="alert alert-success alert-dismissible fade show" role="alert">
                        <strong>Usuario activado</strong>
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>

                <?php
                } 



                if (isset($_GET['error'])) {
                ?>

                    <div class="alert alert-danger alert-dismissible fade show" role="alert">
                        <strong>Accion no ralizada!</strong> acción no realizada.
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>

                <?php
                } 


                ?>
            </div>

          <div class="d-sm-flex align-items-center justify-content-between mb-4">
            <h1 class="h6 mb-0 text-gray-800">
              <?php
                echo strftime("%a %d de %B del %Y");
              ?>
            </h1>            
          </div>

                    <div class="row">
            <div class="col-12">
              <div class="card">
                <div class="card-header">
                  <h4>Usuarios</h4> 
                </div>
                <div class="card-body p-0">

                  <div class="table-responsive">
                    <table class="table table-striped" align="center" >
                      <tr> 
                        <th>#</th>
                        <th>Nombres</th>
                        <th>Apellidos</th>
                        <th>Código Ingreso</th>
                        <th>Correo</th> 
                        <th>Fecha de Registro</th>                         
                        <th>Acciones</th>
                      </tr>

                      <?php

                      $id_ocupante = $_SESSION['k_id_table'];

                      $contador = 1; 



                        $result = mysqli_query($conexion, 'SELECT * FROM usuario_area where estado = 0 order by id_table_ocup desc');
                        while($row = mysqli_fetch_array($result)){   

                          echo " 
                            <tr>
                            <form method='post' action='validation/act_user.php'>
                              <td class='p-0 text-center'>".$contador++."</td> 
                              <td>".$row['nombres']."</td> 
                              <td>".$row['apellidos']."</td> 
                              <td>".$row['code_reserva']."</td> 
                              <td>".$row['email']."</td>    
                              <td>".$row['fecha_reg']."</td>                               
                              <td>
                                <button type='sumbit' name='btnactivate' value='".$row['id_table_ocup']."' class='btn btn-outline-success btn-sm'>
                                    Activar
                                </button>
                              </td> 
                              </form>
                            </tr>
                          ";


                        }

                      ?>

                      
                    </table>
                  </div>
                </div>
              </div>
            </div>
          </div> 
        </section>

        
      </div>

      <?php include('footer.php'); ?>

    </div>
  </div>
  <!-- General JS Scripts -->
  <script src="assets/js/app.min.js"></script>
  <!-- JS Libraies -->
  <script src="assets/bundles/apexcharts/apexcharts.min.js"></script>
  <!-- Page Specific JS File -->
  <script src="assets/js/page/index.js"></script>
  <!-- Template JS File -->
  <script src="assets/js/scripts.js"></script>
  <!-- Custom JS File -->
  <script src="assets/js/custom.js"></script>
</body>

</html>
<?php
  }
?>