source: sipp/0.3-stable-modules/proyectos_operativos/js/proyectos_operativos_generales.js @ a0b4327

0.3-stable
Last change on this file since a0b4327 was a0b4327, checked in by José Gregorio Puentes <jpuentes@…>, 9 años ago

Se agregaron los nuevos cambios a los modulos

  • Propiedad mode establecida a 100755
File size: 3.0 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 - Msc. Juan Vizcarrondo
22  * @date 2012-02-02 // (a&#241;o-mes-dia)
23  * @version 0.1 // (0.1)
24  */
25
26/*
27 * Implementacion valores iniciales
28 */
29Drupal.behaviors.proyectosOperativosGenerales = function (context) {
30  $(".number").each(function() {
31    $(this).val($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
32  });
33  for(var i in Drupal.settings.beneficiarios){
34    sumabeneficiario(Drupal.settings.beneficiarios[i]);
35  }
36  $(".number").each(function() {
37    $(this).val($.number($(this).val(), Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
38  });
39  $(".number").keyup(function(evt) {
40    $(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));
41  });
42  $("#proyectos-operativos-proyecto-generales-form").submit(function( event ) {
43    $(".number").each(function() {
44      $(this).val($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
45    });
46    return ;
47  });
48}
49
50/*
51 * Implementacion of sumabeneficiario
52 */
53function sumabeneficiario(clase) {
54  var sum = 0;
55  var i = 0;
56  var valor = 0;
57  $('.' + clase).each(function() {
58    valor = parseFloat($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
59    if (valor < 0 || isNaN(valor) || !isFinite(valor)) {
60      $(this).val(0);
61      valor = 0;
62    }
63    sum += valor;
64  });
65  $('.' + clase + '_total').text($.number(sum, Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
66}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.