source: sipp/0.3-stable-modules/proyectos_operativos/js/accion_especifica.js @ 4b7848a

0.3-stable
Last change on this file since 4b7848a 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: 4.3 KB
Línea 
1 /**
2  * Sistema Integral de Planificación y Presupuesto (SIPP)
3  * @file proyectos_operativos2.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 * Implementation of sumatexto()
28 */
29function sumatexto(clase) {
30  var sum = 0;
31  var i = 0;
32  var valor = 0;
33  $('.' + clase).each(function() {
34    valor = parseFloat($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
35    if (isNaN(valor) || !isFinite(valor)) {
36      $(this).val(0);
37      valor = 0;
38    }
39    sum += valor;
40  });
41  if (sum == 0){sum = '0';}
42  $('.' + clase + '_total').html($.number(sum, Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
43}
44
45/*
46 * Implementacion valores iniciales
47 */
48var accionEspecifica = {};
49Drupal.behaviors.accionEspecifica = function (context) {
50  //myplanner
51  $(".totales-financieros").attr('readonly', true);
52  for(var i = 0; i < 12; i++) {
53    sumatexto("field_accion_esp_programacion_m" + i + "_field");
54  }
55  sumatexto("field_accion_esp_programacion_dato_field");
56    $(".number").each(function() {
57      $(this).val($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
58    });
59  $(".number, .totales, .totales-financieros, .subtotales").each(function() {
60    $(this).val($.number($(this).val(), 0, ',', '.'));
61  });
62  $(".number").keyup(function(evt) {
63    $(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));
64  });
65  $("#proyectos-operativos-accion-especifica-crear-form").submit(function( event ) {
66    $(".number").each(function() {
67      $(this).val($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
68    });
69    return ;
70  });
71}
72
73/*
74 * Implementation of sumarff()
75 */
76function sumarff(clase) {
77  var sum = 0;
78  var i = 0;
79  var valor = 0;
80  $('.total-' + clase).each(function() {
81    valor = parseFloat($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
82    if (isNaN(valor) || !isFinite(valor)) {
83      $(this).val(0);
84      valor = 0;
85    }
86    sum += valor;
87  });
88  $('#edit-total-' + clase).val($.number(sum, Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
89}
90
91/*
92 * Implementation of sumarff1()
93 */
94function sumarff1(clase) {
95  var sum = 0;
96  var i = 0;
97  var valor = 0;
98  $('.' + clase).each(function() {
99    valor = parseFloat($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
100    if (isNaN(valor) || !isFinite(valor)) {
101      alert('Debe introducir solo números');
102      $(this).val(0);
103      valor = 0;
104    }
105    sum += valor;
106  });
107  $('#edit-total-financiamiento').val($.number(sum, Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
108}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.