{% 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 %}Menu del dia
{% endblock %}
{% block body %}
<div class="container py-3">
<section class="pb-2 pt-2">
<form action="{{ path('menus') }}" 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>{{ menus|length }}</strong>
<em>
menús cerca de ti.
</em>
</p>
</div>
</section>
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-4 mt-1">
{% for menu in menus %}
<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': menu.restaurante.nombre|replace({' ': '-'})|lower, 'id': menu.restaurante.id }) }}" title="{{ menu.restaurante.nombre }}" target="_blank">
<em class="fw-semibold text-dark-emphasis fs-6">{{ menu.restaurante.nombre }}</em>
</a>
</div>
{{ include('default/partials/_carousel.html.twig', { 'images': menu.images , 'restaurant' : menu.restaurante}) }}
{% if latActual and lngActual %}
<div class="restaurant-km">
<small class="badge bg-success bg-gradient text-wrap fw-bolder fs-6">
<em>
{{ menu.restaurante.distancia }}
Km
</em>
</small>
</div>
{% endif %}
<div class="card-body text-center py-1">
{% if menu.restaurante.rating %}
<div class="col-12 text-center">
<div class="float-start badge bg-primary text-wrap fw-bold fs-6">
{{ menu.precio|number_format(1, '.', ',') }}€
</div>
<div class="float-end">
{% set rating = menu.restaurante.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 %}
{{ menu.restaurante.rating }}
</div>
</div>
{% else %}
<div class="col-12 text-center">
<div class="float-start badge bg-primary text-wrap fw-bold fs-6">
{{ menu.precio|number_format(1, '.', ',') }}€
</div>
<span class="float-end fw-lighter fst-italic">
Sin puntuar</span>
</div>
{% endif %}
</div>
<div class="card-footer d-flex justify-content-between align-items-center text-center">
<a href="whatsapp://send?text={{url('showrestaurant',{'restaurante' : menu.restaurante.nombre|replace({' ': '-'})|lower, 'id' : menu.restaurante.id})}}" data-action="share/whatsapp/share">
<i class="fas fa-share-alt mx-3"></i>
</a>
{% if menu.restaurante.telefono %}
<a href="tel:{{ menu.restaurante.telefono }}" title="{{ menu.restaurante.telefono }}">
<i class="fa fa-phone mx-3"></i>
</a>
{% endif %}
{% if menu.restaurante.lat and menu.restaurante.lng %}
<a href="https://www.google.es/maps/dir//{{ menu.restaurante.lat }}+{{ menu.restaurante.lng }}" target="_blank">
<i class="fa fa-map-marker m-3" aria-hidden="true"></i>
</a>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<div class="modal" id="imagemodal" tabindex="-1">
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h6 class="nombre"></h6>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<img src="" class="imagepreview" style="width: 100%;">
</div>
</div>
</div>
</div>
{% endblock %}
{% block postjavascripts %}
{{ parent() }}
<!-- parse-ignore-start -->
<script>
$(document).ready(function () {
$('.zoom').on('click', function () {
$(".nombre").html($(this).attr('restaurante'));
$('.imagepreview').attr('src', $(this).attr('src'));
$('#imagemodal').modal('show');
});
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 %}