/** * Sistema Integral de Planificación y Presupuesto (SIPP) * @file proyectos_operativos_generales.js * Drupal part Module to Sistema Integral de Planificación y Presupuesto (SIPP) * Copyright 2011 Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana (CENDITEL) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * @author Cenditel Merida - Msc. Juan Vizcarrondo * @date 2012-02-02 // (año-mes-dia) * @version 0.1 // (0.1) */ /* * Implementacion valores iniciales */ Drupal.behaviors.proyectosOperativosGenerales = function (context) { $(".number").each(function() { $(this).val($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.')); }); for(var i in Drupal.settings.beneficiarios){ sumabeneficiario(Drupal.settings.beneficiarios[i]); } $(".number").each(function() { $(this).val($.number($(this).val(), Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep)); }); $(".number").keyup(function(evt) { $(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)); }); $("#proyectos-operativos-proyecto-generales-form").submit(function( event ) { $(".number").each(function() { $(this).val($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.')); }); return ; }); } /* * Implementacion of sumabeneficiario */ function sumabeneficiario(clase) { var sum = 0; var i = 0; var valor = 0; $('.' + clase).each(function() { valor = parseFloat($(this).val().replace(/[Drupal.settings.format_number.thousands_sep\s]/g, '').replace(/[Drupal.settings.format_number.dec_point\s]/g, '.')); if (valor < 0 || isNaN(valor) || !isFinite(valor)) { $(this).val(0); valor = 0; } sum += valor; }); $('.' + clase + '_total').text($.number(sum, Drupal.settings.format_number.decimals, Drupal.settings.format_number.dec_point, Drupal.settings.format_number.thousands_sep)); }