templates/default/restaurants.html.twig line 47

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block metas %}
  3.     <meta name="description" content="Encuentra los mejores menús cerca de ti.">
  4.     <meta property="og:title" content="Menu del dia"/>
  5.     <meta property="og:url" content="{{ url(app.request.attributes.get("_route"), app.request.attributes.get("_route_params")) }}"/>
  6.     <meta property="og:description" content="Encuentra los mejores menús cerca de ti.">
  7.     <meta property="og:image" itemprop="image" content="https://menusdeldia.com/uploads/menu.jpg">
  8. {% endblock %}
  9. {% block stylesheets %}
  10.     {{ parent() }}
  11.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.3.1/css/ion.rangeSlider.min.css"/>
  12. {% endblock %}
  13. {% block javascripts %}
  14.     {{ parent() }}
  15.     <script src="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.3.1/js/ion.rangeSlider.min.js"></script>
  16. {% endblock %}
  17. {% block title %}Restaurantes
  18. {% endblock %}
  19. {% block body %}
  20.     <div class="container py-3">
  21.         <section class="pb-2 pt-2">
  22.             <form action="{{ path('restaurants') }}" method="post" role="form" enctype="multipart/form-data" class="w-100">
  23.                 <div class="row">
  24.                     <div class='col-md-6 text-center'>
  25.                         <h6>
  26.                             <small>Precio</small>
  27.                         </h6>
  28.                         <input type="text" class="js-range-precio" name="precioMax" value=""/>
  29.                     </div>
  30.                     <div class='col-md-6 text-center'>
  31.                         <h6>
  32.                             <small>Distancia</small>
  33.                         </h6>
  34.                         <input type="text" class="js-range-distancia" name="distanciaMax" value=""/>
  35.                     </div>
  36.                     <input name="latActual" type="hidden" value="{{ latActual }}">
  37.                     <input name="lngActual" type="hidden" value="{{ lngActual }}">
  38.                 </div>
  39.             </form>
  40.             <div class="row text-center mt-2">
  41.                 <p>
  42.                     <em>Se han encontrado
  43.                     </em>
  44.                     <strong>{{ restaurants|length }}</strong>
  45.                     <em>
  46.                         restaurantes cerca de ti.
  47.                     </em>
  48.                 </p>
  49.             </div>
  50.         </section>
  51.         <div class="row row-cols-1 row-cols-sm-2 row-cols-md-4 mt-1">
  52.             {% for restaurant in restaurants %}
  53.                 <div class="col my-4">
  54.                     <div class="card shadow-sm">
  55.                         <div class="card-header text-center py-1">
  56.                             <a class="text-decoration-none" href="{{ path('showrestaurant' , { 'restaurante': restaurant.nombre|replace({' ': '-'})|lower, 'id': restaurant.id }) }}" title="{{ restaurant.nombre }}" target="_blank">
  57.                                 <em class="fw-semibold text-dark-emphasis fs-6">{{ restaurant.nombre }}</em>
  58.                             </a>
  59.                         </div>
  60.                         <a class="text-decoration-none" href="{{ path('showrestaurant' , { 'restaurante': restaurant.nombre|replace({' ': '-'})|lower, 'id': restaurant.id }) }}" title="{{ restaurant.nombre }}" target="_blank">
  61.                             {% if restaurant.images|length  %}
  62.                                 <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}}">
  63.                             {% else %}
  64.                                 <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}}">
  65.                             {% endif %}
  66.                         </a>
  67.                         {% if latActual and lngActual %}
  68.                             <div class="restaurant-km">
  69.                                 <small class="badge bg-success bg-gradient text-wrap fw-bolder fs-6">
  70.                                     <em>
  71.                                         {{ restaurant.distancia }}
  72.                                         Km
  73.                                     </em>
  74.                                 </small>
  75.                             </div>
  76.                         {% endif %}
  77.                         <div class="card-body text-center py-1">
  78.                             {% if restaurant.rating %}
  79.                                 <div class="col-12 text-center">
  80.                                     {% set rating = restaurant.rating|split('.') %}
  81.                                     {% for i in 1..rating[0] %}
  82.                                         <i class="text-warning fa fa-star"></i>
  83.                                     {% endfor %}
  84.                                     {% if rating[1] is defined %}
  85.                                         <i class="text-warning fa fa-star-half"></i>
  86.                                     {% endif  %}
  87.                                     {{ restaurant.rating }}
  88.                                 </div>
  89.                             {% else %}
  90.                                 <div class="col-12 text-center fw-lighter fst-italic">Sin puntuar</div>
  91.                             {% endif %}
  92.                         </div>
  93.                         <div class="card-footer d-flex justify-content-between align-items-center text-center">
  94.                             <a class="text-decoration-none" href="{{ path('showrestaurant' , { 'restaurante': restaurant.nombre|replace({' ': '-'})|lower, 'id': restaurant.id }) }}" title="Ver menus de {{ restaurant.nombre }}" target="_blank">
  95.                                 <i class="fas fa-file mx-3"></i>
  96.                             </a>
  97.                             <a href="whatsapp://send?text={{url('showrestaurant',{'restaurante' : restaurant.nombre|replace({' ': '-'})|lower, 'id' : restaurant.id})}}" data-action="share/whatsapp/share">
  98.                                 <i class="fas fa-share-alt mx-3"></i>
  99.                             </a>
  100.                             {% if restaurant.telefono %}
  101.                                 <a href="tel:{{ restaurant.telefono }}" title="{{ restaurant.telefono }}">
  102.                                     <i class="fa fa-phone mx-3"></i>
  103.                                 </a>
  104.                             {% endif %}
  105.                             {% if restaurant.lat and restaurant.lng %}
  106.                                 <a href="https://www.google.es/maps/dir//{{ restaurant.lat }}+{{ restaurant.lng }}" target="_blank">
  107.                                     <i class="fa fa-map-marker m-3" aria-hidden="true"></i>
  108.                                 </a>
  109.                             {% endif %}
  110.                         </div>
  111.                     </div>
  112.                 </div>
  113.             {% endfor %}
  114.         </div>
  115.     </div>    
  116. {% endblock %}
  117. {% block postjavascripts %}
  118.     {{ parent() }}
  119.     <!-- parse-ignore-start -->
  120.     <script>
  121.         $(document).ready(function () {
  122.             const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
  123.             const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
  124.             if (!$("input[name='latActual']").val() && !$("input[name='lngActual']").val()) {
  125.                 if (navigator.geolocation) {
  126.                     navigator.geolocation.getCurrentPosition(showPosition);
  127.                 } else {
  128.                     console.log("Geolocation is not supported by this browser.");
  129.                 }
  130.             }
  131.             
  132.             $(".js-range-precio").ionRangeSlider({
  133.                 skin: "round",
  134.                 step: 5,
  135.                 grid: true,
  136.                 min: 0,
  137.                 max: 50,
  138.                 from: {{ precioMax }},
  139.                 prefix: "€",
  140.                 onFinish: function (data) {
  141.                     $("form").submit();
  142.                 }
  143.             });
  144.             $(".js-range-distancia").ionRangeSlider({
  145.                 skin: "round",
  146.                   step: 5,
  147.                 grid: true,
  148.                 min: 0,
  149.                 max: 50,
  150.                 from: {{ distanciaMax }},
  151.                 prefix: "Km",
  152.                 onFinish: function (data) {
  153.                     $("form").submit();
  154.                 }
  155.             });
  156.             function showPosition(position) {
  157.                 $("input[name='latActual']").val(position.coords.latitude);
  158.                 $("input[name='lngActual']").val(position.coords.longitude);
  159.                 $("form").submit();
  160.             }
  161.         });
  162.     </script>
  163.     <!-- parse-ignore-end -->
  164. {% endblock %}