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