source: seiven/economico/templates/economico.pib.html

Last change on this file was 5bd3e39, checked in by edgoldo <edgetrono@…>, 6 años ago

Modificación en consulta del submódulo PIB. Se incluyen las consultas de los submódulos Agregados Monetarios y Tasas de Interés

  • Propiedad mode establecida a 100644
File size: 7.6 KB
Línea 
1{% extends 'base.template.html' %}
2{% load i18n %}
3{% load static from staticfiles %}
4{% block content_header_title %}{% trans 'CARGAR DATOS' %}{% endblock %}
5{% block content_header_roadmap %}
6    <li><a href="{% url 'economico-cargar-datos' %}">{% trans 'Economía - Cargar Datos' %}</a></li>
7    <li class="active">{% block active_link %}{% trans 'Real - PIB' %}{% endblock %}</li>
8{% endblock %}
9{% block content %}
10    <div class="panel panel-primary">
11        <div class="panel-heading">
12            <h2 class="panel-title">{% trans 'Economía' %} - {% trans 'Real' %} - {% trans 'PIB' %}</h2>
13        </div>
14        <div class="panel-body">
15            <div class="row">
16                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
17                    <p>
18                        {% blocktrans %}
19                            Para cargar los datos asociados al <b>Producto Interno Bruto - PIB </b> seleccione el tipo, dominio y el año base.
20                        {% endblocktrans %}
21                    </p>
22                </div>
23            </div>
24            <div align="center">
25                {% include 'base/base.pib.html' %}
26            </div>
27            <!-- -->
28            <div class="enlaces" style='display:none;'>
29                {% include 'base.down.up.files.html' with app='economico' mod='PIB' %}
30            </div>
31        </div>
32    </div>
33{% endblock %}
34{% block extra_footer %}
35    <script>       
36        var tipo = $("#{{ form.tipo.auto_id }}");
37        var dominio = $("#{{ form.dominio.auto_id }}");
38        var anho_base = $("#{{ form.anho_base.auto_id }}");
39        var anho_ini = $("#{{ form.periodo_anho_ini.auto_id }}");
40        var anho_fin = $("#{{ form.periodo_anho_fin.auto_id }}");
41        var trimestre_ini = $("#{{ form.periodo_trimestre_ini.auto_id }}");
42        var trimestre_fin = $("#{{ form.periodo_trimestre_fin.auto_id }}");
43        var select_dominio = $('#id_dominio');
44        var options_dominio = select_dominio.html();
45        var tipo_ant = "";
46
47        function set_filters() {
48            /**
49            * @brief Realiza cambios en la vista ocasionados por modificaciones
50            * en los formularios. Almacena los valores de los parámetros que serán usados
51            * en el modelo
52            *
53            * @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
54            * @author Edgar A. Linares (elinares at cenditel.gob.ve)
55            * @copyright GNU/GPLv2
56            * @date 05-04-2017
57            */ 
58            var filters = $("#filters"), json_filter = '';
59
60            if (tipo.val()) {               
61                if (tipo.val() == 'R') {
62                    json_filter += "\"real__isnull\": \"false\",";
63                    $('.anho_base').show();
64                    if (tipo_ant != tipo.val())
65                        select_dominio.html(options_dominio);
66                }
67                else {
68                    json_filter += "\"nominal__isnull\": \"false\",";
69                    $('.anho_base').hide();
70                    if (tipo_ant != tipo.val()){
71                        $("#id_dominio option[value='AE']").remove();
72                        $("#id_dominio option[value='SI']").remove();
73                    }
74                }
75            }
76            if (dominio.val()) {
77                if (dominio.val() == 'ED') {
78                    json_filter += "\"pibdemanda__isnull\": \"false\",";
79                }
80                else if (dominio.val() == 'EO') {
81                    json_filter += "\"pibproduccion__isnull\": \"false\",";
82                }
83                else if (dominio.val() == 'AE') {
84                    json_filter += "\"pibactividad__isnull\": \"false\","; 
85                }
86                else if (dominio.val() == 'SI') {
87                    json_filter += "\"pibsector__isnull\": \"false\",";
88                }
89            }
90            if (tipo.val() == 'R' && dominio.val() && anho_base.val()) {
91                if ((dominio.val() == 'AE' || dominio.val() == 'SI')){
92                    $('.periodo').show();
93                    $('.trimestral').show();
94                }
95                else{
96                    $('.periodo').show();
97                    $('.trimestral').hide();   
98                }
99            }
100            else if (tipo.val() == 'N' && dominio.val()) {
101                $('.periodo').show();
102                $('.trimestral').hide();
103            }
104            else {
105                $('.periodo').hide();
106                $('.trimestral').hide();
107            }
108            if (dominio.val() && anho_ini.val() && anho_fin.val()){
109                if ( (dominio.val() == 'ED' || dominio.val() == 'EO') &&
110                     anho_fin.val() >= anho_ini.val() ) {
111                    $('.enlaces').show();
112                }
113                else if ( (dominio.val() == 'AE' || dominio.val() == 'SI') &&
114                        (anho_fin.val() >= anho_ini.val()) &&
115                        trimestre_ini.val() && trimestre_fin.val() ) {
116                    if ( (anho_fin.val() == anho_ini.val()) && 
117                        (trimestre_fin.val() >= trimestre_ini.val()) )
118                        $('.enlaces').show();
119                    else if (anho_fin.val() > anho_ini.val())
120                        $('.enlaces').show();
121                    else
122                        $('.enlaces').hide();
123                }
124                else {
125                    $('.enlaces').hide();
126               }
127            }
128            if (anho_base.val()) {
129                json_filter += "\"anho_base\": \"" + anho_base.val() + "\",";
130            }
131            if (anho_ini.val()) {
132                json_filter += "\"anho__gte\": \"" + anho_ini.val() + "\",";
133            }
134            if (anho_fin.val()) {
135                json_filter += "\"anho__lte\": \"" + anho_fin.val() + "\",";
136            }
137            if (trimestre_ini.val()) {
138                json_filter += "\"trimestre__gte\": \"" + trimestre_ini.val() + "\",";
139            }
140            if (trimestre_fin.val()) {
141                json_filter += "\"trimestre__lte\": \"" + trimestre_fin.val() + "\",";
142            }
143            tipo_ant = tipo.val();
144            if (json_filter) {
145                json_filter = json_filter.slice(0, -1);
146                filters.val(json_filter);
147            }
148        }
149
150        $(document).ready(function() {
151            tipo.on('change', function() { set_filters() });
152            dominio.on('change', function() { set_filters() });
153            anho_base.on('change', function() { set_filters() });
154            anho_ini.on('change', function() { set_filters() });
155            anho_fin.on('change', function() { set_filters() });
156            trimestre_ini.on('change', function() { set_filters() });
157            trimestre_fin.on('change', function() { set_filters() });
158
159            // Función para procesar el archivo de carga masiva
160            $('.fileinput-upload-button').click(function(event){
161                event.preventDefault();
162                var fdata = new FormData();
163                fdata.append('file',file.files[0]);
164                $.ajax({
165                    url: URL_CARGAR_ARCHIVO_CM+models,
166                    data: fdata,
167                    contentType: false,
168                    processData: false,
169                    type: 'POST',
170                    dataType: 'json',
171                    success: function(data){
172                        var msg = data.message ? data.result : data.error;
173                        bootbox.alert(msg);
174                    },
175                    error: function(error){
176                        console.log(error);
177                    }
178                });
179            });
180        });
181    </script>
182{% endblock %}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.