

<?php $__env->startSection('content'); ?>        
        <style type="text/css">
          .img-card{
            min-width: 100%; 
            max-width: 100%; 
            min-height: 100%; 
            max-height: 100%;
            position: absolute;
          }

          @media(max-width:768px){
              .img-card {
                min-width: 100%; 
                max-width: 100%; 
                min-height: 150px; 
                max-height: 150px;
                position: relative;
              }
          }

        </style>
        <section class="pt-md-4 pb-md-0 bg-dark">
          <div class="container">
            <div class="row justify-content-between align-items-center">
              <div class="col-lg-8 col-md-9">
                <div class="d-none d-md-block">
                  <br>
                </div>
                <h1 class="d-none d-md-block" style="color: white;">Busca más fácil tu hotel</h1>
                <p class="lead"></p>           
              </div>
              <div class="col-md-3 d-none d-md-none">
                <img src="<?php echo e(asset('img/hotel.png')); ?>" style="width: 1000px;" alt="Image">
              </div>
            </div>
            <form action="<?php echo e(asset('/hoteles')); ?>" method="GET">
                <div class="row">
                    <div class="col-12 col-md-2">
                       <label style="margin: 0px; color: white;">Departamento</label>
                       <select class="form-control" name="departamento" id="departamento" required="required">
                           <option value="">Selecciona una opción</option>
                           <?php $__currentLoopData = $departamentos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($key->id); ?>"
                              <?php if ($data['departamento']==$key->id) {
                                echo 'selected="selected"';
                              } ?>
                              ><?php echo e($key->departamento); ?></option>
                           <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                       </select><br>
                    </div>
                    <div class="col-12 col-md-2">
                       <label style="margin: 0px; color: white;">Municipio</label>
                       <select class="form-control" name="municipio" id="municipio">
                           <option value="">Selecciona una opción</option>
                            <?php $__currentLoopData = $municipios; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($key->id); ?>"
                              <?php if ($data['municipio']==$key->id) {
                                echo 'selected="selected"';
                              } ?>
                              ><?php echo e($key->municipio); ?></option>
                           <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                       </select><br>
                    </div>
                    <div class="col-12 col-md-3">
                        <label style="margin: 0px; color: white;">Fecha de llegada</label>
                        <input type="date" name="check_in" class="form-control" required="required" value="<?php echo e($data['check_in']); ?>"><br>
                    </div>
                    <div class="col-12 col-md-3">
                        <label style="margin: 0px; color: white;">Fecha de salida</label>
                        <input type="date" name="check_out" class="form-control" required="required" value="<?php echo e($data['check_out']); ?>"><br>
                    </div>
                    <div class="col-12 col-md-1">
                        <label style="margin: 0px; color: white;">Huésped</label>
                        <input type="number" name="huesped" class="form-control" id="huesped" value="<?php echo e($data['huesped']); ?>" required="required" min="1"><br>
                    </div>
                    <div class="col-12 col-md-1">
                        <br>
                        <input type="hidden" name="a" id="form-a" value="<?php echo e($data['a']); ?>">
                        <input type="hidden" name="n" id="form-n" value="<?php echo e($data['n']); ?>">
                        <center><button class="btn btn-primary" type="submit">Buscar</button></center>
                    </div>
                </div>
                <div style="display: none;" id="form-edad">
                  <?php 
                    if (is_array($data['edad'])) {
                      foreach ($data['edad'] as $key) {
                        echo '<input type="hidden" name="edad[]" value="'.$key.'">';
                      }
                    }
                  ?>
                </div>
            </form>              
          </div>
        </section>  
        <?php $data_hoteles = $data; ?>
        
        <section>
          <div class="pl-5 pr-5 pt-1 pb-1">
            <div class="row">
            	<div class="col-md-3">
                <div class="card" style="border-radius: 10px; box-shadow: 0 0 3px grey;">
                  <div class="card-body">
                    <center>
                      <h5>Filtros</h5>
                    </center>
                      <form action="<?php echo e(asset('/hoteles')); ?>" method="GET">

                        <input type="hidden" name="departamento" value="<?php echo e($data['departamento']); ?>">
                        <input type="hidden" name="municipio" value="<?php echo e($data['municipio']); ?>">

                        <input type="hidden" name="check_in" value="<?php echo e($data['check_in']); ?>">
                        <input type="hidden" name="check_out" value="<?php echo e($data['check_out']); ?>">

                        <input type="hidden" name="huesped" value="<?php echo e($data['huesped']); ?>">

                        <input type="hidden" name="a" id="form-a" value="<?php echo e($data['a']); ?>">
                        <input type="hidden" name="n" id="form-n" value="<?php echo e($data['n']); ?>">
                          <?php 
                            if (is_array($data['edad'])) {
                              foreach ($data['edad'] as $key) {
                                echo '<input type="hidden" name="edad[]" value="'.$key.'">';
                              }
                            }
                          ?>

                        <h6>Categorías</h6>

                        <?php 
                          $array_categoria = array(); 

                          if (isset($request->categorias)) {
                              if (is_array($request->categorias)) {
                                  $array_categoria = $request->categorias; 
                              }
                          }

                        ?>

                        <?php $__currentLoopData = $categorias; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                          <div class="custom-control custom-checkbox">
                            <input type="checkbox" id="categorias-<?php echo e($key->id); ?>" class="custom-control-input" name="categorias[]" value="<?php echo e($key->id); ?>" <?php if(in_array($key->id,$array_categoria)){
                              echo "checked";
                            } ?>>
                            <label class="custom-control-label" for="categorias-<?php echo e($key->id); ?>"><?php echo e($key->categoria); ?></label>
                          </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        <?php 
                          $array_estrellas = array(); 

                          if (isset($request->estrellas)) {
                              if (is_array($request->estrellas)) {
                                  $array_estrellas = $request->estrellas; 
                              }
                          }

                        ?>
                        
                        <h6 class="mt-3">Estrellas</h6>

                        <?php for($i=0;$i<=5;$i++): ?>
                          <div class="custom-control custom-checkbox">
                            <input type="checkbox" id="estrellas-<?php echo e($i); ?>" class="custom-control-input" 
                            name="estrellas[]" value="<?php echo e($i); ?>" <?php if(in_array($i,$array_estrellas)){
                              echo "checked";
                            } ?>>
                            <label class="custom-control-label" for="estrellas-<?php echo e($i); ?>"><?php echo e($i); ?> <?php if($i==1): ?> estrella <?php else: ?> estrellas <?php endif; ?></label>
                          </div>
                        <?php endfor; ?>

                        <h6 class="mt-3">Recomendados por:</h6>

                        <?php 
                          $array_recomendaciones = array(); 

                          if (isset($request->recomendaciones)) {
                              if (is_array($request->recomendaciones)) {
                                  $array_recomendaciones = $request->recomendaciones; 
                              }
                          }

                        ?>

                        <?php $__currentLoopData = $empresas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                          <div class="custom-control custom-checkbox">
                            <input type="checkbox" id="empresas-<?php echo e($key->id); ?>" class="custom-control-input" name="recomendaciones[]" value="<?php echo e($key->id); ?>" <?php if(in_array($key->id,$array_recomendaciones)){
                              echo "checked";
                            } ?>>
                            <label class="custom-control-label" for="empresas-<?php echo e($key->id); ?>"><?php echo e($key->empresa); ?></label>
                          </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        <center>
                          <br>
                          <button class="btn btn-primary" type="submit">Aplicar filtro</button>
                        </center>
                      </form>                    
                  </div>
                </div>
              </div>
                <?php if($hoteles->count() != 0): ?>
                	<div class="col-md-9">
                		<div class="row">
                      <?php $__currentLoopData = $hoteles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="col-md-12 mb-3 p-0" style="min-width: 100% !important">
                           <div class="card" style="border-radius: 10px; box-shadow: 0 0 3px grey;">
                              <div class="row">
                                <div class="col-md-4">
                                  <?php $i_ser = 0; ?>
                                    <?php if(isset($data_hoteles)): ?>
                                        <?php $url = route('hotel.single',$key->url).$data_hoteles['url']; ?>
                                      <?php else: ?>
                                        <?php $url = route('hotel.single',$key->url)?>
                                      <?php endif; ?>
                                    <?php if($key->imagenes->count() == 0): ?> 
                                      <a href="<?php echo e($url); ?>">
                                        <img class="card-img-top img-card" src="<?php echo e(asset('img/hotel.png')); ?>" alt="Hotel" />
                                      </a>                    
                                    <?php else: ?>
                                      <a href="<?php echo e($url); ?>">
                                        <img class="card-img-top img-card" src="<?php echo e(asset($key->imagenes[0]->img)); ?>" alt="Hotel" />
                                      </a>                    
                                    <?php endif; ?> 
                                </div>
                                <div class="col-md-8">
                                  <div class="card-body" style="min-height: 200px;">
                                     <a href="<?php echo e($url); ?>" class="m-0"><h6 class="m-0"><?php echo e($key->nombre); ?></h6></a>
                                      <?php if($key->servicios_principales_count() != 0): ?>
                                        <small class="mt-1">Servicios </small>
                                        <div data-flickity='{ "cellAlign": "center", "contain": true, "pageDots":true, "wrapAround":true, "autoPlay":false, "imagesLoaded":true, "groupCells": true,"groupCells": 3,"freeScroll": true}'> 
                                          <?php $i_ser = 1; $i=0; ?>
                                                <?php 
                                                $ser_cant = $key->servicios_principales_count();
                                                if ($ser_cant >= 5) {
                                                  $cant=2;
                                                }else{
                                                  $cant =  12 / $ser_cant;
                                                } 
                                                $data = $key->servicios_principales();
                                            ?>      

                                            <?php for($i=0; $i<($ser_cant*2); $i++): ?>
                                              <div class="col-<?php echo e($cant); ?>" style="padding: 0px;">
                                                  <img style="display: inline-block;" class="material-icons" 
                                                  src="<?php echo e(asset($data[$i])); ?>" data-toggle="tooltip" data-placement="top" 
                                                  <?php $i++; ?>
                                                  title="<?php echo e($data[$i]); ?>">
                                                </div>
                                            <?php endfor; ?>
                                        </div>
                                      <?php endif; ?>
                                      <div class="mb-1 mt-3">
                                      <div>

                                        <div class="row">
                                          <div class="col-md-4">
                                              <h5>
                                                <small>
                                                  Desde 
                                                  <strong>
                                                    <?php if(session('id_moneda')==2): ?> Q <?php endif; ?>
                                                    <?php if(session('id_moneda')==1): ?> $ <?php endif; ?>
                                                 </strong>
                                                </small>
                                                <strong> <?php echo e($key->precio_desde(session('id_moneda'))); ?> </strong> 
                                              </h5>
                                          </div>

                                          <div class="col-md-4">
                                            <?php for($e=0;$e<$key->estrellas;$e++): ?>
                                              <i class="material-icons text-warning" style="display: inline-block;">star</i>
                                            <?php endfor; ?>  
                                          </div>

                                          <div class="col-md-4">
                                            <div class="bg-dark text-white" style="min-width: 50px; max-width: 50px; float: right; border-radius: 5px;">
                                              <center><?php echo e($key->promedio()); ?></center>
                                            </div>
                                          </div>

                                        </div>
                                        <div class="row">
                                          <div class="col-md-5">
                                              <center>
                                                <?php if($key->recomendaciones->count() != 0): ?>
                                                <strong>recomendado por:</strong><br>
                                                  <div class="row">
                                                    <?php $__currentLoopData = $key->recomendaciones; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key2): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <div class="col">
                                                      <img src="<?php echo e(asset($key2->empresa->logo)); ?>" width="100px" height="40px">
                                                    </div>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>                         
                                                  </div>
                                                <?php endif; ?> 
                                              </center> 
                                          </div>
                                          <div class="col-md-7">
                                            <div class="mt-2"></div>
                                            <?php if(isset($data_hoteles)): ?>
                                              <?php if($key->check_disponibilidades($data_hoteles) == 'OK'): ?>
                                                <small class="text-success">Hay habitaciones disponibles para la fecha indicada </small>                             
                                              <?php else: ?>
                                                <small class="text-danger"><?php echo e($key->check_disponibilidades($data_hoteles)); ?></small>       
                                              <?php endif; ?> 
                                            <?php endif; ?> 
                                          </div>
                                        </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                          </div>
                        </div>
                      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>  
                      <div class="col-md-12">
                        <nav class="d-flex justify-content-between pt-2" aria-label="Page navigation">
                          <ul class="pagination">
                                      
                          </ul>
                            <?php echo $hoteles->render(); ?>

                          <ul class="pagination">
                                      
                          </ul>
                        </nav>
                      </div>
                    </div>
        			    </div>
                 <?php else: ?>
                  <div class="col-md-9">
                    <div class="mt-5"></div>
                    <center>
                      <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>
                      <h3>No se encontraron resultado <br> que coincida con la búsqueda</h3>
                    </center>
                  </div>
                <?php endif; ?>
              </div>
            </div>
          </div>
        </section>
       
          

<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
    <script type="text/javascript">
    var departamentos = [
      <?php 
        foreach ($departamentos as $key) {
          echo "
            {
              id:".$key->id.',
              municipios:[              
            ';

            foreach ($key->municipios as $key2) {
              echo "
                {
                  id:".$key2->id.",
                  municipio: '".$key2->municipio."'
                },
              ";
            }

            echo "]},";
        }
      ?>
    ];

    $('#departamento').change(function(){

      var value = $(this).val();

      if (value=='') {

        var option = '<option value="">Selecciona una opción</option>';
        $('#municipio').html(option);

      }else{
        var option = '<option value="">Selecciona una opción</option>';

        var municipios = departamentos[value - 1].municipios;

        municipios.forEach(function(element){
          option = option + '<option value="'+element.id+'">'+element.municipio+'</option>';
        });

        $('#municipio').html(option);
      }
    });    
  </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\guatehoteles\resources\views/hoteles.blade.php ENDPATH**/ ?>