1 | /** |
---|
2 | * Sistema Integral de Planificación y Presupuesto (SIPP) |
---|
3 | * @file proyectos_operativos_generales.js |
---|
4 | * Drupal part Module to Sistema Integral de Planificación y Presupuesto (SIPP) |
---|
5 | * Copyright 2011 Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana (CENDITEL) |
---|
6 | * |
---|
7 | * This program is free software; you can redistribute it and/or modify |
---|
8 | * it under the terms of the GNU General Public License as published by |
---|
9 | * the Free Software Foundation; either version 2 of the License, or |
---|
10 | * (at your option) any later version. |
---|
11 | * |
---|
12 | * This program is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | * GNU General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU General Public License |
---|
18 | * along with this program; if not, write to the Free Software |
---|
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
20 | * |
---|
21 | * @author Cenditel Merida - Ing. José Puentes |
---|
22 | * @date 2012-02-02 // (año-mes-dia) |
---|
23 | * @version 0.1 // (0.1) |
---|
24 | */ |
---|
25 | |
---|
26 | /** |
---|
27 | * Modifica los valores de la lista select para los responsables del proyecto |
---|
28 | */ |
---|
29 | Drupal.behaviors.proyectosOperativosDatosBasicosMcti = function (context) { |
---|
30 | $('#field_proyecto_ente_datos_basicos').hide(); |
---|
31 | //cambio de institucion |
---|
32 | $('#field_proyecto_ente_datos_basicos select').change(function() { |
---|
33 | $('#default_gerente input:text').each(function(index) { |
---|
34 | $(this).attr('value', ''); |
---|
35 | }); |
---|
36 | $('#default_tecnico input:text').each(function(index) { |
---|
37 | $(this).attr('value', ''); |
---|
38 | }); |
---|
39 | $('#default_registrador input:text').each(function(index) { |
---|
40 | $(this).attr('value', ''); |
---|
41 | }); |
---|
42 | $('#default_administrativo input:text').each(function(index) { |
---|
43 | $(this).attr('value', ''); |
---|
44 | }); |
---|
45 | }); |
---|
46 | |
---|
47 | $('#wrapper-proyectos-resposab select[name=default_gerente]').change(function() { |
---|
48 | cambiar_estado_responsables('gerente', this); |
---|
49 | }); |
---|
50 | $('#wrapper-proyectos-resposab select[name=default_tecnico]').change(function() { |
---|
51 | cambiar_estado_responsables('tecnico', this); |
---|
52 | }); |
---|
53 | $('#wrapper-proyectos-resposab select[name=default_registrador]').change(function() { |
---|
54 | cambiar_estado_responsables('registrador', this); |
---|
55 | }); |
---|
56 | $('#wrapper-proyectos-resposab select[name=default_administrativo]').change(function() { |
---|
57 | cambiar_estado_responsables('administrativo', this); |
---|
58 | }); |
---|
59 | |
---|
60 | //ocultando el campo comentario de no ser seleccionado |
---|
61 | $("#workflow-tab-form input[type='radio']").each(function() { |
---|
62 | if (this.checked == true) { |
---|
63 | var label = this.id; |
---|
64 | var text = $('label[for="'+label+'"]').text(); |
---|
65 | if (text == ' Anulado') { |
---|
66 | $("#edit-workflow-comment-wrapper").show(); |
---|
67 | } |
---|
68 | /*else { |
---|
69 | $("#edit-workflow-comment-wrapper").hide(); |
---|
70 | }*/ |
---|
71 | } |
---|
72 | }); |
---|
73 | $("#workflow-tab-form input[type='radio']").change(function() { |
---|
74 | var label = this.id; |
---|
75 | var text = $('label[for="'+label+'"]').text(); |
---|
76 | if (text == ' Anulado') { |
---|
77 | $("#edit-workflow-comment-wrapper").show(); |
---|
78 | } |
---|
79 | /*else { |
---|
80 | $("#edit-workflow-comment-wrapper").hide(); |
---|
81 | }*/ |
---|
82 | }); |
---|
83 | |
---|
84 | } |
---|
85 | |
---|
86 | /** |
---|
87 | * Modifica el estado de los responsables del proyecto |
---|
88 | */ |
---|
89 | function cambiar_estado_responsables(responsable, referencia) { |
---|
90 | var ultimo = 0; |
---|
91 | var opciones = 0; |
---|
92 | $('#wrapper-proyectos-resposab select[name=default_' + responsable + '] option').each(function(index) { |
---|
93 | ultimo = $(this).val(); |
---|
94 | }); |
---|
95 | //estructura del array_proyecto => nid del proyecto, ente o institucion, nombre, cedula, correo, telefono |
---|
96 | if (responsable == 'gerente') { |
---|
97 | opciones = JSON.parse(Drupal.settings.gerente); |
---|
98 | } |
---|
99 | if (responsable == 'tecnico') { |
---|
100 | opciones = JSON.parse(Drupal.settings.tecnico); |
---|
101 | } |
---|
102 | if (responsable == 'registrador') { |
---|
103 | opciones = JSON.parse(Drupal.settings.registrador); |
---|
104 | } |
---|
105 | if (responsable == 'administrativo') { |
---|
106 | opciones = JSON.parse(Drupal.settings.administrativo); |
---|
107 | } |
---|
108 | var status_institu = $('#field_proyecto_ente_datos_basicos select').val(); |
---|
109 | for (var j in opciones) { |
---|
110 | if (status_institu == opciones[j][1]) { |
---|
111 | if ($(referencia).val() == opciones[j][0]) { |
---|
112 | $('#default_' + responsable + ' input:text').each(function(index) { |
---|
113 | $(this).attr('value', opciones[j][index+2]); |
---|
114 | }); |
---|
115 | } |
---|
116 | } |
---|
117 | if ($(referencia).val() == 0 || $(referencia).val() == ultimo) { |
---|
118 | $('#default_' + responsable + ' input:text').each(function(index) { |
---|
119 | $(this).attr('value', ''); |
---|
120 | }); |
---|
121 | } |
---|
122 | } |
---|
123 | } |
---|