source: sipes/0.3-modules/proyectos_reformulacion/js/proyectos_reformulacion.js @ 2fa3319

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

se agregaron los modulos

  • Propiedad mode establecida a 100755
File size: 6.7 KB
Línea 
1  /**
2  * Sistema Integral de Planificación y Presupuesto (SIPP)
3  * @file proyectos_reformulacion.js
4  * Drupal part Module to Sistema Integral de Planificación y Presupuesto (SIPP)
5  * Copyright 2013 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 2013-04-11 // (a&#241;o-mes-dia)
23  * @version 0.1 // (0.1)
24  *
25  */
26
27/*
28 * Agregar los cambios iniciales
29 */
30Drupal.behaviors.proyectosReformulacion = function (context) {
31  $('.' + 'campo-bloqueado').attr('readonly', true);
32  $(".number").each(function() {
33    var valores = $(this).attr('valor');
34    var indice = $(this).attr('indice');
35    var taxonomia = $(this).attr('taxonomia');
36    var nodo = $(this).attr('nodo');
37    var total_partida = $(this).attr('total_partida');
38    if (typeof valores !== 'undefined' && valores !== false && typeof indice !== 'undefined' && indice !== false && typeof taxonomia !== 'undefined' && taxonomia !== false && typeof nodo !== 'undefined' && nodo !== false && typeof total_partida !== 'undefined' && total_partida !== false) {
39      if (indice == 0) {
40        sumatotalAE(nodo + '-field-accion-esp-programacion-' +  taxonomia + '-value',valores);
41      }
42      else {
43        sumatotalAE(nodo + '-field-accion-esp-programacion-' +  taxonomia + '-value-' + indice,valores);
44      }
45      sumatotalAE(nodo + '-field-accion-esp-programacion-' + taxonomia + '-t',total_partida);
46    }
47    var valor = $(this).val();
48    valor.replace(/[+\s]/g, '');
49    valor.replace(/^[0]+/g,"");
50    var sign = '';
51    if (valor > 0) {
52      sign = '+';
53    }
54    $(this).val(sign + $.number(valor, Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
55  });
56  $(".number1").each(function() {
57    var valor = $(this).val();
58    valor.replace(/[+\s]/g, '');
59    valor.replace(/^[0]+/g,"");
60    $(this).val($.number(valor, Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
61  });
62  $(".number").keyup(function(evt) {
63    var signo = '';
64    var valor = $(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.');
65    if (valor > 0) {
66      signo = '+';
67      valor.replace(/[+\s]/g, '');
68    }
69    if (valor != '-' || valor != '+') {
70      if (valor == '0-') {
71        $(this).val('-');
72      }
73      else if(valor == '0+') {
74        $(this).val('+');
75      } 
76      else {
77        valor.replace(/^[0]+/g,"");
78        $(this).val(signo + $.number(valor, Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
79      }
80    }
81  });
82  $("#proyectos-reformulacion-reformula-tab-page-form, #proyectos-reformulacion-reformula-tab-page-ae-form").submit(function( event ) {
83    $(".number").each(function() {
84      $(this).val($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
85    });
86    return ;
87  });
88  var financiera = Drupal.settings.proyectos_reformulacion['mfisicas']['financia'];
89  if (typeof(financiera) != "undefined" && financiera !== null) {
90    $.each( financiera, function( key, value ) {
91      prsumaref2('subtotalff-' + key, 'financia', key);
92    });
93  }
94}
95
96
97
98/*
99 * Implementation of valpositivo()
100 */
101function valpositivo(elemento){
102  var valor = parseFloat($('#edit-' + elemento).val());
103  if (valor <= 0) {
104    $('#edit-' + elemento).val(0);
105  }
106}
107
108/*
109 * Implementation of sumaref()
110 */
111function prsumaref(clase) {
112  var sum = 0;
113  var i = 0;
114  var valor = 0;
115  $('.' + clase).each(function() {
116    valor = parseFloat($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
117    if (isNaN(valor) || !isFinite(valor)) {
118      $(this).val(0);
119      valor = 0;
120    }
121    sum += valor;
122  });
123  $('.' + clase + '-total').val($.number(sum, Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
124}
125
126/*
127 * Implementation of sumaref()
128 */
129function prsumaref2(clase, elemento, elemento1) {
130  var sum = 0;
131  var i = 0;
132  var valor = 0;
133  $('.' + clase).each(function() {
134    valor = parseFloat($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
135    if (isNaN(valor) || !isFinite(valor)) {
136      $(this).val(0);
137      valor = 0;
138    }
139    sum += valor;
140  });
141  sum += parseFloat(Drupal.settings.proyectos_reformulacion['mfisicas'][elemento][elemento1]);
142  $('.' + clase + '-total').val($.number(sum, Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
143}
144
145/*
146 * Implementation of valminimo()
147 */
148function prvalminimo(elemento, minimo){
149  var valor = parseFloat($('#edit-' + elemento).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
150  if (isNaN(valor) || !isFinite(valor)) {
151    $('#edit-' + elemento).val(0);
152    return;
153  }
154  minimo = parseFloat(minimo);
155  if (minimo + valor < 0) {
156    alert('El monto minimo a introducir debe ser de -' + minimo)
157    $('#edit-' + elemento).val(0);
158  }
159}
160
161/*
162 * Implementation of sumatotalAE()
163 */
164function sumatotalAE(identificador, inicio) {
165  var sum = 0;
166  var valor = 0;
167  valor = parseFloat($('#edit-' + identificador).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.'));
168  inicio = parseFloat(inicio);
169  if (isNaN(valor) || !isFinite(valor)) {
170    $('#edit-' + identificador).val(0);
171    valor = 0;
172  }
173  sum = valor + inicio;
174  $('#' + identificador + '-texto').text($.number(sum, Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep));
175}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.