<?php
  session_start();
  if(!(isset($_SESSION["k_name"]))){
        header("location:index.php");
        }
        else{  
 include("includes/conect.php");
 include("includes/timezone.php");
 include("includes/ruta_imagen.php");
 
 $antelacion =  date("Y".'-'."m".'-'."d" ,strtotime($fecha_actual."+ 0 days")); 
//  $fecha_hoy = '2024-03-28'

?>
<!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['success'])) {
                ?>

                    <div class="alert alert-danger alert-dismissible fade show" role="alert">
                        <strong>Reservada cancelada!</strong> Has cancelado tu reserva de forma exitosa.
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>

                <?php
                } 



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

                    <div class="alert alert-success alert-dismissible fade show" role="alert">
                        <strong>Confirmación realizada!</strong>.
                        <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>Salida realizada!</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(" %d de %B del %Y"); 
              ?>
            </h1>  
          </div>
          
          
          



                    <?php

                      $id_ocupante = $_SESSION['k_id_table'];

                      $contador = 1;
                      $contador2 = 1;
                      $estado = 0;
                      

                      if (isset($_GET['input_search'])) {

                      $id_area = $_GET['input_search'];
                      $param_search = $_GET['select_search'];

                        switch ($param_search) {
                            
                            
                            // búsqueda por manilla: Huéspedes
                            case '1':

                            $num_manilla = $_GET['input_search'];
                            $tipo_ocu_manilla = 'HUESPED';

                                $result = mysqli_query($conexion, "SELECT * FROM checkin inner join reserva on checkin.consecutivo = reserva.id_consecutivo where checkin.num_manilla LIKE '%$num_manilla%'  and ocupacion= '$tipo_ocu_manilla' ORDER BY checkin.id_tabla DESC LIMIT 1 ");

                                    $row = mysqli_fetch_array($result);

                                    if(mysqli_num_rows($result) > 0){

                                    $conse_sistema = $row['consecutivo'];

                                    foreach(mysqli_query($conexion, 'SELECT COUNT(*) FROM checkin WHERE consecutivo=\''.$conse_sistema.'\'') as $conteo_hp){  
                                    $cantidad_huesped  = $conteo_hp['COUNT(*)'];}  
                                   

                                    $show_id = $row['id'];

                                     $consulta = mysqli_query($conexion, 'SELECT *  FROM fotos where id_usuario =\''.$show_id.'\' ORDER BY id_foto desc limit 1');
                                       $ro = mysqli_fetch_array($consulta);
                                       $url = $ro['id_foto'];   
                                    ?>


                                    <div class="section-body">
                                      <div class="row mt-sm-4">

                                        <div class="col-12 col-md-12 col-lg-4">
                                          <div class="card author-box">
                                            <div class="card-body">
                                              <h5 style="text-align: center;">Reservas del Mar</h5>
                                              <p></p>


                                              <div class="author-box-center">
                                                <img alt="image" height="100" src="<?php echo $ruta_img.$url.".jpg"; ?>" class="rounded-circle author-box-picture">
                                                <div class="clearfix"></div>
                                                <div class="author-box-name">
                                                  <a href="#"><?php  echo $row['nombre_uno']." ".$row['nombre_dos']." ".$row['apellido_uno']." ".$row['apellido_dos'];?></a>
                                                </div>
                                                <div class="author-box-job"><?php  echo str_replace("_"," ",$row['ocupacion']); ?></div>
                                              </div>
                                              <div class="text-center">
                                                <div class="author-box-description">

                                                  <table style="width: 100%;" border="0">
                                                    <tr>
                                                      <td style='width: 50%; text-align:right'><b>Apartamento: </b></td>
                                                      <td style='width: 50%; text-align:left'><?php echo $row['num_apto']. " - <i class='fas fa-user'></i> (".$cantidad_huesped.")";?></td>
                                                    </tr>   
                                                    <tr>
                                                      <td style='width: 50%; text-align:right'><b>Manilla #: </b></td>
                                                      <td style='width: 50%; text-align:left'><?php echo $row['num_manilla'];?></td> 
                                                    </tr>
                                                    <tr>
                                                      <td colspan="2" style='width: 100%; text-align:center'><b>Reserva: </b><?php echo $row['fecha_checkin']." <i class='fas fa-angle-double-right'></i> ".$row['fecha_checkout']; ?></td>
                                                    </tr> 
                                                  </table>   
                                                  <br> 
                                                  <?php
                                                    if($row['fecha_checkout'] < $fecha_hoy){
                                                        
                                                        if($row['ocupacion'] == 'PROPIETARIO' || $row['ocupacion'] == 'HUESPED_INVITADO'){
                                                            $diabled = '';
                                                            $class='btn-success';    
                                                        }else{
                                                            $diabled = 'disabled';
                                                            $class='btn-default';    
                                                        }
                                                    }else{
                                                        $diabled = '';
                                                        $class='btn-success';
                                                    }
                                                  
                                                  ?>
                                                  
                                                    <button class='btn <?php echo $class;?>' onclick="booked_modal('<?php echo $row['num_apto'];?>', '<?php echo $conse_sistema;?>', '<?php echo $row['ocupacion'];?>')" <?php echo $diabled;?> >Reservar</button>
                                                
                                                </div> 
                                              </div>
                                            </div>
                                          </div> 
                                        </div>

                                        <div class="col-12 col-md-12 col-lg-8">
                                          <div class="card">
                                            <div class="padding-20">
                                              <ul class="nav nav-tabs" id="myTab2" role="tablist">
                                                <li class="nav-item">
                                                  <a class="nav-link active" id="home-tab2" data-toggle="tab" href="#about" role="tab"
                                                    aria-selected="true">Reservas</a>
                                                </li>
                                                <li class="nav-item">
                                                  <a class="nav-link" id="profile-tab2" data-toggle="tab" href="#settings" role="tab"
                                                    aria-selected="false">Integrantes</a>
                                                </li>
                                              </ul>
                                              <div class="tab-content tab-bordered" id="myTab3Content">
                                                <div class="tab-pane fade show active" id="about" role="tabpanel" aria-labelledby="home-tab2">
                                                  <div class="row">

                                                    <div class="table-responsive">
                                                          <table class="table table-striped">
                                                            <tr> 
                                                              <th>#</th>
                                                              <th>Apartamento</th>
                                                              <th>Nombres y Apellidos</th>
                                                              <th>Área</th>
                                                              <th>Reservación</th> 
                                                              <!-- <th>Manilla</th>  -->
                                                              <th>Estado</th> 
                                                            </tr>

                                                            <?php


                                                            $result = mysqli_query($conexion, 'SELECT *, COUNT(*) as cant_rsv FROM ocupante_reserva inner join area on ocupante_reserva.idarea = area.id inner join turno on ocupante_reserva.jornada = turno.id_tabla_turno inner join usuario_area on ocupante_reserva.id_ocupante = usuario_area.idocupante where consecutivo =\''.$conse_sistema.'\' and ocupante_reserva.fecha_in >= \''.$fecha_hoy.'\' GROUP BY ocupante_reserva.consecutivo, ocupante_reserva.fecha_in, ocupante_reserva.hora_in, ocupante_reserva.idarea ORDER BY ocupante_reserva.estado asc, ocupante_reserva.fecha_in asc, ocupante_reserva.hora_in asc');

                                                            // $result = mysqli_query($conexion, 'SELECT * FROM ocupante_reserva inner join area on ocupante_reserva.idarea = area.id inner join usuario_area on ocupante_reserva.id_ocupante = usuario_area.idocupante  where ocupante_reserva.consecutivo =\''.$conse_sistema.'\' and ocupante_reserva.fecha_in >= \''.$fecha_hoy.'\' order by ocupante_reserva.cancelado asc, ocupante_reserva.fecha_in desc, ocupante_reserva.hora_in asc');

                                                             while($row_find_book = mysqli_fetch_array($result)){  
                                                                 
                                                                 if($row_find_book['verificado'] == 1){
                                                                    $style_gray = "style='background-color:#6DCCB8'";        
                                                                    }


                                                                  if($row_find_book['cancelado'] == 1){
                                                                    $cancelado = 'Cancelada';     
                                                                  }else{
                                                                    $cancelado = 'Activa'; 
                                                                  }  

                                                                  echo "
                                                                    <tr>
                                                                      <td class='p-0 text-center'>".$contador++."</td>
                                                                      <td>".$row_find_book['apto_from']."</td>
                                                                      <td >".$row_find_book['nombres']." ".$row_find_book['apellidos']." | ". $row['ocupacion']."</td>
                                                                      <td >".$row_find_book['nombre']."</td>
                                                                      <td >".$row_find_book['fecha_in']." | ".$row_find_book['hora_in']."</td> 
                                                                        <td >";
                                                                      
                                                                    //   $cancelado
                                                                    
                                                                    
                                                                    if($row_find_book['cancelado'] == 1){
                                                                    //   echo $row_find_book['cancelado']; 
                                                                       echo "Cancelado";
                                                                    }else{
                                                                        if($row_find_book[13] == 1){
                                                                        //   echo $row_find_book[13];
                                                                           echo "Anulado";
                                                                        }else{
                                                                            if($row_find_book['verificado'] == 1){
                                                                                echo "En sitio";
                                                                            //   echo $row_find_book['verificado']; 
                                                                            }    
                                                                            else{
                                                                                echo "Activa";
                                                                            }
                                                                        }    
                                                                    }
                                                                      
                                                                      echo "</td>
                                                                    </tr>
                                                                  ";


                                                                }

                                                              ?>

                                                          </table>
                                                        </div>
                                                    

                                                  </div>

                                                </div>

                                                <div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="profile-tab2">
                                                  <div class="table-responsive">
                                                          <table class="table table-striped">
                                                            <tr> 
                                                              <th>#</th>
                                                              <th>Apartamento</th>
                                                              <th>Nombres y Apellidos</th>
                                                              <th>Manilla</th> 
                                                            </tr>

                                                            <?php


                                                            $result_find = mysqli_query($conexion, 'SELECT checkin.num_manilla, checkin.ocupacion as ocup_from_check, checkin.nombre_uno as nombres, checkin.apellido_uno as apellidos, reserva.id_consecutivo as conse_sistema_show, reserva.num_apto as apto_show FROM checkin inner join reserva on checkin.consecutivo = reserva.id_consecutivo where reserva.id_consecutivo =\''.$conse_sistema.'\' ORDER BY checkin.id_tabla asc'); 

                                                             while($row_find_chk = mysqli_fetch_array($result_find)){                                                               
 

                                                                  echo "
                                                                    <tr>
                                                                      <td class='p-0 text-center'>".$contador2++."</td>
                                                                      <td>".$row_find_chk['apto_show']."</td>
                                                                      <td >".$row_find_chk['nombres']." ".$row_find_chk['apellidos']." | ". $row_find_chk['ocup_from_check']."</td>
                                                                      <td >".$row_find_chk['num_manilla']."</td> 
                                                                    </tr>
                                                                  ";


                                                                }

                                                              ?>

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

                                <!-- moadal para ingreso -->
                                <div class="modal fade" id='modal_reservation' tabindex="-1" role="dialog" aria-labelledby="formModal"
                                  aria-hidden="true">
                                  <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                      <div class="modal-header">
                                        <h5 class="modal-title" id="formModal">Zona a reservar: <span id="span_text_rsv"></span></h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                          <span aria-hidden="true">&times;</span>
                                        </button>
                                      </div>
                        
                                      <div class="modal-body">                
                         
                        
                                       <form id="form_hpds">
                                        <input type="hidden" id='input_area' name="input_area">
                        
                                        <?php
                        
                                        /*Apto */
                                        $apto_reserva  = $_SESSION['k_code_reserva'];
                        
                                        /*Folio*/
                                        $k_id_tabla    = $_SESSION['k_code'];
                        
                                         echo "<input type='hidden' name='id_factura' value='".$apto_reserva."'>";
                                         echo "<input type='hidden' name='apto_from' value='".$apto_reserva."'>";
                                        ?>
                         
                                          <div class="form-group">
                                            <label>Apartamento:</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-home"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12">
                                                <!-- <div class="col-md-1 col-sm-1 col-xs-1"> -->
                                                <input type="text" id="apto_from" name='apto_from'  readonly="readonly" class="form-control" style="width: 180px">
                                              </div>
                                            </div>
                                          </div> 
                         
                                          
                                            <div class="form-group">
                                            <label for="post_day">Fecha de Reservación: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-calendar"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12" > 
                                                <input type='date' name='date_reserva' id='date_reserva' min='<?php echo $fecha_hoy; ?>' max='<?php echo $antelacion; ?>' value='<?php echo $fecha_hoy; ?>' class="form-control " style="width: 180px">
                                              </div>
                                            </div>
                                          </div>
                                          
                                            <!-- <div class="form-group show_number_reserva" style="display:none;">
                                            <label for="post_day">Número de personas:</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-user"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-9">  -->
                                                <input type='hidden' name='number_reserva' id='number_reserva' min="1" max="6" value='0' class="form-control  " style="width: 180px">
                                          <!--     </div>
                                            </div>
                                          </div> -->
                                          
                                            <div class="form-group">
                                            <label for="post_day">Zona Común: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-tag"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12"> 
                                                <select name='select_area' id='select_area' class='form-control' style="width: 180px"></select>
                                              </div>
                                            </div>
                                          </div>
                                          
                                          
                                          
                                          <div class="form-group div_nucleo" style="display: nonex; width: 85%;">
                                             <div class="table-responsive">
                                              <caption>Integrantes de Reserva</caption>
                                            <table class="table table-striped">
                                              <tr> 
                                                <th style="text-align:left; width: 5%;">Elegir</th>
                                                <th style="text-align:left">Nombres y Apellidos</th>
                                                <!-- <th style="text-align:left">ID</th> -->
                                              </tr> 
                        
                                               <?php 
                        
                                              $contador = 1;
                                                
                                                $cod_nucleo = $conse_sistema;
                        
                                                $result = mysqli_query($conexion, 'SELECT id as idocupante, apellido_uno, nombre_uno, nombre_dos FROM checkin where consecutivo =\''.$conse_sistema.'\' order by id_tabla asc');
                                                while($row_nucleo = mysqli_fetch_array($result)){        
                         
                        
                                                  echo "
                                                    <tr>
                                                      <td style='text-align:left' class='p-0 text-center'>".$contador++." 
                                                        <input type='checkbox' for='name_huesped' name='check_huesped' id='".$cod_nucleo.$contador."' class='check_huesped' value='".$row_nucleo['idocupante']."' checked>
                                                        <input type='hidden' name='name_huesped[]' id='".$cod_nucleo.$contador."name_huesped' class='name_huesped'  value='".$row_nucleo['nombre_uno']." ".$row_nucleo['nombre_dos']."'></td> 
                                                      <td style='text-align:left'> 
                                                        <input type='hidden' name='ide_nucleo[]' value='".$row_nucleo['idocupante']."' id='".$cod_nucleo.$contador."ide_nucleo'>
                                                        <input type='hidden' name='ide_consecutivo[]' value='".$cod_nucleo."' id='".$cod_nucleo.$contador."ide_consecutivo'>
                                                       
                                                      ".$row_nucleo['nombre_uno']." ".$row_nucleo['apellido_uno']."
                                                    </td>                         
                                                    <!--<td style='text-align:left' class='p-0 text-center'>".$row_nucleo['idocupante']."</td>-->
                                                    </tr>
                                                  "; 
                                                } 
                        
                                              ?>
                        
                                              
                                            </table>
                                          </div>
                                          </div> 
                                          
                                          
                                            <div class="form-group">
                                            <label for="post_day">Horario: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-clock"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12"> 
                                                <select name='select_turno' id='select_turno' class='form-control' style="width: 180px"></select>
                                              </div>
                                            </div>
                                          </div>
                                          
                                            
                        
                        
                                            <div class="form-group" style="text-align: center;"> 
                                            <div class="input-group" style="text-align: center;">
                                              <div class="input-group-prepend" style="text-align: center;"> 
                                                <input type='hidden' name='modalidad_reserva_send' id='modalidad_reserva_send' class="form-control" style="width: 180px">
                                                <input type='hidden' name='consecucion_reserva_send' id='consecucion_reserva_send' class="form-control" style="width: 180px">
                                                <button type="submit" id="btn_send_hpds" class="btn btn-success m-t-15 waves-effect" disabled='disabled'>Confirmar Reserva</button>
                                              </div>  
                                            </div>
                                          </div>                   
                        
                                        </form>
                        
                                      </div>
                                    </div>
                                  </div>
                                </div> 

                    <?php 
                        
                        
                        /*si no existe coincidencias*/
                                    }else{
                                      ?>  
                                      
                                      <section class="section">          
                                          <div class="row">
                                            <div class="col-12">
                                              <div class="card">
                                                <div class="card-header">
                                                  <h4>Resultados de búsqueda: <?php 
                                                    if (isset($_GET['input_search'])) {
                                                      echo "";
                                                    }else{
                                                      echo $_GET['na'];    
                                                    }
                                                   ?></h4> 
                                                </div>
                                                <div class="card-body p-100">
                    
                                                  
                                                    <?php
                    
                                                      $param_search = $_GET['select_search'];
                    
                                                        switch ($param_search) {
                                                            // búsqueda por manilla: {datos de huésped, datos de reserva, todas las reservas por apto}
                                                            case '1':
                                                              echo "# de Manilla no encontrada (Manilla Blanca).";
                                                              break;
                    
                                                              // nombres y ap
                                                            case '2':                               
                                                              echo "Nombres o Apellidos no encontrados.";
                                                              break;
                    
                                                              // aptp
                                                            case '3':
                                                              echo "Apartamento no encontrado.";
                                                              break;
                                                          }
                    
                                                    ?>
                                                  
                                                </div>
                                              </div>
                                            </div>
                                          </div> 
                                        </section>
            
                                          <?php
                                        }


                              break;

                              // búsqueda por nombres y apellidos
                            case '2':
                              
                              $result = mysqli_query($conexion, 'SELECT * FROM ocupante_reserva inner join area on ocupante_reserva.idarea = area.id inner join usuario_area on ocupante_reserva.id_ocupante = usuario_area.idocupante inner join checkin on ocupante_reserva.id_ocupante = checkin.id where usuario_area.nombres like \''.$id_area.'\' and ocupante_reserva.estado =\''.$estado.'\' and ocupante_reserva.fecha_in >=\''.$fecha_hoy.'\' order by ocupante_reserva.fecha_in desc');

                              break;

                              // búsqueda por manilla: Invitados    
                            case '3': 

                                  $num_apto = $_GET['input_search'];  
                                  
                                  

                                $result = mysqli_query($conexion, 'SELECT * FROM checkin inner join reserva on checkin.consecutivo = reserva.id_consecutivo where reserva.num_apto =\''.$num_apto.'\' order by reserva.id_consecutivo desc');

                                    $row = mysqli_fetch_array($result);

                                    if(mysqli_num_rows($result) > 0){

                                    $conse_sistema = $row['consecutivo'];

                                    foreach(mysqli_query($conexion, 'SELECT COUNT(*) FROM checkin WHERE consecutivo=\''.$conse_sistema.'\'') as $conteo_hp){  
                                    $cantidad_huesped  = $conteo_hp['COUNT(*)'];}  
                                   

                                    $show_id = $row['id'];

                                     $consulta = mysqli_query($conexion, 'SELECT *  FROM fotos where id_usuario =\''.$show_id.'\' ORDER BY id_foto desc limit 1');
                                       $ro = mysqli_fetch_array($consulta);
                                       $url = $ro['id_foto'];   
                                    ?>


                                    <div class="section-body">
                                      <div class="row mt-sm-4">

                                        <div class="col-12 col-md-12 col-lg-4">
                                          <div class="card author-box">
                                            <div class="card-body">
                                              <h5 style="text-align: center;">Reservas del Mar</h5>
                                              <p></p>


                                              <div class="author-box-center">
                                                
                                                <div class="clearfix"></div>
                                                <div class="author-box-name">
                                                  <a href="#">OCUPACIÓN: <?php  echo str_replace("_"," ",$row['ocupacion']); ?></a>
                                                </div>
                                                <div class="author-box-job"></div>
                                              </div>
                                              <div class="text-center">
                                                <div class="author-box-description">

                                                  <table style="width: 100%;" border="0">
                                                    <tr>
                                                      <td style='width: 50%; text-align:right'><b>Apartamento: </b></td>
                                                      <td style='width: 50%; text-align:left'><?php echo $row['num_apto']. " - <i class='fas fa-user'></i> (".$cantidad_huesped.")";?></td>
                                                    </tr>   
                                                    <tr>
                                                      <td style='width: 50%; text-align:right'><b> </b></td>
                                                      <td style='width: 50%; text-align:left'></td> 
                                                    </tr>
                                                    <tr>
                                                      <td colspan="2" style='width: 100%; text-align:center'><b>Reserva: </b><?php echo $row['fecha_checkin']." <i class='fas fa-angle-double-right'></i> ".$row['fecha_checkout']; ?></td>
                                                    </tr> 
                                                  </table>   
                                                  <br> 
                                                  <?php
                                                    if($row['fecha_checkout'] < $fecha_hoy){
                                                        if($row['ocupacion'] == 'PROPIETARIO' || $row['ocupacion']== 'HUESPED_INVITADO'){
                                                            $diabled = '';
                                                            $class='btn-success';    
                                                        }else{
                                                            $diabled = 'disabled';
                                                            $class='btn-default';    
                                                        }
                                                    }else{
                                                        $diabled = '';
                                                        $class='btn-success';
                                                    }
                                                  
                                                  ?>
                                                  
                                                    <button class='btn <?php echo $class;?>' onclick="booked_modal('<?php echo $row['num_apto'];?>', '<?php echo $conse_sistema;?>', '<?php echo $row['ocupacion'];?>')" <?php echo $diabled;?> >Reservar</button>
                                                
                                                </div> 
                                              </div>
                                            </div>
                                          </div> 
                                        </div>

                                        <div class="col-12 col-md-12 col-lg-8">
                                          <div class="card">
                                            <div class="padding-20">
                                              <ul class="nav nav-tabs" id="myTab2" role="tablist">
                                                <li class="nav-item">
                                                  <a class="nav-link active" id="home-tab2" data-toggle="tab" href="#about" role="tab"
                                                    aria-selected="true">Reservas</a>
                                                </li>
                                                <li class="nav-item">
                                                  <a class="nav-link" id="profile-tab2" data-toggle="tab" href="#settings" role="tab"
                                                    aria-selected="false">Integrantes</a>
                                                </li>
                                              </ul>
                                              <div class="tab-content tab-bordered" id="myTab3Content">
                                                <div class="tab-pane fade show active" id="about" role="tabpanel" aria-labelledby="home-tab2">
                                                  <div class="row">

                                                    <div class="table-responsive">
                                                          <table class="table table-striped">
                                                            <tr> 
                                                              <th>#</th>
                                                              <th>Apartamento</th>
                                                              <th>Nombres y Apellidos</th>
                                                              <th>Área</th>
                                                              <th>Reservación</th> 
                                                              <!-- <th>Manilla</th>  -->
                                                              <th>Estado</th> 
                                                            </tr>

                                                            <?php


                                                            $result = mysqli_query($conexion, 'SELECT * FROM ocupante_reserva inner join area on ocupante_reserva.idarea = area.id inner join turno on ocupante_reserva.jornada = turno.id_tabla_turno inner join usuario_area on ocupante_reserva.id_ocupante = usuario_area.idocupante where ocupante_reserva.consecutivo =\''.$conse_sistema.'\' and ocupante_reserva.fecha_in >= \''.$fecha_hoy.'\' ORDER BY ocupante_reserva.estado asc, ocupante_reserva.fecha_in asc, ocupante_reserva.hora_in asc');

                                                            // $result = mysqli_query($conexion, 'SELECT * FROM ocupante_reserva inner join area on ocupante_reserva.idarea = area.id inner join usuario_area on ocupante_reserva.id_ocupante = usuario_area.idocupante  where ocupante_reserva.consecutivo =\''.$conse_sistema.'\' and ocupante_reserva.fecha_in >= \''.$fecha_hoy.'\' order by ocupante_reserva.cancelado asc, ocupante_reserva.fecha_in desc, ocupante_reserva.hora_in asc');

                                                             while($row_find_book = mysqli_fetch_array($result)){                                                                 


                                                                  if($row_find_book['cancelado'] == 1){
                                                                    $cancelado = 'Cancelada';     
                                                                  }else{
                                                                    $cancelado = 'Activa'; 
                                                                  }  
                                                                  
                                                                   if($row_find_book['verificado'] == 1){
                                                                    $style_gray = "style='background-color:#6DCCB8'";        
                                                                    }

                                                                  echo "
                                                                    <tr>
                                                                      <td class='p-0 text-center'>".$contador++."</td>
                                                                      <td>".$row_find_book['apto_from']."</td>
                                                                      <td >".$row_find_book['nombres']." ".$row_find_book['apellidos']." | ". $row['ocupacion']."</td>
                                                                      <td >".$row_find_book['nombre']."</td>
                                                                      <td >".$row_find_book['fecha_in']." | ".$row_find_book['hora_in']."</td> 
                                                                      <td >";
                                                                      
                                                                    //   $cancelado
                                                                    
                                                                    
                                                                    if($row_find_book['cancelado'] == 1){
                                                                    //   echo $row_find_book['cancelado']; 
                                                                       echo "Cancelado";
                                                                    }else{
                                                                        if($row_find_book[13] == 1){
                                                                        //   echo $row_find_book[13];
                                                                           echo "Anulado";
                                                                        }else{
                                                                            if($row_find_book['verificado'] == 1){
                                                                                echo "En sitio";
                                                                            //   echo $row_find_book['verificado']; 
                                                                            }    
                                                                            else{
                                                                                echo "Activa";
                                                                            }
                                                                        }    
                                                                    }
                                                                      
                                                                      echo "</td>";
                                                                      
                                                                      
                                                                      //   $accion_show &nbsp; $checkout &nbsp; $cancelado</td>
                                                              echo"<td align='right'> 
                                                                    </tr>
                                                                  ";


                                                                }

                                                              ?>

                                                          </table>
                                                        </div>
                                                    

                                                  </div>

                                                </div>

                                                <div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="profile-tab2">
                                                  <div class="table-responsive">
                                                          <table class="table table-striped">
                                                            <tr> 
                                                              <th>#</th>
                                                              <th>Apartamento</th>
                                                              <th>Nombres y Apellidos</th>
                                                              <th>Manilla</th> 
                                                            </tr>

                                                            <?php


                                                            $result_find = mysqli_query($conexion, 'SELECT checkin.num_manilla, checkin.ocupacion as ocup_from_check, checkin.nombre_uno as nombres, checkin.apellido_uno as apellidos, reserva.id_consecutivo as conse_sistema_show, reserva.num_apto as apto_show FROM checkin inner join reserva on checkin.consecutivo = reserva.id_consecutivo where reserva.id_consecutivo =\''.$conse_sistema.'\' ORDER BY checkin.id_tabla asc'); 

                                                             while($row_find_chk = mysqli_fetch_array($result_find)){                                                               
 

                                                                  echo "
                                                                    <tr>
                                                                      <td class='p-0 text-center'>".$contador2++."</td>
                                                                      <td>".$row_find_chk['apto_show']."</td>
                                                                      <td >".$row_find_chk['nombres']." ".$row_find_chk['apellidos']." | ". $row_find_chk['ocup_from_check']."</td>
                                                                      <td >".$row_find_chk['num_manilla']."</td> 
                                                                    </tr>
                                                                  ";


                                                                }

                                                              ?>

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

                                <!-- modal para ingreso -->
                                <div class="modal fade" id='modal_reservation' tabindex="-1" role="dialog" aria-labelledby="formModal"
                                  aria-hidden="true">
                                  <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                      <div class="modal-header">
                                        <h5 class="modal-title" id="formModal">Zona a reservar: <span id="span_text_rsv"></span></h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                          <span aria-hidden="true">&times;</span>
                                        </button>
                                      </div>
                        
                                      <div class="modal-body">                
                         
                        
                                       <form id="form_hpds">
                                        <input type="hidden" id='input_area' name="input_area">
                        
                                        <?php
                        
                                        /*Apto */
                                        $apto_reserva  = $_SESSION['k_code_reserva'];
                        
                                        /*Folio*/
                                        $k_id_tabla    = $_SESSION['k_code'];
                        
                                         echo "<input type='hidden' name='id_factura' value='".$apto_reserva."'>";
                                         echo "<input type='hidden' name='apto_from' value='".$apto_reserva."'>";
                                        ?>
                         
                                          <div class="form-group">
                                            <label>Apartamento:</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-home"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12">
                                                <!-- <div class="col-md-1 col-sm-1 col-xs-1"> -->
                                                <input type="text" id="apto_from" name='apto_from'  readonly="readonly" class="form-control" style="width: 180px">
                                              </div>
                                            </div>
                                          </div> 
                         
                                          
                                            <div class="form-group">
                                            <label for="post_day">Fecha de Reservación: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-calendar"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12" > 
                                                <input type='date' name='date_reserva' id='date_reserva' min='<?php echo $fecha_hoy; ?>' max='<?php echo $antelacion; ?>' value='<?php echo $fecha_hoy; ?>' class="form-control " style="width: 180px">
                                              </div>
                                            </div>
                                          </div>
                                           
                                            <input type='hidden' name='number_reserva' id='number_reserva' min="1" max="6" value='0' class="form-control  " style="width: 180px">
                                           
                                          
                                            <div class="form-group">
                                            <label for="post_day">Zona Común: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-tag"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12"> 
                                                <select name='select_area' id='select_area' class='form-control' style="width: 180px"></select>
                                              </div>
                                            </div>
                                          </div>
                                          
                                          
                                          
                                          <div class="form-group div_nucleo" style="display: nonex; width: 85%;">
                                             <div class="table-responsive">
                                              <caption>Integrantes de Reserva</caption>
                                            <table class="table table-striped">
                                              <tr> 
                                                <th style="text-align:left; width: 5%;">Elegir</th>
                                                <th style="text-align:left">Nombres y Apellidos</th>
                                                <!-- <th style="text-align:left">ID</th> -->
                                              </tr> 
                        
                                               <?php 
                        
                                              $contador = 1;
                                                
                                                $cod_nucleo = $conse_sistema;
                        
                                                $result = mysqli_query($conexion, 'SELECT id as idocupante, apellido_uno, nombre_uno, nombre_dos FROM checkin where consecutivo =\''.$conse_sistema.'\' order by id_tabla asc');
                                                while($row_nucleo = mysqli_fetch_array($result)){        
                         
                        
                                                  echo "
                                                    <tr>
                                                      <td style='text-align:left' class='p-0 text-center'>".$contador++." 
                                                        <input type='checkbox' for='name_huesped' name='check_huesped' id='".$cod_nucleo.$contador."' class='check_huesped' value='".$row_nucleo['idocupante']."' checked>
                                                        <input type='hidden' name='name_huesped[]' id='".$cod_nucleo.$contador."name_huesped' class='name_huesped'  value='".$row_nucleo['nombre_uno']." ".$row_nucleo['nombre_dos']."'></td> 
                                                      <td style='text-align:left'> 
                                                        <input type='hidden' name='ide_nucleo[]' value='".$row_nucleo['idocupante']."' id='".$cod_nucleo.$contador."ide_nucleo'>
                                                        <input type='hidden' name='ide_consecutivo[]' value='".$cod_nucleo."' id='".$cod_nucleo.$contador."ide_consecutivo'>
                                                       
                                                      ".$row_nucleo['nombre_uno']." ".$row_nucleo['apellido_uno']."
                                                    </td>                         
                                                    <!--<td style='text-align:left' class='p-0 text-center'>".$row_nucleo['idocupante']."</td>-->
                                                    </tr>
                                                  "; 
                                                } 
                        
                                              ?>
                        
                                              
                                            </table>
                                          </div>
                                          </div> 
                                          
                                          
                                            <div class="form-group">
                                            <label for="post_day">Horario: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-clock"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12"> 
                                                <select name='select_turno' id='select_turno' class='form-control' style="width: 180px"></select>
                                              </div>
                                            </div>
                                          </div>
                                          
                                            
                        
                        
                                            <div class="form-group" style="text-align: center;"> 
                                            <div class="input-group" style="text-align: center;">
                                              <div class="input-group-prepend" style="text-align: center;"> 
                                                <input type='hidden' name='modalidad_reserva_send' id='modalidad_reserva_send' class="form-control" style="width: 180px">
                                                <input type='hidden' name='consecucion_reserva_send' id='consecucion_reserva_send' class="form-control" style="width: 180px">
                                                <button type="submit" id="btn_send_hpds" class="btn btn-success m-t-15 waves-effect" disabled='disabled'>Confirmar Reserva</button>
                                              </div>  
                                            </div>
                                          </div>                   
                        
                                        </form>
                        
                                      </div>
                                    </div>
                                  </div>
                                </div> 

                    <?php 
                        
                        
                        /*si no existe coincidencias*/
                                    }else{
                                      ?>  
                                      
                                      <section class="section">          
                                          <div class="row">
                                            <div class="col-12">
                                              <div class="card">
                                                <div class="card-header">
                                                  <h4>Resultados de búsqueda: <?php 
                                                    if (isset($_GET['input_search'])) {
                                                      echo "";
                                                    }else{
                                                      echo $_GET['na'];    
                                                    }
                                                   ?></h4> 
                                                </div>
                                                <div class="card-body p-100">
                    
                                                  
                                                    <?php
                    
                                                      $param_search = $_GET['select_search'];
                    
                                                        switch ($param_search) {
                                                            // búsqueda por manilla: {datos de huésped, datos de reserva, todas las reservas por apto}
                                                            case '1':
                                                              echo "# de Manilla no encontrada.";
                                                              break;
                    
                                                              // nombres y ap
                                                            case '2':                               
                                                              echo "Nombres o Apellidos no encontrados.";
                                                              break;
                    
                                                              // aptp
                                                            case '3':
                                                              echo "Apartamento no encontrado.";
                                                              break;
                                                          }
                    
                                                    ?>
                                                  
                                                </div>
                                              </div>
                                            </div>
                                          </div> 
                                        </section>
            
                                          <?php
                                        }
                                  
                                  


                              break;


                              // búsqueda por Identificación
                            case '4': 
                                
                                $identidad = $_GET['input_search'];
                                $result = mysqli_query($conexion, 'SELECT * FROM checkin inner join reserva on checkin.consecutivo = reserva.id_consecutivo where  checkin.id = \''.$identidad.'\' order by reserva.id_consecutivo desc');

                                    $row = mysqli_fetch_array($result);

                                    if(mysqli_num_rows($result) > 0){

                                    $conse_sistema = $row['consecutivo'];

                                    foreach(mysqli_query($conexion, 'SELECT COUNT(*) FROM checkin WHERE consecutivo=\''.$conse_sistema.'\'') as $conteo_hp){  
                                    $cantidad_huesped  = $conteo_hp['COUNT(*)'];}  
                                   

                                    $show_id = $row['id'];

                                     $consulta = mysqli_query($conexion, 'SELECT *  FROM fotos where id_usuario =\''.$show_id.'\' ORDER BY id_foto desc limit 1');
                                       $ro = mysqli_fetch_array($consulta);
                                       $url = $ro['id_foto'];   
                                    ?>


                                    <div class="section-body">
                                      <div class="row mt-sm-4">

                                        <div class="col-12 col-md-12 col-lg-4">
                                          <div class="card author-box">
                                            <div class="card-body">
                                              <h5 style="text-align: center;">Reservas del Mar</h5>
                                              <p></p>


                                              <div class="author-box-center">
                                                <img alt="image" height="100" src="<?php echo $ruta_img.$url.".jpg"; ?>" class="rounded-circle author-box-picture">
                                                <div class="clearfix"></div>
                                                <div class="author-box-name">
                                                  <a href="#"><?php  echo $row['nombre_uno']." ".$row['nombre_dos']." ".$row['apellido_uno']." ".$row['apellido_dos'];?></a>
                                                </div>
                                                <div class="author-box-job"><?php  echo str_replace("_"," ",$row['ocupacion']); ?></div>
                                              </div>
                                              <div class="text-center">
                                                <div class="author-box-description">

                                                  <table style="width: 100%;" border="0">
                                                    <tr>
                                                      <td style='width: 50%; text-align:right'><b>Apartamento: </b></td>
                                                      <td style='width: 50%; text-align:left'><?php echo $row['num_apto']. " - <i class='fas fa-user'></i> (".$cantidad_huesped.")";?></td>
                                                    </tr>   
                                                    <tr>
                                                      <td style='width: 50%; text-align:right'><b>Manilla #: </b></td>
                                                      <td style='width: 50%; text-align:left'><?php echo $row['num_manilla'];?></td> 
                                                    </tr>
                                                    <tr>
                                                      <td colspan="2" style='width: 100%; text-align:center'><b>Reserva: </b><?php echo $row['fecha_checkin']." <i class='fas fa-angle-double-right'></i> ".$row['fecha_checkout']; ?></td>
                                                    </tr> 
                                                  </table>   
                                                  <br> 
                                                  
                                                  <?php
                                                    if($row['fecha_checkout'] < $fecha_hoy){
                                                        if($row['ocupacion'] == 'PROPIETARIO' || $row['ocupacion']== 'HUESPED_INVITADO'){
                                                            $diabled = '';
                                                            $class='btn-success';    
                                                        }else{
                                                            $diabled = 'disabled';
                                                            $class='btn-default';    
                                                        }
                                                    }else{
                                                        $diabled = '';
                                                        $class='btn-success';
                                                    }
                                                  
                                                  ?>
                                                  
                                                    <button class='btn <?php echo $class;?>' onclick="booked_modal('<?php echo $row['num_apto'];?>', '<?php echo $conse_sistema;?>', '<?php echo $row['ocupacion'];?>')" <?php echo $diabled;?> >Reservar</button>
                                                
                                                </div> 
                                              </div>
                                            </div>
                                          </div> 
                                        </div>

                                        <div class="col-12 col-md-12 col-lg-8">
                                          <div class="card">
                                            <div class="padding-20">
                                              <ul class="nav nav-tabs" id="myTab2" role="tablist">
                                                <li class="nav-item">
                                                  <a class="nav-link active" id="home-tab2" data-toggle="tab" href="#about" role="tab"
                                                    aria-selected="true">Reservas</a>
                                                </li>
                                                <li class="nav-item">
                                                  <a class="nav-link" id="profile-tab2" data-toggle="tab" href="#settings" role="tab"
                                                    aria-selected="false">Integrantes</a>
                                                </li>
                                              </ul>
                                              <div class="tab-content tab-bordered" id="myTab3Content">
                                                <div class="tab-pane fade show active" id="about" role="tabpanel" aria-labelledby="home-tab2">
                                                  <div class="row">

                                                    <div class="table-responsive">
                                                          <table class="table table-striped">
                                                            <tr> 
                                                              <th>#</th>
                                                              <th>Apartamento</th>
                                                              <th>Nombres y Apellidos</th>
                                                              <th>Área</th>
                                                              <th>Reservación</th> 
                                                              <!-- <th>Manilla</th>  -->
                                                              <th>Estado</th> 
                                                            </tr>

                                                            <?php


                                                            $result = mysqli_query($conexion, 'SELECT *, COUNT(*) as cant_rsv FROM ocupante_reserva inner join area on ocupante_reserva.idarea = area.id inner join turno on ocupante_reserva.jornada = turno.id_tabla_turno inner join usuario_area on ocupante_reserva.id_ocupante = usuario_area.idocupante where consecutivo =\''.$conse_sistema.'\' and ocupante_reserva.fecha_in >= \''.$fecha_hoy.'\' GROUP BY ocupante_reserva.consecutivo, ocupante_reserva.fecha_in, ocupante_reserva.hora_in, ocupante_reserva.idarea ORDER BY ocupante_reserva.estado asc, ocupante_reserva.fecha_in asc, ocupante_reserva.hora_in asc');

                                                            // $result = mysqli_query($conexion, 'SELECT * FROM ocupante_reserva inner join area on ocupante_reserva.idarea = area.id inner join usuario_area on ocupante_reserva.id_ocupante = usuario_area.idocupante  where ocupante_reserva.consecutivo =\''.$conse_sistema.'\' and ocupante_reserva.fecha_in >= \''.$fecha_hoy.'\' order by ocupante_reserva.cancelado asc, ocupante_reserva.fecha_in desc, ocupante_reserva.hora_in asc');

                                                             while($row_find_book = mysqli_fetch_array($result)){                                                                 


                                                                  if($row_find_book['cancelado'] == 1){
                                                                    $cancelado = 'Cancelada';     
                                                                  }else{
                                                                    $cancelado = 'Activa'; 
                                                                  }  
                                                                  
                                                                   if($row_find_book['verificado'] == 1){
                                                                    $style_gray = "style='background-color:#6DCCB8'";        
                                                                    }

                                                                  echo "
                                                                    <tr>
                                                                      <td class='p-0 text-center'>".$contador++."</td>
                                                                      <td>".$row_find_book['apto_from']."</td>
                                                                      <td >".$row_find_book['nombres']." ".$row_find_book['apellidos']." | ". $row['ocupacion']."</td>
                                                                      <td >".$row_find_book['nombre']."</td>
                                                                      <td >".$row_find_book['fecha_in']." | ".$row_find_book['hora_in']."</td> 
                                                                        <td >";
                                                                      
                                                                    //   $cancelado
                                                                    
                                                                    
                                                                    if($row_find_book['cancelado'] == 1){
                                                                    //   echo $row_find_book['cancelado']; 
                                                                       echo "Cancelado";
                                                                    }else{
                                                                        if($row_find_book[13] == 1){
                                                                        //   echo $row_find_book[13];
                                                                           echo "Anulado";
                                                                        }else{
                                                                            if($row_find_book['verificado'] == 1){
                                                                                echo "En sitio";
                                                                            //   echo $row_find_book['verificado']; 
                                                                            }    
                                                                            else{
                                                                                echo "Activa";
                                                                            }
                                                                        }    
                                                                    }
                                                                      
                                                                      echo "</td>
                                                                    </tr>
                                                                  ";


                                                                }

                                                              ?>

                                                          </table>
                                                        </div>
                                                    

                                                  </div>

                                                </div>

                                                <div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="profile-tab2">
                                                  <div class="table-responsive">
                                                          <table class="table table-striped">
                                                            <tr> 
                                                              <th>#</th>
                                                              <th>Apartamento</th>
                                                              <th>Nombres y Apellidos</th>
                                                              <th>Manilla</th> 
                                                            </tr>

                                                            <?php


                                                            $result_find = mysqli_query($conexion, 'SELECT checkin.num_manilla, checkin.ocupacion as ocup_from_check, checkin.nombre_uno as nombres, checkin.apellido_uno as apellidos, reserva.id_consecutivo as conse_sistema_show, reserva.num_apto as apto_show FROM checkin inner join reserva on checkin.consecutivo = reserva.id_consecutivo where reserva.id_consecutivo =\''.$conse_sistema.'\' ORDER BY checkin.id_tabla asc'); 

                                                             while($row_find_chk = mysqli_fetch_array($result_find)){                                                               
 

                                                                  echo "
                                                                    <tr>
                                                                      <td class='p-0 text-center'>".$contador2++."</td>
                                                                      <td>".$row_find_chk['apto_show']."</td>
                                                                      <td >".$row_find_chk['nombres']." ".$row_find_chk['apellidos']." | ". $row_find_chk['ocup_from_check']."</td>
                                                                      <td >".$row_find_chk['num_manilla']."</td> 
                                                                    </tr>
                                                                  ";


                                                                }

                                                              ?>

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

                                <!-- moadal para ingreso -->
                                <div class="modal fade" id='modal_reservation' tabindex="-1" role="dialog" aria-labelledby="formModal"
                                  aria-hidden="true">
                                  <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                      <div class="modal-header">
                                        <h5 class="modal-title" id="formModal">Zona a reservar: <span id="span_text_rsv"></span></h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                          <span aria-hidden="true">&times;</span>
                                        </button>
                                      </div>
                        
                                      <div class="modal-body">                
                         
                        
                                       <form id="form_hpds">
                                        <input type="hidden" id='input_area' name="input_area">
                        
                                        <?php
                        
                                        /*Apto */
                                        $apto_reserva  = $_SESSION['k_code_reserva'];
                        
                                        /*Folio*/
                                        $k_id_tabla    = $_SESSION['k_code'];
                        
                                         echo "<input type='hidden' name='id_factura' value='".$apto_reserva."'>";
                                         echo "<input type='hidden' name='apto_from' value='".$apto_reserva."'>";
                                        ?>
                         
                                          <div class="form-group">
                                            <label>Apartamento:</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-home"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12">
                                                <!-- <div class="col-md-1 col-sm-1 col-xs-1"> -->
                                                <input type="text" id="apto_from" name='apto_from'  readonly="readonly" class="form-control" style="width: 180px">
                                              </div>
                                            </div>
                                          </div> 
                         
                                          
                                            <div class="form-group">
                                            <label for="post_day">Fecha de Reservación: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-calendar"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12" > 
                                                <input type='date' name='date_reserva' id='date_reserva' min='<?php echo $fecha_hoy; ?>' max='<?php echo $antelacion; ?>' value='<?php echo $fecha_hoy; ?>' class="form-control " style="width: 180px">
                                              </div>
                                            </div>
                                          </div>
                                          
                                            <!-- <div class="form-group show_number_reserva" style="display:none;">
                                            <label for="post_day">Número de personas:</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-user"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-9">  -->
                                                <input type='hidden' name='number_reserva' id='number_reserva' min="1" max="6" value='0' class="form-control  " style="width: 180px">
                                          <!--     </div>
                                            </div>
                                          </div> -->
                                          
                                            <div class="form-group">
                                            <label for="post_day">Zona Común: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-tag"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12"> 
                                                <select name='select_area' id='select_area' class='form-control' style="width: 180px"></select>
                                              </div>
                                            </div>
                                          </div>
                                          
                                          
                                          
                                          <div class="form-group div_nucleo" style="display: nonex; width: 85%;">
                                             <div class="table-responsive">
                                              <caption>Integrantes de Reserva</caption>
                                            <table class="table table-striped">
                                              <tr> 
                                                <th style="text-align:left; width: 5%;">Elegir</th>
                                                <th style="text-align:left">Nombres y Apellidos</th>
                                                <!-- <th style="text-align:left">ID</th> -->
                                              </tr> 
                        
                                               <?php 
                        
                                              $contador = 1;
                                                
                                                $cod_nucleo = $conse_sistema;
                        
                                                $result = mysqli_query($conexion, 'SELECT id as idocupante, apellido_uno, nombre_uno, nombre_dos FROM checkin where consecutivo =\''.$conse_sistema.'\' order by id_tabla asc');
                                                while($row_nucleo = mysqli_fetch_array($result)){        
                         
                        
                                                  echo "
                                                    <tr>
                                                      <td style='text-align:left' class='p-0 text-center'>".$contador++." 
                                                        <input type='checkbox' for='name_huesped' name='check_huesped' id='".$cod_nucleo.$contador."' class='check_huesped' value='".$row_nucleo['idocupante']."' checked>
                                                        <input type='hidden' name='name_huesped[]' id='".$cod_nucleo.$contador."name_huesped' class='name_huesped'  value='".$row_nucleo['nombre_uno']." ".$row_nucleo['nombre_dos']."'></td> 
                                                      <td style='text-align:left'> 
                                                        <input type='hidden' name='ide_nucleo[]' value='".$row_nucleo['idocupante']."' id='".$cod_nucleo.$contador."ide_nucleo'>
                                                        <input type='hidden' name='ide_consecutivo[]' value='".$cod_nucleo."' id='".$cod_nucleo.$contador."ide_consecutivo'>
                                                       
                                                      ".$row_nucleo['nombre_uno']." ".$row_nucleo['apellido_uno']."
                                                    </td>                         
                                                    <!--<td style='text-align:left' class='p-0 text-center'>".$row_nucleo['idocupante']."</td>-->
                                                    </tr>
                                                  "; 
                                                } 
                        
                                              ?>
                        
                                              
                                            </table>
                                          </div>
                                          </div> 
                                          
                                          
                                            <div class="form-group">
                                            <label for="post_day">Horario: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-clock"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12"> 
                                                <select name='select_turno' id='select_turno' class='form-control' style="width: 180px"></select>
                                              </div>
                                            </div>
                                          </div>
                                          
                                            
                        
                        
                                            <div class="form-group" style="text-align: center;"> 
                                            <div class="input-group" style="text-align: center;">
                                              <div class="input-group-prepend" style="text-align: center;"> 
                                                <input type='hidden' name='modalidad_reserva_send' id='modalidad_reserva_send' class="form-control" style="width: 180px">
                                                <input type='hidden' name='consecucion_reserva_send' id='consecucion_reserva_send' class="form-control" style="width: 180px">
                                                <button type="submit" id="btn_send_hpds" class="btn btn-success m-t-15 waves-effect" disabled='disabled'>Confirmar Reserva</button>
                                              </div>  
                                            </div>
                                          </div>                   
                        
                                        </form>
                        
                                      </div>
                                    </div>
                                  </div>
                                </div> 

                    <?php 
                        
                        
                        /*si no existe coincidencias*/
                                    }else{
                                      ?>  
                                      
                                      <section class="section">          
                                          <div class="row">
                                            <div class="col-12">
                                              <div class="card">
                                                <div class="card-header">
                                                  <h4>Resultados de búsqueda: <?php 
                                                    if (isset($_GET['input_search'])) {
                                                      echo "";
                                                    }else{
                                                      echo $_GET['na'];    
                                                    }
                                                   ?></h4> 
                                                </div>
                                                <div class="card-body p-100">
                    
                                                  
                                                    <?php
                    
                                                      $param_search = $_GET['select_search'];
                    
                                                        switch ($param_search) {
                                                            // búsqueda por manilla: {datos de huésped, datos de reserva, todas las reservas por apto}
                                                            case '1':
                                                              echo "# de Manilla no encontrada.";
                                                              break;
                    
                                                              // nombres y ap
                                                            case '2':                               
                                                              echo "Nombres o Apellidos no encontrados.";
                                                              break;
                    
                                                              // aptp
                                                            case '3':
                                                              echo "Apartamento no encontrado.";
                                                              break;
                                                          }
                    
                                                    ?>
                                                  
                                                </div>
                                              </div>
                                            </div>
                                          </div> 
                                        </section>
            
                                          <?php
                                        }

        


                              break;                              
                              
                              case '5':

                            $num_manilla = $_GET['input_search'];
                            $tipo_ocu_manilla = 'HUESPED_INVITADO'; 

                                $result = mysqli_query($conexion, 'SELECT * FROM checkin inner join reserva on checkin.consecutivo = reserva.id_consecutivo where checkin.num_manilla =\''.$num_manilla.'\' and ocupacion=\''.$tipo_ocu_manilla.'\' ORDER BY checkin.id_tabla DESC LIMIT 1 ');

                                    $row = mysqli_fetch_array($result);

                                    if(mysqli_num_rows($result) > 0){

                                    $conse_sistema = $row['consecutivo'];

                                    foreach(mysqli_query($conexion, 'SELECT COUNT(*) FROM checkin WHERE consecutivo=\''.$conse_sistema.'\'') as $conteo_hp){  
                                    $cantidad_huesped  = $conteo_hp['COUNT(*)'];}  
                                   

                                    $show_id = $row['id'];

                                     $consulta = mysqli_query($conexion, 'SELECT *  FROM fotos where id_usuario =\''.$show_id.'\' ORDER BY id_foto desc limit 1');
                                       $ro = mysqli_fetch_array($consulta);
                                       $url = $ro['id_foto'];   
                                    ?>


                                    <div class="section-body">
                                      <div class="row mt-sm-4">

                                        <div class="col-12 col-md-12 col-lg-4">
                                          <div class="card author-box">
                                            <div class="card-body">
                                              <h5 style="text-align: center;">Reservas del Mar</h5>
                                              <p></p>


                                              <div class="author-box-center">
                                                <img alt="image" height="100" src="<?php echo $ruta_img.$url.".jpg"; ?>" class="rounded-circle author-box-picture">
                                                <div class="clearfix"></div>
                                                <div class="author-box-name">
                                                  <a href="#"><?php  echo $row['nombre_uno']." ".$row['nombre_dos']." ".$row['apellido_uno']." ".$row['apellido_dos'];?></a>
                                                </div>
                                                <div class="author-box-job"><?php  echo str_replace("_"," ",$row['ocupacion']); ?></div>
                                              </div>
                                              <div class="text-center">
                                                <div class="author-box-description">

                                                  <table style="width: 100%;" border="0">
                                                    <tr>
                                                      <td style='width: 50%; text-align:right'><b>Apartamento: </b></td>
                                                      <td style='width: 50%; text-align:left'><?php echo $row['num_apto']. " - <i class='fas fa-user'></i> (".$cantidad_huesped.")";?></td>
                                                    </tr>   
                                                    <tr>
                                                      <td style='width: 50%; text-align:right'><b>Manilla #: </b></td>
                                                      <td style='width: 50%; text-align:left'><?php echo $row['num_manilla'];?></td> 
                                                    </tr>
                                                    <tr>
                                                      <td colspan="2" style='width: 100%; text-align:center'><b>Reserva: </b><?php echo $row['fecha_checkin']." <i class='fas fa-angle-double-right'></i> ".$row['fecha_checkout']; ?></td>
                                                    </tr> 
                                                  </table>   
                                                  <br> 
                                                  <?php
                                                    if($row['fecha_checkout'] < $fecha_hoy){
                                                         if($row['ocupacion'] == 'PROPIETARIO'){
                                                            $diabled = '';
                                                            $class='btn-success';    
                                                        }else{
                                                            $diabled = 'disabled';
                                                            $class='btn-default';    
                                                        }
                                                    }else{
                                                        $diabled = '';
                                                        $class='btn-success';
                                                    }
                                                  
                                                  ?>
                                                  
                                                    <button class='btn <?php echo $class;?>' onclick="booked_modal('<?php echo $row['num_apto'];?>', '<?php echo $conse_sistema;?>', '<?php echo $row['ocupacion'];?>')" <?php echo $diabled;?> >Reservar</button>
                                                
                                                </div> 
                                              </div>
                                            </div>
                                          </div> 
                                        </div>

                                        <div class="col-12 col-md-12 col-lg-8">
                                          <div class="card">
                                            <div class="padding-20">
                                              <ul class="nav nav-tabs" id="myTab2" role="tablist">
                                                <li class="nav-item">
                                                  <a class="nav-link active" id="home-tab2" data-toggle="tab" href="#about" role="tab"
                                                    aria-selected="true">Reservas</a>
                                                </li>
                                                <li class="nav-item">
                                                  <a class="nav-link" id="profile-tab2" data-toggle="tab" href="#settings" role="tab"
                                                    aria-selected="false">Integrantes</a>
                                                </li>
                                              </ul>
                                              <div class="tab-content tab-bordered" id="myTab3Content">
                                                <div class="tab-pane fade show active" id="about" role="tabpanel" aria-labelledby="home-tab2">
                                                  <div class="row">

                                                    <div class="table-responsive">
                                                          <table class="table table-striped">
                                                            <tr> 
                                                              <th>#</th>
                                                              <th>Apartamento</th>
                                                              <th>Nombres y Apellidos</th>
                                                              <th>Área</th>
                                                              <th>Reservación</th> 
                                                              <!-- <th>Manilla</th>  -->
                                                              <th>Estado</th> 
                                                            </tr>

                                                            <?php


                                                            $result = mysqli_query($conexion, 'SELECT *, COUNT(*) as cant_rsv FROM ocupante_reserva inner join area on ocupante_reserva.idarea = area.id inner join turno on ocupante_reserva.jornada = turno.id_tabla_turno inner join usuario_area on ocupante_reserva.id_ocupante = usuario_area.idocupante where consecutivo =\''.$conse_sistema.'\' and ocupante_reserva.fecha_in >= \''.$fecha_hoy.'\' GROUP BY ocupante_reserva.consecutivo, ocupante_reserva.fecha_in, ocupante_reserva.hora_in, ocupante_reserva.idarea ORDER BY ocupante_reserva.estado asc, ocupante_reserva.fecha_in asc, ocupante_reserva.hora_in asc');

                                                            // $result = mysqli_query($conexion, 'SELECT * FROM ocupante_reserva inner join area on ocupante_reserva.idarea = area.id inner join usuario_area on ocupante_reserva.id_ocupante = usuario_area.idocupante  where ocupante_reserva.consecutivo =\''.$conse_sistema.'\' and ocupante_reserva.fecha_in >= \''.$fecha_hoy.'\' order by ocupante_reserva.cancelado asc, ocupante_reserva.fecha_in desc, ocupante_reserva.hora_in asc');

                                                             while($row_find_book = mysqli_fetch_array($result)){                                                                 


                                                                  if($row_find_book['cancelado'] == 1){
                                                                    $cancelado = 'Cancelada';     
                                                                  }else{
                                                                    $cancelado = 'Activa'; 
                                                                  }  
                                                                  
                                                                   if($row_find_book['verificado'] == 1){
                                                                    $style_gray = "style='background-color:#6DCCB8'";        
                                                                    }

                                                                  echo "
                                                                    <tr>
                                                                      <td class='p-0 text-center'>".$contador++."</td>
                                                                      <td>".$row_find_book['apto_from']."</td>
                                                                      <td >".$row_find_book['nombres']." ".$row_find_book['apellidos']." | ". $row['ocupacion']."</td>
                                                                      <td >".$row_find_book['nombre']."</td>
                                                                      <td >".$row_find_book['fecha_in']." | ".$row_find_book['hora_in']."</td> 
                                                                        <td >";
                                                                      
                                                                    //   $cancelado
                                                                    
                                                                    
                                                                    if($row_find_book['cancelado'] == 1){
                                                                    //   echo $row_find_book['cancelado']; 
                                                                       echo "Cancelado";
                                                                    }else{
                                                                        if($row_find_book[13] == 1){
                                                                        //   echo $row_find_book[13];
                                                                           echo "Anulado";
                                                                        }else{
                                                                            if($row_find_book['verificado'] == 1){
                                                                                echo "En sitio";
                                                                            //   echo $row_find_book['verificado']; 
                                                                            }    
                                                                            else{
                                                                                echo "Activa";
                                                                            }
                                                                        }    
                                                                    }
                                                                      
                                                                      echo "</td>
                                                                    </tr>
                                                                  ";


                                                                }

                                                              ?>

                                                          </table>
                                                        </div>
                                                    

                                                  </div>

                                                </div>

                                                <div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="profile-tab2">
                                                  <div class="table-responsive">
                                                          <table class="table table-striped">
                                                            <tr> 
                                                              <th>#</th>
                                                              <th>Apartamento</th>
                                                              <th>Nombres y Apellidos</th>
                                                              <th>Manilla</th> 
                                                            </tr>

                                                            <?php


                                                            $result_find = mysqli_query($conexion, 'SELECT checkin.num_manilla, checkin.ocupacion as ocup_from_check, checkin.nombre_uno as nombres, checkin.apellido_uno as apellidos, reserva.id_consecutivo as conse_sistema_show, reserva.num_apto as apto_show FROM checkin inner join reserva on checkin.consecutivo = reserva.id_consecutivo where reserva.id_consecutivo =\''.$conse_sistema.'\' ORDER BY checkin.id_tabla asc'); 

                                                             while($row_find_chk = mysqli_fetch_array($result_find)){                                                               
 

                                                                  echo "
                                                                    <tr>
                                                                      <td class='p-0 text-center'>".$contador2++."</td>
                                                                      <td>".$row_find_chk['apto_show']."</td>
                                                                      <td >".$row_find_chk['nombres']." ".$row_find_chk['apellidos']." | ". $row_find_chk['ocup_from_check']."</td>
                                                                      <td >".$row_find_chk['num_manilla']."</td> 
                                                                    </tr>
                                                                  ";


                                                                }

                                                              ?>

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

                                <!-- moadal para ingreso -->
                                <div class="modal fade" id='modal_reservation' tabindex="-1" role="dialog" aria-labelledby="formModal"
                                  aria-hidden="true">
                                  <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                      <div class="modal-header">
                                        <h5 class="modal-title" id="formModal">Zona a reservar: <span id="span_text_rsv"></span></h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                          <span aria-hidden="true">&times;</span>
                                        </button>
                                      </div>
                        
                                      <div class="modal-body">                
                         
                        
                                       <form id="form_hpds">
                                        <input type="hidden" id='input_area' name="input_area">
                        
                                        <?php
                        
                                        /*Apto */
                                        $apto_reserva  = $_SESSION['k_code_reserva'];
                        
                                        /*Folio*/
                                        $k_id_tabla    = $_SESSION['k_code'];
                        
                                         echo "<input type='hidden' name='id_factura' value='".$apto_reserva."'>";
                                         echo "<input type='hidden' name='apto_from' value='".$apto_reserva."'>";
                                        ?>
                         
                                          <div class="form-group">
                                            <label>Apartamento:</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-home"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12">
                                                <!-- <div class="col-md-1 col-sm-1 col-xs-1"> -->
                                                <input type="text" id="apto_from" name='apto_from'  readonly="readonly" class="form-control" style="width: 180px">
                                              </div>
                                            </div>
                                          </div> 
                         
                                          
                                            <div class="form-group">
                                            <label for="post_day">Fecha de Reservación: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-calendar"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12" > 
                                                <input type='date' name='date_reserva' id='date_reserva' min='<?php echo $fecha_hoy; ?>' max='<?php echo $antelacion; ?>' value='<?php echo $fecha_hoy; ?>' class="form-control " style="width: 180px">
                                              </div>
                                            </div>
                                          </div>
                                          
                                            <!-- <div class="form-group show_number_reserva" style="display:none;">
                                            <label for="post_day">Número de personas:</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-user"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-9">  -->
                                                <input type='hidden' name='number_reserva' id='number_reserva' min="1" max="6" value='0' class="form-control  " style="width: 180px">
                                          <!--     </div>
                                            </div>
                                          </div> -->
                                          
                                            <div class="form-group">
                                            <label for="post_day">Zona Común: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-tag"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12"> 
                                                <select name='select_area' id='select_area' class='form-control' style="width: 180px"></select>
                                              </div>
                                            </div>
                                          </div>
                                          
                                          
                                          
                                          <div class="form-group div_nucleo" style="display: nonex; width: 85%;">
                                             <div class="table-responsive">
                                              <caption>Integrantes de Reserva</caption>
                                            <table class="table table-striped">
                                              <tr> 
                                                <th style="text-align:left; width: 5%;">Elegir</th>
                                                <th style="text-align:left">Nombres y Apellidos</th>
                                                <!-- <th style="text-align:left">ID</th> -->
                                              </tr> 
                        
                                               <?php 
                        
                                              $contador = 1;
                                                
                                                $cod_nucleo = $conse_sistema;
                        
                                                $result = mysqli_query($conexion, 'SELECT id as idocupante, apellido_uno, nombre_uno, nombre_dos FROM checkin where consecutivo =\''.$conse_sistema.'\' order by id_tabla asc');
                                                while($row_nucleo = mysqli_fetch_array($result)){        
                         
                        
                                                  echo "
                                                    <tr>
                                                      <td style='text-align:left' class='p-0 text-center'>".$contador++." 
                                                        <input type='checkbox' for='name_huesped' name='check_huesped' id='".$cod_nucleo.$contador."' class='check_huesped' value='".$row_nucleo['idocupante']."' checked>
                                                        <input type='hidden' name='name_huesped[]' id='".$cod_nucleo.$contador."name_huesped' class='name_huesped'  value='".$row_nucleo['nombre_uno']." ".$row_nucleo['nombre_dos']."'></td> 
                                                      <td style='text-align:left'> 
                                                        <input type='hidden' name='ide_nucleo[]' value='".$row_nucleo['idocupante']."' id='".$cod_nucleo.$contador."ide_nucleo'>
                                                        <input type='hidden' name='ide_consecutivo[]' value='".$cod_nucleo."' id='".$cod_nucleo.$contador."ide_consecutivo'>
                                                       
                                                      ".$row_nucleo['nombre_uno']." ".$row_nucleo['apellido_uno']."
                                                    </td>                         
                                                    <!--<td style='text-align:left' class='p-0 text-center'>".$row_nucleo['idocupante']."</td>-->
                                                    </tr>
                                                  "; 
                                                } 
                        
                                              ?>
                        
                                              
                                            </table>
                                          </div>
                                          </div> 
                                          
                                          
                                            <div class="form-group">
                                            <label for="post_day">Horario: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-clock"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12"> 
                                                <select name='select_turno' id='select_turno' class='form-control' style="width: 180px"></select>
                                              </div>
                                            </div>
                                          </div>
                                          
                                            
                        
                        
                                            <div class="form-group" style="text-align: center;"> 
                                            <div class="input-group" style="text-align: center;">
                                              <div class="input-group-prepend" style="text-align: center;"> 
                                                <input type='hidden' name='modalidad_reserva_send' id='modalidad_reserva_send' class="form-control" style="width: 180px">
                                                <input type='hidden' name='consecucion_reserva_send' id='consecucion_reserva_send' class="form-control" style="width: 180px">
                                                <button type="submit" id="btn_send_hpds" class="btn btn-success m-t-15 waves-effect" disabled='disabled'>Confirmar Reserva</button>
                                              </div>  
                                            </div>
                                          </div>                   
                        
                                        </form>
                        
                                      </div>
                                    </div>
                                  </div>
                                </div> 

                    <?php 
                        
                        
                        /*si no existe coincidencias*/
                                    }else{
                                      ?>  
                                      
                                      <section class="section">          
                                          <div class="row">
                                            <div class="col-12">
                                              <div class="card">
                                                <div class="card-header">
                                                  <h4>Resultados de búsqueda: <?php 
                                                    if (isset($_GET['input_search'])) {
                                                      echo "";
                                                    }else{
                                                      echo $_GET['na'];    
                                                    }
                                                   ?></h4> 
                                                </div>
                                                <div class="card-body p-100">
                    
                                                  
                                                    <?php
                    
                                                      $param_search = $_GET['select_search'];
                    
                                                        switch ($param_search) {
                                                            // búsqueda por manilla: {datos de huésped, datos de reserva, todas las reservas por apto}
                                                            case '1':
                                                              echo "# de Manilla no encontrada.";
                                                              break;
                    
                                                              // nombres y ap
                                                            case '2':                               
                                                              echo "Nombres o Apellidos no encontrados.";
                                                              break;
                    
                                                              // aptp
                                                            case '3':
                                                              echo "Apartamento no encontrado.";
                                                              break;
                                                          }
                    
                                                    ?>
                                                  
                                                </div>
                                              </div>
                                            </div>
                                          </div> 
                                        </section>
            
                                          <?php
                                        }



                              break;
                              
                            case '6':

                            $num_manilla = $_GET['input_search'];
                            $tipo_ocu_manilla = 'PROPIETARIO';
 

                                // $result = mysqli_query($conexion, 'SELECT * FROM manilla_control_gris left join checkin on manilla_control_gris.num_manilla_control = checkin.num_manilla inner join reserva on checkin.consecutivo = reserva.id_consecutivo where manilla_control_gris.num_manilla_control =\''.$num_manilla.'\'');
                                $result_manilla = mysqli_query($conexion, 'SELECT * FROM manilla_control_gris where manilla_control_gris.num_manilla_control =\''.$num_manilla.'\'');

                                    $row_manilla = mysqli_fetch_array($result_manilla);
                                    
                                    // echo $row_manilla['id_hp_manilla'];

                                    if(mysqli_num_rows($result_manilla) > 0){
                                        
                                $result = mysqli_query($conexion, "SELECT * FROM checkin inner join reserva on checkin.consecutivo = reserva.id_consecutivo where checkin.num_manilla like '%$num_manilla%' and checkin.ocupacion = '$tipo_ocu_manilla' ORDER BY checkin.id_tabla DESC LIMIT 1 ");

                                $row = mysqli_fetch_array($result);
                                        
                                        

                                    $conse_sistema = $row['consecutivo'];

                                    foreach(mysqli_query($conexion, 'SELECT COUNT(*) FROM checkin WHERE consecutivo=\''.$conse_sistema.'\'') as $conteo_hp){  
                                    $cantidad_huesped  = $conteo_hp['COUNT(*)'];}  
                                   

                                    $show_id = $row['id'];

                                     $consulta = mysqli_query($conexion, 'SELECT *  FROM fotos where id_usuario =\''.$show_id.'\' ORDER BY id_foto desc limit 1');
                                       $ro = mysqli_fetch_array($consulta);
                                       $url = $ro['id_foto'];   
                                    ?>


                                    <div class="section-body">
                                      <div class="row mt-sm-4">

                                        <div class="col-12 col-md-12 col-lg-4">
                                          <div class="card author-box">
                                            <div class="card-body">
                                              <h5 style="text-align: center;">Reservas del Mar</h5>
                                              <p></p>


                                              <div class="author-box-center">
                                                <img alt="image" height="100" src="<?php echo $ruta_img.$url.".jpg"; ?>" class="rounded-circle author-box-picture">
                                                <div class="clearfix"></div>
                                                <div class="author-box-name">
                                                  <a href="#"><?php  echo $row['nombre_uno']." ".$row['nombre_dos']." ".$row['apellido_uno']." ".$row['apellido_dos'];?></a>
                                                </div>
                                                <div class="author-box-job"><?php  echo str_replace("_"," ",$row['ocupacion']); ?></div>
                                              </div>
                                              <div class="text-center">
                                                <div class="author-box-description">

                                                  <table style="width: 100%;" border="0">
                                                    <tr>
                                                      <td style='width: 50%; text-align:right'><b>Apartamento: </b></td>
                                                      <td style='width: 50%; text-align:left'><?php echo $row['num_apto']. " - <i class='fas fa-user'></i> (".$cantidad_huesped.")";?></td>
                                                    </tr>   
                                                    <tr>
                                                      <td style='width: 50%; text-align:right'><b>Manilla #: </b></td>
                                                      <td style='width: 50%; text-align:left'><?php echo $row['num_manilla'];?></td> 
                                                    </tr>
                                                    <tr>
                                                      <td colspan="2" style='width: 100%; text-align:center'><b>Reserva: </b><?php echo $row['fecha_checkin']." <i class='fas fa-angle-double-right'></i> ".$row['fecha_checkout']; ?></td>
                                                    </tr> 
                                                  </table>   
                                                  <br> 
                                                  <?php
                                                    if($row['fecha_checkout'] < $fecha_hoy){
                                                         if($row['ocupacion'] == 'PROPIETARIO'|| $row['ocupacion']=='HUESPED_INVITADO'){
                                                            $diabled = '';
                                                            $class='btn-success';    
                                                        }else{
                                                            $diabled = 'disabled';
                                                            $class='btn-default';    
                                                        }
                                                    }else{
                                                        $diabled = '';
                                                        $class='btn-success';
                                                    }
                                                  
                                                  ?>
                                                  
                                                    <button class='btn <?php echo $class;?>' onclick="booked_modal('<?php echo $row['num_apto'];?>', '<?php echo $conse_sistema;?>', '<?php echo $row['ocupacion'];?>')" <?php echo $diabled;?> >Reservar</button>
                                                
                                                </div> 
                                              </div>
                                            </div>
                                          </div> 
                                        </div>

                                        <div class="col-12 col-md-12 col-lg-8">
                                          <div class="card">
                                            <div class="padding-20">
                                              <ul class="nav nav-tabs" id="myTab2" role="tablist">
                                                <li class="nav-item">
                                                  <a class="nav-link active" id="home-tab2" data-toggle="tab" href="#about" role="tab"
                                                    aria-selected="true">Reservas</a>
                                                </li>
                                                <li class="nav-item">
                                                  <a class="nav-link" id="profile-tab2" data-toggle="tab" href="#settings" role="tab"
                                                    aria-selected="false">Integrantes</a>
                                                </li>
                                              </ul>
                                              <div class="tab-content tab-bordered" id="myTab3Content">
                                                <div class="tab-pane fade show active" id="about" role="tabpanel" aria-labelledby="home-tab2">
                                                  <div class="row">

                                                    <div class="table-responsive">
                                                          <table class="table table-striped">
                                                            <tr> 
                                                              <th>#</th>
                                                              <th>Apartamento</th>
                                                              <th>Nombres y Apellidos</th>
                                                              <th>Área</th>
                                                              <th>Reservación</th> 
                                                              <!-- <th>Manilla</th>  -->
                                                              <th>Estado</th> 
                                                            </tr>

                                                            <?php


                                                            $result = mysqli_query($conexion, 'SELECT *, COUNT(*) as cant_rsv FROM ocupante_reserva inner join area on ocupante_reserva.idarea = area.id inner join turno on ocupante_reserva.jornada = turno.id_tabla_turno inner join usuario_area on ocupante_reserva.id_ocupante = usuario_area.idocupante where consecutivo =\''.$conse_sistema.'\' and ocupante_reserva.fecha_in >= \''.$fecha_hoy.'\' GROUP BY ocupante_reserva.consecutivo, ocupante_reserva.fecha_in, ocupante_reserva.hora_in, ocupante_reserva.idarea ORDER BY ocupante_reserva.estado asc, ocupante_reserva.fecha_in asc, ocupante_reserva.hora_in asc');

                                                            // $result = mysqli_query($conexion, 'SELECT * FROM ocupante_reserva inner join area on ocupante_reserva.idarea = area.id inner join usuario_area on ocupante_reserva.id_ocupante = usuario_area.idocupante  where ocupante_reserva.consecutivo =\''.$conse_sistema.'\' and ocupante_reserva.fecha_in >= \''.$fecha_hoy.'\' order by ocupante_reserva.cancelado asc, ocupante_reserva.fecha_in desc, ocupante_reserva.hora_in asc');

                                                             while($row_find_book = mysqli_fetch_array($result)){                                                                 


                                                                  if($row_find_book['cancelado'] == 1){
                                                                    $cancelado = 'Cancelada';     
                                                                  }else{
                                                                    $cancelado = 'Activa'; 
                                                                  }  
                                                                  
                                                                   if($row_find_book['verificado'] == 1){
                                                                    $style_gray = "style='background-color:#6DCCB8'";        
                                                                    }

                                                                  echo "
                                                                    <tr>
                                                                      <td class='p-0 text-center'>".$contador++."</td>
                                                                      <td>".$row_find_book['apto_from']."</td>
                                                                      <td >".$row_find_book['nombres']." ".$row_find_book['apellidos']." | ". $row['ocupacion']."</td>
                                                                      <td >".$row_find_book['nombre']."</td>
                                                                      <td >".$row_find_book['fecha_in']." | ".$row_find_book['hora_in']."</td> 
                                                                        <td >";
                                                                      
                                                                    //   $cancelado
                                                                    
                                                                    
                                                                    
                                                                    
                                                                    if($row_find_book['cancelado'] == 1){
                                                                    //   echo $row_find_book['cancelado']; 
                                                                       echo "Cancelado";
                                                                    }else{
                                                                        if($row_find_book[13] == 1){
                                                                        //   echo $row_find_book[13];
                                                                           echo "Anulado";
                                                                        }else{
                                                                            if($row_find_book['verificado'] == 1){
                                                                                echo "En sitio";
                                                                            //   echo $row_find_book['verificado']; 
                                                                            }    
                                                                            else{
                                                                                echo "Activa";
                                                                            }
                                                                        }    
                                                                    }
                                                                      
                                                                      echo "</td>
                                                                    </tr>
                                                                  ";


                                                                }

                                                              ?>

                                                          </table>
                                                        </div>
                                                    

                                                  </div>

                                                </div>

                                                <div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="profile-tab2">
                                                  <div class="table-responsive">
                                                          <table class="table table-striped">
                                                            <tr> 
                                                              <th>#</th>
                                                              <th>Apartamento</th>
                                                              <th>Nombres y Apellidos</th>
                                                              <th>Manilla</th> 
                                                            </tr>

                                                            <?php


                                                            $result_find = mysqli_query($conexion, 'SELECT checkin.num_manilla, checkin.ocupacion as ocup_from_check, checkin.nombre_uno as nombres, checkin.apellido_uno as apellidos, reserva.id_consecutivo as conse_sistema_show, reserva.num_apto as apto_show FROM checkin inner join reserva on checkin.consecutivo = reserva.id_consecutivo where reserva.id_consecutivo =\''.$conse_sistema.'\' ORDER BY checkin.id_tabla asc'); 

                                                             while($row_find_chk = mysqli_fetch_array($result_find)){                                                               
 

                                                                  echo "
                                                                    <tr>
                                                                      <td class='p-0 text-center'>".$contador2++."</td>
                                                                      <td>".$row_find_chk['apto_show']."</td>
                                                                      <td >".$row_find_chk['nombres']." ".$row_find_chk['apellidos']." | ". $row_find_chk['ocup_from_check']."</td>
                                                                      <td >".$row_find_chk['num_manilla']."</td> 
                                                                    </tr>
                                                                  ";


                                                                }

                                                              ?>

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

                                <!-- moadal para ingreso -->
                                <div class="modal fade" id='modal_reservation' tabindex="-1" role="dialog" aria-labelledby="formModal"
                                  aria-hidden="true">
                                  <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                      <div class="modal-header">
                                        <h5 class="modal-title" id="formModal">Zona a reservar: <span id="span_text_rsv"></span></h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                          <span aria-hidden="true">&times;</span>
                                        </button>
                                      </div>
                        
                                      <div class="modal-body">                
                         
                        
                                       <form id="form_hpds">
                                        <input type="hidden" id='input_area' name="input_area">
                        
                                        <?php
                        
                                        /*Apto */
                                        $apto_reserva  = $_SESSION['k_code_reserva'];
                        
                                        /*Folio*/
                                        $k_id_tabla    = $_SESSION['k_code'];
                        
                                         echo "<input type='hidden' name='id_factura' value='".$apto_reserva."'>";
                                         echo "<input type='hidden' name='apto_from' value='".$apto_reserva."'>";
                                        ?>
                         
                                          <div class="form-group">
                                            <label>Apartamento:</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-home"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12">
                                                <!-- <div class="col-md-1 col-sm-1 col-xs-1"> -->
                                                <input type="text" id="apto_from" name='apto_from'  readonly="readonly" class="form-control" style="width: 180px">
                                              </div>
                                            </div>
                                          </div> 
                         
                                          
                                            <div class="form-group">
                                            <label for="post_day">Fecha de Reservación: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-calendar"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12" > 
                                                <input type='date' name='date_reserva' id='date_reserva' min='<?php echo $fecha_hoy; ?>' max='<?php echo $antelacion; ?>' value='<?php echo $fecha_hoy; ?>' class="form-control " style="width: 180px">
                                              </div>
                                            </div>
                                          </div>
                                          
                                            <!-- <div class="form-group show_number_reserva" style="display:none;">
                                            <label for="post_day">Número de personas:</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-user"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-9">  -->
                                                <input type='hidden' name='number_reserva' id='number_reserva' min="1" max="6" value='0' class="form-control  " style="width: 180px">
                                          <!--     </div>
                                            </div>
                                          </div> -->
                                          
                                            <div class="form-group">
                                            <label for="post_day">Zona Común: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-tag"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12"> 
                                                <select name='select_area' id='select_area' class='form-control' style="width: 180px"></select>
                                              </div>
                                            </div>
                                          </div>
                                          
                                          
                                          
                                          <div class="form-group div_nucleo" style="display: nonex; width: 85%;">
                                             <div class="table-responsive">
                                              <caption>Integrantes de Reserva</caption>
                                            <table class="table table-striped">
                                              <tr> 
                                                <th style="text-align:left; width: 5%;">Elegir</th>
                                                <th style="text-align:left">Nombres y Apellidos</th>
                                                <!-- <th style="text-align:left">ID</th> -->
                                              </tr> 
                        
                                               <?php 
                        
                                              $contador = 1;
                                                
                                                $cod_nucleo = $conse_sistema;
                        
                                                $result = mysqli_query($conexion, 'SELECT id as idocupante, apellido_uno, nombre_uno, nombre_dos FROM checkin where consecutivo =\''.$conse_sistema.'\' order by id_tabla asc');
                                                while($row_nucleo = mysqli_fetch_array($result)){        
                         
                        
                                                  echo "
                                                    <tr>
                                                      <td style='text-align:left' class='p-0 text-center'>".$contador++." 
                                                        <input type='checkbox' for='name_huesped' name='check_huesped' id='".$cod_nucleo.$contador."' class='check_huesped' value='".$row_nucleo['idocupante']."' checked>
                                                        <input type='hidden' name='name_huesped[]' id='".$cod_nucleo.$contador."name_huesped' class='name_huesped'  value='".$row_nucleo['nombre_uno']." ".$row_nucleo['nombre_dos']."'></td> 
                                                      <td style='text-align:left'> 
                                                        <input type='hidden' name='ide_nucleo[]' value='".$row_nucleo['idocupante']."' id='".$cod_nucleo.$contador."ide_nucleo'>
                                                        <input type='hidden' name='ide_consecutivo[]' value='".$cod_nucleo."' id='".$cod_nucleo.$contador."ide_consecutivo'>
                                                       
                                                      ".$row_nucleo['nombre_uno']." ".$row_nucleo['apellido_uno']."
                                                    </td>                         
                                                    <!--<td style='text-align:left' class='p-0 text-center'>".$row_nucleo['idocupante']."</td>-->
                                                    </tr>
                                                  "; 
                                                } 
                        
                                              ?>
                        
                                              
                                            </table>
                                          </div>
                                          </div> 
                                          
                                          
                                            <div class="form-group">
                                            <label for="post_day">Horario: *</label>
                                            <div class="input-group">
                                              <div class="input-group-prepend">
                                                <div class="input-group-text">
                                                  <i class="fas fa-clock"></i>
                                                </div>
                                              </div>
                                              <div class="col-xs-12"> 
                                                <select name='select_turno' id='select_turno' class='form-control' style="width: 180px"></select>
                                              </div>
                                            </div>
                                          </div>
                                          
                                            
                        
                        
                                            <div class="form-group" style="text-align: center;"> 
                                            <div class="input-group" style="text-align: center;">
                                              <div class="input-group-prepend" style="text-align: center;"> 
                                                <input type='hidden' name='modalidad_reserva_send' id='modalidad_reserva_send' class="form-control" style="width: 180px">
                                                <input type='hidden' name='consecucion_reserva_send' id='consecucion_reserva_send' class="form-control" style="width: 180px">
                                                <button type="submit" id="btn_send_hpds" class="btn btn-success m-t-15 waves-effect" disabled='disabled'>Confirmar Reserva</button>
                                              </div>  
                                            </div>
                                          </div>                   
                        
                                        </form>
                        
                                      </div>
                                    </div>
                                  </div>
                                </div> 

                    <?php 
                        
                        
                        /*si no existe coincidencias*/
                                    }else{
                                      ?>  
                                      
                                      <section class="section">          
                                          <div class="row">
                                            <div class="col-12">
                                              <div class="card">
                                                <div class="card-header">
                                                  <h4>Resultados de búsqueda: <?php 
                                                    if (isset($_GET['input_search'])) {
                                                      echo "";
                                                    }else{
                                                      echo $_GET['na'];    
                                                    }
                                                   ?></h4> 
                                                </div>
                                                <div class="card-body p-100">
                    
                                                  
                                                    <?php
                    
                                                      $param_search = $_GET['select_search'];
                    
                                                        switch ($param_search) {
                                                            // búsqueda por manilla: {datos de huésped, datos de reserva, todas las reservas por apto}
                                                            case '1':
                                                              echo "# de Manilla no encontrada.";
                                                              break;
                    
                                                              // nombres y ap
                                                            case '2':                               
                                                              echo "Nombres o Apellidos no encontrados.";
                                                              break;
                    
                                                              // aptp
                                                            case '3':
                                                              echo "Apartamento no encontrado.";
                                                              break;
                                                          }
                    
                                                    ?>
                                                  
                                                </div>
                                              </div>
                                            </div>
                                          </div> 
                                        </section>
            
                                          <?php
                                        }




                              break;
                          }


                          

                      }else{

                      $id_area = $_GET['ida'];

                        $result = mysqli_query($conexion, 'SELECT * FROM ocupante_reserva inner join area on ocupante_reserva.idarea = area.id inner join usuario_area on ocupante_reserva.id_ocupante = usuario_area.idocupante inner join checkin on ocupante_reserva.id_ocupante = checkin.id where area.id_rel_area =\''.$id_area.'\' and ocupante_reserva.estado =\''.$estado.'\' and ocupante_reserva.fecha_in >=\''.$fecha_hoy.'\' order by ocupante_reserva.fecha_in desc');
                        
                        ?>
                        
                        <div class="row">
                            <div class="col-12">
                              <div class="card">
                                <div class="card-header">
                                  <h4>Reservaciones de: <?php echo $_GET['na']; ?> <a href="dashboard.php" class='btn btn-sm btn-primary'> Regresar</a></h4> 
                                </div>
                                <div class="card-body p-0">
                
                                
                                  <div class="table-responsive">
                                    <table class="table table-striped">
                                      <tr> 
                                        <th>#</th>
                                        <th>Huésped</th>
                                        <th>Apartamento</th> 
                                        <th>Área</th>
                                        <th>Reservación</th>
                                        <th>Turno | Horario</th> 
                                        <th>Estado</th>
                                        <th align='right' style="text-align: center;" colspan="2">Acciones</th>
                                      </tr>
                
                                      <?php
                
                                        switch ($_SESSION['k_access']) {
                                            // huésped
                                            case '0':
                                               $disabled_edit = 'disabled'; 
                                              break;
                
                                              // admin
                                            case '1':                                
                                               $disabled_edit = ''; 
                                              break;
                
                                              // 2 Gym
                                            case '2':                                                 
                                               $disabled_edit = ''; 
                                              break;
                
                                              // 3 piscina 4 piso
                                            case '3':                                                      
                                               $disabled_edit = ''; 
                                              break;
                
                                              // 4 Recepción
                                            case '4':                                                      
                                               $disabled_edit = 'disabled'; 
                                              break;
                
                                              // 5 salon social
                                            case '5':                                                      
                                               $disabled_edit = ''; 
                                              break;
                
                                            //acceso general
                                            case '6':
                                               $disabled_edit = ''; 
                                              break;
                                            
                                            default:
                                              # code...
                                              break;
                                          }
                            
                
                                        $id_ocupante = $_SESSION['k_id'];
                                        $idarea_in = $_GET['ida'];
                
                                        $contador = 1;
                                        
                                        // $fecha_hoy = '2024-08-09';
                                        
                                        $result = mysqli_query($conexion, 'SELECT *  FROM `area_matriz` inner join area on area_matriz.id_area_matriz = area.id_rel_area inner join ocupante_reserva on area.id = ocupante_reserva.idarea inner join usuario_area on ocupante_reserva.id_ocupante = usuario_area.idocupante WHERE area_matriz.id_area_matriz =\''.$idarea_in.'\' and ocupante_reserva.fecha_in  >=\''.$fecha_hoy.'\'');     
                                        while($row = mysqli_fetch_array($result)){  
                                            
                                            $date_reservation = $row['fecha_in'];
                                            
                                            
                
                                          $turno = $row['jornada'];
                                          $id_area = $row['idarea'];
                
                                          $result_turno = mysqli_query($conexion, 'SELECT * FROM turno where id_tabla_turno =\''.$turno.'\' and id_area =\''.$id_area.'\' ');
                                          $row_turno = mysqli_fetch_array($result_turno);
                
                                          $turno_desc = $row_turno['descripcion']; 
                                          $turno_number = $row_turno['num_turno'];
                
                                        //   if($row['nucleo'] == 'SI'){                           
                                        //     $ver_nucleo = "<a href='reservacion_familiares.php?cod=".$row['cod_reservacion']."'  style='text-decoration:none' class='btn btn-info m-t-15 waves-effect'><i class='fas fa-eye'></i> Ver familiares</a>";
                                        //   }else{
                                        //     $ver_nucleo = 'NO';
                                        //   } 
                 
                                          if($row['cancelado'] == 1){
                                            $cancelado = 'Cancelada';   
                                            $disabledx = '';  
                                          }else{
                                            $cancelado = 'Activa';  
                                            $disabledx = "validation/cancel_book.php?id_table=".$row['id_tabla']."&ida=".$_GET['ida']."&na=".$_GET['na']."";  
                                          } 
                                          
                
                                          //campo estado
                                          if($row[13] == 1){
                                            $checkout = 'checkout';     
                                            $disable_down = 'disabled';
                                            $disable_down_out = '';
                                          }else{
                                            $checkout = ''; 
                                            $disable_down = '';
                                             $disable_down_out = 'disabled';
                                          } 
                 
                                          if($row['verificado'] == 1){
                                            $disable_btn = 'disabled';   
                                            $accion_show = "En sitio";  
                                            $cancelado = '';
                                            $active_down ='';
                                          }else{
                                            $disable_btn = '';
                                            $accion_show = "";
                                            $cancelado = 'salida';
                                            $active_down = 'disabled';
                                          } 
                
                                          if($fecha_hoy != $date_reservation){
                                            $disabled = 'disabled';
                                          }else{
                                            $disabled = '';
                                          }
                                           
                                           
                                            if($row['verificado'] == 1){
                                                $style_gray = "background-color:#BAE6DD";        
                                            }else{
                                                $style_gray = "";
                                            }
                
                                        // ?ida=1&na=Baño%20Turco
                                          echo "
                                            <tr style='".$style_gray."'>
                                              <td class='p-0 text-center'>
                                                <a  href='$disabledx' style='text-decoration:none' class='btn btn-danger'>".$contador++." <i class='fas fa-trash'></i>
                                                </a>
                                              </td>
                                              <td>".$row['nombres']." ".$row['apellidos']." </td>
                                              <td>".$row['apto_from']."</td> 
                                              <td >".$row['nombre']."</td>
                                              <td >".$row['fecha_in']."</td>
                                              <td >$turno_number| $turno_desc </td> 
                                              <td >";
                                              
                                                    if($row['cancelado'] == 1){
                                                    //   echo $row['cancelado']; 
                                                       echo "Cancelado";
                                                    }else{
                                                        if($row[13] == 1){
                                                        //   echo $row[13];
                                                           echo "Anulado";
                                                        }else{
                                                            if($row['verificado'] == 1){
                                                                echo "En sitio.";
                                                            //   echo $row['verificado']; 
                                                            }        
                                                        }    
                                                    }
                                                    
                                                    
                                              
                                            
                                            //   $accion_show &nbsp; $checkout &nbsp; $cancelado</td>
                                              echo"<td align='right'>     
                                                
                                                <a  href='validation/cancel_book.php?id_tablex=".$row['id_tabla']."&ida=".$_GET['ida']."&na=".$_GET['na']."&valid=1' style='text-decoration:none' class='btn btn-outline-success'>Confirmar 
                                                </a>
                                              </td> 
                                              <td>  
                                                <a  href='validation/cancel_book.php?id_tablex=".$row['id_tabla']."&ida=".$_GET['ida']."&na=".$_GET['na']."&valid=0' style='text-decoration:none' class='btn btn-outline-danger'>Salida 
                                                </a>
                
                                                </td> 
                                            
                                            </tr>
                                          ";
                 
                                        } 
                
                                      ?>
                
                                      
                                    </table>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                          
                          <?php
                        
                        }
 
         ?>
 


        
      </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>
  
  <!-- Custom JS File boked -->
  <script src="assets/js/booked.js?ver=2.22"></script>
</body>



</html>
<?php
  }
?>