source: sipes/0.3-modules/proyectos_operativos/js/proyectos_operativos1.js @ d753a68

stableversion-3.0
Last change on this file since d753a68 was d753a68, checked in by lhernandez <lhernandez@…>, 8 años ago

se corrigio la restuctura referente a las fechas permitidas

  • Propiedad mode establecida a 100755
File size: 4.3 KB
Línea 
1 /**
2  * Sistema Integral de Planificación y Presupuesto (SIPP)
3  * @file proyectos_proyectos_operativos1.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 - Msc. Juan Vizcarrondo
22  * @date 2015-02-06 // (a&#241;o-mes-dia)
23  * @version 0.2 // (0.1)
24  */
25
26/*
27 * Implementacion valores iniciales
28 */
29var proyectosOperativos = {};
30Drupal.behaviors.proyectosOperativos = function (context) {
31  var n = Drupal.settings.proyectos_operativos.fecha[0];
32  var personas = Drupal.settings.proyectos_operativos.unidadmpers;
33  var valorundm = $('#edit-field-proyecto-unidadm-value').val();
34  if (typeof personas[valorundm] == "undefined") {
35    $('#meta-unidm-pers').hide();
36  }
37  var year_current = parseInt(Drupal.settings.proyectos_operativos.fecha[2]['year'], 10);
38  var year_prev = parseInt(Drupal.settings.proyectos_operativos.fecha[0]['year'], 10);
39  var month = parseInt(n, 10);
40  if (year_current == year_prev && month > 0) {
41    for (var i = 0; i < month;i++) {
42      $(".field_proyecto_meta_fisica_m" + i + "_field").attr('readonly', true);
43    }
44  }
45  n = Drupal.settings.proyectos_operativos.fecha[1]['month'];
46  var year_next = parseInt(Drupal.settings.proyectos_operativos.fecha[1]['year'], 10);
47  month = parseInt(n, 10);
48  if (year_current == year_next && month < 11) {
49    for (var i = month + 1; i < 12; i++) {
50      $(".field_proyecto_meta_fisica_m" + i + "_field").attr('readonly', true);
51    }
52  }
53  $("#edit-field-proyecto-unidadm-value").change(function() {
54    valorundm = $(this).val();
55    if (typeof personas[valorundm] == "undefined") {
56      $("#edit-field-proyecto-meta-m-0-value").val(0);
57      $("#edit-field-proyecto-meta-f-0-value").val(0);
58      $('#meta-unidm-pers').hide();
59    }
60    else {
61      $('#meta-unidm-pers').show();
62    }
63  });
64  $(".number").each(function() {
65    $(this).val($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
66  });
67  $(".number").each(function() {
68    $(this).val($.number($(this).val(), Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
69  });
70  $(".number").keyup(function(evt) {
71    $(this).val($.number($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'), Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
72  });
73  $("#proyectos-operativos-proyecto-indicadores-form").submit(function( event ) {
74    $(".number").each(function() {
75      $(this).val($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
76    });
77    return ;
78  });
79}
80
81/*
82 * Implementacion of sumunidpersonas
83 */
84function sumunidpersonas(clase) {
85  var sum = 0;
86  var i = 0;
87  var valor = 0;
88  $('.' + clase).each(function() {
89    valor = parseFloat($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
90    if (valor < 0 || isNaN(valor) || !isFinite(valor)) {
91      $(this).val(0);
92      valor = 0;
93    }
94    sum += valor;
95  });
96  $('.' + clase + '_total').text($.number(sum, Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
97}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.