/** * Sistema Integral de Planificación y Presupuesto (SIPP) * @file proyectos_proyectos_operativos1.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 2015-02-06 // (año-mes-dia) * @version 0.2 // (0.1) */ /* * Implementacion valores iniciales */ var proyectosOperativos = {}; Drupal.behaviors.proyectosOperativos = function (context) { var n = Drupal.settings.proyectos_operativos.fecha[0]; var personas = Drupal.settings.proyectos_operativos.unidadmpers; var valorundm = $('#edit-field-proyecto-unidadm-value').val(); if (typeof personas[valorundm] == "undefined") { $('#meta-unidm-pers').hide(); } var year_current = parseInt(Drupal.settings.proyectos_operativos.fecha[2]['year'], 10); var year_prev = parseInt(Drupal.settings.proyectos_operativos.fecha[0]['year'], 10); var month = parseInt(n, 10); if (year_current == year_prev && month > 0) { for (var i = 0; i < month;i++) { $(".field_proyecto_meta_fisica_m" + i + "_field").attr('readonly', true); } } n = Drupal.settings.proyectos_operativos.fecha[1]['month']; var year_next = parseInt(Drupal.settings.proyectos_operativos.fecha[1]['year'], 10); month = parseInt(n, 10); if (year_current == year_next && month < 11) { for (var i = month + 1; i < 12; i++) { $(".field_proyecto_meta_fisica_m" + i + "_field").attr('readonly', true); } } $("#edit-field-proyecto-unidadm-value").change(function() { valorundm = $(this).val(); if (typeof personas[valorundm] == "undefined") { $("#edit-field-proyecto-meta-m-0-value").val(0); $("#edit-field-proyecto-meta-f-0-value").val(0); $('#meta-unidm-pers').hide(); } else { $('#meta-unidm-pers').show(); } }); $(".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, '.')); }); $(".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-indicadores-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 sumunidpersonas */ function sumunidpersonas(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)); }