templates/default/cotizaciones.html.twig line 1

  1. {# {% extends 'default/contenido.html.twig' %} #}
  2. {% extends 'base.html.twig' %}
  3. {% block title %}{{ contenido.metaTitle|default(contenido.titulo)| replace({'| Eurochange.es':''}) }}{% endblock %}
  4. {% block metadescription %}{{ contenido.metaDescription|default(contenido.intro) }}{% endblock %}
  5. {% block metakeywords %}{{ contenido.metaKeywords }}{% endblock %}
  6. {% block metarobots %}{{ contenido.metaRobots|default(parent()) }}{% endblock %}
  7. {% block canonical %}{% if contenido.canonical %}<link rel="canonical" href="{{contenido.canonical}}" />{% endif %}{% endblock %}
  8. {% block bodyId %}cotizacion{% endblock %}
  9. {% block body %}
  10.     <div class="title container">
  11.         <h1>{{ 'Cotizaciones y tipo de cambio de divisas' | trans}}</h1>
  12.     </div>
  13.     
  14.     <div id="cotizaciones" class="container">
  15.         <p id="pri" class="d-none d-md-block">{{ 'Si vas a viajar al extranjero, en Eurochange.es podrás cambiar tus Euros a la divisa que necesites. A tu vuelta también podrás cambiar los billetes extranjeros que te sobren a Euros en cualquiera de nuestras oficinas de cambio de divisas.' | trans}}</p>
  16.         <p class="d-none d-md-block">{{ 'Consulta el tipo de cambio de las principales divisas a continuación. Busca tu oficina de cambio más cercana y comprueba los servicios disponibles, o haz tu reserva online y recóge tu dinero en cualquiera de nuestras casas de cambio, de una manera comoda en cualquier punto de España. ¡Así de sencillo!' | trans}}</p>
  17.         
  18.         {#<select id="select-ofi" class="form-select" aria-label="Default select example">
  19.             <option value="todos" selected>Para comenzar, selecciona tu oficina más cercana</option>
  20.             {% for oficina in oficinas %}
  21.                 <option value="{{ oficina.nombre }}">{{ oficina.nombre }}</option>
  22.             {% endfor %}
  23.         </select>#}
  24.         
  25.         {{ render(controller('App\\Controller\\DefaultController::oficinaAction', { select_id: 'select_ofi2' } )) }}
  26.         
  27.         {% if of != "" %}<p class="info-select">{{ 'Precios para' | trans}} {{ of.nombre }} {{ diaMax }}</p>{% endif %}
  28.         
  29.         {% if ofi_var == 0 %}
  30.             <span id="no-cot">{{ 'Porfavor selecciona una oficina para que le podamos dar las tarifas correctas' | trans}}</span>
  31.         {% endif %}
  32.         <table id="tabla-cot">
  33.             <tr>
  34.                 <th>{{ 'Divisa' | trans}}</th>
  35.                 <th>{{ 'Compramos' | trans}}<span class="info-valor1">i<p style="display:none;">{{ 'Utiliza la flecha para ver el tipo de cambio directo o indirecto.' | trans}}</p></span></th>
  36.                 <th>{{ 'Vendemos' | trans}}<span class="info-valor2">i<p style="display:none;">{{ 'Utiliza la flecha para ver el tipo de cambio directo o indirecto.' | trans}}</p></span></th>
  37.             </tr>
  38.             {% for cotizacion in cotizaciones %}
  39.                 <tr data-oficina="{{ cotizacion.oficina }}">
  40.                     <td>
  41.                         <a href="{{ path('divisas', {'nombre': cotizacion.shortName.slug}) }}"><span class="banderas">
  42.                             {% if cotizacion.shortName.imagen %}
  43.                                 {{ sonata_thumbnail(cotizacion.shortName.imagen, 'flag', {'title': cotizacion.shortName.nombre}) }}
  44.                             {% endif %}
  45.                         </span>{{ cotizacion.shortName.shortName }} - {{ cotizacion.shortName.nombre }}</a>
  46.                     </td>
  47.                     <td>
  48.                         {% if cotizacion.oficina.id == 66 %}
  49.                             -
  50.                         {% elseif cotizacion.oficina.franjas is empty %}
  51.                             -
  52.                         {% else %}
  53.                             <span class="antes">1</span>
  54.                             <label class="switch">
  55.                                 <input type="checkbox" class="toggleSwitch" autocomplete="off">
  56.                                 <span class="slider"></span>
  57.                                 <span class="label-on">{{ cotizacion.shortName }}</span>
  58.                                 <span class="label-off">EUR</span>
  59.                             </label>
  60.                             <span class="despues">{{ cotizacion.precioCompra|number_format(cotizacion.shortName.numDecimales) }}</span>
  61.                         {% endif %}
  62.                     </td>
  63.                     <td>
  64.                         {% if cotizacion.oficina.franjas is empty %}
  65.                             -
  66.                         {% elseif cotizacion.oficina.permiteCompra == 1 %}
  67.                             <span class="antes">1</span>
  68.                             <label class="switch">
  69.                                 <input type="checkbox" class="toggleSwitch" autocomplete="off">
  70.                                 <span class="slider"></span>
  71.                                 <span class="label-on">{{ cotizacion.shortName }}</span>
  72.                                 <span class="label-off">EUR</span>
  73.                             </label>
  74.                             <span class="despues">{{ cotizacion.precioVenta|number_format(cotizacion.shortName.numDecimales) }}</span>
  75.                         {% else %}
  76.                             -
  77.                         {% endif %}
  78.                     </td>
  79.                 </tr>
  80.             {% endfor %}
  81.         </table>
  82.         
  83.         <div id="tabla-cot-res">
  84.                 <ul class="nav nav-tabs" id="tabla-res" role="tablist">
  85.                     <span id="divRes">{{ 'Divisa' | trans}}</span>
  86.                     <span class="info-valor1">i<p style="display:none;">{{ 'Utiliza la flecha para ver el tipo de cambio directo o indirecto.' | trans}}</p></span>
  87.                     <li class="nav-item" role="presentation">
  88.                         <button class="nav-link active" id="comp" data-bs-toggle="tab" data-bs-target="#compramos" type="button" role="tab" aria-controls="home" aria-selected="true">{{ 'Compramos' | trans}}</button>
  89.                     </li>
  90.                     <li class="nav-item" role="presentation">
  91.                         <button class="nav-link" id="vend" data-bs-toggle="tab" data-bs-target="#vendemos" type="button" role="tab" aria-controls="profile" aria-selected="false">{{ 'Vendemos' | trans}}</button>
  92.                     </li>
  93.                 </ul>
  94.                 
  95.                 <div class="tab-content" id="tabla-res-content">
  96.                     <div class="tab-pane fade show active" id="compramos" role="tabpanel" aria-labelledby="home-tab">
  97.                         {% for cotizacion in cotizaciones %}
  98.                             <div class="row">
  99.                                 <div class="col-6 voltN">
  100.                                     <a href="{{ path('divisas', {'nombre': cotizacion.shortName}) }}"><span class="banderas">
  101.                                         {% if cotizacion.shortName.imagen %}
  102.                                             {{ sonata_thumbnail(cotizacion.shortName.imagen, 'flag', {'title': cotizacion.shortName.nombre}) }}
  103.                                         {% endif %}
  104.                                     </span>{{ cotizacion.shortName }}</a>
  105.                                 </div>
  106.                                 <div class="col-6 volt">
  107.                                     {% if cotizacion.oficina.id == 66 %}
  108.                                         -
  109.                                     {% elseif cotizacion.oficina.franjas is empty %}
  110.                                         -
  111.                                     {% else %}
  112.                                         <span class="antes">1</span>
  113.                                         <label class="switch">
  114.                                             <input type="checkbox" class="toggleSwitch" autocomplete="off">
  115.                                             <span class="slider"></span>
  116.                                             <span class="label-on">{{ cotizacion.shortName }}</span>
  117.                                             <span class="label-off">EUR</span>
  118.                                         </label>
  119.                                         <span class="despues">{{ cotizacion.precioCompra|number_format(cotizacion.shortName.numDecimales) }}</span>
  120.                                     {% endif %}
  121.                                 </div>
  122.                             </div>
  123.                         {% endfor %}
  124.                     </div>
  125.                     
  126.                     <div class="tab-pane fade" id="vendemos" role="tabpanel" aria-labelledby="profile-tab">
  127.                         {% for cotizacion in cotizaciones %}
  128.                             <div class="row">
  129.                                 <div class="col-6 voltN">
  130.                                     <a href="{{ path('divisas', {'nombre': cotizacion.shortName}) }}"><span class="banderas">
  131.                                         {% if cotizacion.shortName.imagen %}
  132.                                             {{ sonata_thumbnail(cotizacion.shortName.imagen, 'flag', {'title': cotizacion.shortName.nombre}) }}
  133.                                         {% endif %}
  134.                                     </span>{{ cotizacion.shortName }}</a>
  135.                                 </div>
  136.                                 <div class="col-6 volt">
  137.                                     {% if cotizacion.oficina.franjas is empty %}
  138.                                         -
  139.                                     {% elseif cotizacion.oficina.permiteCompra == 1 %}
  140.                                         <span class="antes">1</span>
  141.                                         <label class="switch">
  142.                                             <input type="checkbox" class="toggleSwitch" autocomplete="off">
  143.                                             <span class="slider"></span>
  144.                                             <span class="label-on">{{ cotizacion.shortName }}</span>
  145.                                             <span class="label-off">EUR</span>
  146.                                         </label>
  147.                                         <span class="despues">{{ cotizacion.precioVenta|number_format(cotizacion.shortName.numDecimales) }}</span>
  148.                                     {% else %}
  149.                                         -
  150.                                     {% endif %}
  151.                                 </div>
  152.                             </div>
  153.                         {% endfor %}
  154.                     </div>
  155.                 </div>
  156.         </div>
  157.         
  158.         <button id="ver-mas">{{ 'Ver +' | trans}}</button>
  159.     </div>
  160.     
  161.      {% block empresas %}
  162.         {{ render(controller('App\\Controller\\DefaultController::empresas' )) }}
  163.     {% endblock %}
  164.     
  165. {% endblock %}
  166. {% block funciones_eventos %}
  167.     {{ parent() }}
  168.     
  169.     <script>
  170.             // Hacer el cambio de Compramos/Vendemos
  171.             
  172.             const toggleSwitches = document.querySelectorAll('.toggleSwitch');
  173.             const spanAntes = document.querySelectorAll('.antes');
  174.             const spanDespues = document.querySelectorAll('.despues');
  175.             toggleSwitches.forEach((toggleSwitch, index) => {
  176.                 toggleSwitch.addEventListener('change', function() {
  177.                 
  178.                     const numero1 = parseFloat(spanAntes[index].innerText);
  179.                     const numero2 = parseFloat(spanDespues[index].innerText);
  180.                     
  181.                     if (toggleSwitch.checked) {
  182.                         spanAntes[index].innerText = (numero1 / numero2).toFixed(3);
  183.                         spanDespues[index].innerText = '1';
  184.                     } else {
  185.                         spanAntes[index].innerText = '1';
  186.                         spanDespues[index].innerText = (numero2 / numero1).toFixed(3);
  187.                     }
  188.                 });
  189.             });
  190.             
  191.             
  192.             // Funcionalidad del botón "Ver +"
  193.             
  194.             var tablaCuerpo = document.getElementById('tabla-cot');
  195.             var verMas = document.getElementById('ver-mas');
  196.             var filasVisibles = 16;
  197.             var aumento = 10;
  198.             function actualizarFilasVisibles() {
  199.                 var filas = tablaCuerpo.getElementsByTagName('tr');
  200.                 var filasOcultas = filas.length - filasVisibles;
  201.                 for (var i = 0; i < filas.length; i++) {
  202.                     if (i < filasVisibles) {
  203.                         filas[i].style.display = 'table-row';
  204.                     } else {
  205.                         filas[i].style.display = 'none';
  206.                     }
  207.                 }
  208.                 
  209.                 if (filasOcultas > 0) {
  210.                     verMas.style.display = 'block';
  211.                 } else {
  212.                     verMas.style.display = 'none';
  213.                 }
  214.             }
  215.             actualizarFilasVisibles();
  216.             verMas.addEventListener('click', function() {
  217.                 filasVisibles += aumento;
  218.                 actualizarFilasVisibles();
  219.             });
  220.     </script>
  221. {% endblock %}