source: sipes/0.3-modules/proyectos_operativos_mcti/js/proyectos_operativos_mcti_datos_basicos.js @ 92f109b

stableversion-3.0
Last change on this file since 92f109b was a20fcb5, checked in by eramirez <eramirez@…>, 8 años ago

se modificaron los responsables del proyecto

  • Propiedad mode establecida a 100755
File size: 6.4 KB
Línea 
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&#241;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 */
29Drupal.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).val('');
35    });
36    $('#default_tecnico input:text').each(function(index) {
37      $(this).val('');
38    });
39    $('#default_registrador input:text').each(function(index) {
40      $(this).val('');
41    });
42    $('#default_administrativo input:text').each(function(index) {
43      $(this).val('');
44    });
45  });
46
47  $('#wrapper-proyectos-resposab select[name=default_gerente]').change(function() {
48    if ($(this).val() != 0 && $(this).val() != 1) {
49      cambiar_estado_responsables('gerente', this);
50    }
51    else {
52      $('.form-text.gerente').val('');
53    }
54  });
55  $('#wrapper-proyectos-resposab select[name=default_tecnico]').change(function() {
56    if ($(this).val() != 0 && $(this).val() != 1) {
57      cambiar_estado_responsables('tecnico', this);
58    }
59    else {
60      $('.form-text.tecnico').val('');
61    }
62  });
63  $('#wrapper-proyectos-resposab select[name=default_registrador]').change(function() {
64    if ($(this).val() != 0 && $(this).val() != 1) {
65     cambiar_estado_responsables('registrador', this);
66    }
67    else {
68      $('.form-text.registrador').val('');
69    }
70  });
71  $('#wrapper-proyectos-resposab select[name=default_administrativo]').change(function() {
72    if ($(this).val() != 0 && $(this).val() != 1) {
73      cambiar_estado_responsables('administrativo', this);
74    }
75    else {
76      $('.form-text.administrativo').val('');
77    }
78  }); 
79
80  //ocultando el campo comentario de no ser seleccionado
81  $("#workflow-tab-form input[type='radio']").each(function() { 
82        if (this.checked == true) {
83        var label = this.id;
84        var text = $('label[for="'+label+'"]').text();
85        if (text == ' Anulado') {
86                $("#edit-workflow-comment-wrapper").show();
87                        }
88        /*else {
89        $("#edit-workflow-comment-wrapper").hide();
90                  }*/
91                }
92        });
93  $("#workflow-tab-form input[type='radio']").change(function() {
94    var label = this.id;
95    var text = $('label[for="'+label+'"]').text();
96    if (text == ' Anulado') {
97        $("#edit-workflow-comment-wrapper").show();
98                }
99    /*else {
100      $("#edit-workflow-comment-wrapper").hide();
101                }*/
102        });
103
104}
105
106/**
107 * Modifica el estado de los responsables del proyecto
108 */
109function cambiar_estado_responsables(responsable, referencia) {
110  var ultimo = 0;
111  var opciones = 0;
112  $('#wrapper-proyectos-resposab select[name=default_' + responsable + '] option').each(function(index) {
113    ultimo = $(this).val();
114  });
115  //estructura del array_proyecto => nid del proyecto, ente o institucion, nombre, cedula, correo, telefono
116  if (responsable == 'gerente') {
117    for (values in Drupal.settings.responsables.gerente) {
118     if (values == $(referencia).val()) {
119       $('[name=field_proyecto_nombre_gere]').val(Drupal.settings.responsables.gerente[values].name[0]);
120       $('[name=field_proyecto_cedul_gere]').val(Drupal.settings.responsables.gerente[values].cedula[0]);
121       $('[name=field_proyecto_corre_gere]').val(Drupal.settings.responsables.gerente[values].email[0]);
122       $('[name=field_proyecto_telef_gere]').val(Drupal.settings.responsables.gerente[values].phone[0]);
123      }
124    }
125  }
126  if (responsable == 'tecnico') {
127    for (values in Drupal.settings.responsables.tecnico) {
128     if (values == $(referencia).val()) {
129       $('[name=field_proyecto_nom_r_tec]').val(Drupal.settings.responsables.tecnico[values].name[0]);
130       $('[name=field_proyecto_ced_r_tec]').val(Drupal.settings.responsables.tecnico[values].cedula[0]);
131       $('[name=field_proyecto_cor_r_tec]').val(Drupal.settings.responsables.tecnico[values].email[0]);
132       $('[name=field_proyecto_tel_r_tec]').val(Drupal.settings.responsables.tecnico[values].phone[0]);
133       $('[name=field_proyecto_und_r_tec]').attr('value', Drupal.settings.responsables.tecnico[values].unidad[0]);
134      }
135    }
136  }
137  if (responsable == 'registrador') {
138    for (values in Drupal.settings.responsables.registrador) {
139     if (values == $(referencia).val()) {
140       $('[name=field_proyecto_nom_r_reg]').val(Drupal.settings.responsables.registrador[values].name[0]);
141       $('[name=field_proyecto_ced_r_reg]').val(Drupal.settings.responsables.registrador[values].cedula[0]);
142       $('[name=field_proyecto_cor_r_reg]').val(Drupal.settings.responsables.registrador[values].email[0]);
143       $('[name=field_proyecto_tel_r_reg]').val(Drupal.settings.responsables.registrador[values].phone[0]);
144      }
145    }
146  }
147  if (responsable == 'administrativo') {
148    for (values in Drupal.settings.responsables.administrativo) {
149     if (values == $(referencia).val()) {
150       $('[name=field_proyecto_nom_r_adm]').val(Drupal.settings.responsables.administrativo[values].name[0]);
151       $('[name=field_proyecto_ced_r_adm]').val(Drupal.settings.responsables.administrativo[values].cedula[0]);
152       $('[name=field_proyecto_cor_r_adm]').val(Drupal.settings.responsables.administrativo[values].email[0]);
153       $('[name=field_proyecto_tel_r_adm]').val(Drupal.settings.responsables.administrativo[values].phone[0]);
154      }
155    }
156  }
157  var status_institu = $('#field_proyecto_ente_datos_basicos select').val();
158}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.