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

stableversion-3.0
Last change on this file since 92f109b was 303fae2, checked in by José Gregorio Puentes <jpuentes@…>, 9 años ago

se agregaron los modulos

  • Propiedad mode establecida a 100755
File size: 3.2 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 * Suma los valores por defecto
28 */
29Drupal.behaviors.proyectosOperativosGeneralesMcti = function (context) {
30  for(var i in Drupal.settings.empleos){
31    sumaempleos(Drupal.settings.empleos[i]);
32  }
33  //mostrando los campos si estan seleccionados por defecto
34  $('.field_tipo_factores').each(function() {
35    if(($.trim($(this).val()) != 8)) {
36      ocultarCampo('field_tipo_factores', 'field_factor_impact_multifc');
37    }
38  });
39  $('.field_factor_segun_origen').each(function() {
40    if(($.trim($(this).val()) != 4)) {
41      ocultarCampo('field_factor_segun_origen', 'field_factor_impact_multiog');
42    }
43  });
44  /*limpiar los campos
45  $('#default_registrador_select select', context).change(function() {
46       
47        if($(this).val() == 0) {
48          $('#responsables_registrador input').each(function() {
49        $(this).val('');
50      });
51    }
52  });*/
53}
54
55
56/*
57 * Implementacion of sumaempleos
58 */
59function sumaempleos(clase) {
60  var claseDiv = '';
61  if (clase == "empleos_estimadosD" || clase == "empleos_estimadosI") {
62    claseDiv = '_totales';
63  }
64  if (clase == "empleos_estimadosDf") {
65    claseDiv = '_totalesDf';
66  }
67  if (clase == "empleos_estimadosDm") {
68    claseDiv = '_totalesDm';
69  }
70  var sum = 0;
71  var i = 0;
72  var valor = 0;
73  $('.' + clase).each(function() {
74    valor = parseFloat($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
75    if (valor < 0 || isNaN(valor) || !isFinite(valor)) {
76      $(this).val(0);
77      valor = 0;
78    }
79    sum += valor;
80  });
81  $('.' + clase + claseDiv).text($.number(sum, Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
82}
83
84/**
85 * Muestra o oculta un campo
86 */
87function ocultarCampo(campo1, campo2) {
88  $('.' + campo1).each(function() {
89    if((($.trim($(this).val()) != 8) && (campo1 == 'field_tipo_factores')) || (($.trim($(this).val()) != 4) && (campo1 == 'field_factor_segun_origen'))) {
90      $('.' + campo2).hide();
91    }
92    else {
93      $('.' + campo2).show();
94    }
95  });
96}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.