templates/default/divisas.html.twig line 1

  1. {# {% extends 'default/contenido.html.twig' %} #}
  2. {% extends 'base.html.twig' %}
  3. {% block title %}{% if divisa %}{{ divisa.metaTitle| replace({'| Eurochange.es':''}) }}{%else%}{{ conversion.metaTitle| replace({'| Eurochange.es':''}) }}{%endif%}{% endblock %}
  4. {% block metadescription %}{% if divisa %}{{ divisa.metaDescription }}{%else%}{{ conversion.metaDescription }}{%endif%}{% endblock %}
  5. {% block metakeywords %}{% if divisa %}{{ divisa.metaKeywords }}{%else%}{{ conversion.metaKeywords }}{%endif%}{% endblock %}
  6. {% block idiomas %}
  7.     {% for k,idioma in locales %}
  8.         {% if k == app.request.locale %}    
  9.             <option selected value="{{ path(app.request.get('_route', 'index'), app.request.get('_route_params', [])|merge({_locale: k})) }}" title="{{ idioma }}">{{ k | upper}}</option>
  10.         {% elseif divisa != null %}
  11.             <option value="{{ path(app.request.get('_route', 'index'), app.request.get('_route_params', [])|merge({_locale: k, nombre: divisa.translate(k).slug })) }}" title="{{ idioma }}">{{ k | upper}}</option>
  12.         {% elseif conversion != null %}
  13.             <option value="{{ path(app.request.get('_route', 'index'), app.request.get('_route_params', [])|merge({_locale: k, nombre: conversion.translate(k).slug })) }}" title="{{ idioma }}">{{ k | upper}}</option>
  14.         {% endif %}
  15.     {% endfor %}
  16. {% endblock %}
  17. {% block bodyId %}divisas{% endblock %}
  18. {% block body %}
  19.     <div class="title container">
  20.         {% if divisa != null %}
  21.             <h1>{{ divisa.altBanner }}</h1>
  22.         {% elseif conversion != null %}
  23.             <h1>{{ conversion.metaTitle| replace({'| Eurochange.es':''}) }}</h1>
  24.         {% endif %}
  25.     </div>
  26.     
  27.     <div id="cab-divisa" class="container">
  28.         <div class="row">
  29.             <div class="col-12 col-lg-7 cambio">
  30.                     {#{% if ofi_var != 0 %}
  31.                         {% set currentDate = date() | date("Y-m-d") %}
  32.                         <p id="precio">{{ 'Precios para' | trans}} {{ oficina.nombre }} {{ currentDate }}</p>
  33.                     {% endif %}#}
  34.                     <div class="sticky-top">
  35.                     
  36.                     <div id="cont_camb">
  37.                         <ul class="nav nav-tabs" id="myTab" role="tablist">
  38.                             <li class="nav-item" id="calc" role="presentation">
  39.                                 <button class="nav-link active" id="calcular-tab" data-bs-toggle="tab" data-bs-target="#calcular_cambio" type="button" role="tab" aria-controls="profile" aria-selected="true"><i class="fa-solid fa-calculator"></i></button>
  40.                             </li>
  41.                             <li class="nav-item" role="presentation">
  42.                                 <button class="nav-link" id="comprar-tab" data-bs-toggle="tab" data-bs-target="#calcular_cambio" type="button" role="tab" aria-controls="profile" aria-selected="false">{{ 'Comprar_online' | trans}}</button>
  43.                             </li>
  44.                         </ul>
  45.                         
  46.                         <div class="tab-content" id="myTabContent">
  47.                             <div class="tab-pane fade show active" id="calcular_cambio" role="tabpanel" aria-labelledby="profile-tab">
  48.                                 {{ render(controller('App\\Controller\\DefaultController::oficinaAction', { select_id: 'select_ofi2' } )) }}
  49.                                 
  50.                                 {#<p class="info-select">{{ '* La tienda online solo permite la compra de divisas extranjeras (no Euros)' | trans}}</p>#}
  51.                             
  52.                             </div>
  53.                         </div>
  54.                     </div>
  55.                     
  56.                     {{ render(controller('App\\Controller\\CotizacionesController::alerta' )) }}
  57.                     </div>
  58.             </div>
  59.             <div class="col-12 col-lg-5 colum-der">
  60.                 <div id="cotizacionesJsonG" style="display:none">{{cotizacionesJsonG}}</div>
  61.                 <script src="https://cdn.amcharts.com/lib/3/amcharts.js"></script>
  62.                 <script src="https://cdn.amcharts.com/lib/3/serial.js"></script>
  63.                 <script src="https://cdn.amcharts.com/lib/3/themes/light.js"></script>
  64.                 <script src="https://cdn.amcharts.com/lib/3/plugins/dataloader/dataloader.min.js"></script>
  65.                 <script src="https://cdn.amcharts.com/lib/3/maps/js/worldLow.js"></script>
  66.                 
  67.                 {% if divisa != null %}
  68.                     <p style="font-weight: bold;">{{ 'EVOLUCIÓN DEL PRECIO DE VENTA DE' | trans}} {{ divisa.nombre|upper }}</p>
  69.                     
  70.                     <div id="" class="chartcontainer p5" style="width:100%; height:300px; margin-bottom:30px;">
  71.                         <div id="chartdiv-precioVenta" style="width:100%;height:100%;"></div>
  72.                     </div>
  73.                     
  74.                     
  75.                     <p style="font-weight: bold;">{{ 'EVOLUCIÓN DEL PRECIO DE COMPRA DE' | trans}} {{ divisa.nombre|upper }}</p>
  76.                     <div id="" class="chartcontainer p5" style="width:100%; height:300px; margin-bottom:30px;">
  77.                         <div id="chartdiv-precioCompra" style="width:100%;height:100%;"></div>
  78.                     </div>
  79.                     {{ divisa.texto2|raw }}
  80.                     {{ render(controller('App\\Controller\\DefaultController::principalesCambios' )) }}
  81.                 {% elseif conversion != null %}
  82.                     <p style="font-weight: bold;">{{ 'EVOLUCIÓN DEL PRECIO DE COMPRA DE' | trans}} {% if conversion.divisaOrigen.id == 10 %}{{ conversion.divisaDestino.nombre|upper }}{% else %}{{ conversion.divisaOrigen.nombre|upper }}{% endif %}</p>
  83.                     <div id="" class="chartcontainer p5" style="width:100%; height:300px; margin-bottom:30px;">
  84.                         <div id="chartdiv-precioCompra" style="width:100%;height:100%;"></div>
  85.                     </div>
  86.                     {% if conversion.divisaOrigen.id == 10 %}{{ conversion.divisaOrigen.texto2|raw }}{% else %}{{ conversion.divisaDestino.texto2|raw }}{% endif %}
  87.                     {{ render(controller('App\\Controller\\DefaultController::principalesCambios' )) }}
  88.                 {% endif %}
  89.                 {% if divisa != null %}
  90.                     {{ divisa.texto1|raw }}
  91.                     <a id="bus" href="/oficinas">{{ 'Busca tu oficina de cambio mas cercana' | trans}}</a>
  92.                 {% endif %}
  93.             </div>
  94.         </div>
  95.     </div>
  96.     
  97. {% endblock %}
  98. {% block funciones_eventos %}
  99.         {{ parent() }}
  100.         <script>
  101.             
  102.             $(document).ready(function() {
  103.                 var contenido = $('#contenedorInv #contenedorMover').clone();
  104.                 if ($('#calcular_cambio .parte-repetida').length === 0) {
  105.                     $('#calcular_cambio').append(contenido);
  106.                     $('#contenedorInv #contenedorMover').remove();
  107.                 }
  108.            
  109.             
  110.                 {% if divisa != null %}
  111.                         $('#selectQuieres').val({{ divisa.id }}).change();
  112.                         $('#inputQuieres').trigger('change');
  113.                 {% endif %}
  114.                 
  115.                 {% if conversion != null %}
  116.                 
  117.                     {% if conversion.divisaOrigen.id != 10 %}    
  118.                         $('#selectTienes').val({{conversion.divisaOrigen.id}}).change();
  119.                         $('#inputTienes').trigger('change');
  120.                     {% else %}
  121.                         $('#selectQuieres').val({{conversion.divisaDestino.id}}).change();
  122.                         $('#inputQuieres').trigger('change');
  123.                     {% endif %}
  124.                         
  125.                 {% endif %}
  126.             
  127.              });
  128.             
  129.             
  130.             $(document).ready(function() {
  131.                 console.log("JS_JSN");
  132.                 var idioma = $('html').attr('lang');
  133.                 function loadCurrencies(jSONCurrencies,tipo) {
  134.                     var chartData = [];
  135.                     var cotizacion = $.parseJSON(jSONCurrencies);
  136.                     for(var i in cotizacion)
  137.                     {
  138.                         var newDate = new Date(cotizacion[i].dia);
  139.                         if(tipo=='precioVenta'){
  140.                             var precio = cotizacion[i].precioVenta;
  141.                         }
  142.                         else{
  143.                             var precio = cotizacion[i].precioCompra;
  144.                         }
  145.                         chartData.push({
  146.                             date: newDate,
  147.                             cotizaciones: precio
  148.                         });
  149.                     }
  150.                 
  151.                     return chartData;
  152.                 }
  153.                 
  154.                 
  155.                 
  156.                 var chart = AmCharts.makeChart("chartdiv-precioVenta", {
  157.                     "type": "serial",
  158.                     "dataProvider": [
  159.                         { "country": "USA", "visits": 3025 },
  160.                         { "country": "China", "visits": 1882 },
  161.                         { "country": "Japan", "visits": 1809 },
  162.                         { "country": "Germany", "visits": 1322 },
  163.                         { "country": "UK", "visits": 1122 },
  164.                         { "country": "France", "visits": 1114 },
  165.                         { "country": "India", "visits": 984 },
  166.                         { "country": "Spain", "visits": 711 },
  167.                         { "country": "Netherlands", "visits": 665 },
  168.                         { "country": "Russia", "visits": 580 }
  169.                     ],
  170.                     "valueAxes": [{
  171.                         "title": "Visits"
  172.                     }],
  173.                     "graphs": [{
  174.                         "balloonText": "[[category]]: <b>[[value]]</b>",
  175.                         "fillColorsField": "color",
  176.                         "fillAlphas": 0.9,
  177.                         "lineAlpha": 0.2,
  178.                         "type": "column",
  179.                         "valueField": "visits"
  180.                     }],
  181.                     "categoryField": "country",
  182.                     "categoryAxis": {
  183.                         "gridPosition": "start",
  184.                         "labelRotation": 45
  185.                     }
  186.                 });
  187.                 
  188.                 
  189.                 
  190.                 function loadChart(chartData,tipo){
  191.                     if(idioma == "es"){
  192.                         decimalSeparator=",",
  193.                         text="Cotizacion"
  194.                     }else{
  195.                         decimalSeparator=".",
  196.                         text="Exchange rate"
  197.                     }
  198.                     var chart = AmCharts.makeChart("chartdiv-"+tipo, {
  199.                         "language": idioma,
  200.                         "type": "serial",
  201.                         "theme": "light",
  202.                         "labelsEnabled": false,
  203.                         "autoMargins": true,
  204.                         "marginTop": 5,
  205.                         "dataProvider": chartData,
  206.                         "valueAxes": [{
  207.                             "position": "left",
  208.                             "title": ""
  209.                         }],
  210.                         "graphs": [{
  211.                             "id": "g1",
  212.                             "fillAlphas": 0.4,
  213.                             "valueField": "cotizaciones",
  214.                             "balloonText": "<div style='margin:5px; font-size:19px;'>"+text+":<b>[[value]]</b></div>"
  215.                         }],
  216.                         "chartScrollbar": {
  217.                             "graph": "g1",
  218.                             "scrollbarHeight": 40,
  219.                             "backgroundAlpha": 0,
  220.                             "selectedBackgroundAlpha": 0.1,
  221.                             "selectedBackgroundColor": "#888888",
  222.                             "graphFillAlpha": 0,
  223.                             "graphLineAlpha": 0.5,
  224.                             "selectedGraphFillAlpha": 0,
  225.                             "selectedGraphLineAlpha": 1,
  226.                             "autoGridCount": true,
  227.                             "color": "#AAAAAA",
  228.                             "offset": 5,
  229.                             "autoHide": true
  230.                         },
  231.                         "chartCursor": {
  232.                             "categoryBalloonDateFormat": "DD/MM",
  233.                             "cursorPosition": "mouse"
  234.                         },
  235.                         "categoryField": "date",
  236.                         "categoryAxis": {
  237.                             "minPeriod": "mm",
  238.                             "parseDates": true
  239.                         },
  240.                         "export": {
  241.                             "enabled": true,
  242.                             "dateFormat": "YYYY-MM-DD"
  243.                         },
  244.                         "numberFormatter": {
  245.                         "decimalSeparator": decimalSeparator,
  246.                         },
  247.                         "responsive": {
  248.                             "enabled": true
  249.                         }
  250.                     });
  251.                     chart.addListener("dataUpdated", zoomChart);
  252.                     // when we apply theme, the dataUpdated event is fired even before we add listener, so
  253.                     // we need to call zoomChart here
  254.                     zoomChart();
  255.                     // this method is called when chart is first inited as we listen for "dataUpdated" event
  256.                     function zoomChart() {
  257.                         // different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues
  258.                         chart.zoomToIndexes(chartData.length - 30, chartData.length);
  259.                     }
  260.                     AmCharts.addInitHandler(function(chart) {
  261.                     
  262.                     // check if scrollbar auto-hide is enabled
  263.                     if (chart.chartScrollbar === undefined || !chart.chartScrollbar.autoHide)
  264.                         return;
  265.                     
  266.                     // add zoomed events
  267.                     chart.addListener("zoomed", function(event) {
  268.                         
  269.                         // check if the chart is completely zoomed out
  270.                         var enabled = true;
  271.                         if (event.startIndex === 0 && event.endIndex === (chart.dataProvider.length - 1))
  272.                         enabled = false;
  273.                         
  274.                         // show or hide the scrollbar
  275.                         if (event.chart.chartScrollbar.enabled === enabled)
  276.                         return;
  277.                         event.chart.chartScrollbar.enabled = enabled
  278.                         event.chart.validateNow(false, true);
  279.                         
  280.                     });
  281.                     
  282.                     }, ["serial"]);
  283.                 }
  284.                 $('body').on('change','.ticker-item .cambio_divisa_check', function () {
  285.                     var parent = $(this).closest('.ticker-item');
  286.                     parent.find('.pVenta').toggle();
  287.                     parent.find('.pCompra').toggle();
  288.                 });
  289.                 $('body').on('change','#widget-change .cambio_divisa_check', function () {
  290.                     var parent = $(this).closest('#widget-change');
  291.                     parent.find('.pVenta').toggle();
  292.                     parent.find('.pCompra').toggle();
  293.                     $('.chart-box').toggle();
  294.                 });
  295.                 if($(".chartcontainer").length != 0) {
  296.                     var jSONCurrencies = $("#cotizacionesJsonG").html();
  297.                     var chartData = loadCurrencies(jSONCurrencies,'precioVenta');
  298.                     loadChart(chartData,'precioVenta');
  299.                     var chartData = loadCurrencies(jSONCurrencies,'precioCompra');
  300.                     loadChart(chartData,'precioCompra');
  301.                 }
  302.             });
  303.         </script>
  304. {% endblock %}