templates/default/divisas.html.twig line 1
- {# {% extends 'default/contenido.html.twig' %} #}
- {% extends 'base.html.twig' %}
- {% block title %}{% if divisa %}{{ divisa.metaTitle| replace({'| Eurochange.es':''}) }}{%else%}{{ conversion.metaTitle| replace({'| Eurochange.es':''}) }}{%endif%}{% endblock %}
- {% block metadescription %}{% if divisa %}{{ divisa.metaDescription }}{%else%}{{ conversion.metaDescription }}{%endif%}{% endblock %}
- {% block metakeywords %}{% if divisa %}{{ divisa.metaKeywords }}{%else%}{{ conversion.metaKeywords }}{%endif%}{% endblock %}
- {% block idiomas %}
- {% for k,idioma in locales %}
- {% if k == app.request.locale %}
- <option selected value="{{ path(app.request.get('_route', 'index'), app.request.get('_route_params', [])|merge({_locale: k})) }}" title="{{ idioma }}">{{ k | upper}}</option>
- {% elseif divisa != null %}
- <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>
- {% elseif conversion != null %}
- <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>
- {% endif %}
- {% endfor %}
- {% endblock %}
- {% block bodyId %}divisas{% endblock %}
- {% block body %}
- <div class="title container">
- {% if divisa != null %}
- <h1>{{ divisa.altBanner }}</h1>
- {% elseif conversion != null %}
- <h1>{{ conversion.metaTitle| replace({'| Eurochange.es':''}) }}</h1>
- {% endif %}
- </div>
- <div id="cab-divisa" class="container">
- <div class="row">
- <div class="col-12 col-lg-7 cambio">
- {#{% if ofi_var != 0 %}
- {% set currentDate = date() | date("Y-m-d") %}
- <p id="precio">{{ 'Precios para' | trans}} {{ oficina.nombre }} {{ currentDate }}</p>
- {% endif %}#}
- <div class="sticky-top">
- <div id="cont_camb">
- <ul class="nav nav-tabs" id="myTab" role="tablist">
- <li class="nav-item" id="calc" role="presentation">
- <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>
- </li>
- <li class="nav-item" role="presentation">
- <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>
- </li>
- </ul>
- <div class="tab-content" id="myTabContent">
- <div class="tab-pane fade show active" id="calcular_cambio" role="tabpanel" aria-labelledby="profile-tab">
- {{ render(controller('App\\Controller\\DefaultController::oficinaAction', { select_id: 'select_ofi2' } )) }}
- {#<p class="info-select">{{ '* La tienda online solo permite la compra de divisas extranjeras (no Euros)' | trans}}</p>#}
- </div>
- </div>
- </div>
- {{ render(controller('App\\Controller\\CotizacionesController::alerta' )) }}
- </div>
- </div>
- <div class="col-12 col-lg-5 colum-der">
- <div id="cotizacionesJsonG" style="display:none">{{cotizacionesJsonG}}</div>
- <script src="https://cdn.amcharts.com/lib/3/amcharts.js"></script>
- <script src="https://cdn.amcharts.com/lib/3/serial.js"></script>
- <script src="https://cdn.amcharts.com/lib/3/themes/light.js"></script>
- <script src="https://cdn.amcharts.com/lib/3/plugins/dataloader/dataloader.min.js"></script>
- <script src="https://cdn.amcharts.com/lib/3/maps/js/worldLow.js"></script>
- {% if divisa != null %}
- <p style="font-weight: bold;">{{ 'EVOLUCIÓN DEL PRECIO DE VENTA DE' | trans}} {{ divisa.nombre|upper }}</p>
- <div id="" class="chartcontainer p5" style="width:100%; height:300px; margin-bottom:30px;">
- <div id="chartdiv-precioVenta" style="width:100%;height:100%;"></div>
- </div>
- <p style="font-weight: bold;">{{ 'EVOLUCIÓN DEL PRECIO DE COMPRA DE' | trans}} {{ divisa.nombre|upper }}</p>
- <div id="" class="chartcontainer p5" style="width:100%; height:300px; margin-bottom:30px;">
- <div id="chartdiv-precioCompra" style="width:100%;height:100%;"></div>
- </div>
- {{ divisa.texto2|raw }}
- {{ render(controller('App\\Controller\\DefaultController::principalesCambios' )) }}
- {% elseif conversion != null %}
- <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>
- <div id="" class="chartcontainer p5" style="width:100%; height:300px; margin-bottom:30px;">
- <div id="chartdiv-precioCompra" style="width:100%;height:100%;"></div>
- </div>
- {% if conversion.divisaOrigen.id == 10 %}{{ conversion.divisaOrigen.texto2|raw }}{% else %}{{ conversion.divisaDestino.texto2|raw }}{% endif %}
- {{ render(controller('App\\Controller\\DefaultController::principalesCambios' )) }}
- {% endif %}
- {% if divisa != null %}
- {{ divisa.texto1|raw }}
- <a id="bus" href="/oficinas">{{ 'Busca tu oficina de cambio mas cercana' | trans}}</a>
- {% endif %}
- </div>
- </div>
- </div>
- {% endblock %}
- {% block funciones_eventos %}
- {{ parent() }}
- <script>
- $(document).ready(function() {
- var contenido = $('#contenedorInv #contenedorMover').clone();
- if ($('#calcular_cambio .parte-repetida').length === 0) {
- $('#calcular_cambio').append(contenido);
- $('#contenedorInv #contenedorMover').remove();
- }
- {% if divisa != null %}
- $('#selectQuieres').val({{ divisa.id }}).change();
- $('#inputQuieres').trigger('change');
- {% endif %}
- {% if conversion != null %}
- {% if conversion.divisaOrigen.id != 10 %}
- $('#selectTienes').val({{conversion.divisaOrigen.id}}).change();
- $('#inputTienes').trigger('change');
- {% else %}
- $('#selectQuieres').val({{conversion.divisaDestino.id}}).change();
- $('#inputQuieres').trigger('change');
- {% endif %}
- {% endif %}
- });
- $(document).ready(function() {
- console.log("JS_JSN");
- var idioma = $('html').attr('lang');
- function loadCurrencies(jSONCurrencies,tipo) {
- var chartData = [];
- var cotizacion = $.parseJSON(jSONCurrencies);
- for(var i in cotizacion)
- {
- var newDate = new Date(cotizacion[i].dia);
- if(tipo=='precioVenta'){
- var precio = cotizacion[i].precioVenta;
- }
- else{
- var precio = cotizacion[i].precioCompra;
- }
- chartData.push({
- date: newDate,
- cotizaciones: precio
- });
- }
- return chartData;
- }
- var chart = AmCharts.makeChart("chartdiv-precioVenta", {
- "type": "serial",
- "dataProvider": [
- { "country": "USA", "visits": 3025 },
- { "country": "China", "visits": 1882 },
- { "country": "Japan", "visits": 1809 },
- { "country": "Germany", "visits": 1322 },
- { "country": "UK", "visits": 1122 },
- { "country": "France", "visits": 1114 },
- { "country": "India", "visits": 984 },
- { "country": "Spain", "visits": 711 },
- { "country": "Netherlands", "visits": 665 },
- { "country": "Russia", "visits": 580 }
- ],
- "valueAxes": [{
- "title": "Visits"
- }],
- "graphs": [{
- "balloonText": "[[category]]: <b>[[value]]</b>",
- "fillColorsField": "color",
- "fillAlphas": 0.9,
- "lineAlpha": 0.2,
- "type": "column",
- "valueField": "visits"
- }],
- "categoryField": "country",
- "categoryAxis": {
- "gridPosition": "start",
- "labelRotation": 45
- }
- });
- function loadChart(chartData,tipo){
- if(idioma == "es"){
- decimalSeparator=",",
- text="Cotizacion"
- }else{
- decimalSeparator=".",
- text="Exchange rate"
- }
- var chart = AmCharts.makeChart("chartdiv-"+tipo, {
- "language": idioma,
- "type": "serial",
- "theme": "light",
- "labelsEnabled": false,
- "autoMargins": true,
- "marginTop": 5,
- "dataProvider": chartData,
- "valueAxes": [{
- "position": "left",
- "title": ""
- }],
- "graphs": [{
- "id": "g1",
- "fillAlphas": 0.4,
- "valueField": "cotizaciones",
- "balloonText": "<div style='margin:5px; font-size:19px;'>"+text+":<b>[[value]]</b></div>"
- }],
- "chartScrollbar": {
- "graph": "g1",
- "scrollbarHeight": 40,
- "backgroundAlpha": 0,
- "selectedBackgroundAlpha": 0.1,
- "selectedBackgroundColor": "#888888",
- "graphFillAlpha": 0,
- "graphLineAlpha": 0.5,
- "selectedGraphFillAlpha": 0,
- "selectedGraphLineAlpha": 1,
- "autoGridCount": true,
- "color": "#AAAAAA",
- "offset": 5,
- "autoHide": true
- },
- "chartCursor": {
- "categoryBalloonDateFormat": "DD/MM",
- "cursorPosition": "mouse"
- },
- "categoryField": "date",
- "categoryAxis": {
- "minPeriod": "mm",
- "parseDates": true
- },
- "export": {
- "enabled": true,
- "dateFormat": "YYYY-MM-DD"
- },
- "numberFormatter": {
- "decimalSeparator": decimalSeparator,
- },
- "responsive": {
- "enabled": true
- }
- });
- chart.addListener("dataUpdated", zoomChart);
- // when we apply theme, the dataUpdated event is fired even before we add listener, so
- // we need to call zoomChart here
- zoomChart();
- // this method is called when chart is first inited as we listen for "dataUpdated" event
- function zoomChart() {
- // different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues
- chart.zoomToIndexes(chartData.length - 30, chartData.length);
- }
- AmCharts.addInitHandler(function(chart) {
- // check if scrollbar auto-hide is enabled
- if (chart.chartScrollbar === undefined || !chart.chartScrollbar.autoHide)
- return;
- // add zoomed events
- chart.addListener("zoomed", function(event) {
- // check if the chart is completely zoomed out
- var enabled = true;
- if (event.startIndex === 0 && event.endIndex === (chart.dataProvider.length - 1))
- enabled = false;
- // show or hide the scrollbar
- if (event.chart.chartScrollbar.enabled === enabled)
- return;
- event.chart.chartScrollbar.enabled = enabled
- event.chart.validateNow(false, true);
- });
- }, ["serial"]);
- }
- $('body').on('change','.ticker-item .cambio_divisa_check', function () {
- var parent = $(this).closest('.ticker-item');
- parent.find('.pVenta').toggle();
- parent.find('.pCompra').toggle();
- });
- $('body').on('change','#widget-change .cambio_divisa_check', function () {
- var parent = $(this).closest('#widget-change');
- parent.find('.pVenta').toggle();
- parent.find('.pCompra').toggle();
- $('.chart-box').toggle();
- });
- if($(".chartcontainer").length != 0) {
- var jSONCurrencies = $("#cotizacionesJsonG").html();
- var chartData = loadCurrencies(jSONCurrencies,'precioVenta');
- loadChart(chartData,'precioVenta');
- var chartData = loadCurrencies(jSONCurrencies,'precioCompra');
- loadChart(chartData,'precioCompra');
- }
- });
- </script>
- {% endblock %}