[303fae2] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /** |
---|
| 4 | * Sistema Integral de Planificación y Presupuesto (SIPP) |
---|
| 5 | * @file accion_especifica.module |
---|
| 6 | * Drupal part Module to Sistema Integral de Planificación y Presupuesto (SIPP) |
---|
| 7 | * Copyright 2013 Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana (CENDITEL) |
---|
| 8 | * |
---|
| 9 | * This program is free software; you can redistribute it and/or modify |
---|
| 10 | * it under the terms of the GNU General Public License as published by |
---|
| 11 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 12 | * (at your option) any later version. |
---|
| 13 | * |
---|
| 14 | * This program is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this program; if not, write to the Free Software |
---|
| 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 22 | * |
---|
| 23 | * @author Cenditel Merida - Msc. Juan Vizcarrondo |
---|
| 24 | * @date 2013-02-02 // (año-mes-dia) |
---|
| 25 | * @version 0.1 // (0.1) |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /* |
---|
| 30 | * Implementation of hook_node_info() |
---|
| 31 | */ |
---|
| 32 | function accion_especifica_node_info() { |
---|
| 33 | return array( |
---|
| 34 | 'accion_especifica' => array( |
---|
| 35 | 'name' => t('Acciones Especificas'), |
---|
| 36 | 'description' => '', |
---|
| 37 | 'has_title' => TRUE, |
---|
| 38 | 'title_label' => 'Nombre de la acción especifica', |
---|
| 39 | 'has_body' => FALSE, |
---|
| 40 | 'body_label' => 'Cuerpo', |
---|
| 41 | 'module' => 'accion_especifica', |
---|
| 42 | ), |
---|
| 43 | ); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | /* |
---|
| 47 | * Implementation of hook_menu() |
---|
| 48 | */ |
---|
| 49 | function accion_especifica_menu() { |
---|
| 50 | $items = array(); |
---|
| 51 | $items['admin/settings/ente_planificador/proyectos_operativos/ae'] = array( |
---|
| 52 | 'title' => t('Acciones EspecÃficas'), |
---|
| 53 | 'page callback' => 'drupal_get_form', |
---|
| 54 | 'page arguments' => array('proyectos_operativos_admin_ae_settings'), |
---|
| 55 | 'access arguments' => array('admin planificador'), |
---|
| 56 | 'weight' => -5, |
---|
| 57 | 'type' => MENU_LOCAL_TASK, |
---|
| 58 | ); |
---|
| 59 | return $items; |
---|
| 60 | |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | /** |
---|
| 64 | * Implementation of proyectos_operativos_admin_settings(). |
---|
| 65 | * COnfigurar proyectos operativos. |
---|
| 66 | */ |
---|
| 67 | function proyectos_operativos_admin_ae_settings() { |
---|
| 68 | $node_type = content_types('accion_especifica'); |
---|
| 69 | $fields = $node_type['fields']; |
---|
| 70 | $campos = array(); |
---|
| 71 | foreach($fields as $id => $field) { |
---|
| 72 | if ($field['module'] == 'number') { |
---|
| 73 | $campos[$id] = $field['widget']['label']; |
---|
| 74 | } |
---|
| 75 | } |
---|
| 76 | $form['accion_especifica'] = array( |
---|
| 77 | '#type' => 'fieldset', |
---|
| 78 | '#title' => t('Accion EspecÃfica'), |
---|
| 79 | '#collapsible' => TRUE, |
---|
| 80 | '#collapsed' => FALSE, |
---|
| 81 | '#weight' => 0, |
---|
| 82 | ); |
---|
| 83 | $form['accion_especifica']['accion_especifica_allow_ponderation'] = array( |
---|
| 84 | '#title' => t('Permitir Acciones Especificas con igual ponderación'), |
---|
| 85 | '#type' => 'checkbox', |
---|
| 86 | '#default_value' => variable_get('accion_especifica_allow_ponderation', 0), |
---|
| 87 | ); |
---|
[de9b283] | 88 | $form['accion_especifica']['accion_especifica_100_ponderation'] = array( |
---|
| 89 | '#title' => t('No permitir Acciones Especificas con ponderación mayor o igual a 100'), |
---|
| 90 | '#type' => 'checkbox', |
---|
| 91 | '#default_value' => variable_get('accion_especifica_100_ponderation', 0), |
---|
| 92 | ); |
---|
[303fae2] | 93 | $accion_especifica_number_fields = variable_get('accion_especifica_number_fields', 4); |
---|
| 94 | $numbers = array(); |
---|
| 95 | for($i = 1; $i < 21; $i++) { |
---|
| 96 | $numbers[$i] = $i; |
---|
| 97 | } |
---|
| 98 | $form['accion_especifica']['financiamiento'] = array( |
---|
| 99 | '#type' => 'fieldset', |
---|
| 100 | '#title' => t('Financiamiento'), |
---|
| 101 | '#collapsible' => TRUE, |
---|
| 102 | '#collapsed' => FALSE, |
---|
| 103 | ); |
---|
| 104 | $form['accion_especifica']['financiamiento']['accion_especifica_number_fields'] = array( |
---|
| 105 | '#title' => t('Cantidad de Campos'), |
---|
| 106 | '#type' => 'select', |
---|
| 107 | '#default_value' => $accion_especifica_number_fields, |
---|
| 108 | '#options' => $numbers, |
---|
| 109 | ); |
---|
| 110 | if ($accion_especifica_number_fields) { |
---|
| 111 | for($i = 0; $i < $accion_especifica_number_fields; $i++) { |
---|
[2473852] | 112 | $form['accion_especifica']['financiamiento']['enable_financiamiento_' . $i] = array( |
---|
| 113 | '#type' => 'radios', |
---|
| 114 | '#title' => t('Enable Field'), |
---|
| 115 | '#options' => array( |
---|
| 116 | 1 => t('true'), |
---|
| 117 | 0 => t('false') |
---|
| 118 | ), |
---|
| 119 | '#default_value' => variable_get('enable_financiamiento_' . $i, true), |
---|
| 120 | ); |
---|
[303fae2] | 121 | $form['accion_especifica']['financiamiento']['financiamiento_' . $i] = array( |
---|
| 122 | '#type' => 'fieldset', |
---|
| 123 | '#title' => t('field %number', array('%number' => $i + 1)), |
---|
| 124 | '#collapsible' => TRUE, |
---|
| 125 | '#collapsed' => FALSE, |
---|
| 126 | ); |
---|
| 127 | $form['accion_especifica']['financiamiento']['financiamiento_' . $i]['accion_especifica_financiamiento_label_' . $i] = array( |
---|
| 128 | '#type' => 'textfield', |
---|
| 129 | '#title' => t('Titulo del financiamiento'), |
---|
| 130 | //'#required' => TRUE, |
---|
| 131 | '#weight' => -9, |
---|
| 132 | '#default_value' => variable_get('accion_especifica_financiamiento_label_' . $i, ''), |
---|
| 133 | ); |
---|
| 134 | $form['accion_especifica']['financiamiento']['financiamiento_' . $i]['accion_especifica_financiamiento_options_' . $i] = array( |
---|
| 135 | '#type' => 'checkboxes', |
---|
| 136 | '#options' => $campos, |
---|
| 137 | '#default_value' => variable_get('accion_especifica_financiamiento_options_' . $i, array()), |
---|
| 138 | '#title' => t('Campos a recolectar'), |
---|
| 139 | '#multiple' => TRUE, |
---|
| 140 | ); |
---|
| 141 | } |
---|
| 142 | } |
---|
| 143 | $vid = $fields['field_accion_esp_unidadm']['vid']; |
---|
| 144 | $tree = taxonomy_get_tree($vid); |
---|
| 145 | $option_unidadm = array(); |
---|
| 146 | if ($tree) { |
---|
| 147 | foreach ($tree as $term) { |
---|
| 148 | $choice = new stdClass(); |
---|
| 149 | $choice->option = array($term->tid => str_repeat('-', $term->depth) . $term->name); |
---|
| 150 | $option_unidadm[] = $choice; |
---|
| 151 | } |
---|
| 152 | } |
---|
| 153 | $form['accion_especifica']['accion_especifica_allow_unidpersona'] = array( |
---|
| 154 | '#type' => 'select', |
---|
| 155 | '#options' => $option_unidadm, |
---|
| 156 | '#default_value' => variable_get('accion_especifica_allow_unidpersona', array()), |
---|
| 157 | '#title' => t('Campos de las unidades de medida que deben relacionarse con personas'), |
---|
| 158 | '#multiple' => TRUE, |
---|
| 159 | ); |
---|
[a0cf94c] | 160 | $form['accion_especifica']['proyectos_operativos_muestra_accion_esp'] = array( |
---|
| 161 | '#type' => 'checkbox', |
---|
| 162 | '#title' => t('Recolectar la ubicacion de ejecución del proyecto.'), |
---|
| 163 | '#default_value' => variable_get('proyectos_operativos_muestra_accion_esp', TRUE), |
---|
| 164 | ); |
---|
| 165 | |
---|
[303fae2] | 166 | return system_settings_form($form); |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | /* |
---|
| 170 | * Implementation of hook_form() |
---|
| 171 | */ |
---|
| 172 | function accion_especifica_form(&$node, $form_state) { |
---|
| 173 | return node_content_form($node, $form_state); |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | /* |
---|
| 177 | * Implementation of hook_access() |
---|
| 178 | */ |
---|
| 179 | function accion_especifica_access($op, $node, $account) { |
---|
| 180 | if ($op == 'view') { |
---|
| 181 | return user_access('admin planificador'); |
---|
| 182 | } |
---|
| 183 | if ($op == 'create') { |
---|
| 184 | return user_access('admin planificador'); |
---|
| 185 | } |
---|
| 186 | if ($op == 'update') { |
---|
| 187 | return user_access('admin planificador'); |
---|
| 188 | } |
---|
| 189 | if ($op == 'delete') { |
---|
[a0cf94c] | 190 | //return user_access('admin planificador'); |
---|
| 191 | return (user_access('admin planificador') || _proyectos_operativos_edita_datos_ae_access($node)); |
---|
[303fae2] | 192 | } |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | /** |
---|
| 196 | * Implementation of hook_theme(). |
---|
| 197 | */ |
---|
| 198 | function accion_especifica_theme() { |
---|
| 199 | return array( |
---|
| 200 | 'proyectos_operativos_accion_especifica_crear_form' => array( |
---|
| 201 | 'arguments' => array('form' => NULL), |
---|
| 202 | ), |
---|
| 203 | ); |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | /** |
---|
| 207 | * Implementation of proyectos_operativos_accion_especifica_crear_form(). |
---|
| 208 | * Crear formulario de accion especifica |
---|
| 209 | */ |
---|
| 210 | function proyectos_operativos_accion_especifica_crear_form(&$form_state, $proyecto = 0, $ae = 0) { |
---|
| 211 | if (!$ae) { |
---|
| 212 | $ae_leido = new stdClass(); |
---|
| 213 | $ae_leido->type = 'accion_especifica'; |
---|
| 214 | $nid = 0; |
---|
| 215 | } |
---|
| 216 | else { |
---|
| 217 | $ae_leido = $ae; |
---|
| 218 | $ae_leido->field_accion_titulo[0]['value'] = trim($ae_leido->field_accion_titulo[0]['value']) == '' ? $ae_leido->title : $ae_leido->field_accion_titulo[0]['value']; |
---|
| 219 | $nid = $ae->nid; |
---|
| 220 | } |
---|
| 221 | //add breadcrumb |
---|
| 222 | $breadcrumb = array(); |
---|
| 223 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
| 224 | $breadcrumb[] = l(t('Proyectos Operativos'), 'proyectos_operativos'); |
---|
| 225 | if ($proyecto->nid) { |
---|
| 226 | $breadcrumb[] = l(check_plain($proyecto->title), 'proyectosop/' . $proyecto->nid); |
---|
| 227 | } |
---|
| 228 | if ($ae->nid) { |
---|
| 229 | $breadcrumb[] = check_plain($ae->title); |
---|
| 230 | } |
---|
| 231 | else { |
---|
| 232 | $breadcrumb[] = t('Agregar Acción EspecÃfica'); // Link to current URL |
---|
| 233 | } |
---|
| 234 | drupal_set_breadcrumb($breadcrumb); |
---|
| 235 | |
---|
| 236 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
| 237 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
| 238 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos.js'); |
---|
| 239 | drupal_add_js($proyectos_operativos_path . '/js/accion_especifica.js'); |
---|
| 240 | $format_number = array( |
---|
| 241 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
| 242 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
| 243 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
| 244 | ); |
---|
| 245 | $form = array(); |
---|
| 246 | $form['#format_number'] = array('format_number' => $format_number); |
---|
| 247 | drupal_add_js($form['#format_number'], 'setting'); |
---|
[2473852] | 248 | $form['#year_current'] = array('year_current' => $proyecto->anhoproyectos_operativos); |
---|
| 249 | drupal_add_js($form['#year_current'], 'setting'); |
---|
[7e751a5] | 250 | $form['#esplurianual'] = ($proyecto->field_proyecto_plurianual[0]['value'] == variable_get('proyectos_operativos_plurianual', 0)) ? 1 : 0; |
---|
[303fae2] | 251 | $form['#node'] = $ae_leido; |
---|
| 252 | $form['#proyecto'] = $proyecto; |
---|
| 253 | $fields_form = array(); |
---|
| 254 | $ejecucion = 0; |
---|
| 255 | $acciones_especificas = array(); |
---|
| 256 | $montos = 0; |
---|
[f579d39] | 257 | $montos_financiamiento = 0; |
---|
| 258 | $montos_afinan = 0; |
---|
[303fae2] | 259 | $porcentajes = array(); |
---|
| 260 | foreach($proyecto->field_proyecto_accion_esp as $accion) { |
---|
| 261 | if ($accion['nid'] && $nid != $accion['nid']) { |
---|
| 262 | $accion_load = node_load($accion['nid']); |
---|
| 263 | if ($accion_load && $accion_load->type == 'accion_especifica') { |
---|
| 264 | if ($accion_load->field_accion_esp_programacion[0]['tid']) { |
---|
| 265 | foreach($accion_load->field_accion_esp_programacion as $programacion) { |
---|
| 266 | foreach($programacion as $id_value => $mesp){ |
---|
| 267 | if ($id_value != 'tid') { |
---|
| 268 | $montos +=$mesp; |
---|
| 269 | } |
---|
| 270 | } |
---|
| 271 | } |
---|
| 272 | } |
---|
[f579d39] | 273 | if ($accion_load->nid != $ae->nid) { |
---|
| 274 | if ($accion_load->field_accion_esp_total_fuent[0]['value']) { |
---|
| 275 | $montos_financiamiento += $accion_load->field_accion_esp_total_fuent[0]['value']; |
---|
| 276 | } |
---|
| 277 | if ($accion_load->field_accion_esp_monto_finan[0]['value']) { |
---|
| 278 | $montos_afinan += $accion_load->field_accion_esp_monto_finan[0]['value']; |
---|
| 279 | } |
---|
| 280 | } |
---|
[303fae2] | 281 | $acciones_especificas[$accion_load->nid] = $accion_load; |
---|
| 282 | $porcentajes[$accion_load->field_accion_esp_ponderacion[0]['value']] = 1; |
---|
| 283 | $ejecucion += $accion_load->field_accion_esp_ponderacion[0]['value']; |
---|
| 284 | } |
---|
| 285 | } |
---|
| 286 | elseif($nid == $accion['nid']) { |
---|
| 287 | $acciones_especificas[$ae->nid] = $ae; |
---|
| 288 | } |
---|
| 289 | } |
---|
| 290 | $monto_restante = $form['#proyecto']->field_proyecto_monto_anual[0]['value'] - $montos; |
---|
| 291 | $et = 100 - $ejecucion; |
---|
[2473852] | 292 | $form['#mensaje_mostrar'] = t('Quedan @asignar % de ponderación a asignar y @montos Bs por asignar en las Acciones EspecÃficas.', array('@asignar' => $et, '@montos' => number_format($monto_restante, $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']))); |
---|
[303fae2] | 293 | $form['#monto_restante'] = $monto_restante; |
---|
[5dccc46] | 294 | $form['#montos_financiamiento'] = $montos_financiamiento; |
---|
[f579d39] | 295 | $form['#montos_afinan'] = $montos_afinan; |
---|
[303fae2] | 296 | $form['#ejecucion'] = $ejecucion; |
---|
| 297 | $form['#porcentajes'] = $porcentajes; |
---|
| 298 | $form['#montos'] = $montos; |
---|
| 299 | $form['#acciones_especificas'] = $acciones_especificas; |
---|
| 300 | $node_type = content_types('accion_especifica'); |
---|
| 301 | $fields = $node_type['fields']; |
---|
| 302 | $field_form = array(); |
---|
| 303 | $arreglo = array( |
---|
| 304 | 'field_accion_titulo' => 'field_accion_titulo', |
---|
| 305 | 'field_accion_esp_fechai' => 'field_accion_esp_fechai', |
---|
| 306 | 'field_accion_esp_fechaf' => 'field_accion_esp_fechaf', |
---|
| 307 | 'field_accion_esp_ejecutor' => 'field_accion_esp_ejecutor', |
---|
| 308 | 'field_accion_esp_bien' => 'field_accion_esp_bien', |
---|
[a609c96] | 309 | 'field_ae_finamonedas' => 'field_ae_finamonedas', |
---|
[303fae2] | 310 | ); |
---|
| 311 | if (is_array($fields) && count($fields)) { |
---|
| 312 | foreach($fields as $field_id => $field) { |
---|
| 313 | if (array_key_exists($field_id, $arreglo)) { |
---|
| 314 | $field_form[] = $field_id; |
---|
| 315 | $fields_form[] = $field_id; |
---|
| 316 | } |
---|
| 317 | elseif (variable_get('proyectos_operativos_ac_d_' . $field_id, FALSE)) { |
---|
| 318 | $field_form[] = $field_id; |
---|
| 319 | $fields_form[] = $field_id; |
---|
| 320 | } |
---|
| 321 | } |
---|
| 322 | } |
---|
| 323 | /*caMBIAR*/ |
---|
| 324 | /* |
---|
| 325 | $form['title'] = array( |
---|
| 326 | '#type' => 'textfield', |
---|
| 327 | '#title' => t('Nombre de la Acción'), |
---|
| 328 | '#required' => TRUE, |
---|
| 329 | '#default_value' => $form['#node']->title, |
---|
| 330 | '#maxlength' => 255, |
---|
| 331 | '#weight' => -5, |
---|
| 332 | ); |
---|
| 333 | */ |
---|
| 334 | if (is_array($field_form) && count($field_form)) { |
---|
| 335 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
| 336 | foreach ($field_form as $field_id) { |
---|
| 337 | $field = content_fields($field_id, 'accion_especifica'); |
---|
| 338 | $form['#field_info'][$field_id] = $field; |
---|
| 339 | $form += (array) content_field_form($form, $form_state, $field); |
---|
| 340 | } |
---|
| 341 | } |
---|
| 342 | $field_form = array(); |
---|
| 343 | $arreglo['field_accion_esp_unidadm'] = 'field_accion_esp_unidadm'; |
---|
| 344 | $personas = variable_get('accion_especifica_allow_unidpersona', array()); |
---|
| 345 | if (count($personas)) { |
---|
| 346 | $arreglo['field_accion_esp_meta_m'] = 'field_accion_esp_meta_m'; |
---|
| 347 | $arreglo['field_accion_esp_meta_f'] = 'field_accion_esp_meta_f'; |
---|
| 348 | } |
---|
| 349 | $form['#personas'] = $personas; |
---|
| 350 | drupal_add_js(array('accion_esp' => array('unidadmpers' => $personas)), 'setting'); |
---|
| 351 | $arreglo['field_accion_esp_ponderacion'] = 'field_accion_esp_ponderacion'; |
---|
| 352 | $arreglo['field_accion_esp_metaf'] = 'field_accion_esp_metaf'; |
---|
| 353 | |
---|
| 354 | if (is_array($fields) && count($fields)) { |
---|
| 355 | foreach($fields as $field_id => $field) { |
---|
| 356 | if (array_key_exists($field_id, $arreglo)) { |
---|
| 357 | $field_form[] = $field_id; |
---|
| 358 | $fields_form[] = $field_id; |
---|
| 359 | } |
---|
| 360 | elseif (variable_get('proyectos_operativos_ac_di_' . $field_id, FALSE)) { |
---|
| 361 | $field_form[] = $field_id; |
---|
| 362 | $fields_form[] = $field_id; |
---|
| 363 | } |
---|
| 364 | } |
---|
| 365 | } |
---|
| 366 | if (is_array($field_form) && count($field_form)) { |
---|
| 367 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
| 368 | foreach ($field_form as $field_id) { |
---|
| 369 | $field = content_fields($field_id, 'accion_especifica'); |
---|
| 370 | $form['#field_info'][$field_id] = $field; |
---|
| 371 | $form += (array) content_field_form($form, $form_state, $field); |
---|
| 372 | } |
---|
| 373 | } |
---|
| 374 | $field_form = array(); |
---|
| 375 | $arreglo = array( |
---|
| 376 | 'field_accion_esp_programacion' => 'field_accion_esp_programacion', |
---|
| 377 | ); |
---|
| 378 | if (is_array($fields) && count($fields)) { |
---|
| 379 | foreach($fields as $field_id => $field) { |
---|
| 380 | if (array_key_exists($field_id, $arreglo)) { |
---|
| 381 | $field_form[] = $field_id; |
---|
| 382 | $fields_form[] = $field_id; |
---|
| 383 | } |
---|
| 384 | elseif (variable_get('proyectos_operativos_ac_p_' . $field_id, FALSE)) { |
---|
| 385 | $field_form[] = $field_id; |
---|
| 386 | $fields_form[] = $field_id; |
---|
| 387 | } |
---|
| 388 | } |
---|
| 389 | } |
---|
| 390 | if (is_array($field_form) && count($field_form)) { |
---|
| 391 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
| 392 | foreach ($field_form as $field_id) { |
---|
| 393 | $field = content_fields($field_id, 'accion_especifica'); |
---|
| 394 | $form['#field_info'][$field_id] = $field; |
---|
| 395 | $form += (array) content_field_form($form, $form_state, $field); |
---|
| 396 | } |
---|
| 397 | } |
---|
| 398 | //financiamiento |
---|
| 399 | $arreglo_financiamiento = array(); |
---|
| 400 | $accion_especifica_number_fields = variable_get('accion_especifica_number_fields', 4); |
---|
| 401 | if ($accion_especifica_number_fields > 0) { |
---|
| 402 | for($i = 0; $i < $accion_especifica_number_fields; $i++) { |
---|
| 403 | $arreglo_financiamiento['financiamiento_' . $i] = variable_get('accion_especifica_financiamiento_label_' . $i, '') ? variable_get('accion_especifica_financiamiento_label_' . $i, '') : ''; |
---|
| 404 | $arreglo_financiamiento_fields['financiamiento_' . $i] = variable_get('accion_especifica_financiamiento_options_' . $i, array()); |
---|
| 405 | } |
---|
| 406 | } |
---|
| 407 | /* |
---|
| 408 | $arreglo_financiamiento = array( |
---|
| 409 | 'ordinarios' => t('Recursos Ordinarios'), |
---|
| 410 | 'propios' => t('Recursos Propios'), |
---|
| 411 | 'transferencias' => t('Transferencias'), |
---|
| 412 | 'otros' => t('Otros'), |
---|
| 413 | ); |
---|
| 414 | $arreglo_financiamiento_fields = array(); |
---|
| 415 | $arreglo_financiamiento_fields['ordinarios'] = array( |
---|
| 416 | 'field_accion_esp_transferencias' => 'field_accion_esp_transferencias', |
---|
| 417 | 'field_accion_esp_creditosa' => 'field_accion_esp_creditosa', |
---|
| 418 | 'field_accion_esp_mcti' => 'field_accion_esp_mcti', |
---|
| 419 | ); |
---|
| 420 | $arreglo_financiamiento_fields['propios'] = array( |
---|
| 421 | 'field_accion_esp_venta_act' => 'field_accion_esp_venta_act', |
---|
| 422 | 'field_accion_esp_activos' => 'field_accion_esp_activos', |
---|
| 423 | 'field_accion_esp_flujocaja' => 'field_accion_esp_flujocaja', |
---|
| 424 | 'field_accion_esp_ventapro' => 'field_accion_esp_ventapro', |
---|
| 425 | ); |
---|
| 426 | $arreglo_financiamiento_fields['transferencias'] = array( |
---|
| 427 | 'field_accion_esp_donaciones' => 'field_accion_esp_donaciones', |
---|
| 428 | ); |
---|
| 429 | $arreglo_financiamiento_fields['otros'] = array( |
---|
| 430 | 'field_accion_esp_gobernacion' => 'field_accion_esp_gobernacion', |
---|
| 431 | 'field_accion_esp_misionc' => 'field_accion_esp_misionc', |
---|
| 432 | 'field_accion_esp_bid_fona' => 'field_accion_esp_bid_fona', |
---|
| 433 | 'field_accion_esp_fonacit' => 'field_accion_esp_fonacit', |
---|
| 434 | 'field_accion_esp_fonden' => 'field_accion_esp_fonden', |
---|
| 435 | 'field_accion_esp_locti' => 'field_accion_esp_locti', |
---|
| 436 | 'field_accion_esp_fondoidi' => 'field_accion_esp_fondoidi', |
---|
| 437 | 'field_accion_esp_capitalrie' => 'field_accion_esp_capitalrie', |
---|
| 438 | 'field_accion_esp_infocentro' => 'field_accion_esp_infocentro', |
---|
| 439 | 'field_accion_esp_fidetel' => 'field_accion_esp_fidetel', |
---|
| 440 | ); |
---|
| 441 | */ |
---|
| 442 | $total_financiamiento = 0; |
---|
| 443 | $fields_financiamiento = array(); |
---|
| 444 | |
---|
| 445 | foreach($arreglo_financiamiento as $id_items => $titulo) { |
---|
[2473852] | 446 | if (variable_get('enable_' . $id_items, false)) { |
---|
| 447 | if (is_array($arreglo_financiamiento_fields[$id_items]) && count($arreglo_financiamiento_fields[$id_items])) { |
---|
| 448 | $form[$id_items] = array( |
---|
| 449 | '#type' => 'fieldset', |
---|
| 450 | '#title' => $titulo, |
---|
| 451 | ); |
---|
| 452 | $field_form = array(); |
---|
[303fae2] | 453 | /* |
---|
| 454 | $arreglo = array( |
---|
| 455 | 'field_accion_esp_transferencias' => 'field_accion_esp_transferencias', |
---|
| 456 | 'field_accion_esp_creditosa' => 'field_accion_esp_creditosa', |
---|
| 457 | 'field_accion_esp_mcti' => 'field_accion_esp_mcti', |
---|
| 458 | ); |
---|
| 459 | */ |
---|
[2473852] | 460 | if (is_array($fields) && count($fields)) { |
---|
| 461 | foreach($fields as $field_id => $field) { |
---|
| 462 | if (array_key_exists($field_id, $arreglo_financiamiento_fields[$id_items]) && $arreglo_financiamiento_fields[$id_items][$field_id]) { |
---|
| 463 | $field_form[] = $field_id; |
---|
| 464 | $fields_form[] = $field_id; |
---|
| 465 | $fields_financiamiento[] = $field_id; |
---|
| 466 | } |
---|
[303fae2] | 467 | } |
---|
| 468 | } |
---|
[2473852] | 469 | $total_local = 0; |
---|
| 470 | if (is_array($field_form) && count($field_form)) { |
---|
| 471 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
| 472 | foreach ($field_form as $field_id) { |
---|
| 473 | if (isset($form['#node']->{$field_id}[0]['value'])) { |
---|
| 474 | $total_local += $form['#node']->{$field_id}[0]['value']; |
---|
| 475 | } |
---|
| 476 | $field = content_fields($field_id, 'accion_especifica'); |
---|
| 477 | $form['#field_info'][$field_id] = $field; |
---|
| 478 | $form[$id_items] += (array) content_field_form($form, $form_state, $field); |
---|
[303fae2] | 479 | } |
---|
| 480 | } |
---|
[2473852] | 481 | $form['#campo_' . $id_items] = $field_form; |
---|
| 482 | $form['total_' . $id_items] = array( |
---|
| 483 | '#type' => 'textfield', |
---|
[f579d39] | 484 | '#title' => t('SUBTOTAL'), |
---|
[2473852] | 485 | '#default_value' => $total_local, |
---|
| 486 | '#size' => 25, |
---|
| 487 | '#attributes' => array('class' => 'totales-financieros subtotales'), |
---|
| 488 | ); |
---|
| 489 | $total_financiamiento += $total_local; |
---|
[303fae2] | 490 | } |
---|
| 491 | } |
---|
| 492 | } |
---|
| 493 | /* |
---|
| 494 | |
---|
| 495 | |
---|
| 496 | |
---|
| 497 | |
---|
| 498 | |
---|
| 499 | |
---|
| 500 | |
---|
| 501 | |
---|
| 502 | |
---|
| 503 | |
---|
| 504 | $form['ordinarios'] = array( |
---|
| 505 | '#type' => 'fieldset', |
---|
| 506 | '#title' => t('Recursos Ordinarios'), |
---|
| 507 | ); |
---|
| 508 | $fields_financiamiento = array(); |
---|
| 509 | $field_form = array(); |
---|
| 510 | $arreglo = array( |
---|
| 511 | 'field_accion_esp_transferencias' => 'field_accion_esp_transferencias', |
---|
| 512 | 'field_accion_esp_creditosa' => 'field_accion_esp_creditosa', |
---|
| 513 | 'field_accion_esp_mcti' => 'field_accion_esp_mcti', |
---|
| 514 | ); |
---|
| 515 | if (is_array($fields) && count($fields)) { |
---|
| 516 | foreach($fields as $field_id => $field) { |
---|
| 517 | if (array_key_exists($field_id, $arreglo)) { |
---|
| 518 | $field_form[] = $field_id; |
---|
| 519 | $fields_form[] = $field_id; |
---|
| 520 | $fields_financiamiento[] = $field_id; |
---|
| 521 | } |
---|
| 522 | elseif (variable_get('proyectos_operativos_ac_fo_' . $field_id, FALSE)) { |
---|
| 523 | $field_form[] = $field_id; |
---|
| 524 | $fields_form[] = $field_id; |
---|
| 525 | $fields_financiamiento[] = $field_id; |
---|
| 526 | } |
---|
| 527 | } |
---|
| 528 | } |
---|
| 529 | $total_ordinarios = 0; |
---|
| 530 | if (is_array($field_form) && count($field_form)) { |
---|
| 531 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
| 532 | foreach ($field_form as $field_id) { |
---|
| 533 | if (isset($form['#node']->{$field_id}[0]['value'])) { |
---|
| 534 | $total_ordinarios += $form['#node']->{$field_id}[0]['value']; |
---|
| 535 | } |
---|
| 536 | $field = content_fields($field_id, 'accion_especifica'); |
---|
| 537 | $form['#field_info'][$field_id] = $field; |
---|
| 538 | $form['ordinarios'] += (array) content_field_form($form, $form_state, $field); |
---|
| 539 | } |
---|
| 540 | } |
---|
| 541 | $form['#campo_ordinarios'] = $field_form; |
---|
| 542 | $form['total_ordinarios'] = array( |
---|
| 543 | '#type' => 'textfield', |
---|
| 544 | '#title' => t('SUBTOTAL'), |
---|
| 545 | '#default_value' => $total_ordinarios, |
---|
| 546 | '#size' => 25, |
---|
| 547 | '#attributes' => array('class' => 'totales-financieros subtotales'), |
---|
| 548 | ); |
---|
| 549 | |
---|
| 550 | |
---|
| 551 | |
---|
| 552 | |
---|
| 553 | |
---|
| 554 | $form['propios'] = array( |
---|
| 555 | '#type' => 'fieldset', |
---|
| 556 | '#title' => t('Recursos Propios'), |
---|
| 557 | ); |
---|
| 558 | $field_form = array(); |
---|
| 559 | $arreglo = array( |
---|
| 560 | 'field_accion_esp_venta_act' => 'field_accion_esp_venta_act', |
---|
| 561 | 'field_accion_esp_activos' => 'field_accion_esp_activos', |
---|
| 562 | 'field_accion_esp_flujocaja' => 'field_accion_esp_flujocaja', |
---|
| 563 | 'field_accion_esp_ventapro' => 'field_accion_esp_ventapro', |
---|
| 564 | ); |
---|
| 565 | if (is_array($fields) && count($fields)) { |
---|
| 566 | foreach($fields as $field_id => $field) { |
---|
| 567 | if (array_key_exists($field_id, $arreglo)) { |
---|
| 568 | $field_form[] = $field_id; |
---|
| 569 | $fields_form[] = $field_id; |
---|
| 570 | $fields_financiamiento[] = $field_id; |
---|
| 571 | } |
---|
| 572 | elseif (variable_get('proyectos_operativos_ac_fp_' . $field_id, FALSE)) { |
---|
| 573 | $field_form[] = $field_id; |
---|
| 574 | $fields_form[] = $field_id; |
---|
| 575 | $fields_financiamiento[] = $field_id; |
---|
| 576 | } |
---|
| 577 | } |
---|
| 578 | } |
---|
| 579 | $total_propios = 0; |
---|
| 580 | if (is_array($field_form) && count($field_form)) { |
---|
| 581 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
| 582 | foreach ($field_form as $field_id) { |
---|
| 583 | if (isset($form['#node']->{$field_id}[0]['value'])) { |
---|
| 584 | $total_propios += $form['#node']->{$field_id}[0]['value']; |
---|
| 585 | } |
---|
| 586 | $field = content_fields($field_id, 'accion_especifica'); |
---|
| 587 | $form['#field_info'][$field_id] = $field; |
---|
| 588 | $form['propios'] += (array) content_field_form($form, $form_state, $field); |
---|
| 589 | } |
---|
| 590 | } |
---|
| 591 | $form['#campo_propios'] = $field_form; |
---|
| 592 | $form['total_propios'] = array( |
---|
| 593 | '#type' => 'textfield', |
---|
| 594 | '#title' => t('SUBTOTAL'), |
---|
| 595 | '#default_value' => $total_propios, |
---|
| 596 | '#size' => 25, |
---|
| 597 | '#attributes' => array('class' => 'totales-financieros subtotales'), |
---|
| 598 | ); |
---|
| 599 | $form['transferencias'] = array( |
---|
| 600 | '#type' => 'fieldset', |
---|
| 601 | '#title' => t('Transferencias'), |
---|
| 602 | ); |
---|
| 603 | $field_form = array(); |
---|
| 604 | $arreglo = array( |
---|
| 605 | 'field_accion_esp_donaciones' => 'field_accion_esp_donaciones', |
---|
| 606 | ); |
---|
| 607 | if (is_array($fields) && count($fields)) { |
---|
| 608 | foreach($fields as $field_id => $field) { |
---|
| 609 | if (array_key_exists($field_id, $arreglo)) { |
---|
| 610 | $field_form[] = $field_id; |
---|
| 611 | $fields_form[] = $field_id; |
---|
| 612 | $fields_financiamiento[] = $field_id; |
---|
| 613 | } |
---|
| 614 | elseif (variable_get('proyectos_operativos_ac_fd_' . $field_id, FALSE)) { |
---|
| 615 | $field_form[] = $field_id; |
---|
| 616 | $fields_form[] = $field_id; |
---|
| 617 | $fields_financiamiento[] = $field_id; |
---|
| 618 | } |
---|
| 619 | } |
---|
| 620 | } |
---|
| 621 | $total_transferencias = 0; |
---|
| 622 | if (is_array($field_form) && count($field_form)) { |
---|
| 623 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
| 624 | foreach ($field_form as $field_id) { |
---|
| 625 | if (isset($form['#node']->{$field_id}[0]['value'])) { |
---|
| 626 | $total_transferencias += $form['#node']->{$field_id}[0]['value']; |
---|
| 627 | } |
---|
| 628 | $field = content_fields($field_id, 'accion_especifica'); |
---|
| 629 | $form['#field_info'][$field_id] = $field; |
---|
| 630 | $form['transferencias'] += (array) content_field_form($form, $form_state, $field); |
---|
| 631 | } |
---|
| 632 | } |
---|
| 633 | $form['#campo_transferencias'] = $field_form; |
---|
| 634 | $form['total_transferencias'] = array( |
---|
| 635 | '#type' => 'textfield', |
---|
| 636 | '#title' => t('SUBTOTAL'), |
---|
| 637 | '#default_value' => $total_transferencias, |
---|
| 638 | '#size' => 25, |
---|
| 639 | '#attributes' => array('class' => 'totales-financieros subtotales'), |
---|
| 640 | ); |
---|
| 641 | $form['otros'] = array( |
---|
| 642 | '#type' => 'fieldset', |
---|
| 643 | '#title' => t('Otros'), |
---|
| 644 | ); |
---|
| 645 | $field_form = array(); |
---|
| 646 | $arreglo = array( |
---|
| 647 | 'field_accion_esp_gobernacion' => 'field_accion_esp_gobernacion', |
---|
| 648 | 'field_accion_esp_misionc' => 'field_accion_esp_misionc', |
---|
| 649 | 'field_accion_esp_bid_fona' => 'field_accion_esp_bid_fona', |
---|
| 650 | 'field_accion_esp_fonacit' => 'field_accion_esp_fonacit', |
---|
| 651 | 'field_accion_esp_fonden' => 'field_accion_esp_fonden', |
---|
| 652 | 'field_accion_esp_locti' => 'field_accion_esp_locti', |
---|
| 653 | 'field_accion_esp_fondoidi' => 'field_accion_esp_fondoidi', |
---|
| 654 | 'field_accion_esp_capitalrie' => 'field_accion_esp_capitalrie', |
---|
| 655 | 'field_accion_esp_infocentro' => 'field_accion_esp_infocentro', |
---|
| 656 | 'field_accion_esp_fidetel' => 'field_accion_esp_fidetel', |
---|
| 657 | ); |
---|
| 658 | if (is_array($fields) && count($fields)) { |
---|
| 659 | foreach($fields as $field_id => $field) { |
---|
| 660 | if (array_key_exists($field_id, $arreglo)) { |
---|
| 661 | $field_form[] = $field_id; |
---|
| 662 | $fields_form[] = $field_id; |
---|
| 663 | $fields_financiamiento[] = $field_id; |
---|
| 664 | } |
---|
| 665 | elseif (variable_get('proyectos_operativos_ac_fo_' . $field_id, FALSE)) { |
---|
| 666 | $field_form[] = $field_id; |
---|
| 667 | $fields_form[] = $field_id; |
---|
| 668 | $fields_financiamiento[] = $field_id; |
---|
| 669 | } |
---|
| 670 | } |
---|
| 671 | } |
---|
| 672 | $total_otros = 0; |
---|
| 673 | $clase = 'total_otros'; |
---|
| 674 | if (is_array($field_form) && count($field_form)) { |
---|
| 675 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
| 676 | foreach ($field_form as $field_id) { |
---|
| 677 | if (isset($form['#node']->{$field_id}[0]['value'])) { |
---|
| 678 | $total_otros += $form['#node']->{$field_id}[0]['value']; |
---|
| 679 | } |
---|
| 680 | $field = content_fields($field_id, 'accion_especifica'); |
---|
| 681 | $form['#field_info'][$field_id] = $field; |
---|
| 682 | $form['otros'] += (array) content_field_form($form, $form_state, $field); |
---|
| 683 | } |
---|
| 684 | } |
---|
| 685 | $form['#campo_otros'] = $field_form; |
---|
| 686 | $form['total_otros'] = array( |
---|
| 687 | '#type' => 'textfield', |
---|
| 688 | '#title' => t('SUBTOTAL'), |
---|
| 689 | '#default_value' => $total_otros, |
---|
| 690 | '#size' => 25, |
---|
| 691 | '#attributes' => array('class' => 'totales-financieros subtotales'), |
---|
| 692 | ); |
---|
| 693 | */ |
---|
| 694 | //$total_financiamiento = $total_otros + $total_transferencias + $total_propios + $total_ordinarios; |
---|
| 695 | $form['total_financiamiento'] = array( |
---|
| 696 | '#type' => 'textfield', |
---|
| 697 | '#default_value' => $total_financiamiento, |
---|
| 698 | '#size' => 25, |
---|
| 699 | '#attributes' => array('class' => 'totales-financieros'), |
---|
| 700 | ); |
---|
| 701 | $field_form = array(); |
---|
[a0cf94c] | 702 | $localizacion = variable_get('proyectos_operativos_muestra_accion_esp', TRUE); |
---|
[303fae2] | 703 | if ($localizacion) { |
---|
| 704 | $arreglo = array( |
---|
| 705 | 'field_accion_esp_localizacion' => 'field_accion_esp_localizacion', |
---|
| 706 | 'field_accion_esp_latitud' => 'field_accion_esp_latitud', |
---|
| 707 | 'field_accion_esp_longitud' => 'field_accion_esp_longitud', |
---|
| 708 | ); |
---|
| 709 | } |
---|
| 710 | if (is_array($fields) && count($fields)) { |
---|
| 711 | foreach($fields as $field_id => $field) { |
---|
| 712 | if (array_key_exists($field_id, $arreglo)) { |
---|
| 713 | $field_form[] = $field_id; |
---|
| 714 | $fields_form[] = $field_id; |
---|
| 715 | } |
---|
| 716 | elseif (variable_get('proyectos_operativos_ac_fp_' . $field_id, FALSE)) { |
---|
| 717 | $field_form[] = $field_id; |
---|
| 718 | $fields_form[] = $field_id; |
---|
| 719 | } |
---|
| 720 | } |
---|
| 721 | } |
---|
| 722 | if (is_array($field_form) && count($field_form)) { |
---|
| 723 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
| 724 | foreach ($field_form as $field_id) { |
---|
| 725 | $field = content_fields($field_id, 'accion_especifica'); |
---|
| 726 | $form['#field_info'][$field_id] = $field; |
---|
| 727 | $form += (array) content_field_form($form, $form_state, $field); |
---|
| 728 | } |
---|
| 729 | } |
---|
| 730 | $form['#arreglo_financiamiento'] = $arreglo_financiamiento; |
---|
| 731 | $form['#arreglo_financiamiento_fields'] = $arreglo_financiamiento_fields; |
---|
| 732 | |
---|
| 733 | $form['#fields_financiamiento'] = $fields_financiamiento; |
---|
| 734 | $form['#proyectos_operativos_fields'] = $fields_form; |
---|
| 735 | $form['buttons'] = array( |
---|
| 736 | '#prefix' => '<div class="container-inline">', |
---|
| 737 | '#suffix' => '</div>', |
---|
| 738 | ); |
---|
| 739 | $form['buttons']['registrar'] = array( |
---|
| 740 | '#type' => 'submit', |
---|
| 741 | '#default_value' => t('Aceptar'), |
---|
| 742 | '#weight' => 100, |
---|
| 743 | ); |
---|
| 744 | $form['buttons']['cancelar'] = array( |
---|
| 745 | '#type' => 'submit', |
---|
| 746 | '#default_value' => t('Cancelar'), |
---|
| 747 | '#attributes' => array('onClick' => 'window.location="' . base_path() .$_GET['q'] . '"; return false;'), |
---|
| 748 | '#weight' => 101, |
---|
| 749 | ); |
---|
| 750 | $form['#proyecto_completed'] = FALSE; |
---|
| 751 | $form['#after_build'] = array('proyectos_operativos_accion_especifica_crear_form_after_build'); |
---|
| 752 | if (!isset($form['#node']->nid) && $form['#ejecucion'] >= 100 && $form['#monto_restante'] == 0){ |
---|
| 753 | //add aditional variables |
---|
| 754 | $aux_form = array(); |
---|
| 755 | $aux_form['#node'] = $form['#node']; |
---|
| 756 | $aux_form['#proyecto'] = $form['#proyecto']; |
---|
| 757 | $aux_form['#mensaje_mostrar'] = $form['#mensaje_mostrar']; |
---|
| 758 | $aux_form['#ejecucion'] = $form['#ejecucion']; |
---|
| 759 | $aux_form['#porcentajes'] = $form['#porcentajes']; |
---|
| 760 | $aux_form['#montos'] = $form['#montos']; |
---|
| 761 | $aux_form['#acciones_especificas'] = $form['#acciones_especificas']; |
---|
| 762 | |
---|
| 763 | $aux_form['#campo_ordinarios'] = $form['#campo_ordinarios']; |
---|
| 764 | $aux_form['#campo_propios'] = $form['#campo_propios']; |
---|
| 765 | $aux_form['#campo_transferencias'] = $form['#campo_transferencias']; |
---|
| 766 | $aux_form['#campo_otros'] = $form['#campo_otros']; |
---|
| 767 | |
---|
| 768 | $aux_form['#fields_financiamiento'] = $form['#fields_financiamiento']; |
---|
| 769 | |
---|
| 770 | $form = $aux_form; |
---|
| 771 | $form['buttons'] = array( |
---|
| 772 | '#prefix' => '<div class="container-inline">', |
---|
| 773 | '#suffix' => '</div>', |
---|
| 774 | ); |
---|
| 775 | $form['buttons']['siguiente'] = array( |
---|
| 776 | '#type' => 'submit', |
---|
| 777 | '#default_value' => t('Terminar'), |
---|
| 778 | '#weight' => 100, |
---|
| 779 | ); |
---|
| 780 | $form['buttons']['cancelar'] = array( |
---|
| 781 | '#type' => 'submit', |
---|
| 782 | '#default_value' => t('Cancelar'), |
---|
| 783 | '#attributes' => array('onClick' => 'window.location="' . base_path() .$_GET['q'] . '"; return false;'), |
---|
| 784 | '#weight' => 101, |
---|
| 785 | ); |
---|
| 786 | $form['#proyecto_completed'] = TRUE; |
---|
| 787 | } |
---|
| 788 | $form['#submit'] = array('proyectos_operativos_accion_especifica_crear_form_submit'); |
---|
| 789 | return $form; |
---|
| 790 | } |
---|
| 791 | |
---|
| 792 | /* |
---|
| 793 | * proyectos_operativos_accion_especifica_crear_form_after_build |
---|
| 794 | * Funcion para agregar funciones javascript al formulario |
---|
| 795 | */ |
---|
| 796 | function proyectos_operativos_accion_especifica_crear_form_after_build($form, &$form_state) { |
---|
| 797 | if (is_array($form['#arreglo_financiamiento']) && count($form['#arreglo_financiamiento'])) { |
---|
| 798 | foreach ($form['#arreglo_financiamiento'] as $id => $macro) { |
---|
| 799 | $nuid = str_replace('_', '-', $id); |
---|
| 800 | if (is_array($form['#campo_' . $id]) && count($form['#campo_' . $id])) { |
---|
| 801 | foreach ($form['#campo_' . $id] as $field_id) { |
---|
| 802 | $form[$id][$field_id][0]['value']['#attributes']['class'] .= ' total-' . $nuid; |
---|
| 803 | if (!isset($form[$id][$field_id]['value']['#attributes']['onchange'])) { |
---|
| 804 | $form[$id][$field_id][0]['value']['#attributes']['onchange'] = "sumarff('" . $nuid . "');sumarff1('subtotales');"; |
---|
| 805 | } |
---|
| 806 | else { |
---|
| 807 | $form[$id][$field_id][0]['value']['#attributes']['onchange'] .= ";sumarff('" . $nuid . "');sumarff1('subtotales');"; |
---|
| 808 | } |
---|
| 809 | } |
---|
| 810 | } |
---|
| 811 | } |
---|
| 812 | } |
---|
| 813 | $form['field_accion_esp_meta_m'][0]['value']['#attributes']['class'] .= ' unidad_personas'; |
---|
| 814 | $form['field_accion_esp_meta_f'][0]['value']['#attributes']['class'] .= ' unidad_personas'; |
---|
| 815 | $form['field_accion_esp_meta_m'][0]['value']['#attributes']['onchange'] .= ";accionEspecificasumunidpersonas('unidad_personas');"; |
---|
| 816 | $form['field_accion_esp_meta_f'][0]['value']['#attributes']['onchange'] .= ";accionEspecificasumunidpersonas('unidad_personas');"; |
---|
| 817 | return $form; |
---|
[f579d39] | 818 | |
---|
[303fae2] | 819 | } |
---|
| 820 | |
---|
| 821 | /* |
---|
| 822 | * proyectos_operativos_accion_especifica_crear_form_validate |
---|
| 823 | * Validar accion especifica |
---|
| 824 | */ |
---|
| 825 | function proyectos_operativos_accion_especifica_crear_form_validate($form, &$form_state) { |
---|
| 826 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
| 827 | if ($op == t('Cancelar') || $op == t('Terminar')) { |
---|
| 828 | return; |
---|
| 829 | } |
---|
| 830 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
| 831 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
| 832 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos.js'); |
---|
| 833 | drupal_add_js($proyectos_operativos_path . '/js/accion_especifica.js'); |
---|
| 834 | drupal_add_js($form['#format_number'], 'setting'); |
---|
| 835 | drupal_add_js(array('accion_esp' => array('unidadmpers' => $form['#personas'])), 'setting'); |
---|
| 836 | //validamos que el porc sea mayor que cero |
---|
| 837 | if (!$form_state['values']['field_accion_esp_ponderacion'][0]['value'] && $form_state['values']['field_accion_esp_ponderacion'][0]['value'] >= 100) { |
---|
| 838 | form_set_error('field_accion_esp_ponderacion', t('La ponderaciones de la Acción especifica debe ser menor que 100')); |
---|
| 839 | } |
---|
| 840 | |
---|
| 841 | //validamos que el porc sea mayor que cero |
---|
| 842 | if (!$form_state['values']['field_accion_esp_ponderacion'][0]['value'] && $form_state['values']['field_accion_esp_ponderacion'][0]['value'] <= 0) { |
---|
| 843 | form_set_error('field_accion_esp_ponderacion', t('La ponderaciones de la Acción especifica debe ser mayor que cero')); |
---|
| 844 | } |
---|
| 845 | //validamos que la ponderacion no sea mayor a 100 |
---|
| 846 | $suma_porc = $form['#ejecucion'] + $form_state['values']['field_accion_esp_ponderacion'][0]['value']; |
---|
| 847 | if ($suma_porc > 100) { |
---|
[de9b283] | 848 | form_set_error('field_accion_esp_ponderacion', t('La suma de las ponderaciones de la Acción especifica debe ser menor o igual a 100%')); |
---|
[303fae2] | 849 | } |
---|
[de9b283] | 850 | // validamos que la cantidad de acciones permitidas cumpla con la minima permitida |
---|
| 851 | if (variable_get('accion_especifica_100_ponderation', 0) && $form_state['values']['field_accion_esp_ponderacion'][0]['value'] >= 100) { |
---|
| 852 | form_set_error('field_accion_esp_ponderacion', t('La ponderación de la Acción especifica debe ser menor o igual a 100%')); |
---|
| 853 | } |
---|
[303fae2] | 854 | //validamos que la ponderacion no se encuentre repetida |
---|
| 855 | if (!variable_get('accion_especifica_allow_ponderation', 0) && isset($form['#porcentajes'][$form_state['values']['field_accion_esp_ponderacion'][0]['value']])) { |
---|
| 856 | form_set_error('field_accion_esp_ponderacion', t('Ya existe una acción especifica con esta ponderación')); |
---|
| 857 | } |
---|
| 858 | //validamos que las fechas esten dentro de la del proyecto |
---|
| 859 | if ($form_state['values']['field_accion_esp_fechai'][0]['value'] > $form_state['values']['field_accion_esp_fechai'][0]['value']) { |
---|
| 860 | form_set_error('field_accion_esp_fechai', t('La fecha de inicio de la Acción especifica debe ser menor a la fecha de fin')); |
---|
| 861 | } |
---|
| 862 | if ($form['#proyecto']->field_proyecto_fecha_i[0]['value'] > $form_state['values']['field_accion_esp_fechai'][0]['value']) { |
---|
| 863 | form_set_error('field_accion_esp_fechai', t('La fecha de inicio de la Acción especifica debe ser mayor o igual a la fecha de inicio del proyecto @fecha', array('@fecha' => $form['#proyecto']->field_proyecto_fecha_i[0]['value']))); |
---|
| 864 | } |
---|
| 865 | if ($form['#proyecto']->field_proyecto_fecha_f[0]['value'] < $form_state['values']['field_accion_esp_fechai'][0]['value']) { |
---|
| 866 | form_set_error('field_accion_esp_fechai', t('La fecha de inicio de la Acción especifica debe ser mayor o igual a la fecha de fin del proyecto @fecha', array('@fecha' => $form['#proyecto']->field_proyecto_fecha_f[0]['value']))); |
---|
| 867 | } |
---|
| 868 | if ($form['#proyecto']->field_proyecto_fecha_i[0]['value'] > $form_state['values']['field_accion_esp_fechaf'][0]['value']) { |
---|
| 869 | form_set_error('field_accion_esp_fechaf', t('La fecha de fin de la Acción especifica debe ser menor o igual a la fecha de inicio del proyecto @fecha', array('@fecha' => $form['#proyecto']->field_proyecto_fecha_i[0]['value']))); |
---|
| 870 | } |
---|
| 871 | if ($form['#proyecto']->field_proyecto_fecha_f[0]['value'] < $form_state['values']['field_accion_esp_fechaf'][0]['value']) { |
---|
| 872 | form_set_error('field_accion_esp_fechaf', t('La fecha de fin de la Acción especifica debe ser menor o igual a la fecha de fin del proyecto @fecha', array('@fecha' => $form['#proyecto']->field_proyecto_fecha_f[0]['value']))); |
---|
| 873 | } |
---|
| 874 | //obtener la fecha de inicio y fin |
---|
| 875 | $mes = explode('-', $form_state['values']['field_accion_esp_fechai'][0]['value']); |
---|
| 876 | $mes_inicio = 0; |
---|
[2473852] | 877 | $year_inicio = 0; |
---|
[303fae2] | 878 | if (count($mes)) { |
---|
| 879 | $mes_inicio = $mes[1] - 1; |
---|
[2473852] | 880 | $year_inicio = $mes[0]; |
---|
[303fae2] | 881 | } |
---|
| 882 | //obtener la fecha de inicio y fin |
---|
| 883 | $mes = explode('-', $form_state['values']['field_accion_esp_fechaf'][0]['value']); |
---|
| 884 | $mes_final = 0; |
---|
[2473852] | 885 | $year_final = 0; |
---|
[303fae2] | 886 | if (count($mes)) { |
---|
| 887 | $mes_final = $mes[1] - 1; |
---|
[2473852] | 888 | $year_final = $mes[0]; |
---|
[303fae2] | 889 | } |
---|
[2473852] | 890 | //validamos los proyectos plurianuales |
---|
| 891 | if ($form['#esplurianual']) { |
---|
| 892 | //se valida que el anho de inicio sea <= año del proyecto |
---|
| 893 | if ($form['#year_current']['year_current'] < $year_inicio) { |
---|
| 894 | form_set_error('field_accion_esp_fechai', t('El año de la fecha de inicio de la Acción especifica (@year_i) debe ser menor o igual a la fecha de ejecución del proyecto (@year_p)', array('@year_i' => $year_inicio, '@year_p' => $form['#year_current']['year_current']))); |
---|
| 895 | } |
---|
| 896 | elseif ($form['#year_current']['year_current'] > $year_inicio) { |
---|
| 897 | $mes_inicio = 0; |
---|
| 898 | } |
---|
| 899 | if ($form['#year_current']['year_current'] > $year_final) { |
---|
| 900 | form_set_error('field_accion_esp_fechai', t('El año de la fecha de finalización de la Acción especifica (@year_i) debe ser mayor o igual al año de ejecución del proyecto (@year_p)', array('@year_i' => $year_final, '@year_p' => $form['#year_current']['year_current']))); |
---|
| 901 | } |
---|
| 902 | elseif ($form['#year_current']['year_current'] < $year_final) { |
---|
| 903 | $mes_final = 12; |
---|
| 904 | } |
---|
| 905 | } |
---|
| 906 | else { |
---|
| 907 | if ($form['#year_current']['year_current'] != $year_inicio) { |
---|
| 908 | form_set_error('field_accion_esp_fechai', t('El año de la fecha de inicio de la Acción especifica (@year_i) debe ser igual a la fecha de ejecución del proyecto (@year_p)', array('@year_i' => $year_inicio, '@year_p' => $form['#year_current']['year_current']))); |
---|
| 909 | } |
---|
| 910 | if ($form['#year_current']['year_current'] > $year_final) { |
---|
| 911 | form_set_error('field_accion_esp_fechai', t('El año de la fecha de finalización de la Acción especifica (@year_i) debe ser igual al año de ejecución del proyecto (@year_p)', array('@year_i' => $year_final, '@year_p' => $form['#year_current']['year_current']))); |
---|
| 912 | } |
---|
| 913 | } |
---|
| 914 | |
---|
[303fae2] | 915 | if (isset($form_state['values']['field_accion_esp_metaf'])) { |
---|
| 916 | $suma = 0; |
---|
| 917 | for ($i = 0; $i < 12; $i++) { |
---|
| 918 | if ($mes_inicio <= $i && $mes_final >= $i) { |
---|
| 919 | $valor = $i ? 'value_' . $i : 'value'; |
---|
| 920 | $suma += $form_state['values']['field_accion_esp_metaf'][0][$valor]; |
---|
| 921 | } |
---|
| 922 | } |
---|
| 923 | if (!$suma) { |
---|
| 924 | form_set_error('field_accion_esp_metaf', t('La Distribución de la Meta FisÃca de la Acción especifica debe tener al menos un resultado')); |
---|
| 925 | } |
---|
| 926 | $personas = $form['#personas']; |
---|
| 927 | if (count($personas) && isset($personas[$form_state['values']['field_accion_esp_unidadm'][0]['value']])) { |
---|
| 928 | $totalpersonas = $form_state['values']['field_accion_esp_meta_m'][0]['value'] + $form_state['values']['field_accion_esp_meta_f'][0]['value']; |
---|
| 929 | if ($totalpersonas != $suma) { |
---|
| 930 | form_set_error('field_accion_esp_meta_m', t('El total de Distribución de la Meta FisÃca de la Acción especifica debe ser igual a la cantidad de personas')); |
---|
| 931 | } |
---|
| 932 | } |
---|
| 933 | } |
---|
| 934 | //validamos la accion especifica |
---|
| 935 | if (isset($form_state['values']['field_accion_esp_programacion']) && count($form_state['values']['field_accion_esp_programacion'])) { |
---|
| 936 | $sumap = 0; |
---|
| 937 | foreach($form_state['values']['field_accion_esp_programacion'] as $id_programacion => $programacion) { |
---|
| 938 | if (is_numeric($id_programacion)) { |
---|
| 939 | for ($i = 0; $i < 12; $i++) { |
---|
| 940 | if ($mes_inicio <= $i && $mes_final >= $i) { |
---|
| 941 | $valor = $i ? 'value_' . $i : 'value'; |
---|
| 942 | $sumap += (float) $programacion[$valor]; |
---|
| 943 | } |
---|
| 944 | } |
---|
| 945 | } |
---|
| 946 | } |
---|
| 947 | if (!$sumap) { |
---|
| 948 | form_set_error('field_accion_esp_programacion', t('La Programación Financiera de la Acción especifica debe tener al menos un valor')); |
---|
| 949 | } |
---|
| 950 | } |
---|
| 951 | $sumaf = 0; |
---|
| 952 | //validamos el financiamiento |
---|
| 953 | $first_field = FALSE; |
---|
| 954 | if (count($form['#fields_financiamiento'])) { |
---|
| 955 | foreach($form['#fields_financiamiento'] as $field_id) { |
---|
| 956 | $start = (float) $form_state['values'][$field_id][0]['value']; |
---|
| 957 | $start = number_format($start, $form['#format_number']['format_number']['decimals'], '.', ''); |
---|
| 958 | $value = preg_replace('@[^-0-9]@', '', $start); |
---|
| 959 | if ($start && $start != $value) { |
---|
| 960 | form_set_error($field_id, t('Solo números enteros son permitidos en la fuente de financiamiento.')); |
---|
| 961 | } |
---|
| 962 | if ($value < 0) { |
---|
| 963 | form_set_error($field_id, t('Solo números positivos son permitidos en la fuente de financiamiento.')); |
---|
| 964 | } |
---|
| 965 | if (!$first_field) { |
---|
| 966 | $first_field = $field_id; |
---|
| 967 | } |
---|
| 968 | if (isset($form_state['values'][$field_id][0]['value'])) { |
---|
| 969 | $sumaf += $form_state['values'][$field_id][0]['value']; |
---|
| 970 | } |
---|
| 971 | } |
---|
| 972 | } |
---|
[15f3818] | 973 | if ($first_field && $sumaf > $sumap) { |
---|
| 974 | form_set_error($first_field, t('Las fuentes de financiamiento (@f_financiamiento) deben ser menor o igual a la programación presupuestaria (@fuente)', array('@fuente' => number_format($sumap, $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']), '@f_financiamiento' => number_format($sumaf, $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep'])))); |
---|
[303fae2] | 975 | } |
---|
| 976 | //validamos que la suma de la programacion financiera sea + las otras acciones sean inferiores o iguales a la suma total del proyecto |
---|
| 977 | $sumaT = $form['#montos'] +$sumap; |
---|
| 978 | if ($sumaT > $form['#proyecto']->field_proyecto_monto_anual[0]['value']) { |
---|
| 979 | form_set_error('field_accion_esp_programacion', t('La suma de los montos de las acciones especificas (@monto) debe ser menor o igual al monto anual del proyecto (@fuente)', array('@fuente' => number_format($form['#proyecto']->field_proyecto_monto_anual[0]['value'], $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']), '@monto' => number_format($sumaT, $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep'])))); |
---|
| 980 | } |
---|
| 981 | if ($suma_porc == 100 && $sumaT < $form['#proyecto']->field_proyecto_monto_anual[0]['value']) { |
---|
| 982 | form_set_error('field_accion_esp_programacion', t('La suma de los montos de las acciones especificas (@monto) debe ser menor igual al monto anual del proyecto (@fuente) cuando las ponderaciones de las Acciones EspecÃficas sume 100%', array('@fuente' => number_format($form['#proyecto']->field_proyecto_monto_anual[0]['value'], $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']), '@monto' => number_format($sumaT, $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep'])))); |
---|
| 983 | } |
---|
| 984 | elseif($suma_porc < 100 && $sumaT == $form['#proyecto']->field_proyecto_monto_anual[0]['value']) { |
---|
| 985 | form_set_error('field_accion_esp_ponderacion', t('La suma de las ponderaciones de la Acción especifica debe ser menor o igual a 100% (@suma_porc % alcanzado) y el monto por asignar no es suficiente para nuevas Acciones (Monto Asignado: @monto_asignado Bs, Monto del proyecto: @monto_proyecto Bs)', array('@suma_porc' => number_format($suma_porc, $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']), '@monto_asignado' => number_format($sumaT, $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']), '@monto_proyecto' => number_format($form['#proyecto']->field_proyecto_monto_anual[0]['value'], $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep'])))); |
---|
| 986 | } |
---|
[f579d39] | 987 | |
---|
[303fae2] | 988 | } |
---|
| 989 | |
---|
| 990 | /* |
---|
| 991 | * proyectos_operativos_accion_especifica_crear_form_submit |
---|
| 992 | * Guardar accion especifica |
---|
| 993 | */ |
---|
| 994 | function proyectos_operativos_accion_especifica_crear_form_submit($form, &$form_state) { |
---|
| 995 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
| 996 | if ($op == t('Cancelar')) { |
---|
| 997 | drupal_set_message(t('Se cancelo el ingreso de la AE.')); |
---|
| 998 | $form_state['redirect'] = 'proyectosopedit/' . $form['#proyecto']->nid; |
---|
| 999 | return; |
---|
| 1000 | } |
---|
| 1001 | if ($op == t('Terminar')) { |
---|
| 1002 | $form_state['redirect'] = 'proyectosopedit/' . $form['#proyecto']->nid . '/finacieros'; |
---|
| 1003 | return; |
---|
| 1004 | } |
---|
| 1005 | if (module_exists('hs_content_taxonomy')) { |
---|
| 1006 | foreach ($form['#field_info'] as $field_name => $field_info) { |
---|
| 1007 | if ($field_info['widget']['type'] == 'content_taxonomy_hs') { |
---|
| 1008 | // Change format of values to the one Content Taxonomy expects |
---|
| 1009 | if (is_array($form_state['values'][$field_name]['tids'])) { |
---|
| 1010 | $values = array(); |
---|
| 1011 | foreach($form_state['values'][$field_name]['tids'] as $tid) { |
---|
| 1012 | $values[] = array('value' => $tid); |
---|
| 1013 | array_unshift($form_state['values'][$field_name], array('value' => $tid)); |
---|
| 1014 | } |
---|
| 1015 | $form_state['values'][$field_name]['tids'] = $values; |
---|
| 1016 | } |
---|
| 1017 | else { |
---|
| 1018 | $values[] = array('value' => $form_state['values'][$field_name]['tids']); |
---|
| 1019 | array_unshift($form_state['values'][$field_name],array('value' => $form_state['values'][$field_name]['tids'])); |
---|
| 1020 | $form_state['values'][$field_name]['tids'] = $values; |
---|
| 1021 | } |
---|
| 1022 | } |
---|
| 1023 | } |
---|
| 1024 | } |
---|
| 1025 | global $user; |
---|
| 1026 | $field_form = $form['#proyectos_operativos_fields']; |
---|
| 1027 | module_load_include('inc', 'node', 'node.pages'); |
---|
| 1028 | $node_load = $form['#node']; |
---|
| 1029 | //obtener la fecha de inicio y fin |
---|
| 1030 | $mes = explode('-', $form_state['values']['field_accion_esp_fechai'][0]['value']); |
---|
| 1031 | $mes_inicio = 0; |
---|
[2473852] | 1032 | $year_inicio = 0; |
---|
[303fae2] | 1033 | if (count($mes)) { |
---|
| 1034 | $mes_inicio = $mes[1] - 1; |
---|
[2473852] | 1035 | $year_inicio = $mes[0]; |
---|
[303fae2] | 1036 | } |
---|
| 1037 | //obtener la fecha de inicio y fin |
---|
| 1038 | $mes = explode('-', $form_state['values']['field_accion_esp_fechaf'][0]['value']); |
---|
| 1039 | $mes_final = 0; |
---|
[2473852] | 1040 | $year_final = 0; |
---|
[303fae2] | 1041 | if (count($mes)) { |
---|
| 1042 | $mes_final = $mes[1] - 1; |
---|
[2473852] | 1043 | $year_final = $mes[0]; |
---|
| 1044 | } |
---|
| 1045 | if ($form['#year_current']['year_current'] > $year_inicio) { |
---|
| 1046 | $mes_inicio = 0; |
---|
| 1047 | } |
---|
| 1048 | if ($form['#year_current']['year_current'] < $year_final) { |
---|
| 1049 | $mes_final = 12; |
---|
[303fae2] | 1050 | } |
---|
[15f3818] | 1051 | $suma = 0; |
---|
[303fae2] | 1052 | if (isset($form_state['values']['field_accion_esp_metaf'])) { |
---|
| 1053 | for ($i = 0; $i < 12; $i++) { |
---|
| 1054 | $valor = $i ? 'value_' . $i : 'value'; |
---|
| 1055 | if ($mes_inicio <= $i && $mes_final >= $i) { |
---|
| 1056 | $suma += $form_state['values']['field_accion_esp_metaf'][0][$valor]; |
---|
| 1057 | } |
---|
| 1058 | else { |
---|
| 1059 | $form_state['values']['field_accion_esp_metaf'][0][$valor] = 0; |
---|
| 1060 | } |
---|
| 1061 | } |
---|
| 1062 | } |
---|
[15f3818] | 1063 | $sumaep = 0; |
---|
[303fae2] | 1064 | if (isset($form_state['values']['field_accion_esp_programacion'])) { |
---|
| 1065 | foreach($form_state['values']['field_accion_esp_programacion'] as $id => $programacion) { |
---|
| 1066 | for ($i = 0; $i < 12; $i++) { |
---|
| 1067 | $valor = $i ? 'value_' . $i : 'value'; |
---|
| 1068 | if ($mes_inicio <= $i && $mes_final >= $i) { |
---|
[15f3818] | 1069 | $sumaep += $form_state['values']['field_accion_esp_programacion'][$id][$valor]; |
---|
[303fae2] | 1070 | } |
---|
| 1071 | else { |
---|
| 1072 | $form_state['values']['field_accion_esp_programacion'][$id][$valor] = 0; |
---|
| 1073 | } |
---|
| 1074 | } |
---|
| 1075 | } |
---|
| 1076 | } |
---|
[15f3818] | 1077 | //sumamos las fuentes d financiamiento |
---|
| 1078 | $sumaf = 0; |
---|
| 1079 | $first_field = FALSE; |
---|
| 1080 | if (count($form['#fields_financiamiento'])) { |
---|
| 1081 | foreach($form['#fields_financiamiento'] as $field_id) { |
---|
| 1082 | if (isset($form_state['values'][$field_id][0]['value'])) { |
---|
| 1083 | $sumaf += $form_state['values'][$field_id][0]['value']; |
---|
| 1084 | } |
---|
| 1085 | } |
---|
| 1086 | } |
---|
| 1087 | |
---|
[303fae2] | 1088 | $form_values = $form_state['values']; |
---|
| 1089 | //cambiar |
---|
| 1090 | $node_load->title = t('Acción EspecÃfica del proyecto @nombreproyecto', array('@nombreproyecto' => $form['#proyecto']->title)); |
---|
| 1091 | if (is_array($field_form) && count($field_form)) { |
---|
| 1092 | foreach ($field_form as $field_id) { |
---|
| 1093 | if (isset($form_values[$field_id]) && is_array($form_values[$field_id])) { |
---|
| 1094 | foreach($form_values[$field_id] as $id => $value) { |
---|
| 1095 | if (is_numeric($id) && isset($form_values[$field_id][$id]['_error_element'])) { |
---|
| 1096 | unset($form_values[$field_id][$id]['_error_element']); |
---|
| 1097 | } |
---|
| 1098 | } |
---|
| 1099 | $node_load->{$field_id} = $form_values[$field_id]; |
---|
| 1100 | } |
---|
| 1101 | } |
---|
| 1102 | } |
---|
[9c32b86] | 1103 | |
---|
| 1104 | |
---|
[15f3818] | 1105 | $node_load->field_accion_esp_monto_finan[0]['value'] = $sumaep - $sumaf; |
---|
| 1106 | $node_load->field_accion_esp_total_fuent[0]['value'] = $sumaf; |
---|
| 1107 | $node_load->field_accion_esp_total_meta[0]['value'] = $suma; |
---|
[f579d39] | 1108 | $form['#proyecto']->field_proyecto_esp_monto_finan[0]['value'] = $form['#montos_afinan'] + $node_load->field_accion_esp_monto_finan[0]['value']; |
---|
| 1109 | $form['#proyecto']->field_proyecto_esp_total_fuent[0]['value'] = $form['#montos_financiamiento'] + $node_load->field_accion_esp_total_fuent[0]['value']; |
---|
| 1110 | |
---|
[303fae2] | 1111 | $nid = FALSE; |
---|
| 1112 | if ($node_load->nid) { |
---|
| 1113 | $nid = TRUE; |
---|
| 1114 | $texto = t('Modificada la Acción especifica del proyecto'); |
---|
| 1115 | $node_load->log = $texto; |
---|
| 1116 | drupal_set_message($texto); |
---|
| 1117 | } |
---|
| 1118 | else { |
---|
| 1119 | //se agrega el enlace al proyecto |
---|
| 1120 | $node_load->uid = $user->uid; |
---|
| 1121 | $node_load->field_accion_esp_proyecto = array(); |
---|
| 1122 | $node_load->field_accion_esp_proyecto[] = array('nid' => $form['#proyecto']->nid); |
---|
| 1123 | $node_load->field_accion_esp_ente = array(); |
---|
| 1124 | $node_load->field_accion_esp_ente[] = array('nid' => $form['#proyecto']->field_proyecto_ente[0]['nid']); |
---|
| 1125 | $texto = t('Agregada la Acción especifica del proyecto'); |
---|
| 1126 | $node_load->log = $texto; |
---|
| 1127 | drupal_set_message($texto); |
---|
| 1128 | } |
---|
| 1129 | $node_load->revision = 1; |
---|
| 1130 | node_save($node_load); |
---|
[f579d39] | 1131 | //Se agregan los totales a financiar y fuentes de financiamiento |
---|
[303fae2] | 1132 | if (!$nid) { |
---|
| 1133 | $proyecto = $form['#proyecto']; |
---|
| 1134 | if (!$proyecto->field_proyecto_accion_esp[0]['nid']) { |
---|
| 1135 | $proyecto->field_proyecto_accion_esp = array(); |
---|
| 1136 | } |
---|
| 1137 | $proyecto->field_proyecto_accion_esp[] = array('nid' => $node_load->nid); |
---|
| 1138 | $proyecto->revision = 1; |
---|
| 1139 | $proyecto->log = t('Agregada Acción especifica del proyecto'); |
---|
| 1140 | node_save($proyecto); |
---|
| 1141 | } |
---|
[a0cf94c] | 1142 | else { |
---|
| 1143 | $proyecto = $form['#proyecto']; |
---|
| 1144 | $proyecto->revision = 1; |
---|
| 1145 | $proyecto->log = t('Modificada la Acción especifica del proyecto'); |
---|
| 1146 | node_save($proyecto); |
---|
| 1147 | } |
---|
[303fae2] | 1148 | if (!$_REQUEST['destination']) { |
---|
| 1149 | // add redirect |
---|
| 1150 | $form_state['redirect'] = 'proyectosopedit/' . $form['#proyecto']->nid . '/ae'; |
---|
| 1151 | } |
---|
[f579d39] | 1152 | |
---|
[303fae2] | 1153 | } |
---|
| 1154 | |
---|
| 1155 | /** |
---|
| 1156 | * @ingroup themeable |
---|
| 1157 | * @see proyectos_operativos_accion_especifica_crear_form |
---|
| 1158 | */ |
---|
| 1159 | function theme_proyectos_operativos_accion_especifica_crear_form($form) { |
---|
| 1160 | $output = ''; |
---|
| 1161 | if (!$form['#proyecto_completed']) { |
---|
| 1162 | $output .= '<div id="mensaje-mostrar" class="mensaje mensaje-mostrar" style="color:red;font-weight: bold;">' . $form['#mensaje_mostrar'] . '</div>'; |
---|
| 1163 | $output .= '<fieldset><legend>' . t('Definición de la Acción Especifica') . '</legend>' . drupal_render($form['field_accion_titulo']) . drupal_render($form['field_accion_esp_fechai']) . drupal_render($form['field_accion_esp_fechaf']);$output .= drupal_render($form['field_accion_esp_ejecutor']) . drupal_render($form['field_accion_esp_bien']) . '</fieldset>'; |
---|
| 1164 | $output .= '<fieldset><legend>' . t('Distribución de la Meta Fisica de la acción Especifica') . '</legend>'; |
---|
| 1165 | $output .= drupal_render($form['field_accion_esp_unidadm']); |
---|
| 1166 | if (isset($form['field_accion_esp_meta_m']) && $form['field_accion_esp_meta_f']) { |
---|
| 1167 | $output .= '<div id="meta-unidm-pers"><table id="unidm-persona" style="width:400px"><tr><th>' . $form['field_accion_esp_meta_m']['#title'] . '</th><th>' . $form['field_accion_esp_meta_f']['#title'] . '</th><th>' . t('Total') . '</th></tr><tr>'; |
---|
| 1168 | $form['field_accion_esp_meta_m'][0]['value']['#title'] = ''; |
---|
| 1169 | $form['field_accion_esp_meta_f'][0]['value']['#title'] = ''; |
---|
| 1170 | $total = $form['field_accion_esp_meta_m'][0]['#value']['value'] + $form['field_accion_esp_meta_f'][0]['#value']['value']; |
---|
| 1171 | $output .= '<td>' . drupal_render($form['field_accion_esp_meta_m']) . '</td>'; |
---|
| 1172 | $output .= '<td>' . drupal_render($form['field_accion_esp_meta_f']) . '</td>'; |
---|
| 1173 | $output .= '<td style="width:100px; text-align: center"><div class="unidad_personas_total">' . number_format($total, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']) . '</div></td></tr></table></div>'; |
---|
| 1174 | } |
---|
| 1175 | $output .= drupal_render($form['field_accion_esp_ponderacion']); |
---|
| 1176 | $output .= drupal_render($form['field_accion_esp_metaf']); |
---|
| 1177 | $output .= '</fieldset>'; |
---|
| 1178 | $output .= drupal_render($form['distribucion']); |
---|
| 1179 | $output .= '<fieldset><legend>' . t('Programación Financiera de la Acción') . '</legend>' . drupal_render($form['field_accion_esp_programacion']); |
---|
| 1180 | $ftypes = array( |
---|
| 1181 | 'tid' => t('Account'), |
---|
| 1182 | 'value' => t('Ene'), |
---|
| 1183 | 'value_1' => t('Feb'), |
---|
| 1184 | 'value_2' => t('Mar'), |
---|
| 1185 | 'value_3' => t('Abr'), |
---|
| 1186 | 'value_4' => t('May'), |
---|
| 1187 | 'value_5' => t('Jun'), |
---|
| 1188 | 'value_6' => t('Jul'), |
---|
| 1189 | 'value_7' => t('Aug'), |
---|
| 1190 | 'value_8' => t('Sep'), |
---|
| 1191 | 'value_9' => t('Oct'), |
---|
| 1192 | 'value_10' => t('Nov'), |
---|
| 1193 | 'value_11' => t('Dic'), |
---|
| 1194 | ); |
---|
| 1195 | $output .= '<div style="width:2250px">'; |
---|
| 1196 | $i = -1; |
---|
| 1197 | foreach ($ftypes as $ftype => $label) { |
---|
| 1198 | if($ftype != 'tid') { |
---|
| 1199 | $output .= '<div class = "field_accion_esp_programacion_m' . $i . '_field_total field_accion_esp_programacion_totales" style = "width:143px;float:left;margin-left:10px; border: 1px solid #D5D5D5;text-align:center;overflow:auto">0</div>'; |
---|
| 1200 | } |
---|
| 1201 | else { |
---|
| 1202 | $output .= '<div style = "width:180px;float:left;margin-left:5px;text-align:right"><b>' . t('TOTAL') . '</b></div>'; |
---|
| 1203 | } |
---|
| 1204 | $i++; |
---|
| 1205 | } |
---|
| 1206 | $output .= '<div class = "field_accion_esp_programacion_dato_field_total" style = "width:143px;float:left;margin-left:10px; border: 1px solid #D5D5D5;text-align:center;overflow:auto">0</div>'; |
---|
| 1207 | $output .= '</div></fieldset>'; |
---|
| 1208 | $rows = array(); |
---|
| 1209 | $row = array(); |
---|
| 1210 | $row1 = array(); |
---|
| 1211 | $cantidad_campos = count($form['#arreglo_financiamiento']); |
---|
| 1212 | if (is_array($form['#arreglo_financiamiento']) && count($form['#arreglo_financiamiento'])) { |
---|
| 1213 | foreach ($form['#arreglo_financiamiento'] as $id => $macro) { |
---|
| 1214 | $row[] = array('data' => drupal_render($form[$id]), ); |
---|
| 1215 | $row1[] = array('data' => drupal_render($form['total_' . $id]), ); |
---|
| 1216 | } |
---|
| 1217 | $rows[] = $row; |
---|
| 1218 | $rows[] = $row1; |
---|
| 1219 | $row = array(); |
---|
[de9b283] | 1220 | $row[] = array('data' => '<b>' . t('TOTAL FUENTES DE FINANCIAMIENTO') . ': </b>' . drupal_render($form['total_financiamiento']), 'colspan' => $cantidad_campos, 'align' => 'center'); |
---|
[303fae2] | 1221 | $rows[] = $row; |
---|
[2473852] | 1222 | $output .= '<fieldset class="width-fieldset"><legend>' . t('Fuentes de Financiamiento (Bs.)') . '</legend>' . theme('table', array(), $rows) . '</fieldset>'; |
---|
[303fae2] | 1223 | } |
---|
[a0cf94c] | 1224 | $localizacion = variable_get('proyectos_operativos_muestra_accion_esp', TRUE); |
---|
[303fae2] | 1225 | if ($localizacion) { |
---|
| 1226 | $output .= '<fieldset><legend>' . t('Localización Geográfica') . '</legend>'; |
---|
| 1227 | $output .= drupal_render($form['field_accion_esp_localizacion']) . drupal_render($form['field_accion_esp_latitud']) . drupal_render($form['field_accion_esp_longitud']); |
---|
| 1228 | $output .= '</fieldset>'; |
---|
| 1229 | $output .= drupal_render($form); |
---|
| 1230 | } |
---|
| 1231 | } |
---|
| 1232 | $header = array(); |
---|
| 1233 | $cab = 6; |
---|
| 1234 | $header[] = array('data' => t('Nro')); |
---|
| 1235 | $header[] = array('data' => t('Nombre')); |
---|
| 1236 | $header[] = array('data' => t('Fecha de inicio')); |
---|
| 1237 | $header[] = array('data' => t('Fecha de Fin')); |
---|
| 1238 | $header[] = array('data' => t('%')); |
---|
| 1239 | $header[] = array('data' => t('Acción')); |
---|
| 1240 | $rows = array(); |
---|
| 1241 | $i = 1; |
---|
| 1242 | if (count($form['#acciones_especificas'])) { |
---|
| 1243 | $suma = 0; |
---|
| 1244 | foreach($form['#acciones_especificas'] as $accion) { |
---|
| 1245 | if (isset($accion->nid)) { |
---|
| 1246 | $row = array(); |
---|
| 1247 | $row[] = array('data' => $i,); |
---|
| 1248 | $row[] = array('data' => $accion->titulo_asignado,); |
---|
| 1249 | //Se cambia el formato de la fecha |
---|
| 1250 | $fecha = explode(' ', $accion->field_accion_esp_fechai[0]['value']); |
---|
| 1251 | $formato = explode('-', $fecha[0]); |
---|
| 1252 | $row[] = array('data' => $formato[2] . '/' . $formato[1] . '/' . $formato[0],); |
---|
| 1253 | //Se cambia el formato de la fecha |
---|
| 1254 | $fecha = explode(' ', $accion->field_accion_esp_fechaf[0]['value']); |
---|
| 1255 | $formato = explode('-', $fecha[0]); |
---|
| 1256 | $row[] = array('data' => $formato[2] . '/' . $formato[1] . '/' . $formato[0],); |
---|
| 1257 | $suma += $accion->field_accion_esp_ponderacion[0]['value']; |
---|
| 1258 | $row[] = array('data' => $accion->field_accion_esp_ponderacion[0]['value'],); |
---|
| 1259 | $links = array(); |
---|
| 1260 | $links[] = l(t('Modificar'), 'proyectosopedit/' . $form['#proyecto']->nid . '/ae/' . $accion->nid . '/edit'); |
---|
| 1261 | $links[] = l(t('Eliminar'), 'proyectosopedit/' . $form['#proyecto']->nid . '/ae/' . $accion->nid . '/remove'); |
---|
| 1262 | $row[] = array('data' => theme('item_list', $links),); |
---|
| 1263 | $rows[] = $row; |
---|
| 1264 | $i++; |
---|
| 1265 | } |
---|
| 1266 | } |
---|
| 1267 | } |
---|
| 1268 | if (count($rows)) { |
---|
| 1269 | $output .= theme('table', $header, $rows); |
---|
| 1270 | } |
---|
| 1271 | //no mostrar el formulario si ya se alcanzo lo asignado |
---|
| 1272 | if ($form['#proyecto_completed']) { |
---|
| 1273 | $output .= drupal_render($form); |
---|
| 1274 | } |
---|
| 1275 | return $output; |
---|
| 1276 | } |
---|
[f579d39] | 1277 | |
---|