feriados.php 7.44 KB
<?php
session_start();

require './database.php';

if (isset($_SESSION['user_id'])) {
  $records = $conn->prepare('SELECT id, email, password FROM users WHERE id = :id');
  $records->bindParam(':id', $_SESSION['user_id']);
  $records->execute();
  $results = $records->fetch(PDO::FETCH_ASSOC);

  $user = null;

  if (count($results) > 0) {
    $user = $results;
  }
}

$feriados = $conn->prepare("SELECT * FROM turnosv_feriados ORDER BY fecha desc");
$feriados->execute();

?>

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Listado de Feriados</title>
  <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/jszip-2.5.0/dt-1.10.21/b-1.6.2/b-html5-1.6.2/b-print-1.6.2/datatables.min.css"/>
  <script src="js/5fc2169900.js" crossorigin="anonymous"></script>
  <link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
  <?php if(!empty($user)): ?>
    <nav class="navbar navbar-light" style="background-image: url('img/fondoheader.png'); background-repeat: no-repeat; background-position: center; background-size: cover;">
      <div class="navbar-brand mx-auto" >
        <img src="img/logo.png" width="75%" height="75%">
      </div>  
    </nav>
    <br>
    <div class="container">
      <div class="row">
        <div class="col-lg-10 col-md-10 col-sm-12 col-xs-12">
          <h5><b>LISTADO DE FERIADOS</b></h5>
        </div>
        <div class="col-lg-2 col-md-2 col-sm-12 col-xs-12 text-right">
          <a href="logout.php" class="btn btn-sm btn-warning"><b>Cerrar Sesión</b></a>
        </div>
      </div>
      <hr style="border-style: solid; border-width: 1px;">
      <div class="row">
       <div class="col-lg-12 text-left">
        <button class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modalnuevo"><i class="fas fa-plus"></i> Nuevo</button>
      </div>
    </div>
    <div class="row">
      <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <!-- Todos los turnos -->
        <br>
        <div class="table-responsive">
          <table class="display tabladt" style="width:100%">
            <thead>
              <tr>
                <th>FECHA (Día-Mes-Año)</th>
                <th>DESCRIPCION</th>
                <th>ACCIONES</th>
              </tr>
            </thead>
            <tbody>
              <?php
              while($row = $feriados->fetch(PDO::FETCH_ASSOC)) {
                $fecha = date('d-m-Y', strtotime($row['fecha']));
                $id = 'asdujvcwergbnvd87webnw4g8'.$row['id_feriado'].strtotime('tomorrow');
                echo "<tr><td>".$fecha."</td><td>".strtoupper($row["descripcion"])."</td><form method='POST' action='scripts/feriados.php'><td class='text-center'><input type='hidden' value='".$id."' name='identificador'><button type='submit' class='btn btn-sm btn-danger'><i title='Eliminar' class='fas fa-trash-alt'></i></button></td></form></tr>";
              }
              ?>
            </tbody>
          </table>
        </div>
      </div>
      
      <br>
      <br>           
    </div>
    <!-- Modal nuevo feriado -->
    <div class="modal fade" id="modalnuevo" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Nuevo</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
          <form  method="post" action="scripts/feriados.php">
            <div class="modal-body">
              <div class="row">
               <div class="col-lg-12">
                <label for="fecha">Fecha</label>
                <input type="date" name="fecha" required class="form-control">
              </div>
            </div>
            <div class="row">
             <div class="col-lg-12">
              <label for="descripcion">Descripción</label>
              <input type="text" name="descripcion" required class="form-control" autocomplete="off">
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
          <button class="btn btn-primary text-white" type="submit">Aceptar</button>
        </div>
      </form>
    </div>
  </div>
</div>
<!-- Fin Modal -->

<?php else:
  header('Location: login.php');  
endif; ?>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/jszip-2.5.0/dt-1.10.21/b-1.6.2/b-html5-1.6.2/b-print-1.6.2/datatables.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
<script src="//cdn.datatables.net/plug-ins/1.10.12/sorting/datetime-moment.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    $.fn.dataTable.moment('DD-MM-YYYY');
    $('.tabladt').DataTable( {
        "order": [[ 0, "desc" ]], //or asc
        "pageLength": 50,
        language: {
          "sProcessing":     "Procesando...",
          "sLengthMenu":     "Mostrar _MENU_ registros",
          "sZeroRecords":    "No se encontraron resultados",
          "sEmptyTable":     "Ningún dato disponible en esta tabla",
          "sInfo":           "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
          "sInfoEmpty":      "Mostrando registros del 0 al 0 de un total de 0 registros",
          "sInfoFiltered":   "(filtrado de un total de _MAX_ registros)",
          "sInfoPostFix":    "",
          "sSearch":         "Buscar:",
          "sUrl":            "",
          "sInfoThousands":  ",",
          "sLoadingRecords": "Cargando...",
          "oPaginate": {
            "sFirst":    "Primero",
            "sLast":     "Último",
            "sNext":     "Siguiente",
            "sPrevious": "Anterior"
          },
          "oAria": {
            "sSortAscending":  ": Activar para ordenar la columna de manera ascendente",
            "sSortDescending": ": Activar para ordenar la columna de manera descendente"
          },
          "buttons": {
            "copy": "Copiar",
            "colvis": "Visibilidad",
            "print": "Imprimir"
          }
        },
        dom: 'Bfrtip',
        
      } );
  } );
</script>
</body>
</html>