1 | /** |
---|
2 | * Función que permite mostrar opciones del submenú vertical |
---|
3 | */ |
---|
4 | $(function(){ |
---|
5 | $(document).ready(function(){ |
---|
6 | $('ul.dropdown-menu [data-toggle=dropdown]').on('click', function(event) { |
---|
7 | event.preventDefault(); |
---|
8 | event.stopPropagation(); |
---|
9 | $(this).parent().siblings().removeClass('open'); |
---|
10 | $(this).parent().toggleClass('open'); |
---|
11 | }); |
---|
12 | }); |
---|
13 | }); |
---|
14 | |
---|
15 | /** |
---|
16 | * @brief Función que valida el ingreso de solo números en un campo de texto |
---|
17 | * |
---|
18 | * @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
19 | * @copyright GNU/GPLv2 |
---|
20 | * @date 18-05-2015 |
---|
21 | * @param evt Variable de tipo object con el evento de la tecla presionada |
---|
22 | * @return Retorna verdadero en caso de que el carácter introducido en el campo de texto sea un número, |
---|
23 | * en caso contrario retorna falso |
---|
24 | */ |
---|
25 | function validar_numeros(evt) { |
---|
26 | evt = (evt) ? evt:event; |
---|
27 | var tecla = (evt.which) ? evt.which:evt.keyCode; |
---|
28 | var keychar = String.fromCharCode(tecla); |
---|
29 | |
---|
30 | return !!/^([0-9\t\b])$/.test(keychar); |
---|
31 | } |
---|
32 | |
---|
33 | /** |
---|
34 | * @brief Función que valida el ingreso de solo carácteres alfanuméricos en un campo de texto |
---|
35 | * |
---|
36 | * @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
37 | * @copyright GNU/GPLv2 |
---|
38 | * @date 18-05-2015 |
---|
39 | * @param evt Variable de tipo object con el evento de la tecla presionada |
---|
40 | * @return Retorna verdadero en caso de que el carácter introducido en el campo de texto sea un carácter alfanumérico, |
---|
41 | * en caso contrario retorna falso |
---|
42 | */ |
---|
43 | function validar_letras(evt) { |
---|
44 | evt = (evt) ? evt:event; |
---|
45 | var tecla = (evt.which) ? evt.which:evt.keyCode; |
---|
46 | var keychar = String.fromCharCode(tecla); |
---|
47 | |
---|
48 | return !!/^([A-Za-z\s\b])$/.test(keychar); |
---|
49 | } |
---|
50 | |
---|
51 | /** |
---|
52 | * @brief Función que muestra la fortaleza de la contraseña del usuario |
---|
53 | * |
---|
54 | * @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
55 | * @copyright GNU/GPLv2 |
---|
56 | * @date 20-05-2015 |
---|
57 | * @param password Variable de tipo string que contiene los caracteres de la contraseña especificada en el formulario |
---|
58 | */ |
---|
59 | function passwordStrength(password) { |
---|
60 | var desc = new Array(); |
---|
61 | desc[0] = "Muy Débil"; |
---|
62 | desc[1] = "Débil"; |
---|
63 | desc[2] = "Mejor"; |
---|
64 | desc[3] = "Buena"; |
---|
65 | desc[4] = "Fuerte"; |
---|
66 | desc[5] = "Muy Fuerte"; |
---|
67 | |
---|
68 | var score = 0; |
---|
69 | |
---|
70 | //if password bigger than 6 give 1 point |
---|
71 | if (password.length > 6) score++; |
---|
72 | |
---|
73 | //if password has both lower and uppercase characters give 1 point |
---|
74 | if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++; |
---|
75 | |
---|
76 | //if password has at least one number give 1 point |
---|
77 | if (password.match(/\d+/)) score++; |
---|
78 | |
---|
79 | //if password has at least one special caracther give 1 point |
---|
80 | if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++; |
---|
81 | |
---|
82 | //if password bigger than 12 give another 1 point |
---|
83 | if (password.length > 12) score++; |
---|
84 | |
---|
85 | document.getElementById("passwordDescription").innerHTML = desc[score]; |
---|
86 | document.getElementById("passwordStrength").className = "strength" + score; |
---|
87 | } |
---|
88 | |
---|
89 | /** |
---|
90 | * @brief Función que valida la fortaleza de la contraseña del usuario en el formulario |
---|
91 | * |
---|
92 | * @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
93 | * @copyright GNU/GPLv2 |
---|
94 | * @date 21-05-2015 |
---|
95 | * @return Devuelve verdadero si la contraseña es considerada aceptable y permite suministrar los datos del formulario, |
---|
96 | * en caso contrario retorna falso y muestra un mensaje al usuario |
---|
97 | */ |
---|
98 | function validar_form_passwordStrength() { |
---|
99 | var passStrength = $("#passwordStrength").attr('class'); |
---|
100 | if (!$.inArray(passStrength, ['strength0', 'strength1', 'strength2'])) { |
---|
101 | bootbox.alert({ |
---|
102 | title: 'Aviso', |
---|
103 | message: 'La nueva contraseña es insegura, intente nuevamente incluyendo símbolos, números y letras' |
---|
104 | }); |
---|
105 | return false; |
---|
106 | } |
---|
107 | return true; |
---|
108 | } |
---|
109 | |
---|
110 | /** |
---|
111 | * @brief Funcion que muestra el formulario de consulta de requerimientos de divisas por Unidad Economica y/o por |
---|
112 | * Producto consultado |
---|
113 | * |
---|
114 | * @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
115 | * @copyright GNU/GPLv2 |
---|
116 | * @date 04-06-2015 |
---|
117 | * @param tipo Variable de tipo string que contiene el tipo de consulta a realizar, los valores posibles son |
---|
118 | * pr = Producto, y ue = Unidad Economica |
---|
119 | * @param id Variable de tipo string que contiene el id del registro a consultar |
---|
120 | * @param template Variable de tipo string que contiene la estructura HTML del formulario a utilizar |
---|
121 | */ |
---|
122 | function requerimiento_divisas(tipo, id, template) { |
---|
123 | |
---|
124 | if (tipo=="ue") { |
---|
125 | /** Requerimientos de divisas por Unidad Económica */ |
---|
126 | get_params = {rif: id}; |
---|
127 | } |
---|
128 | else if (tipo=="pr") { |
---|
129 | /** Requerimientos de divisas por producto */ |
---|
130 | get_params = {pr_id: id}; |
---|
131 | } |
---|
132 | |
---|
133 | var modal = bootbox.dialog({ |
---|
134 | title: TITLE_BOOTBOX_DIVISAS, |
---|
135 | message: template, |
---|
136 | buttons: { |
---|
137 | success: { |
---|
138 | label: BTN_CALCULAR, |
---|
139 | className: "btn btn-primary btn-sm", |
---|
140 | callback: function () { |
---|
141 | var divisas_form = $("#divisas-form"); |
---|
142 | divisas_form.validate({ |
---|
143 | ignore: 'input[type=hidden]', //Requerido para validar elementos select2 |
---|
144 | rules: { |
---|
145 | cambionominal: { |
---|
146 | required: true, |
---|
147 | number: true, |
---|
148 | minlength: 1, |
---|
149 | min: 1 |
---|
150 | }, |
---|
151 | anhoregistro: { |
---|
152 | date: true, |
---|
153 | required: true |
---|
154 | } |
---|
155 | }, |
---|
156 | messages: { |
---|
157 | cambionominal: { |
---|
158 | required: ERROR_REQUIRED, |
---|
159 | minlength: ERROR_MINLENGTH, |
---|
160 | number: ERROR_NUMBER, |
---|
161 | min: ERROR_MIN |
---|
162 | , }, |
---|
163 | anhoregistro: { |
---|
164 | date: ERROR_YEAR_SELECT, |
---|
165 | required: ERROR_REQUIRED |
---|
166 | } |
---|
167 | }, |
---|
168 | highlight: function(element) { |
---|
169 | $(element).closest('.form-group').removeClass('has-success').addClass('has-error'); |
---|
170 | }, |
---|
171 | unhighlight: function(element) { |
---|
172 | $(element).closest('.form-group').removeClass('has-error').addClass('has-success'); |
---|
173 | }, |
---|
174 | errorElement: 'span', |
---|
175 | errorClass: 'help-block', |
---|
176 | errorPlacement: function(error, element) { |
---|
177 | if(element.parent('.input-group').length) { |
---|
178 | error.insertAfter(element.parent()); |
---|
179 | } else { |
---|
180 | error.insertAfter(element); |
---|
181 | } |
---|
182 | } |
---|
183 | }); |
---|
184 | divisas_form.attr('action', |
---|
185 | URL_REQUERIMIENTO_DIVISAS+"?id="+id+ |
---|
186 | "&cambio="+$(modal).find("#cambionominal").val()+ |
---|
187 | "&tipo="+tipo |
---|
188 | ); |
---|
189 | divisas_form.submit(); |
---|
190 | return false; |
---|
191 | } |
---|
192 | }, |
---|
193 | main: { |
---|
194 | label: BTN_CANCEL, |
---|
195 | className: "btn btn-warning btn-sm" |
---|
196 | } |
---|
197 | } |
---|
198 | }); |
---|
199 | |
---|
200 | $(modal).find('[data-toggle="tooltip"]').tooltip({}); |
---|
201 | $(modal).find('.select2').select2({}); |
---|
202 | if (tipo=="ue") { |
---|
203 | $(modal).find("#rifCalcDivisas").val(id); |
---|
204 | } |
---|
205 | else if (tipo=="pr") { |
---|
206 | $(modal).find("#prodCalcDivisas").val(id); |
---|
207 | } |
---|
208 | |
---|
209 | // Instrucción AJAX que permite obtener los años de registro de productos |
---|
210 | set_anhos_registro("#anhoregistro", modal, get_params); |
---|
211 | } |
---|
212 | |
---|
213 | /** |
---|
214 | * @brief Función que muestra el formulario de consulta que permite modelar una cadena productiva |
---|
215 | * |
---|
216 | * @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
217 | * @copyright GNU/GPLv2 |
---|
218 | * @date 08-06-2015 |
---|
219 | * @param id Variable de tipo string que contiene el id del producto a modelar |
---|
220 | * @param template Variable de tipo string que contiene la estructura HTML del formulario a utilizar |
---|
221 | */ |
---|
222 | function modelar_producto(id, template, rif) { |
---|
223 | var modal = bootbox.dialog({ |
---|
224 | title: TITLE_BOOTBOX_MODELAR_CADENA, |
---|
225 | message: template, |
---|
226 | buttons: { |
---|
227 | success: { |
---|
228 | label: BTN_ACEPT, |
---|
229 | className: "btn btn-primary btn-sm", |
---|
230 | callback: function() { |
---|
231 | |
---|
232 | $("#cadenas-form").validate({ |
---|
233 | ignore: 'input[type=hidden]', //Requerido para validar elementos select2 |
---|
234 | rules: { |
---|
235 | nivelesarriba: { |
---|
236 | minlength: 1, |
---|
237 | maxlength: 2, |
---|
238 | required: true, |
---|
239 | digits: true, |
---|
240 | min: 1 |
---|
241 | }, |
---|
242 | nivelesabajo: { |
---|
243 | minlength: 1, |
---|
244 | maxlength: 2, |
---|
245 | required: true, |
---|
246 | digits: true, |
---|
247 | min: 1 |
---|
248 | }, |
---|
249 | anhoregistro: { |
---|
250 | date: true, |
---|
251 | required: true, |
---|
252 | min: 0 |
---|
253 | } |
---|
254 | }, |
---|
255 | messages: { |
---|
256 | nivelesarriba: { |
---|
257 | required: ERROR_REQUIRED, |
---|
258 | minlength: ERROR_MINLENGTH, |
---|
259 | maxlength: ERROR_MAXLENGTH, |
---|
260 | digits: ERROR_DIGITS, |
---|
261 | min: ERROR_MIN |
---|
262 | }, |
---|
263 | nivelesabajo: { |
---|
264 | required: ERROR_REQUIRED, |
---|
265 | minlength: ERROR_MINLENGTH, |
---|
266 | maxlength: ERROR_MAXLENGTH, |
---|
267 | digits: ERROR_DIGITS, |
---|
268 | min: ERROR_MIN |
---|
269 | , }, |
---|
270 | anhoregistro: { |
---|
271 | date: ERROR_YEAR_SELECT, |
---|
272 | required: ERROR_REQUIRED |
---|
273 | } |
---|
274 | }, |
---|
275 | highlight: function(element) { |
---|
276 | $(element).closest('.form-group').removeClass('has-success').addClass('has-error'); |
---|
277 | }, |
---|
278 | unhighlight: function(element) { |
---|
279 | $(element).closest('.form-group').removeClass('has-error').addClass('has-success'); |
---|
280 | }, |
---|
281 | errorElement: 'span', |
---|
282 | errorClass: 'help-block', |
---|
283 | errorPlacement: function(error, element) { |
---|
284 | if(element.parent('.input-group').length) { |
---|
285 | error.insertAfter(element.parent()); |
---|
286 | } else { |
---|
287 | error.insertAfter(element); |
---|
288 | } |
---|
289 | }, |
---|
290 | submitHandler: function(form) { |
---|
291 | generar_cadena( |
---|
292 | URL_GEN_XML_SIGESIC, id, $(modal).find("#nivelesarriba").val(), |
---|
293 | $(modal).find("#nivelesabajo").val(), $(modal).find(".select2 :selected").text() |
---|
294 | ); |
---|
295 | |
---|
296 | $("#cadenas-form").attr('action', URL_CADENA_PRODUCTIVA+"?ciiu="+id+ |
---|
297 | "&narriba="+$(modal).find("#nivelesarriba").val()+ |
---|
298 | "&nabajo="+$(modal).find("#nivelesabajo").val()+ |
---|
299 | "&anho="+$(modal).find(".select2 :selected").text()+ |
---|
300 | "&rif="+rif |
---|
301 | ); |
---|
302 | |
---|
303 | form.submit(); |
---|
304 | } |
---|
305 | }); |
---|
306 | |
---|
307 | bootbox.confirm(MSG_GEN_CADENA, function(result) { |
---|
308 | if (result) { |
---|
309 | $("#cadenas-form").submit(); |
---|
310 | } |
---|
311 | }); |
---|
312 | |
---|
313 | return false; |
---|
314 | } |
---|
315 | }, |
---|
316 | main: { |
---|
317 | label: BTN_CANCEL, |
---|
318 | className: "btn btn-warning btn-sm" |
---|
319 | } |
---|
320 | } |
---|
321 | }); |
---|
322 | |
---|
323 | $(modal).find('[data-toggle="tooltip"]').tooltip({}); |
---|
324 | $(modal).find('.select2').select2({}); |
---|
325 | |
---|
326 | // Instrucción AJAX que permite obtener los años de registro del producto seleccionado |
---|
327 | set_anhos_registro("#anhoregistro", modal, {pr_id:id}); |
---|
328 | } |
---|
329 | |
---|
330 | /** |
---|
331 | * @brief Función que deshabilita los nodos seleccionados para su posterior eliminación de la cadena productiva |
---|
332 | * |
---|
333 | * @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
334 | * @copyright GNU/GPLv2 |
---|
335 | * @date 31-07-2015 |
---|
336 | * @param list_pr_id Variable de tipo string que contiene una lista de id a ser eliminados |
---|
337 | */ |
---|
338 | function eliminar_nodos_tree(list_pr_id) { |
---|
339 | |
---|
340 | var tree = $("#tree"), node_checked = $(".node-checked"); |
---|
341 | |
---|
342 | if (tree.length && node_checked.length) { |
---|
343 | var productos = ''; |
---|
344 | var lista = list_pr_id.split(","); |
---|
345 | for (i=0; i<lista.length; i++) { |
---|
346 | productos+="producto_id="+lista[i]+"&"; |
---|
347 | } |
---|
348 | node_checked.each(function(index) { |
---|
349 | nodeId = parseInt($(this).attr('data-nodeid')); |
---|
350 | tree.treeview('disableNode', [ nodeId, { silent: true } ]); |
---|
351 | tree.treeview('checkNode', [ nodeId, { silent: true } ]); |
---|
352 | tree.treeview('expandNode', [ nodeId, { silent: true } ]); |
---|
353 | }); |
---|
354 | bootbox.alert(MSG_DELETE_NODES); |
---|
355 | } |
---|
356 | else { |
---|
357 | bootbox.alert(MSG_NOT_NODES); |
---|
358 | } |
---|
359 | } |
---|
360 | |
---|
361 | /** |
---|
362 | * @brief Función que deshace las modificaciones para la eliminación de nodos de la cadena productiva |
---|
363 | * |
---|
364 | * @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
365 | * @copyright GNU/GPLv2 |
---|
366 | * @date 31-07-2015 |
---|
367 | */ |
---|
368 | function revert_eliminar_node() { |
---|
369 | var tree = $("#tree"), node_disabled = $('.node-disabled'); |
---|
370 | if (!node_disabled.length) { |
---|
371 | bootbox.alert(MSG_NOT_NODE_DISABLED); |
---|
372 | return false; |
---|
373 | } |
---|
374 | node_disabled.each(function(index) { |
---|
375 | nodeId = parseInt($(this).attr('data-nodeid')); |
---|
376 | tree.treeview('getNode', nodeId).color = "green"; |
---|
377 | tree.treeview('uncheckNode', [ nodeId, { silent: true } ]); |
---|
378 | tree.treeview('enableNode', [ nodeId, { silent: true } ]); |
---|
379 | }); |
---|
380 | $("#list_pr_id").val(""); |
---|
381 | bootbox.alert(MSG_REVERT_NODES); |
---|
382 | } |
---|
383 | |
---|
384 | /** |
---|
385 | * @brief Función que muestra una ventana emergente con el formulario para el proceso de modificación de la cadena productiva |
---|
386 | * |
---|
387 | * @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
388 | * @copyright GNU/GPLv2 |
---|
389 | * @date 04-08-2015 |
---|
390 | */ |
---|
391 | function modificar_cadena(template) { |
---|
392 | if (!$('.node-disabled').length) { |
---|
393 | bootbox.alert(MSG_NOT_NODE_SELECTED); |
---|
394 | return false; |
---|
395 | } |
---|
396 | var confirm = bootbox.confirm(MSG_SURE_MOD_CADENA, function(result) { |
---|
397 | if (result) { |
---|
398 | var box = bootbox.prompt({ |
---|
399 | label: "OK", |
---|
400 | title: TITLE_BOOTBOX_MODIFICAR_CADENA, |
---|
401 | buttons: { |
---|
402 | confirm: { |
---|
403 | label: 'guardar cadena' |
---|
404 | } |
---|
405 | }, |
---|
406 | callback: function(nombre_cadena){ |
---|
407 | var list_pr_ids = new Array(); |
---|
408 | var anho = parseInt($("#anho").html()); |
---|
409 | var tree = $('#tree'); |
---|
410 | var prd = tree.treeview('getNode', 0).tags[0].pr_id; |
---|
411 | |
---|
412 | $('.node-disabled').each(function(index) { |
---|
413 | nodeId = parseInt($(this).attr('data-nodeid')); |
---|
414 | pr_id = tree.treeview('getNode', nodeId).tags[0].pr_id; |
---|
415 | list_pr_ids.push(pr_id); |
---|
416 | }); |
---|
417 | guardar_cadena_productiva(URL_EDIT_CADENA, prd, list_pr_ids, 'S', anho, nombre_cadena); |
---|
418 | } |
---|
419 | }); |
---|
420 | $(box).find('.bootbox-input').addClass('input-sm'); |
---|
421 | $(box).find('.bootbox-input').before("<label>Nombre</label>"); |
---|
422 | // Centra la ventana modal verticalmente |
---|
423 | box.css({ |
---|
424 | 'top': '50%', |
---|
425 | 'margin-top': function () { |
---|
426 | return -(box.height() / 2); |
---|
427 | } |
---|
428 | }); |
---|
429 | } |
---|
430 | |
---|
431 | }); |
---|
432 | |
---|
433 | // Centra la ventana modal verticalmente |
---|
434 | confirm.css({ |
---|
435 | 'top': '50%', |
---|
436 | 'margin-top': function () { |
---|
437 | return -(confirm.height() / 2); |
---|
438 | } |
---|
439 | }); |
---|
440 | } |
---|
441 | |
---|
442 | /** |
---|
443 | * @brief Función que muestra una ventana emergente con el listado de cadenas modificadas, permitiendo abrir o comparar |
---|
444 | * alguna de ellas |
---|
445 | * |
---|
446 | * @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
447 | * @copyright GNU/GPLv2 |
---|
448 | * @date 07-08-2015 |
---|
449 | */ |
---|
450 | function abrir_cadena(template) { |
---|
451 | |
---|
452 | var cadena_id = ''; |
---|
453 | |
---|
454 | /// Dialogo modal que muestra el listado de cadenas modificadas |
---|
455 | var modal = bootbox.dialog({ |
---|
456 | title: TITLE_BOOTBOX_ABRIR_CADENA, |
---|
457 | message: template, |
---|
458 | buttons: { |
---|
459 | success: { |
---|
460 | label: BTN_OPEN, |
---|
461 | className: "btn btn-primary btn-sm", |
---|
462 | callback: function() { |
---|
463 | /// Verifica cual de los radio options fue seleccionado para asignar el identificador de la cadena modificada |
---|
464 | $(modal).find("input").attr("name", "sel-cad").each(function() { |
---|
465 | if ($(this).is(":checked")) { |
---|
466 | cadena_id = $(this).val(); |
---|
467 | } |
---|
468 | }); |
---|
469 | |
---|
470 | if (cadena_id=='') { |
---|
471 | bootbox.alert(MSG_NOT_CHAIN_SELECTED); |
---|
472 | return false; |
---|
473 | } |
---|
474 | |
---|
475 | // Genera el archivo xml de la cadena para posteriormente ser mostrada en la consulta del modelado |
---|
476 | gen_new_xml_cadena(cadena_id); |
---|
477 | |
---|
478 | return false; |
---|
479 | } |
---|
480 | }, |
---|
481 | "compare": { |
---|
482 | label: BTN_COMPARE, |
---|
483 | className: "btn btn-success btn-sm", |
---|
484 | callback: function() { |
---|
485 | |
---|
486 | $(modal).find("input").attr("name", "sel-cad").each(function() { |
---|
487 | if ($(this).is(":checked")) { |
---|
488 | cadena_id = $(this).val(); |
---|
489 | } |
---|
490 | }); |
---|
491 | |
---|
492 | if (cadena_id=='') { |
---|
493 | bootbox.alert(MSG_NOT_CHAIN_SELECTED); |
---|
494 | return false; |
---|
495 | } |
---|
496 | |
---|
497 | /// Dialogo modal que muestra la estructura de la cadena original y la cadena modificada seleccionada |
---|
498 | var modal_compare = bootbox.dialog({ |
---|
499 | title: TITLE_BOOTBOX_COMPARE_CADENAS, |
---|
500 | message: $("#compara-cadenas").html(), |
---|
501 | buttons: { |
---|
502 | main: { |
---|
503 | label: BTN_CANCEL, |
---|
504 | className: "btn btn-warning btn-sm" |
---|
505 | } |
---|
506 | } |
---|
507 | }); |
---|
508 | // Carga los datos de la cadena original a comparar |
---|
509 | $(modal_compare).find("#pop-cadena-nombre").text($("#cadena_nombre").text()); |
---|
510 | $(modal_compare).find("#tree-cadena-original").html($("#tree").html()); |
---|
511 | $(modal_compare).find("#tree-cadena-original").treeview({ |
---|
512 | levels: 99, |
---|
513 | data: tree, |
---|
514 | color: "#000000", |
---|
515 | backColor: "#FFFFFF", |
---|
516 | showIcon: false |
---|
517 | }); |
---|
518 | $(modal_compare).find("#tree-cadena-original").treeview('expandAll', { silent: true }); |
---|
519 | // Carga los datos de la cadena consultada |
---|
520 | $(modal_compare).find("#cadena_id_consultada").val(cadena_id); |
---|
521 | var treeSet = get_tree_cadena_modificada(URL_SHOW_COMPARE_CADENA, cadena_id); |
---|
522 | $(modal_compare).find("#pop-cadena-nombre-consulta").text(treeSet.nombre); |
---|
523 | $(modal_compare).find("#tree-cadena-consultada").treeview({ |
---|
524 | levels: 99, |
---|
525 | data: treeSet.tree, |
---|
526 | color: "#000000", |
---|
527 | backColor: "#FFFFFF", |
---|
528 | selectable: false |
---|
529 | }); |
---|
530 | $(modal_compare).find("#tree-cadena-consultada").treeview('expandAll', { silent: true }); |
---|
531 | |
---|
532 | return false; |
---|
533 | } |
---|
534 | }, |
---|
535 | main: { |
---|
536 | label: BTN_CANCEL, |
---|
537 | className: "btn btn-warning btn-sm" |
---|
538 | } |
---|
539 | } |
---|
540 | }); |
---|
541 | |
---|
542 | var dataSet = []; |
---|
543 | |
---|
544 | // Configura las peticiones AJAX para que no sean asincronas |
---|
545 | $.ajaxSetup({ |
---|
546 | async: false |
---|
547 | }); |
---|
548 | |
---|
549 | // Obtiene un listado de cadenas modificadas, y en caso de error muestra un mensaje al usuario |
---|
550 | $.getJSON(URL_LIST_CADENAS, {ciiu: $.urlParam('ciiu')}, function(datos) { |
---|
551 | if (datos.resultado) { |
---|
552 | i = 0; |
---|
553 | for (a in datos.dataSet) { |
---|
554 | dataSet[i] = datos.dataSet[a]; |
---|
555 | i ++; |
---|
556 | } |
---|
557 | } |
---|
558 | else { |
---|
559 | bootbox.alert(datos.error); |
---|
560 | return false; |
---|
561 | } |
---|
562 | }).fail(function(jqxhr, textStatus, error) { |
---|
563 | var err = textStatus + ", " + error; |
---|
564 | bootbox.alert(ERROR_AJAX_REQUEST + err); |
---|
565 | return false; |
---|
566 | }); |
---|
567 | |
---|
568 | // Carga los datos en la tabla con los registros de las cadenas modificadas |
---|
569 | $(modal).find("#table-lista-cadenas").dataTable({ |
---|
570 | "language": { |
---|
571 | "url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json" |
---|
572 | }, |
---|
573 | "lengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]], |
---|
574 | "data": dataSet, |
---|
575 | "columns": [ |
---|
576 | { "class": "text-center" }, |
---|
577 | { "class": "text-left" }, |
---|
578 | { "class": "text-left" }, |
---|
579 | { "class": "text-left" } |
---|
580 | ] |
---|
581 | }); |
---|
582 | } |
---|
583 | |
---|
584 | /** |
---|
585 | * @brief Función que ejecuta la accion que permite imprimir la cadena productiva en formato pdf |
---|
586 | * |
---|
587 | * @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
588 | * @copyright GNU/GPLv2 |
---|
589 | * @date 12-08-2015 |
---|
590 | */ |
---|
591 | function print_cadena_productiva(url, tree, nombre_cadena) { |
---|
592 | var tree_content = tree.treeview('expandAll', { silent: true }).html(); |
---|
593 | var year = new Date().getFullYear(); |
---|
594 | var header = "<div><img src='"+CINTILLO+"'></div>"; |
---|
595 | header += "<div class='text-center'>"+TITLE_REPORT_CADENA+" - "+nombre_cadena+"</div><br/>"; |
---|
596 | var footer = "<div class='text-center'>Centro Nacional de Desarrollo e Investigación en Tecnologías Libres (CENDITEL)</div>"; |
---|
597 | footer += "<div class='text-center'>GPL v2.0 - Copyleft 2015 - "+year+".</div><br/>"; |
---|
598 | |
---|
599 | tree.attr('style', ''); |
---|
600 | tree.print({ |
---|
601 | // Use Global styles |
---|
602 | globalStyles : true, |
---|
603 | // Add link with attrbute media=print |
---|
604 | mediaPrint : true, |
---|
605 | //Custom stylesheet |
---|
606 | //stylesheet : "http://fonts.googleapis.com/css?family=Inconsolata", |
---|
607 | //Print in a hidden iframe |
---|
608 | iframe : true, |
---|
609 | // Don't print this |
---|
610 | //noPrintSelector : ".avoid-this", |
---|
611 | // Add this on bottom |
---|
612 | append : footer, |
---|
613 | // Add this at top |
---|
614 | prepend : header, |
---|
615 | // Manually add form values |
---|
616 | manuallyCopyFormValues: true, |
---|
617 | // resolves after print and restructure the code for better maintainability |
---|
618 | deferred: $.Deferred() |
---|
619 | // timeout |
---|
620 | //timeout: 250 |
---|
621 | }); |
---|
622 | tree.treeview('collapseAll', { silent: true }).html(); |
---|
623 | } |
---|
624 | |
---|
625 | /** |
---|
626 | * @brief Objeto que permite obtener el valor de un parámetro pasado por el GET |
---|
627 | * @param sParam |
---|
628 | * @date 17-08-2015 |
---|
629 | * @returns {boolean} |
---|
630 | */ |
---|
631 | var getUrlParameter = function getUrlParameter(sParam) { |
---|
632 | var sPageURL = decodeURIComponent(window.location.search.substring(1)), |
---|
633 | sURLVariables = sPageURL.split('&'), |
---|
634 | sParameterName, |
---|
635 | i; |
---|
636 | |
---|
637 | for (i = 0; i < sURLVariables.length; i++) { |
---|
638 | sParameterName = sURLVariables[i].split('='); |
---|
639 | |
---|
640 | if (sParameterName[0] === sParam) { |
---|
641 | return sParameterName[1] === undefined ? true : sParameterName[1]; |
---|
642 | } |
---|
643 | } |
---|
644 | }; |
---|
645 | |
---|
646 | |
---|
647 | /** |
---|
648 | * @brief Función que ejecuta la accion que permite visualizar/ocultar la cadena de la fuente de datos Encuesta en el panel-footer |
---|
649 | * |
---|
650 | * @author Ing. Erwin Paredes (eparedes at cenditel.gob.ve) |
---|
651 | * @copyright GNU/GPLv2 |
---|
652 | * @date 17-08-2015 |
---|
653 | */ |
---|
654 | function ver_ocultar_panel_footer(fuente) { |
---|
655 | var url_grafico = ''; |
---|
656 | var rif = getUrlParameter('rif'); |
---|
657 | var id_prod = getUrlParameter('ciiu'); |
---|
658 | |
---|
659 | if($('#panel-al-pie').css('display') == 'none'){ |
---|
660 | $('#panel-al-pie').show('slow'); |
---|
661 | $('html, body').animate({scrollTop: $("#panel-al-pie").offset().top},2000); |
---|
662 | var dt = new Date(); |
---|
663 | var time = dt.toLocaleTimeString(); |
---|
664 | if (fuente=='encuesta') { |
---|
665 | url_grafico = URL_GRAFICAR_ENCUESTA; |
---|
666 | $("#panel-title-fuentes-diversas").html("Encuesta Industrial"); |
---|
667 | $("#niveles-arriba-grafico").html("4"); |
---|
668 | $("#niveles-abajo-grafico").html("4"); |
---|
669 | $("#panel-matrizip").hide(); |
---|
670 | $("#panel-composicion-accionaria").hide(); |
---|
671 | } |
---|
672 | else if (fuente=='matriz') { |
---|
673 | url_grafico = URL_GRAFICAR_MATRIZ; |
---|
674 | $("#panel-title-fuentes-diversas").html("Matriz Insumo / Producto"); |
---|
675 | $("#niveles-arriba-grafico").html("2"); |
---|
676 | $("#niveles-abajo-grafico").html("2"); |
---|
677 | $.getJSON(URL_DATOS_PRODUCCION_MATRIZ, {id_prod: id_prod, rif: rif}, function(datos) { |
---|
678 | if (datos.resultado) { |
---|
679 | $("#matrizip-actividad-economica").html(datos.ae_ciiu.codigo+" - "+datos.ae_ciiu.descripcion); |
---|
680 | var produccion = [], utilizacion = [], importacion = []; |
---|
681 | for (i=0;i<datos.produccion.length; i++) { |
---|
682 | produccion.push( |
---|
683 | [ |
---|
684 | datos.produccion[i].codigo_producto, |
---|
685 | datos.produccion[i].descripcion, |
---|
686 | datos.produccion[i].total_produccion, |
---|
687 | datos.produccion[i].porcentaje+" %" |
---|
688 | ] |
---|
689 | ); |
---|
690 | } |
---|
691 | for (i=0;i<datos.utilizacion.length; i++) { |
---|
692 | utilizacion.push( |
---|
693 | [ |
---|
694 | datos.utilizacion[i].codigo_producto, |
---|
695 | datos.utilizacion[i].descripcion, |
---|
696 | datos.utilizacion[i].total_utilizacion, |
---|
697 | datos.utilizacion[i].porcentaje+" %" |
---|
698 | ] |
---|
699 | ); |
---|
700 | } |
---|
701 | for (i=0;i<datos.importacion.length; i++) { |
---|
702 | importacion.push( |
---|
703 | [ |
---|
704 | datos.importacion[i].codigo_producto, |
---|
705 | datos.importacion[i].descripcion, |
---|
706 | datos.importacion[i].total_importacion, |
---|
707 | datos.importacion[i].porcentaje+" %" |
---|
708 | ] |
---|
709 | ); |
---|
710 | } |
---|
711 | $('#table-matrizip-produccion').dataTable( { |
---|
712 | "bDestroy": true, |
---|
713 | "language": { |
---|
714 | "url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json" |
---|
715 | }, |
---|
716 | "bAutoWidth": false, |
---|
717 | "data": produccion, |
---|
718 | "aoColumns": [ |
---|
719 | { "sClass": "text-left", "sWidth": "20%" }, |
---|
720 | { "sClass": "text-left", "sWidth": "40%" }, |
---|
721 | { "sClass": "text-right", "sWidth": "20%" }, |
---|
722 | { "sClass": "text-right", "sWidth": "20%" } |
---|
723 | ] |
---|
724 | } ); |
---|
725 | |
---|
726 | $("#total-matrizip-produccion").html(datos.produccion_total); |
---|
727 | $('#table-matrizip-utilizacion').dataTable( { |
---|
728 | "bDestroy": true, |
---|
729 | "language": { |
---|
730 | "url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json" |
---|
731 | }, |
---|
732 | "bAutoWidth": false, |
---|
733 | "data": utilizacion, |
---|
734 | "aoColumns": [ |
---|
735 | { "sClass": "text-left", "sWidth": "20%" }, |
---|
736 | { "sClass": "text-left", "sWidth": "40%" }, |
---|
737 | { "sClass": "text-right", "sWidth": "20%" }, |
---|
738 | { "sClass": "text-right", "sWidth": "20%" } |
---|
739 | ] |
---|
740 | } ); |
---|
741 | $("#total-matrizip-utilizacion").html(datos.utilizacion_total); |
---|
742 | $('#table-matrizip-importacion').dataTable( { |
---|
743 | "bDestroy": true, |
---|
744 | "language": { |
---|
745 | "url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json" |
---|
746 | }, |
---|
747 | "bAutoWidth": false, |
---|
748 | "data": importacion, |
---|
749 | "aoColumns": [ |
---|
750 | { "sClass": "text-left", "sWidth": "20%" }, |
---|
751 | { "sClass": "text-left", "sWidth": "40%" }, |
---|
752 | { "sClass": "text-right", "sWidth": "20%" }, |
---|
753 | { "sClass": "text-right", "sWidth": "20%" } |
---|
754 | ] |
---|
755 | } ); |
---|
756 | $("#total-matrizip-importacion").html(datos.importacion_total); |
---|
757 | |
---|
758 | } |
---|
759 | else { |
---|
760 | bootbox.alert(datos.error); |
---|
761 | return false; |
---|
762 | } |
---|
763 | }).fail(function(jqxhr, textStatus, error) { |
---|
764 | var err = textStatus + ", " + error; |
---|
765 | bootbox.alert(ERROR_AJAX_REQUEST + err); |
---|
766 | return false; |
---|
767 | }); |
---|
768 | $("#panel-matrizip").show(); |
---|
769 | } |
---|
770 | else if (fuente=='composicion_accionaria') { |
---|
771 | $("#panel-title-fuentes-diversas").html("Composicion Accionaria"); |
---|
772 | $("#niveles-arriba-grafico").parent().hide(); |
---|
773 | $("#panel-matrizip").hide(); |
---|
774 | $.getJSON(URL_COMPOSICION_ACCIONARIA, {rif: rif}, function(datos) { |
---|
775 | if (datos.resultado) { |
---|
776 | var factores_hegemonicos = [], empresas_asociadas = []; |
---|
777 | for (i=0; i<datos.lista_socios.length; i++) { |
---|
778 | factores_hegemonicos.push( |
---|
779 | [ |
---|
780 | datos.lista_socios[i].rif_pasaporte, |
---|
781 | datos.lista_socios[i].nombre, |
---|
782 | datos.lista_socios[i].acciones+" %", |
---|
783 | datos.lista_socios[i].rif_empresa, |
---|
784 | datos.lista_socios[i].nombre_empresa/*, |
---|
785 | datos.lista_socios[i].nivel*/ |
---|
786 | ] |
---|
787 | ); |
---|
788 | } |
---|
789 | for (i=0; i<datos.lista_empresas_asociadas.length; i++) { |
---|
790 | empresas_asociadas.push( |
---|
791 | [ |
---|
792 | datos.lista_empresas_asociadas[i].rif_pasaporte, |
---|
793 | datos.lista_empresas_asociadas[i].nombre, |
---|
794 | datos.lista_empresas_asociadas[i].rif_empresa, |
---|
795 | datos.lista_empresas_asociadas[i].nombre_empresa |
---|
796 | ] |
---|
797 | ); |
---|
798 | } |
---|
799 | |
---|
800 | $('#table-factores-hegemonicos').dataTable( { |
---|
801 | "bDestroy": true, |
---|
802 | "language": { |
---|
803 | "url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json" |
---|
804 | }, |
---|
805 | "bAutoWidth": false, |
---|
806 | "data": factores_hegemonicos, |
---|
807 | "aoColumns": [ |
---|
808 | { "sClass": "text-left", "sWidth": "20%" }, |
---|
809 | { "sClass": "text-left", "sWidth": "20%" }, |
---|
810 | { "sClass": "text-right", "sWidth": "20%" }, |
---|
811 | { "sClass": "text-right", "sWidth": "20%" }, |
---|
812 | { "sClass": "text-right", "sWidth": "20%" } |
---|
813 | ] |
---|
814 | } ); |
---|
815 | |
---|
816 | $('#table-empresas-asociadas').dataTable( { |
---|
817 | "bDestroy": true, |
---|
818 | "language": { |
---|
819 | "url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json" |
---|
820 | }, |
---|
821 | "bAutoWidth": false, |
---|
822 | "data": empresas_asociadas, |
---|
823 | "aoColumns": [ |
---|
824 | { "sClass": "text-left", "sWidth": "20%" }, |
---|
825 | { "sClass": "text-left", "sWidth": "20%" }, |
---|
826 | { "sClass": "text-right", "sWidth": "20%" }, |
---|
827 | { "sClass": "text-right", "sWidth": "40%" } |
---|
828 | ] |
---|
829 | } ); |
---|
830 | } |
---|
831 | else { |
---|
832 | bootbox.alert(datos.error); |
---|
833 | return false; |
---|
834 | } |
---|
835 | }).fail(function(jqxhr, textStatus, error) { |
---|
836 | var err = textStatus + ", " + error; |
---|
837 | bootbox.alert(ERROR_AJAX_REQUEST + err); |
---|
838 | return false; |
---|
839 | }); |
---|
840 | $("#panel-composicion-accionaria").show(); |
---|
841 | } |
---|
842 | |
---|
843 | if (url_grafico!="") { |
---|
844 | $( "#grafico" ).load( url_grafico +"?rif="+rif+"&id_prod="+id_prod+"&ahora="+time ); |
---|
845 | } |
---|
846 | |
---|
847 | } else { |
---|
848 | $('#panel-al-pie').hide('slow'); |
---|
849 | $('#panel-al-pie').attr('style','display:none'); |
---|
850 | } |
---|
851 | |
---|
852 | } |
---|