{% extends 'base.html.twig' %}
{% block metas %}
<meta name="description" content="Encuentra los mejores menús cerca de ti.">
<meta property="og:title" content="Menu del dia"/>
<meta property="og:url" content="{{ url(app.request.attributes.get("_route"), app.request.attributes.get("_route_params")) }}"/>
<meta property="og:description" content="Encuentra los mejores menús cerca de ti.">
<meta property="og:image" itemprop="image" content="https://menusdeldia.com/uploads/menu.jpg">
{% endblock %}
{% block stylesheets %}
{{ parent() }}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.3.1/css/ion.rangeSlider.min.css"/>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.3.1/js/ion.rangeSlider.min.js"></script>
{% endblock %}
{% block title %}Restaurantes
{% endblock %}
{% block body %}
<div class="container py-3">
<section class="pb-2 pt-2">
<form action="{{ path('restaurants') }}" method="post" role="form" enctype="multipart/form-data" class="w-100">
<div class="row">
<div class='col-md-6 text-center'>
<h6>
<small>Precio</small>
</h6>
<input type="text" class="js-range-precio" name="precioMax" value=""/>
</div>
<div class='col-md-6 text-center'>
<h6>
<small>Distancia</small>
</h6>
<input type="text" class="js-range-distancia" name="distanciaMax" value=""/>
</div>
<input name="latActual" type="hidden" value="{{ latActual }}">
<input name="lngActual" type="hidden" value="{{ lngActual }}">
</div>
</form>
<div class="row text-center mt-2">
<p>
<em>Se han encontrado
</em>
<strong>{{ restaurants|length }}</strong>
<em>
restaurantes cerca de ti.
</em>
</p>
</div>
</section>
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-4 mt-1">
{% for restaurant in restaurants %}
<div class="col my-4">
<div class="card shadow-sm">
<div class="card-header text-center py-1">
<a class="text-decoration-none" href="{{ path('showrestaurant' , { 'restaurante': restaurant.nombre|replace({' ': '-'})|lower, 'id': restaurant.id }) }}" title="{{ restaurant.nombre }}" target="_blank">
<em class="fw-semibold text-dark-emphasis fs-6">{{ restaurant.nombre }}</em>
</a>
</div>
<a class="text-decoration-none" href="{{ path('showrestaurant' , { 'restaurante': restaurant.nombre|replace({' ': '-'})|lower, 'id': restaurant.id }) }}" title="{{ restaurant.nombre }}" target="_blank">
{% if restaurant.images|length %}
<img class="bd-placeholder-img card-img-top" width="100%" height="200" src="/uploads/images/{{ restaurant.images[0].filePath }}" title="Menu diario de {{restaurant.nombre }}" alt="Menu diario de {{ restaurant.nombre }}" restaurante="{{restaurant.nombre}}">
{% else %}
<img class="bd-placeholder-img card-img-top" width="100%" height="200" src="/img/default-restaurant.webp" title="Menu diario de {{restaurant.nombre }}" alt="Menu diario de {{restaurant.nombre }}" restaurante="{{restaurant.nombre}}">
{% endif %}
</a>
{% if latActual and lngActual %}
<div class="restaurant-km">
<small class="badge bg-success bg-gradient text-wrap fw-bolder fs-6">
<em>
{{ restaurant.distancia }}
Km
</em>
</small>
</div>
{% endif %}
<div class="card-body text-center py-1">
{% if restaurant.rating %}
<div class="col-12 text-center">
{% set rating = restaurant.rating|split('.') %}
{% for i in 1..rating[0] %}
<i class="text-warning fa fa-star"></i>
{% endfor %}
{% if rating[1] is defined %}
<i class="text-warning fa fa-star-half"></i>
{% endif %}
{{ restaurant.rating }}
</div>
{% else %}
<div class="col-12 text-center fw-lighter fst-italic">Sin puntuar</div>
{% endif %}
</div>
<div class="card-footer d-flex justify-content-between align-items-center text-center">
<a class="text-decoration-none" href="{{ path('showrestaurant' , { 'restaurante': restaurant.nombre|replace({' ': '-'})|lower, 'id': restaurant.id }) }}" title="Ver menus de {{ restaurant.nombre }}" target="_blank">
<i class="fas fa-file mx-3"></i>
</a>
<a href="whatsapp://send?text={{url('showrestaurant',{'restaurante' : restaurant.nombre|replace({' ': '-'})|lower, 'id' : restaurant.id})}}" data-action="share/whatsapp/share">
<i class="fas fa-share-alt mx-3"></i>
</a>
{% if restaurant.telefono %}
<a href="tel:{{ restaurant.telefono }}" title="{{ restaurant.telefono }}">
<i class="fa fa-phone mx-3"></i>
</a>
{% endif %}
{% if restaurant.lat and restaurant.lng %}
<a href="https://www.google.es/maps/dir//{{ restaurant.lat }}+{{ restaurant.lng }}" target="_blank">
<i class="fa fa-map-marker m-3" aria-hidden="true"></i>
</a>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}
{% block postjavascripts %}
{{ parent() }}
<!-- parse-ignore-start -->
<script>
$(document).ready(function () {
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
if (!$("input[name='latActual']").val() && !$("input[name='lngActual']").val()) {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
console.log("Geolocation is not supported by this browser.");
}
}
$(".js-range-precio").ionRangeSlider({
skin: "round",
step: 5,
grid: true,
min: 0,
max: 50,
from: {{ precioMax }},
prefix: "€",
onFinish: function (data) {
$("form").submit();
}
});
$(".js-range-distancia").ionRangeSlider({
skin: "round",
step: 5,
grid: true,
min: 0,
max: 50,
from: {{ distanciaMax }},
prefix: "Km",
onFinish: function (data) {
$("form").submit();
}
});
function showPosition(position) {
$("input[name='latActual']").val(position.coords.latitude);
$("input[name='lngActual']").val(position.coords.longitude);
$("form").submit();
}
});
</script>
<!-- parse-ignore-end -->
{% endblock %}