[1819be7] | 1 | <?php |
---|
| 2 | /** |
---|
| 3 | * Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana |
---|
| 4 | * @file situacion_actual.module |
---|
| 5 | * Drupal part Module to code ente planificador module |
---|
| 6 | * Copyright 2011 Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana (CENDITEL) |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or modify |
---|
| 9 | * it under the terms of the GNU General Public License as published by |
---|
| 10 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | * (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 21 | * |
---|
| 22 | * @author Cenditel Merida - Msc. Juan Vizcarrondo |
---|
| 23 | * @date 2011-10-27 // (año-mes-dia) |
---|
| 24 | * @version 0.2 // (0.2) |
---|
| 25 | * |
---|
| 26 | */ |
---|
| 27 | |
---|
| 28 | /* |
---|
| 29 | * Implementation of hook_ente_procesos_alter() |
---|
| 30 | */ |
---|
| 31 | function proyecto_estrategico_ente_procesos_alter(&$procesos, $type) { |
---|
| 32 | if ($type == 'status') { |
---|
| 33 | $procesos['proyecto_estrategico'] = array( |
---|
| 34 | 'title' => t('Gestión de proyectos estratégicos institucional.'), |
---|
| 35 | 'description' => t('Gestión de Información de proyectos estratégicos institucional del actor planificador.'), |
---|
| 36 | 'weight' => -9, |
---|
| 37 | ); |
---|
| 38 | } |
---|
| 39 | else { |
---|
| 40 | $procesos['proyecto_estrategico_proyectos'] = array( |
---|
| 41 | 'title' => t('Registro de proyectos estratégicos institucionales.'), |
---|
| 42 | 'description' => t('Registro de proyectos estratégicos institucionales.'), |
---|
| 43 | 'message' => 'Se podrá registrar y/o modificar los proceso de los proyectos estratégicos desde %fecha hasta la fecha %fecha1', |
---|
| 44 | 'message_expire' => 'Registrar y/o modificar los proceso de los proyectos estratégicos no se encuentra disponible, se podra realizar desde %fecha hasta la fecha %fecha1)', |
---|
| 45 | 'weight' => 9, |
---|
| 46 | 'proceso' => 'proyecto_estrategico', |
---|
| 47 | ); |
---|
| 48 | } |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | /* |
---|
| 53 | * Implementation of proyectos_direccionales_status_planificacion_proyectos() |
---|
| 54 | */ |
---|
| 55 | function proyecto_estrategico_status_planificacion_proyecto_estrategico($ente_planificador, $tipo = 2) { |
---|
| 56 | $ente = node_load($ente_planificador); |
---|
| 57 | $mi_fecha = ente_planificador_user_acceso_proceso('proyecto_estrategico_proyectos', $tipo); |
---|
| 58 | $proyectos = proyecto_estrategico_obtiene_proyectos($ente, $mi_fecha); |
---|
| 59 | //se verifica que exista la planificacion, si existe al menos los datos de familiarizacion fueron ingresados |
---|
| 60 | $proyecto_estrategico_status['proyecto_estrategico_proyectos']['value'] = count($proyectos) ? 1 : 0; |
---|
| 61 | $proyecto_estrategico_status['proyecto_estrategico_proyectos']['title'] = t('Gestión de proyectos estratégicos institucional'); |
---|
| 62 | $proyecto_estrategico_status['proyecto_estrategico_proyectos']['link'] = 'planificacion/' . $ente_planificador . '/proyecto_estrategico'; |
---|
| 63 | $proyecto_estrategico_status['proyecto_estrategico_proyectos']['mylink'] = 'mi_ente_planificador/planificacion/proyecto_estrategico'; |
---|
| 64 | $proyecto_estrategico_status['proyecto_estrategico_proyectos']['weight'] = -10; |
---|
| 65 | return $proyecto_estrategico_status; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | /* |
---|
| 69 | * Implementation of hook_menu() |
---|
| 70 | */ |
---|
| 71 | function proyecto_estrategico_menu() { |
---|
| 72 | $items = array(); |
---|
| 73 | $items['planificacion/%ente_planificador_menu/proyecto_estrategico'] = array( |
---|
| 74 | 'title' => t('Proyectos estratégicos'), |
---|
| 75 | 'page callback' => 'proyecto_estrategico_listar_proyectos', |
---|
| 76 | 'page arguments' => array(1), |
---|
| 77 | 'access arguments' => array('ver planificador'), |
---|
| 78 | 'weight' => -7, |
---|
| 79 | 'type' => MENU_LOCAL_TASK, |
---|
| 80 | ); |
---|
| 81 | $items['planificacion/%ente_planificador_menu/proyecto_estrategico/ver'] = array( |
---|
| 82 | 'title' => t('Proyectos estratégicos'), |
---|
| 83 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
---|
| 84 | 'weight' => -10 |
---|
| 85 | ); |
---|
| 86 | $items['planificacion/%ente_planificador_menu/proyecto_estrategico/registrar'] = array( |
---|
| 87 | 'title' => t('Registrar proyecto estratégico'), |
---|
| 88 | 'page callback' => 'drupal_get_form', |
---|
| 89 | 'page arguments' => array('proyecto_estrategico_datos_basicos_form', 1), |
---|
| 90 | 'access callback' => 'proyecto_estrategico_usuario_crea_proyectos', |
---|
| 91 | 'access arguments' => array(1), |
---|
| 92 | 'weight' => -9, |
---|
| 93 | 'type' => MENU_LOCAL_TASK, |
---|
| 94 | ); |
---|
| 95 | $items['planificacion/%ente_planificador_menu/proyecto_estrategico/%proyecto_estrategico_menu'] = array( |
---|
| 96 | 'title' => t('Ver proyecto estratégico'), |
---|
| 97 | 'page callback' => 'proyecto_estrategico_mostrar_proyectos', |
---|
| 98 | 'page arguments' => array(1, 3), |
---|
| 99 | 'access arguments' => array('ver planificador'), |
---|
| 100 | 'weight' => -7, |
---|
| 101 | 'type' => MENU_LOCAL_TASK, |
---|
| 102 | ); |
---|
| 103 | $items['planificacion/%ente_planificador_menu/proyecto_estrategico/%proyecto_estrategico_menu/ver'] = array( |
---|
| 104 | 'title' => t('Proyecto estratégico'), |
---|
| 105 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
---|
| 106 | 'weight' => -10 |
---|
| 107 | ); |
---|
| 108 | |
---|
| 109 | $items['planificacion/%ente_planificador_menu/proyecto_estrategico/%proyecto_estrategico_menu/datos_basicos'] = array( |
---|
| 110 | 'title' => t('Datos básicos'), |
---|
| 111 | 'page callback' => 'drupal_get_form', |
---|
| 112 | 'page arguments' => array('proyecto_estrategico_datos_basicos_form', 1, 3), |
---|
| 113 | 'access callback' => 'proyecto_estrategico_usuario_tiene_proyectos', |
---|
| 114 | 'access arguments' => array(1, 3), |
---|
| 115 | 'weight' => -9, |
---|
| 116 | 'type' => MENU_LOCAL_TASK, |
---|
| 117 | ); |
---|
| 118 | $items['planificacion/%ente_planificador_menu/proyecto_estrategico/%proyecto_estrategico_menu/planes_politicas'] = array( |
---|
| 119 | 'title' => t('Planes y polÃticas'), |
---|
| 120 | 'page callback' => 'drupal_get_form', |
---|
| 121 | 'page arguments' => array('proyecto_estrategico_planes_politicas_form', 1, 3), |
---|
| 122 | 'access callback' => 'proyecto_estrategico_usuario_tiene_proyectos', |
---|
| 123 | 'access arguments' => array(1, 3), |
---|
| 124 | 'weight' => -5, |
---|
| 125 | 'type' => MENU_LOCAL_TASK, |
---|
| 126 | ); |
---|
| 127 | $items['planificacion/%ente_planificador_menu/proyecto_estrategico/%proyecto_estrategico_menu/objetivos'] = array( |
---|
| 128 | 'title' => t('objetivos estratégicos'), |
---|
[44f67f8] | 129 | 'page callback' => 'proyecto_estrategico_mostrar_objetivos', |
---|
| 130 | 'page arguments' => array(1, 3), |
---|
[1819be7] | 131 | 'access callback' => 'proyecto_estrategico_usuario_tiene_proyectos', |
---|
| 132 | 'access arguments' => array(1, 3), |
---|
| 133 | 'weight' => -8, |
---|
| 134 | 'type' => MENU_LOCAL_TASK, |
---|
| 135 | ); |
---|
| 136 | $items['planificacion/%ente_planificador_menu/proyecto_estrategico/%proyecto_estrategico_menu/objetivos/registrar'] = array( |
---|
| 137 | 'title' => t('Registrar objetivo estratégico'), |
---|
| 138 | 'page callback' => 'drupal_get_form', |
---|
| 139 | 'page arguments' => array('proyecto_estrategico_objetivos_estrategicos_registrar_form', 1, 3), |
---|
| 140 | 'access callback' => 'proyecto_estrategico_usuario_tiene_proyectos', |
---|
| 141 | 'access arguments' => array(1, 3), |
---|
| 142 | 'weight' => -8, |
---|
| 143 | 'type' => MENU_LOCAL_TASK, |
---|
| 144 | ); |
---|
| 145 | |
---|
| 146 | $items['planificacion/%ente_planificador_menu/proyecto_estrategico/%proyecto_estrategico_menu/objetivos/%proyecto_objetivos_menu/modificar'] = array( |
---|
| 147 | 'title' => t('Modificar objetivo estratégico'), |
---|
| 148 | 'page callback' => 'drupal_get_form', |
---|
| 149 | 'page arguments' => array('proyecto_estrategico_objetivos_estrategicos_registrar_form', 1, 3, 5), |
---|
| 150 | 'access callback' => 'proyecto_estrategico_usuario_tiene_objetivos_estrategicos', |
---|
| 151 | 'access arguments' => array(1, 3), |
---|
| 152 | 'weight' => -8, |
---|
| 153 | 'type' => MENU_CALLBACk, |
---|
| 154 | ); |
---|
| 155 | $items['planificacion/%ente_planificador_menu/proyecto_estrategico/%proyecto_estrategico_menu/objetivos/%proyecto_objetivos_menu/eliminar'] = array( |
---|
| 156 | 'title' => t('Eliminar objetivo estratégico'), |
---|
| 157 | 'page callback' => 'drupal_get_form', |
---|
| 158 | 'page arguments' => array('proyecto_estrategico_objetivos_estrategicos_eliminar_form', 1, 3, 5), |
---|
| 159 | 'access callback' => 'proyecto_estrategico_usuario_tiene_objetivos_estrategicos', |
---|
| 160 | 'access arguments' => array(1, 3), |
---|
| 161 | 'weight' => -8, |
---|
| 162 | 'type' => MENU_CALLBACk, |
---|
| 163 | ); |
---|
| 164 | return $items; |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | /* |
---|
| 168 | * Implementation of hook_perm |
---|
| 169 | */ |
---|
| 170 | function proyecto_estrategico_perm() { |
---|
| 171 | return array( |
---|
| 172 | 'editar proyectos estrategicos de mi ente', |
---|
| 173 | ); |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | /** |
---|
| 177 | * Implementation of proyecto_estrategico_menu_load(). |
---|
| 178 | * Menu loader callback. Load a proyecto estrategico. |
---|
| 179 | */ |
---|
| 180 | function proyecto_estrategico_menu_load($proyecto_estrategico_menu = 0) { |
---|
| 181 | global $user; |
---|
| 182 | $proyecto_estrategico = FALSE; |
---|
| 183 | if($proyecto_estrategico_menu && is_numeric($proyecto_estrategico_menu)) { |
---|
| 184 | $proyecto_estrategico = node_load($proyecto_estrategico_menu); |
---|
| 185 | } |
---|
| 186 | if (!$proyecto_estrategico->status || $proyecto_estrategico->type != 'proyecto_estrategico' || $proyecto_estrategico->field_estrategico_ente[0]['nid'] != arg(1)) { |
---|
| 187 | $proyecto_estrategico = FALSE; |
---|
| 188 | } |
---|
| 189 | return $proyecto_estrategico; |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | /** |
---|
| 193 | * Implementation of proyecto_objetivos_menu_load(). |
---|
| 194 | * Menu loader callback. Load a proyecto estrategico. |
---|
| 195 | */ |
---|
| 196 | function proyecto_objetivos_menu_load($proyecto_estrategico_objetivos_menu = 0) { |
---|
| 197 | global $user; |
---|
| 198 | $objetivo_estrategico = FALSE; |
---|
| 199 | if($proyecto_estrategico_objetivos_menu && is_numeric($proyecto_estrategico_objetivos_menu)) { |
---|
| 200 | $proyecto_estrategico_objetivos = node_load($proyecto_estrategico_objetivos_menu); |
---|
| 201 | $proyecto_estrategico = FALSE; |
---|
| 202 | if (isset($proyecto_estrategico_objetivos->field_objetivo_proyecto_estra[0]['nid']) && $proyecto_estrategico_objetivos->field_objetivo_proyecto_estra[0]['nid']) { |
---|
| 203 | $proyecto_estrategico = node_load($proyecto_estrategico_objetivos->field_objetivo_proyecto_estra[0]['nid']); |
---|
| 204 | } |
---|
| 205 | if (!$proyecto_estrategico_objetivos->status || !$proyecto_estrategico->status || $proyecto_estrategico->type != 'proyecto_estrategico' || $proyecto_estrategico_objetivos->type != 'objetivos_estrategicos' || $proyecto_estrategico_objetivos->field_objetivo_ente[0]['nid'] != arg(1)) { |
---|
| 206 | $proyecto_estrategico = FALSE; |
---|
| 207 | } |
---|
| 208 | } |
---|
| 209 | return $proyecto_estrategico_objetivos; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | /* |
---|
[44f67f8] | 213 | * Implementation of proyecto_estrategico_usuario_tiene_proyectos() |
---|
| 214 | */ |
---|
[1819be7] | 215 | function proyecto_estrategico_usuario_tiene_proyectos($ente_planificador, $proyecto_estrategico) { |
---|
| 216 | global $user; |
---|
| 217 | $ente = usuario_tiene_ente($user->uid); |
---|
| 218 | $accesso = proyecto_estrategico_obtiene_acceso_proceso('proyecto_estrategico_proyectos', $ente_planificador, $ente); |
---|
| 219 | return ($proyecto_estrategico->nid && $accesso); |
---|
| 220 | } |
---|
| 221 | |
---|
[44f67f8] | 222 | /* |
---|
| 223 | * Implementation of proyecto_estrategico_usuario_crea_proyectos() |
---|
| 224 | */ |
---|
[1819be7] | 225 | function proyecto_estrategico_usuario_crea_proyectos($ente_planificador) { |
---|
| 226 | global $user; |
---|
| 227 | $ente = usuario_tiene_ente($user->uid); |
---|
| 228 | $accesso = proyecto_estrategico_obtiene_acceso_proceso('proyecto_estrategico_proyectos', $ente_planificador, $ente); |
---|
| 229 | return $accesso; |
---|
| 230 | } |
---|
| 231 | |
---|
[44f67f8] | 232 | /* |
---|
| 233 | * Implementation of proyecto_estrategico_usuario_tiene_objetivos_estrategicos() |
---|
| 234 | */ |
---|
[1819be7] | 235 | function proyecto_estrategico_usuario_tiene_objetivos_estrategicos($ente_planificador, $objetivo_estrategico) { |
---|
| 236 | global $user; |
---|
| 237 | $ente = usuario_tiene_ente($user->uid); |
---|
| 238 | $accesso = proyecto_estrategico_obtiene_acceso_proceso('proyecto_estrategico_proyectos', $ente_planificador, $ente); |
---|
| 239 | return ($objetivo_estrategico->nid && $accesso); |
---|
| 240 | } |
---|
| 241 | |
---|
[44f67f8] | 242 | /* |
---|
| 243 | * Implementation of proyecto_estrategico_obtiene_acceso_proceso() |
---|
| 244 | */ |
---|
[1819be7] | 245 | function proyecto_estrategico_obtiene_acceso_proceso($tipo_plan, $ente_planificador, $user_ente = NULL){ |
---|
| 246 | $current_time = time(); |
---|
| 247 | $accesso = FALSE; |
---|
| 248 | if (isset($ente_planificador->tipo) && $ente_planificador->nid && is_numeric($ente_planificador->nid) && isset($ente_planificador->type) && $ente_planificador->type == 'ente_planificador') { |
---|
| 249 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador->tipo); |
---|
| 250 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
| 251 | if ((user_access('admin planificador') || ($user_ente->nid == $ente_planificador->nid && user_access('editar proyectos estrategicos de mi ente')))) { |
---|
| 252 | $accesso = TRUE; |
---|
| 253 | } |
---|
| 254 | } |
---|
| 255 | } |
---|
| 256 | return $accesso; |
---|
| 257 | } |
---|
| 258 | |
---|
[44f67f8] | 259 | /* |
---|
| 260 | * Implementation of proyecto_estrategico_obtiene_datos_objetivos() |
---|
| 261 | */ |
---|
[1819be7] | 262 | function proyecto_estrategico_obtiene_datos_objetivos($ente_planificador, $proyecto) { |
---|
| 263 | $objetivos = array(); |
---|
| 264 | // leemos las funciones |
---|
| 265 | $sql_query = "SELECT sap.nid FROM {content_type_objetivos_estrategicos} AS sap INNER JOIN {node} AS n ON sap.nid = n.nid AND sap.vid = n.vid WHERE sap.field_objetivo_ente_nid = %d AND sap.field_objetivo_proyecto_estra_nid = %d AND n.status > 0"; |
---|
| 266 | $sql_variables = array(); |
---|
| 267 | $sql_variables[] = $ente_planificador->nid; |
---|
| 268 | $sql_variables[] = $proyecto->nid; |
---|
| 269 | $result = db_query($sql_query, $sql_variables); |
---|
| 270 | while($objetivo = db_fetch_object($result)) { |
---|
| 271 | $objetivo_load = node_load($objetivo->nid); |
---|
| 272 | $objetivos[$objetivo_load->nid] = $objetivo_load; |
---|
| 273 | } |
---|
| 274 | return $objetivos; |
---|
| 275 | } |
---|
| 276 | |
---|
[44f67f8] | 277 | /* |
---|
| 278 | * Implementation of proyecto_estrategico_obtiene_proyectos() |
---|
| 279 | */ |
---|
[1819be7] | 280 | function proyecto_estrategico_obtiene_proyectos($ente_planificador, $fecha) { |
---|
| 281 | $proyectos = array(); |
---|
| 282 | // leemos las funciones |
---|
| 283 | $sql_query = "SELECT sap.nid FROM {content_type_proyecto_estrategico} AS sap INNER JOIN {node} AS n ON sap.nid = n.nid AND sap.vid = n.vid WHERE sap.field_estrategico_ente_nid = %d AND n.status > 0"; |
---|
| 284 | $sql_variables = array(); |
---|
| 285 | $sql_variables[] = $ente_planificador->nid; |
---|
| 286 | $result = db_query($sql_query, $sql_variables); |
---|
| 287 | while($proyecto = db_fetch_object($result)) { |
---|
| 288 | $proyecto_load = node_load($proyecto->nid); |
---|
| 289 | $proyectos[$proyecto_load->nid] = $proyecto_load; |
---|
| 290 | } |
---|
| 291 | return $proyectos; |
---|
| 292 | } |
---|
| 293 | |
---|
[44f67f8] | 294 | /* |
---|
| 295 | * Implementation of proyecto_estrategico_listar_proyectos() |
---|
| 296 | */ |
---|
[1819be7] | 297 | function proyecto_estrategico_listar_proyectos($ente_planificador) { |
---|
[44f67f8] | 298 | global $user; |
---|
[1819be7] | 299 | $tipo_plan = 'proyecto_estrategico_proyectos'; |
---|
| 300 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador->tipo); |
---|
| 301 | $current_time = time(); |
---|
| 302 | $fecha = FALSE; |
---|
| 303 | $ente = usuario_tiene_ente($user->uid); |
---|
| 304 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
| 305 | $fecha = TRUE; |
---|
| 306 | } |
---|
| 307 | if (!$fecha) { |
---|
| 308 | muestra_mensaje($tipo_plan, $ente_planificador->tipo); |
---|
| 309 | } |
---|
| 310 | else { |
---|
| 311 | if ($ente->nid == $ente_planificador->nid) { |
---|
[44f67f8] | 312 | $fecha = TRUE; |
---|
[1819be7] | 313 | muestra_mensaje($tipo_plan, $ente_planificador->tipo, 0); |
---|
| 314 | } |
---|
| 315 | elseif (!user_access('admin planificador')) { |
---|
| 316 | $fecha = FALSE; |
---|
| 317 | } |
---|
| 318 | } |
---|
| 319 | $output = ''; |
---|
[44f67f8] | 320 | $proyectos = proyecto_estrategico_obtiene_proyectos($ente_planificador, $mi_fecha); |
---|
[1819be7] | 321 | $headers_table = array(); |
---|
| 322 | $headers_table[] = array( |
---|
| 323 | 'data' => t('Código del Proyecto'), |
---|
| 324 | ); |
---|
| 325 | $headers_table[] = array( |
---|
| 326 | 'data' => t('Proyecto'), |
---|
| 327 | ); |
---|
| 328 | $headers_table[] = array( |
---|
| 329 | 'data' => t('Producto del proyecto'), |
---|
| 330 | ); |
---|
| 331 | $headers_table[] = array( |
---|
| 332 | 'data' => t('Lapso de ejecución'), |
---|
| 333 | ); |
---|
| 334 | $headers_table[] = array( |
---|
| 335 | 'data' => t('Monto total del proyecto'), |
---|
| 336 | ); |
---|
| 337 | $count_headers_table = count($headers_table); |
---|
| 338 | if ($fecha) { |
---|
| 339 | $count_headers_table += 4; |
---|
| 340 | $headers_table[] = array( |
---|
| 341 | 'data' => t('Operación'), |
---|
| 342 | 'colspan' => '4' |
---|
| 343 | ); |
---|
| 344 | } |
---|
| 345 | $rows = array(); |
---|
| 346 | if (is_array($proyectos) && count($proyectos)) { |
---|
| 347 | foreach($proyectos as $proyecto_id => $proyecto_value) { |
---|
| 348 | $row = array(); |
---|
| 349 | //Código del Proyecto |
---|
| 350 | $row[] = array('data' => $proyecto_value->field_estrategico_codigo[0]['value'], ); |
---|
| 351 | //titulo del Proyecto |
---|
| 352 | $row[] = array('data' => $proyecto_value->title, ); |
---|
| 353 | //Producto del proyecto |
---|
| 354 | $row[] = array('data' => $proyecto_value->field_estrategico_producto[0]['value'], ); |
---|
| 355 | //Lapso de ejecución |
---|
| 356 | $row[] = array('data' => $proyecto_value->field_estrategico_ejecucion[0]['value'], ); |
---|
| 357 | //Monto total del proyecto |
---|
| 358 | $row[] = array('data' => $proyecto_value->field_estrategico_total[0]['value'], ); |
---|
| 359 | $row[] = array( |
---|
| 360 | 'data' => l( |
---|
| 361 | t('Ver Proyecto'), |
---|
| 362 | 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto_value->nid. '/ver', |
---|
| 363 | array( |
---|
| 364 | 'query' => array( |
---|
| 365 | 'destination' => 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico' |
---|
| 366 | ) |
---|
| 367 | ) |
---|
| 368 | ), |
---|
| 369 | ); |
---|
| 370 | if ($fecha) { |
---|
| 371 | $row[] = array( |
---|
| 372 | 'data' => l( |
---|
| 373 | t('Modificar datos Básicos'), |
---|
| 374 | 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto_value->nid. '/datos_basicos', |
---|
| 375 | array( |
---|
| 376 | 'query' => array( |
---|
| 377 | 'destination' => 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto_value->nid. '/ver' |
---|
| 378 | ) |
---|
| 379 | ) |
---|
| 380 | ), |
---|
| 381 | ); |
---|
| 382 | $row[] = array( |
---|
| 383 | 'data' => l( |
---|
| 384 | t('Planes y polÃticas'), |
---|
| 385 | 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto_value->nid. '/planes_politicas', |
---|
| 386 | array( |
---|
| 387 | 'query' => array( |
---|
| 388 | 'destination' => 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto_value->nid. '/ver' |
---|
| 389 | ) |
---|
| 390 | ) |
---|
| 391 | ), |
---|
| 392 | ); |
---|
| 393 | $row[] = array( |
---|
| 394 | 'data' => l( |
---|
| 395 | t('Objetivos estratégicos'), |
---|
[44f67f8] | 396 | 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto_value->nid. '/objetivos', |
---|
[1819be7] | 397 | array( |
---|
| 398 | 'query' => array( |
---|
| 399 | 'destination' => 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto_value->nid. '/ver' |
---|
| 400 | ) |
---|
| 401 | ) |
---|
| 402 | ), |
---|
| 403 | ); |
---|
| 404 | |
---|
| 405 | } |
---|
| 406 | $rows[] = $row; |
---|
| 407 | } |
---|
| 408 | } |
---|
| 409 | else { |
---|
| 410 | $row = array(); |
---|
| 411 | $row[] = array('data' => t('No se encontraron proyectos estratégicos para este ente'), 'colspan' => $count_headers_table); |
---|
| 412 | $rows[] = $row; |
---|
| 413 | } |
---|
| 414 | $output .= theme('table', $headers_table, $rows); |
---|
| 415 | if ($fecha) { |
---|
| 416 | $output .= l(t('Registrar nuevo proyecto'), 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/registrar'); |
---|
| 417 | } |
---|
| 418 | return $output; |
---|
| 419 | } |
---|
| 420 | |
---|
[44f67f8] | 421 | /* |
---|
| 422 | * Implementation of proyecto_estrategico_mostrar_proyectos() |
---|
| 423 | */ |
---|
[1819be7] | 424 | function proyecto_estrategico_mostrar_proyectos($ente_planificador, $proyecto) { |
---|
| 425 | global $user; |
---|
| 426 | $output = ''; |
---|
| 427 | drupal_set_title(t('Ver Proyecto @nombre_proyecto', array('@nombre_proyecto' => $proyecto->title))); |
---|
| 428 | $ente = usuario_tiene_ente($user->uid); |
---|
| 429 | $accesso = proyecto_estrategico_obtiene_acceso_proceso('proyecto_estrategico_proyectos', $ente_planificador, $ente); |
---|
[44f67f8] | 430 | //proceso de familiarización |
---|
| 431 | $output .= '<div class ="proyecto-estrategico-datos-basicos" id ="proyecto-estrategico-datos-basicos-' . $ente_planificador->nid . '"><h2>' . t('Datos Básicos') . '</h2>'; |
---|
| 432 | $contenido = array(); |
---|
| 433 | $content = node_build_content($proyecto); |
---|
| 434 | $arreglo = array( |
---|
| 435 | 'field_estrategico_codigo' => 'field_estrategico_codigo', |
---|
| 436 | 'field_estrategico_necesi' => 'field_estrategico_necesi', |
---|
| 437 | 'field_estrategico_objetivo' => 'field_estrategico_objetivo', |
---|
| 438 | 'field_estrategico_producto' => 'field_estrategico_producto', |
---|
| 439 | 'field_estrategico_cantidad' => 'field_estrategico_cantidad', |
---|
| 440 | 'field_estrategico_unidad' => 'field_estrategico_unidad', |
---|
| 441 | 'field_estrategico_ejecucion' => 'field_estrategico_ejecucion', |
---|
| 442 | 'field_estrategico_poblacion' => 'field_estrategico_poblacion', |
---|
| 443 | 'field_estrategico_institu' => 'field_estrategico_institu', |
---|
| 444 | 'field_estrategico_total' => 'field_estrategico_total', |
---|
| 445 | 'field_estrategico_anual' => 'field_estrategico_anual', |
---|
| 446 | 'field_estrategicorespnombre' => 'field_estrategicorespnombre', |
---|
| 447 | 'field_estrategicoresptelf' => 'field_estrategicoresptelf', |
---|
| 448 | 'field_estrategicorespemail' => 'field_estrategicorespemail', |
---|
| 449 | 'field_estrategicoenlanombre' => 'field_estrategicoenlanombre', |
---|
| 450 | 'field_estrategicoenlatelf' => 'field_estrategicoenlatelf', |
---|
| 451 | 'field_estrategicoenlemail' => 'field_estrategicoenlemail', |
---|
| 452 | ); |
---|
| 453 | $node_type = content_types('proyecto_estrategico'); |
---|
| 454 | $fields = $node_type['fields']; |
---|
| 455 | foreach($content->content as $field_id => $field_value) { |
---|
| 456 | if (array_key_exists($field_id, $arreglo)) { |
---|
| 457 | $contenido[$field_id] = $field_value; |
---|
[1819be7] | 458 | } |
---|
[44f67f8] | 459 | elseif (variable_get('proyecto_estrategico_db' . $field_id, FALSE)) { |
---|
| 460 | $contenido[$field_id] = $field_value; |
---|
[1819be7] | 461 | } |
---|
[44f67f8] | 462 | } |
---|
| 463 | $output .= '<h3>' . $proyecto->title . '</h3>'; |
---|
| 464 | if (is_array($contenido) && count($contenido)) { |
---|
| 465 | $output .= drupal_render($contenido); |
---|
| 466 | } |
---|
| 467 | if ($accesso) { |
---|
| 468 | $output .= l(t('Modificar datos básicos'), 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto->nid. '/datos_basicos'); |
---|
| 469 | } |
---|
| 470 | $output .= '</div>'; |
---|
| 471 | $output .= '<div class ="proyecto-estrategico-datos-basicos" id ="proyecto-estrategico-datos-basicos-' . $ente_planificador->nid . '"><h2>' . t('Planes y polÃticas que aborda el proyecto') . '</h2>'; |
---|
| 472 | $contenido = array(); |
---|
| 473 | $taxonomy = array(); |
---|
| 474 | $c = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $proyecto->type); |
---|
| 475 | while ($vocabulary = db_fetch_object($c)) { |
---|
| 476 | $taxonomy[$vocabulary->vid] = $vocabulary->name; |
---|
| 477 | } |
---|
| 478 | $node_taxonomy = array(); |
---|
| 479 | if (is_array($proyecto->taxonomy) && count($proyecto->taxonomy)) { |
---|
| 480 | foreach($proyecto->taxonomy as $tid => $term) { |
---|
| 481 | $term->name_vocabulary = $taxonomy[$term->vid]; |
---|
| 482 | $node_taxonomy[$term->vid][] = $term; |
---|
[1819be7] | 483 | } |
---|
[44f67f8] | 484 | } |
---|
| 485 | if (is_array($node_taxonomy) && count($node_taxonomy)) { |
---|
| 486 | foreach($node_taxonomy as $tid => $terms) { |
---|
| 487 | $output .= '<div class = "field field-type-text">'; |
---|
| 488 | $output .= '<div class="field-label">' . $taxonomy[$tid] . ': </div>'; |
---|
| 489 | $output .= '<div class="field-items">'; |
---|
| 490 | $i = 1; |
---|
| 491 | foreach($terms as $term) { |
---|
| 492 | $count = $i % 2 ? 'odd' : 'even'; |
---|
| 493 | $output .= '<div class="field-item ' . $count .'"> ' . $term->name . ' </div>'; |
---|
| 494 | $i++; |
---|
[1819be7] | 495 | } |
---|
[44f67f8] | 496 | $output .= '</div>'; |
---|
| 497 | $output .= '</div>'; |
---|
| 498 | } |
---|
| 499 | } |
---|
| 500 | $arreglo = array( |
---|
| 501 | 'field_estrategicoopolinspoa' => 'field_estrategicoopolinspoa', |
---|
| 502 | ); |
---|
| 503 | $estado_p_p = FALSE; |
---|
| 504 | foreach($content->content as $field_id => $field_value) { |
---|
| 505 | if (array_key_exists($field_id, $arreglo)) { |
---|
| 506 | $contenido[$field_id] = $field_value; |
---|
| 507 | if (!$estado_p_p) { |
---|
| 508 | $items = array(); |
---|
| 509 | foreach($proyecto->$field_id as $value) { |
---|
| 510 | if ($value['value']) { |
---|
| 511 | $items[] = $value['value']; |
---|
[1819be7] | 512 | } |
---|
| 513 | } |
---|
[44f67f8] | 514 | if (count($items)) { |
---|
| 515 | $estado_p_p = TRUE; |
---|
[1819be7] | 516 | } |
---|
| 517 | } |
---|
| 518 | } |
---|
[44f67f8] | 519 | elseif (variable_get('proyecto_estrategico_pp' . $field_id, FALSE)) { |
---|
| 520 | $contenido[$field_id] = $field_value; |
---|
[1819be7] | 521 | } |
---|
[44f67f8] | 522 | } |
---|
| 523 | if (is_array($contenido) && count($contenido)) { |
---|
| 524 | $output .= drupal_render($contenido); |
---|
| 525 | } |
---|
| 526 | if ($accesso) { |
---|
| 527 | if ($estado_p_p) { |
---|
| 528 | $output .= l(t('Modificar Planes y polÃticas'), 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto->nid. '/planes_politicas'); |
---|
[1819be7] | 529 | } |
---|
[44f67f8] | 530 | else { |
---|
| 531 | $output .= l(t('Agregar Planes y polÃticas'), 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto->nid. '/planes_politicas'); |
---|
| 532 | } |
---|
| 533 | } |
---|
| 534 | $output .= '</div>'; |
---|
| 535 | //OBJETIVOS ESTRATEGICOS |
---|
| 536 | $objetivos = array(); |
---|
| 537 | $headers_table = array(); |
---|
| 538 | $headers_table[] = array( |
---|
| 539 | 'data' => t('objetivo estratégico'), |
---|
| 540 | ); |
---|
| 541 | $headers_table[] = array( |
---|
| 542 | 'data' => t('Perspectiva asociada al objetivo estratégico'), |
---|
| 543 | ); |
---|
| 544 | $headers_table[] = array( |
---|
| 545 | 'data' => t('Descripción del indicador'), |
---|
| 546 | ); |
---|
| 547 | $headers_table[] = array( |
---|
| 548 | 'data' => t('Unidad de medida'), |
---|
| 549 | ); |
---|
| 550 | $headers_table[] = array( |
---|
| 551 | 'data' => t('Meta total'), |
---|
| 552 | ); |
---|
| 553 | $headers_table[] = array( |
---|
| 554 | 'data' => t('Meta anual'), |
---|
| 555 | ); |
---|
| 556 | $headers_table[] = array( |
---|
| 557 | 'data' => t('Monto anual'), |
---|
| 558 | ); |
---|
| 559 | $count_headers_table = count($headers_table); |
---|
| 560 | if ($accesso) { |
---|
| 561 | $count_headers_table += 3; |
---|
[1819be7] | 562 | $headers_table[] = array( |
---|
[44f67f8] | 563 | 'data' => t('Operación'), |
---|
| 564 | 'colspan' => '3' |
---|
[1819be7] | 565 | ); |
---|
[44f67f8] | 566 | } |
---|
| 567 | $objetivos = proyecto_estrategico_obtiene_datos_objetivos($ente_planificador, $proyecto); |
---|
| 568 | $rows = array(); |
---|
| 569 | if (is_array($objetivos) && count($objetivos)) { |
---|
| 570 | foreach($objetivos as $objetivo_id => $objetivo_value) { |
---|
| 571 | $row = array(); |
---|
| 572 | $row[] = array('data' => $objetivo_value->title, ); |
---|
| 573 | //Perspectiva |
---|
| 574 | $items = array(); |
---|
| 575 | foreach($objetivo_value->field_objetivo_perspectiva as $value) { |
---|
| 576 | $items[] = $value['value']; |
---|
| 577 | } |
---|
| 578 | $row[] = array('data' => theme('item_list', $items), ); |
---|
| 579 | //indicador |
---|
| 580 | $items = array(); |
---|
| 581 | foreach($objetivo_value->field_objetivo_indicador as $value) { |
---|
| 582 | $items[] = $value['value']; |
---|
| 583 | } |
---|
| 584 | $row[] = array('data' => theme('item_list', $items), ); |
---|
| 585 | //Unidad de medida |
---|
| 586 | $items = array(); |
---|
| 587 | foreach($objetivo_value->field_objetivo_medida as $value) { |
---|
| 588 | $items[] = $value['value']; |
---|
| 589 | } |
---|
| 590 | $row[] = array('data' => theme('item_list', $items), ); |
---|
| 591 | //Meta total |
---|
| 592 | $items = array(); |
---|
| 593 | foreach($objetivo_value->field_objetivo_meta_total as $value) { |
---|
| 594 | $items[] = $value['value']; |
---|
| 595 | } |
---|
| 596 | $row[] = array('data' => theme('item_list', $items), ); |
---|
| 597 | //Meta anual |
---|
| 598 | $items = array(); |
---|
| 599 | foreach($objetivo_value->field_objetivo_meta_anual as $value) { |
---|
| 600 | $items[] = $value['value']; |
---|
| 601 | } |
---|
| 602 | $row[] = array('data' => theme('item_list', $items), ); |
---|
| 603 | //'Monto anual |
---|
| 604 | $items = array(); |
---|
| 605 | foreach($objetivo_value->field_objetivo_monto_anual as $value) { |
---|
| 606 | $items[] = $value['value']; |
---|
| 607 | } |
---|
| 608 | $row[] = array('data' => theme('item_list', $items), ); |
---|
| 609 | if ($accesso) { |
---|
[1819be7] | 610 | $row[] = array( |
---|
| 611 | 'data' => l( |
---|
[44f67f8] | 612 | t('Modificar'), |
---|
| 613 | 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto->nid . '/objetivos/' . $objetivo_value->nid . '/modificar', |
---|
[1819be7] | 614 | array( |
---|
| 615 | 'query' => array( |
---|
| 616 | 'destination' => 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico' |
---|
| 617 | ) |
---|
| 618 | ) |
---|
| 619 | ), |
---|
| 620 | ); |
---|
| 621 | } |
---|
[44f67f8] | 622 | $row[] = array( |
---|
| 623 | 'data' => l( |
---|
| 624 | t('Eliminar'), |
---|
| 625 | 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $funcion_value->nid . '/eliminar', |
---|
| 626 | array( |
---|
| 627 | 'query' => array( |
---|
| 628 | 'destination' => 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico' |
---|
| 629 | ) |
---|
| 630 | ) |
---|
| 631 | ), |
---|
| 632 | ); |
---|
[1819be7] | 633 | $rows[] = $row; |
---|
| 634 | } |
---|
[44f67f8] | 635 | } |
---|
| 636 | else { |
---|
| 637 | $row = array(); |
---|
| 638 | $row[] = array('data' => t('No se encontraron objetivos estratégicos para este ente'), 'colspan' => $count_headers_table); |
---|
| 639 | $rows[] = $row; |
---|
| 640 | } |
---|
| 641 | $output .= '<div id ="proceso-analisis-objetivo-' . $ente_planificador->nid . '"><h2>' . t('Objetivos Estrategicos') . '</h2>'; |
---|
| 642 | $output .= theme('table', $headers_table, $rows); |
---|
| 643 | if ($accesso) { |
---|
| 644 | $output .= l(t('Registrar un objetivo estratégico'), 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto->nid . '/objetivos/registrar'); |
---|
| 645 | } |
---|
[1819be7] | 646 | $output .= '</div>'; |
---|
| 647 | return $output; |
---|
| 648 | } |
---|
| 649 | |
---|
[44f67f8] | 650 | /* |
---|
| 651 | * Implementation of proyecto_estrategico_datos_basicos_form() |
---|
| 652 | */ |
---|
[1819be7] | 653 | function proyecto_estrategico_datos_basicos_form(&$form_state, $ente_planificador, $proyecto = 0) { |
---|
| 654 | global $user; |
---|
| 655 | $tipo_plan = 'proyecto_estrategico_proyectos'; |
---|
| 656 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador->tipo); |
---|
| 657 | $current_time = time(); |
---|
| 658 | $fecha = FALSE; |
---|
| 659 | $ente = usuario_tiene_ente($user->uid); |
---|
| 660 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
| 661 | $fecha = TRUE; |
---|
| 662 | } |
---|
| 663 | if ($proyecto_estrategico->nid) { |
---|
| 664 | if (!$fecha) { |
---|
| 665 | muestra_mensaje($tipo_plan, $ente_planificador->tipo); |
---|
| 666 | } |
---|
| 667 | else { |
---|
| 668 | if ($ente->nid == $ente_planificador->nid) { |
---|
| 669 | muestra_mensaje($tipo_plan, $ente_planificador->tipo, 0); |
---|
| 670 | } |
---|
| 671 | } |
---|
| 672 | $proyecto_estrategico_load = node_load($proyecto_estrategico->nid); |
---|
| 673 | } |
---|
| 674 | else { |
---|
| 675 | if ($fecha && (user_access('admin planificador') || ($ente->nid == $ente_planificador->nid && user_access('editar datos institucionales de mi ente')))) { |
---|
| 676 | muestra_mensaje($tipo_plan, $ente_planificador->tipo, 0); |
---|
| 677 | } |
---|
| 678 | else { |
---|
| 679 | muestra_mensaje("explicacion", $ente_planificador->tipo); |
---|
| 680 | return t('El ente @ente_planificador aun no tiene proyectos estratégicos.', array('@ente_planificador' => $ente_planificador->title)); |
---|
| 681 | } |
---|
| 682 | } |
---|
| 683 | $form = array(); |
---|
| 684 | $form['ente_planificador_nid'] = array( |
---|
| 685 | '#type' => 'hidden', |
---|
| 686 | '#default_value' => $ente_planificador->nid, |
---|
| 687 | ); |
---|
| 688 | if ($proyecto && isset($proyecto->nid) && $proyecto->nid) { |
---|
| 689 | drupal_set_title(t('Modificar Proyecto @nombre_proyecto', array('@nombre_proyecto' => $proyecto->title))); |
---|
| 690 | $form['#node'] = $proyecto; |
---|
| 691 | } |
---|
| 692 | else { |
---|
| 693 | drupal_set_title(t('Registrar proyecto estratégico')); |
---|
| 694 | $form['#node'] = new stdClass(); |
---|
| 695 | $form['#node']->type = 'proyecto_estrategico'; |
---|
| 696 | $form['#node']->uid = $user->uid; |
---|
| 697 | $form['#node']->field_estrategico_ente[0]['nid'] = $ente_planificador->nid; |
---|
| 698 | $form['#node']->title = ''; |
---|
| 699 | $form['#node']->field_estrategico_anual[0]['value'] = 0; |
---|
| 700 | } |
---|
| 701 | $form['title'] = array( |
---|
| 702 | '#type' => 'textfield', |
---|
| 703 | '#title' => t('TÃtulo del Proyecto'), |
---|
| 704 | '#required' => TRUE, |
---|
| 705 | '#default_value' => $form['#node']->title, |
---|
| 706 | ); |
---|
| 707 | $node_type = content_types('proyecto_estrategico'); |
---|
| 708 | $fields = $node_type['fields']; |
---|
| 709 | $field_form = array(); |
---|
| 710 | $arreglo = array( |
---|
| 711 | 'field_estrategico_codigo' => 'field_estrategico_codigo', |
---|
| 712 | 'field_estrategico_necesi' => 'field_estrategico_necesi', |
---|
| 713 | 'field_estrategico_objetivo' => 'field_estrategico_objetivo', |
---|
| 714 | 'field_estrategico_producto' => 'field_estrategico_producto', |
---|
| 715 | 'field_estrategico_cantidad' => 'field_estrategico_cantidad', |
---|
| 716 | 'field_estrategico_unidad' => 'field_estrategico_unidad', |
---|
| 717 | 'field_estrategico_ejecucion' => 'field_estrategico_ejecucion', |
---|
| 718 | 'field_estrategico_poblacion' => 'field_estrategico_poblacion', |
---|
| 719 | 'field_estrategico_institu' => 'field_estrategico_institu', |
---|
| 720 | 'field_estrategico_total' => 'field_estrategico_total', |
---|
[44f67f8] | 721 | 'field_estrategicorespnombre' => 'field_estrategicorespnombre', |
---|
| 722 | 'field_estrategicoresptelf' => 'field_estrategicoresptelf', |
---|
| 723 | 'field_estrategicorespemail' => 'field_estrategicorespemail', |
---|
| 724 | 'field_estrategicoenlanombre' => 'field_estrategicoenlanombre', |
---|
| 725 | 'field_estrategicoenlatelf' => 'field_estrategicoenlatelf', |
---|
| 726 | 'field_estrategicoenlemail' => 'field_estrategicoenlemail', |
---|
[1819be7] | 727 | ); |
---|
| 728 | if (is_array($fields) && count($fields)) { |
---|
| 729 | foreach($fields as $field_id => $field) { |
---|
| 730 | if (array_key_exists($field_id, $arreglo)) { |
---|
| 731 | $field_form[] = $field_id; |
---|
| 732 | } |
---|
| 733 | elseif (variable_get('proyecto_estrategico_db' . $field_id, FALSE)) { |
---|
| 734 | $field_form[] = $field_id; |
---|
| 735 | } |
---|
| 736 | } |
---|
| 737 | } |
---|
| 738 | $form['#proyecto_estrategico_fields_datos'] = $field_form; |
---|
| 739 | if (is_array($field_form) && count($field_form)) { |
---|
| 740 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
| 741 | foreach ($field_form as $field_id) { |
---|
| 742 | $field = content_fields($field_id, 'proyecto_estrategico'); |
---|
| 743 | $form['#field_info'][$field_id] = $field; |
---|
| 744 | $form += (array) content_field_form($form, $form_state, $field); |
---|
| 745 | } |
---|
| 746 | } |
---|
| 747 | $form["field_estrategico_anual"] = array( |
---|
| 748 | '#type' => 'textfield', |
---|
| 749 | '#title' => t('Monto Anual del Proyecto'), |
---|
| 750 | '#required' => TRUE, |
---|
| 751 | '#default_value' => $form['#node']->field_estrategico_anual[0]['value'], |
---|
| 752 | '#size' => 12, |
---|
| 753 | '#weight' => $form['field_estrategico_total']['#weight'] + 1, |
---|
| 754 | ); |
---|
[44f67f8] | 755 | $form['buttons'] = array( |
---|
| 756 | '#type' => 'fieldset', |
---|
| 757 | '#collapsible' => TRUE, |
---|
| 758 | // Collapsed by default when "Create new revision" is unchecked |
---|
| 759 | '#weight' => 100, |
---|
| 760 | ); |
---|
| 761 | $form['buttons']['registrar'] = array( |
---|
[1819be7] | 762 | '#type' => 'submit', |
---|
| 763 | '#default_value' => t('Registrar proyecto estratégico'), |
---|
| 764 | '#weight' => 100, |
---|
| 765 | ); |
---|
[44f67f8] | 766 | $form['buttons']['cancelar'] = array( |
---|
| 767 | '#type' => 'submit', |
---|
| 768 | '#default_value' => t('Cancelar'), |
---|
| 769 | '#weight' => 101, |
---|
| 770 | '#skip_validation' => TRUE, |
---|
| 771 | ); |
---|
[1819be7] | 772 | $form['field_estrategico_codigo']['#weight'] = -11; |
---|
| 773 | return $form; |
---|
| 774 | } |
---|
[44f67f8] | 775 | |
---|
[1819be7] | 776 | /* |
---|
[44f67f8] | 777 | * Implementation of proyecto_estrategico_datos_basicos_form_validate() |
---|
[1819be7] | 778 | */ |
---|
| 779 | function proyecto_estrategico_datos_basicos_form_validate($form, &$form_state) { |
---|
| 780 | if (!is_numeric($form_state['values']['field_estrategico_anual'])) { |
---|
| 781 | form_set_error('field_estrategico_anual', t('El monto anual del proyecto deberia ser un número')); |
---|
| 782 | } |
---|
| 783 | if ($form_state['values']['field_estrategico_total'][0]['value'] < $form_state['values']['field_estrategico_anual']) { |
---|
| 784 | form_set_error('field_estrategico_anual', t('El monto anual del proyecto no debe ser mayor al monto total del proyecto')); |
---|
| 785 | } |
---|
| 786 | } |
---|
| 787 | |
---|
| 788 | /* |
---|
[44f67f8] | 789 | * Implementation of proyecto_estrategico_datos_basicos_form_submit() |
---|
[1819be7] | 790 | */ |
---|
| 791 | function proyecto_estrategico_datos_basicos_form_submit($form, &$form_state) { |
---|
[44f67f8] | 792 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
| 793 | if ($op == t('Cancelar')) { |
---|
| 794 | $form_state['redirect'] = 'planificacion/' . $form_state['values']['ente_planificador_nid'] . '/proyecto_estrategico'; |
---|
| 795 | return; |
---|
| 796 | } |
---|
[1819be7] | 797 | module_load_include('inc', 'node', 'node.pages'); |
---|
| 798 | $node_load = $form['#node']; |
---|
| 799 | $field_form = $form['#proyecto_estrategico_fields_datos']; |
---|
| 800 | $form_values = $form_state['values']; |
---|
| 801 | if (is_array($field_form) && count($field_form)) { |
---|
| 802 | foreach ($field_form as $field_id) { |
---|
| 803 | if (isset($form_values[$field_id]) && is_array($form_values[$field_id])) { |
---|
| 804 | foreach($form_values[$field_id] as $id => $value) { |
---|
| 805 | if (is_numeric($id) && isset($form_values[$field_id][$id]['_error_element'])) { |
---|
| 806 | unset($form_values[$field_id][$id]['_error_element']); |
---|
| 807 | } |
---|
| 808 | } |
---|
| 809 | $node_load->{$field_id} = $form_values[$field_id]; |
---|
| 810 | } |
---|
| 811 | } |
---|
| 812 | } |
---|
| 813 | $node_load->field_estrategico_anual[0]['value'] = $form_state['values']['field_estrategico_anual']; |
---|
| 814 | $node_load->title = check_plain($form_state['values']['title']); |
---|
| 815 | $node_load->log = t('Agregado el proyecto estrátegico del actor planificador'); |
---|
| 816 | $node_load->revision = 1; |
---|
| 817 | node_save($node_load); |
---|
| 818 | drupal_set_message(t("Agregado el proyecto estrátegico del actor planificador")); |
---|
| 819 | if ($_REQUEST['destination']) { |
---|
| 820 | $form_state['redirect'] = url('planificacion/' . $form_state['values']['ente_planificador_nid'] . '/proyecto_estrategico', |
---|
| 821 | array( |
---|
| 822 | 'query' => array( |
---|
| 823 | 'destination' => $_REQUEST['destination'], |
---|
| 824 | ), |
---|
| 825 | 'absolute' => TRUE, |
---|
| 826 | ) |
---|
| 827 | ); |
---|
| 828 | unset($_REQUEST['destination']); |
---|
| 829 | } |
---|
| 830 | else { |
---|
| 831 | // add redirect |
---|
| 832 | $form_state['redirect'] = 'planificacion/' . $form_state['values']['ente_planificador_nid'] . '/proyecto_estrategico'; |
---|
| 833 | } |
---|
| 834 | } |
---|
| 835 | |
---|
[44f67f8] | 836 | /* |
---|
| 837 | * Implementation of proyecto_estrategico_planes_politicas_form() |
---|
| 838 | */ |
---|
[1819be7] | 839 | function proyecto_estrategico_planes_politicas_form(&$form_state, $ente_planificador, $proyecto = 0) { |
---|
| 840 | global $user; |
---|
| 841 | $tipo_plan = 'proyecto_estrategico_proyectos'; |
---|
| 842 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador->tipo); |
---|
| 843 | $current_time = time(); |
---|
| 844 | $fecha = FALSE; |
---|
| 845 | $ente = usuario_tiene_ente($user->uid); |
---|
| 846 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
| 847 | $fecha = TRUE; |
---|
| 848 | } |
---|
| 849 | if ($proyecto_estrategico->nid) { |
---|
| 850 | if (!$fecha) { |
---|
| 851 | muestra_mensaje($tipo_plan, $ente_planificador->tipo); |
---|
| 852 | } |
---|
| 853 | else { |
---|
| 854 | if ($ente->nid == $ente_planificador->nid) { |
---|
| 855 | muestra_mensaje($tipo_plan, $ente_planificador->tipo, 0); |
---|
| 856 | } |
---|
| 857 | } |
---|
| 858 | $proyecto_estrategico_load = node_load($proyecto_estrategico->nid); |
---|
| 859 | } |
---|
| 860 | else { |
---|
| 861 | if ($fecha && (user_access('admin planificador') || ($ente->nid == $ente_planificador->nid && user_access('editar datos institucionales de mi ente')))) { |
---|
| 862 | muestra_mensaje($tipo_plan, $ente_planificador->tipo, 0); |
---|
| 863 | } |
---|
| 864 | else { |
---|
| 865 | muestra_mensaje("explicacion", $ente_planificador->tipo); |
---|
| 866 | return t('El ente @ente_planificador aun no tiene proyectos estratégicos.', array('@ente_planificador' => $ente_planificador->title)); |
---|
| 867 | } |
---|
| 868 | } |
---|
| 869 | $form = array(); |
---|
| 870 | $form['ente_planificador_nid'] = array( |
---|
| 871 | '#type' => 'hidden', |
---|
| 872 | '#default_value' => $ente_planificador->nid, |
---|
| 873 | ); |
---|
| 874 | drupal_set_title(t('Modificar Planes y polÃticas del proyecto @nombre_proyecto', array('@nombre_proyecto' => $proyecto->title))); |
---|
[44f67f8] | 875 | //add taxonomy if exist |
---|
| 876 | if (module_exists('taxonomy')) { |
---|
| 877 | if (!isset($proyecto->taxonomy)) { |
---|
| 878 | $terms = empty($proyecto->nid) ? array() : taxonomy_node_get_terms($proyecto); |
---|
| 879 | } |
---|
| 880 | else { |
---|
| 881 | // After a preview or form reload, the terms must be converted to objects. |
---|
| 882 | reset($proyecto->taxonomy); |
---|
| 883 | if (!is_object(current($proyecto->taxonomy))) { |
---|
| 884 | $proyecto->taxonomy = taxonomy_preview_terms($proyecto); |
---|
[1819be7] | 885 | } |
---|
[44f67f8] | 886 | $terms = $proyecto->taxonomy; |
---|
| 887 | } |
---|
| 888 | $c = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $proyecto->type); |
---|
| 889 | while ($vocabulary = db_fetch_object($c)) { |
---|
| 890 | if ($vocabulary->tags) { |
---|
| 891 | if (isset($form_state['node_preview'])) { |
---|
| 892 | // Typed string can be changed by the user before preview, |
---|
| 893 | // so we just insert the tags directly as provided in the form. |
---|
| 894 | $typed_string = $proyecto->taxonomy['tags'][$vocabulary->vid]; |
---|
[1819be7] | 895 | } |
---|
[44f67f8] | 896 | else { |
---|
| 897 | $typed_string = taxonomy_implode_tags($terms, $vocabulary->vid) . (array_key_exists('tags', $terms) ? $terms['tags'][$vocabulary->vid] : NULL); |
---|
| 898 | } |
---|
| 899 | if ($vocabulary->help) { |
---|
| 900 | $help = filter_xss_admin($vocabulary->help); |
---|
[1819be7] | 901 | } |
---|
| 902 | else { |
---|
[44f67f8] | 903 | $help = t('A comma-separated list of terms describing this content. Example: funny, bungee jumping, "Company, Inc.".'); |
---|
[1819be7] | 904 | } |
---|
[44f67f8] | 905 | $form['taxonomy']['tags'][$vocabulary->vid] = array('#type' => 'textfield', |
---|
| 906 | '#title' => $vocabulary->name, |
---|
| 907 | '#description' => $help, |
---|
| 908 | '#required' => $vocabulary->required, |
---|
| 909 | '#default_value' => $typed_string, |
---|
| 910 | '#autocomplete_path' => 'taxonomy/autocomplete/'. $vocabulary->vid, |
---|
| 911 | '#weight' => $vocabulary->weight, |
---|
| 912 | '#maxlength' => 1024, |
---|
| 913 | ); |
---|
[1819be7] | 914 | } |
---|
[44f67f8] | 915 | else { |
---|
| 916 | // Extract terms belonging to the vocabulary in question. |
---|
| 917 | $default_terms = array(); |
---|
| 918 | foreach ($terms as $term) { |
---|
| 919 | // Free tagging has no default terms and also no vid after preview. |
---|
| 920 | if (isset($term->vid) && $term->vid == $vocabulary->vid) { |
---|
| 921 | $default_terms[$term->tid] = $term; |
---|
| 922 | } |
---|
[1819be7] | 923 | } |
---|
[44f67f8] | 924 | $form['taxonomy'][$vocabulary->vid] = taxonomy_form($vocabulary->vid, array_keys($default_terms), filter_xss_admin($vocabulary->help)); |
---|
| 925 | $form['taxonomy'][$vocabulary->vid]['#weight'] = $vocabulary->weight; |
---|
| 926 | $form['taxonomy'][$vocabulary->vid]['#required'] = $vocabulary->required; |
---|
[1819be7] | 927 | } |
---|
| 928 | } |
---|
[44f67f8] | 929 | if (!empty($form['taxonomy']) && is_array($form['taxonomy'])) { |
---|
| 930 | if (count($form['taxonomy']) > 1) { |
---|
| 931 | // Add fieldset only if form has more than 1 element. |
---|
| 932 | $form['taxonomy'] += array( |
---|
| 933 | '#type' => 'fieldset', |
---|
| 934 | '#title' => t('Planes y PolÃticas'), |
---|
| 935 | '#collapsible' => TRUE, |
---|
| 936 | '#collapsed' => FALSE, |
---|
| 937 | ); |
---|
| 938 | } |
---|
| 939 | $form['taxonomy']['#weight'] = 8; |
---|
| 940 | $form['taxonomy']['#tree'] = TRUE; |
---|
| 941 | } |
---|
| 942 | } |
---|
[1819be7] | 943 | $form['#node'] = $proyecto; |
---|
| 944 | $node_type = content_types('proyecto_estrategico'); |
---|
| 945 | $fields = $node_type['fields']; |
---|
| 946 | $field_form = array(); |
---|
| 947 | $arreglo = array( |
---|
| 948 | 'field_estrategicoopolinspoa' => 'field_estrategicoopolinspoa', |
---|
| 949 | ); |
---|
| 950 | if (is_array($fields) && count($fields)) { |
---|
| 951 | foreach($fields as $field_id => $field) { |
---|
| 952 | if (array_key_exists($field_id, $arreglo)) { |
---|
| 953 | $field_form[] = $field_id; |
---|
| 954 | } |
---|
| 955 | elseif (variable_get('proyecto_estrategico_pp' . $field_id, FALSE)) { |
---|
| 956 | $field_form[] = $field_id; |
---|
| 957 | } |
---|
| 958 | } |
---|
| 959 | } |
---|
| 960 | $form['#proyecto_estrategico_fields_datos'] = $field_form; |
---|
| 961 | if (is_array($field_form) && count($field_form)) { |
---|
| 962 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
| 963 | foreach ($field_form as $field_id) { |
---|
| 964 | $field = content_fields($field_id, 'proyecto_estrategico'); |
---|
| 965 | $form['#field_info'][$field_id] = $field; |
---|
| 966 | $form += (array) content_field_form($form, $form_state, $field); |
---|
| 967 | } |
---|
| 968 | } |
---|
[44f67f8] | 969 | $form['buttons'] = array( |
---|
| 970 | '#type' => 'fieldset', |
---|
| 971 | '#collapsible' => TRUE, |
---|
| 972 | // Collapsed by default when "Create new revision" is unchecked |
---|
| 973 | '#weight' => 100, |
---|
| 974 | ); |
---|
| 975 | $form['buttons']['registrar'] = array( |
---|
[1819be7] | 976 | '#type' => 'submit', |
---|
| 977 | '#default_value' => t('Registrar Planes y polÃticas'), |
---|
| 978 | '#weight' => 100, |
---|
| 979 | ); |
---|
[44f67f8] | 980 | $form['buttons']['cancelar'] = array( |
---|
| 981 | '#type' => 'submit', |
---|
| 982 | '#default_value' => t('Cancelar'), |
---|
| 983 | '#weight' => 101, |
---|
| 984 | '#skip_validation' => TRUE, |
---|
| 985 | ); |
---|
| 986 | |
---|
| 987 | |
---|
[1819be7] | 988 | return $form; |
---|
| 989 | } |
---|
| 990 | |
---|
| 991 | /* |
---|
[44f67f8] | 992 | * Implementation of proyecto_estrategico_planes_politicas_form_submit() |
---|
[1819be7] | 993 | */ |
---|
| 994 | function proyecto_estrategico_planes_politicas_form_submit($form, &$form_state) { |
---|
[44f67f8] | 995 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
| 996 | if ($op == t('Cancelar')) { |
---|
| 997 | $form_state['redirect'] = 'planificacion/' . $form_state['values']['ente_planificador_nid'] . '/proyecto_estrategico'; |
---|
| 998 | return; |
---|
| 999 | } |
---|
[1819be7] | 1000 | module_load_include('inc', 'node', 'node.pages'); |
---|
| 1001 | $node_load = $form['#node']; |
---|
| 1002 | $field_form = $form['#proyecto_estrategico_fields_datos']; |
---|
| 1003 | $form_values = $form_state['values']; |
---|
| 1004 | if (isset($form_state['values']['taxonomy'])) { |
---|
| 1005 | $node_load->taxonomy = $form_state['values']['taxonomy']; |
---|
| 1006 | } |
---|
| 1007 | if (is_array($field_form) && count($field_form)) { |
---|
| 1008 | foreach ($field_form as $field_id) { |
---|
| 1009 | if (isset($form_values[$field_id]) && is_array($form_values[$field_id])) { |
---|
| 1010 | foreach($form_values[$field_id] as $id => $value) { |
---|
| 1011 | if (is_numeric($id) && isset($form_values[$field_id][$id]['_error_element'])) { |
---|
| 1012 | unset($form_values[$field_id][$id]['_error_element']); |
---|
| 1013 | } |
---|
| 1014 | } |
---|
| 1015 | $node_load->{$field_id} = $form_values[$field_id]; |
---|
| 1016 | } |
---|
| 1017 | } |
---|
| 1018 | } |
---|
| 1019 | $node_load->log = t('Agregado el proyecto estrátegico del actor planificador'); |
---|
| 1020 | $node_load->revision = 1; |
---|
| 1021 | node_save($node_load); |
---|
| 1022 | drupal_set_message(t("Agregado el proyecto estrátegico del actor planificador")); |
---|
| 1023 | if ($_REQUEST['destination']) { |
---|
| 1024 | $form_state['redirect'] = url('planificacion/' . $form_state['values']['ente_planificador_nid'] . '/proyecto_estrategico', |
---|
| 1025 | array( |
---|
| 1026 | 'query' => array( |
---|
| 1027 | 'destination' => $_REQUEST['destination'], |
---|
| 1028 | ), |
---|
| 1029 | 'absolute' => TRUE, |
---|
| 1030 | ) |
---|
| 1031 | ); |
---|
| 1032 | unset($_REQUEST['destination']); |
---|
| 1033 | } |
---|
| 1034 | else { |
---|
| 1035 | // add redirect |
---|
| 1036 | $form_state['redirect'] = 'planificacion/' . $form_state['values']['ente_planificador_nid'] . '/proyecto_estrategico'; |
---|
| 1037 | } |
---|
| 1038 | } |
---|
| 1039 | |
---|
| 1040 | /* |
---|
[44f67f8] | 1041 | * Implementation of proyecto_estrategico_objetivos_estrategicos_registrar_form() |
---|
[1819be7] | 1042 | */ |
---|
| 1043 | function proyecto_estrategico_objetivos_estrategicos_registrar_form(&$form_state, $ente_planificador, $proyecto_estrategico, $objetivo = 0) { |
---|
| 1044 | global $user; |
---|
| 1045 | $tipo_plan = 'proyecto_estrategico_proyectos'; |
---|
| 1046 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador->tipo); |
---|
| 1047 | $current_time = time(); |
---|
| 1048 | $fecha = FALSE; |
---|
| 1049 | $ente = usuario_tiene_ente($user->uid); |
---|
| 1050 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
| 1051 | $fecha = TRUE; |
---|
| 1052 | } |
---|
| 1053 | if (!$fecha) { |
---|
| 1054 | muestra_mensaje($tipo_plan, $ente_planificador->tipo); |
---|
| 1055 | } |
---|
| 1056 | else { |
---|
| 1057 | if ($ente->nid == $ente_planificador->nid) { |
---|
| 1058 | muestra_mensaje($tipo_plan, $ente_planificador->tipo, 0); |
---|
| 1059 | } |
---|
| 1060 | } |
---|
| 1061 | $form = array(); |
---|
| 1062 | $form['#ente_planificador'] = $ente_planificador; |
---|
| 1063 | $form['#proyecto_estrategico'] = $proyecto_estrategico; |
---|
| 1064 | $form['#objetivo_estrategico'] = is_object($objetivo) ? $objetivo : 0;; |
---|
| 1065 | if (!$form['#objetivo_estrategico']) { |
---|
| 1066 | $title = t('Registrar objetivo estratégico'); |
---|
| 1067 | drupal_set_title($title); |
---|
| 1068 | $objetivo = new stdClass(); |
---|
| 1069 | $objetivo->type = 'objetivos_estrategicos'; |
---|
| 1070 | $objetivo->uid = $user->uid; |
---|
| 1071 | $objetivo->field_objetivo_ente[0] = array('nid' => $ente_planificador->nid); |
---|
| 1072 | $objetivo->field_objetivo_proyecto_estra[0] = array('nid' => $proyecto_estrategico->nid); |
---|
| 1073 | $form['#objetivo_estrategico'] = $objetivo; |
---|
| 1074 | } |
---|
| 1075 | else{ |
---|
| 1076 | drupal_set_title(t('Modificar objetivo estratégico @nombre_objetivo', array('@nombre_objetivo' => $objetivo->title))); |
---|
| 1077 | $title = t('Modificar objetivo estratégico'); |
---|
| 1078 | } |
---|
| 1079 | $form['title'] = array( |
---|
| 1080 | '#type' => 'textfield', |
---|
| 1081 | '#title' => t('Objetivo estratégico'), |
---|
| 1082 | '#required' => FALSE, |
---|
| 1083 | '#default_value' => isset($objetivo->title) ? $objetivo->title : '', |
---|
| 1084 | ); |
---|
| 1085 | $node_type = content_types('objetivos_estrategicos'); |
---|
| 1086 | $fields = $node_type['fields']; |
---|
| 1087 | $field_form = array(); |
---|
| 1088 | $arreglo = array( |
---|
| 1089 | 'field_objetivo_perspectiva' => 'field_objetivo_perspectiva', |
---|
| 1090 | 'field_objetivo_indicador' => 'field_objetivo_indicador', |
---|
| 1091 | 'field_objetivo_medida' => 'field_objetivo_medida', |
---|
| 1092 | 'field_objetivo_meta_total' => 'field_objetivo_meta_total', |
---|
| 1093 | 'field_objetivo_meta_anual' => 'field_objetivo_meta_anual', |
---|
| 1094 | 'field_objetivo_monto_anual' => 'field_objetivo_monto_anual', |
---|
| 1095 | ); |
---|
| 1096 | if (is_array($fields) && count($fields)) { |
---|
| 1097 | foreach($fields as $field_id => $field) { |
---|
| 1098 | if (array_key_exists($field_id, $arreglo)) { |
---|
| 1099 | $field_form[] = $field_id; |
---|
| 1100 | } |
---|
| 1101 | elseif (variable_get('proyecto_estrategico_oes_' . $field_id, FALSE)) { |
---|
| 1102 | $field_form[] = $field_id; |
---|
| 1103 | } |
---|
| 1104 | } |
---|
| 1105 | } |
---|
| 1106 | $form['#proyecto_estrategico_fields_datos'] = $field_form; |
---|
| 1107 | if (is_array($field_form) && count($field_form)) { |
---|
| 1108 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
| 1109 | $form['#node'] = $objetivo; |
---|
| 1110 | foreach ($field_form as $field_id) { |
---|
| 1111 | $field = content_fields($field_id, 'objetivos_estrategicos'); |
---|
| 1112 | $form['#field_info'][$field_id] = $field; |
---|
| 1113 | $form += (array) content_field_form($form, $form_state, $field); |
---|
| 1114 | } |
---|
| 1115 | } |
---|
[44f67f8] | 1116 | $form['buttons'] = array( |
---|
| 1117 | '#type' => 'fieldset', |
---|
| 1118 | '#collapsible' => TRUE, |
---|
| 1119 | // Collapsed by default when "Create new revision" is unchecked |
---|
| 1120 | '#weight' => 100, |
---|
| 1121 | ); |
---|
| 1122 | $form['buttons']['registrar'] = array( |
---|
[1819be7] | 1123 | '#type' => 'submit', |
---|
| 1124 | '#default_value' => $title, |
---|
| 1125 | '#weight' => 100, |
---|
| 1126 | ); |
---|
[44f67f8] | 1127 | $form['buttons']['cancelar'] = array( |
---|
| 1128 | '#type' => 'submit', |
---|
| 1129 | '#default_value' => t('Cancelar'), |
---|
| 1130 | '#weight' => 101, |
---|
| 1131 | '#skip_validation' => TRUE, |
---|
| 1132 | ); |
---|
[1819be7] | 1133 | return $form; |
---|
| 1134 | } |
---|
| 1135 | |
---|
| 1136 | /* |
---|
[44f67f8] | 1137 | * Implementation of proyecto_estrategico_objetivos_estrategicos_registrar_form_submit() |
---|
[1819be7] | 1138 | */ |
---|
| 1139 | function proyecto_estrategico_objetivos_estrategicos_registrar_form_submit($form, &$form_state) { |
---|
[44f67f8] | 1140 | $node_load = $form['#objetivo_estrategico']; |
---|
| 1141 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
| 1142 | if ($op == t('Cancelar')) { |
---|
| 1143 | $form_state['redirect'] = 'planificacion/' . $node_load->field_objetivo_ente[0]['nid'] . '/proyecto_estrategico/' . $node_load->field_objetivo_proyecto_estra[0]['nid']; |
---|
| 1144 | return; |
---|
| 1145 | } |
---|
[1819be7] | 1146 | $field_form = $form['#ente_planificador_fields_datos']; |
---|
| 1147 | module_load_include('inc', 'node', 'node.pages'); |
---|
| 1148 | $node_load->title = check_plain($form_state['values']['title']); |
---|
| 1149 | $field_form = $form['#proyecto_estrategico_fields_datos']; |
---|
| 1150 | $form_values = $form_state['values']; |
---|
| 1151 | if (is_array($field_form) && count($field_form)) { |
---|
| 1152 | foreach ($field_form as $field_id) { |
---|
| 1153 | if (isset($form_values[$field_id]) && is_array($form_values[$field_id])) { |
---|
| 1154 | foreach($form_values[$field_id] as $id => $value) { |
---|
| 1155 | if (is_numeric($id) && isset($form_values[$field_id][$id]['_error_element'])) { |
---|
| 1156 | unset($form_values[$field_id][$id]['_error_element']); |
---|
| 1157 | } |
---|
| 1158 | } |
---|
| 1159 | $node_load->{$field_id} = $form_values[$field_id]; |
---|
| 1160 | } |
---|
| 1161 | } |
---|
| 1162 | } |
---|
| 1163 | $node_load->log = t('Modificado el objetivos estratégico del ente'); |
---|
| 1164 | $node_load->revision = 1; |
---|
| 1165 | node_save($node_load); |
---|
| 1166 | drupal_set_message(t('Se modifico la información del objetivos estratégico del ente @nombre_objetivo', array('@nombre_objetivo' => $node_load->title))); |
---|
| 1167 | if ($_REQUEST['destination']) { |
---|
| 1168 | $form_state['redirect'] = url('planificacion/' . $node_load->field_objetivo_ente[0]['nid'] . '/proyecto_estrategico/' . $node_load->field_objetivo_proyecto_estra[0]['nid'], |
---|
| 1169 | array( |
---|
| 1170 | 'query' => array( |
---|
| 1171 | 'destination' => $_REQUEST['destination'], |
---|
| 1172 | ), |
---|
| 1173 | 'absolute' => TRUE, |
---|
| 1174 | ) |
---|
| 1175 | ); |
---|
| 1176 | unset($_REQUEST['destination']); |
---|
| 1177 | } |
---|
| 1178 | else { |
---|
| 1179 | // add redirect |
---|
| 1180 | $form_state['redirect'] = 'planificacion/' . $node_load->field_objetivo_ente[0]['nid'] . '/proyecto_estrategico/' . $node_load->field_objetivo_proyecto_estra[0]['nid']; |
---|
| 1181 | } |
---|
| 1182 | } |
---|
| 1183 | |
---|
| 1184 | |
---|
| 1185 | /** |
---|
| 1186 | * Implementation of hook_planner_items_toolbar(). |
---|
| 1187 | */ |
---|
| 1188 | function proyecto_estrategico_planner_items_toolbar($ente_planificador, $handler_icon) { |
---|
| 1189 | $link = array(); |
---|
[65995a6] | 1190 | $icon_path = entes_planificadores_toolbar_get_icon_path('planner', 'proyectoes', $handler_icon); |
---|
[1819be7] | 1191 | $link[] = array( |
---|
| 1192 | 'path' => 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico', |
---|
| 1193 | 'icon_path' => $icon_path, |
---|
| 1194 | 'icon' => theme('image', $icon_path, t('Consultar Información Institucional del actor planificador'), t('Consultar Información Institucional del actor planificador'), array('class' => 'handler-icon-' . $handler_icon)), |
---|
[65995a6] | 1195 | 'title' => t('Proyectos estrategicos'), |
---|
| 1196 | 'description' => t('Consultar Información de los proyectos estrategicos del actor planificador'), |
---|
[1819be7] | 1197 | 'category' => 'planner', |
---|
| 1198 | ); |
---|
| 1199 | return $link; |
---|
| 1200 | } |
---|
| 1201 | |
---|
| 1202 | |
---|
| 1203 | /* |
---|
| 1204 | * Implementation of hook_node_info() |
---|
| 1205 | */ |
---|
| 1206 | function proyecto_estrategico_node_info() { |
---|
| 1207 | return array( |
---|
| 1208 | 'proyecto_estrategico' => array( |
---|
| 1209 | 'name' => t('Proyecto Estratégico'), |
---|
| 1210 | 'description' => '', |
---|
| 1211 | 'has_title' => TRUE, |
---|
| 1212 | 'title_label' => 'TÃtulo del Proyecto', |
---|
| 1213 | 'has_body' => FALSE, |
---|
| 1214 | 'body_label' => 'Cuerpo', |
---|
| 1215 | 'module' => 'proyecto_estrategico', |
---|
| 1216 | ), |
---|
| 1217 | 'objetivos_estrategicos' => array( |
---|
| 1218 | 'name' => t('Objetivos estratégicos'), |
---|
| 1219 | 'description' => '', |
---|
| 1220 | 'has_title' => TRUE, |
---|
| 1221 | 'title_label' => 'TÃtulo', |
---|
| 1222 | 'has_body' => TRUE, |
---|
| 1223 | 'body_label' => 'Cuerpo', |
---|
| 1224 | 'module' => 'proyecto_estrategico', |
---|
| 1225 | ), |
---|
| 1226 | ); |
---|
| 1227 | } |
---|
| 1228 | |
---|
| 1229 | /* |
---|
| 1230 | * Implementation of hook_form() |
---|
| 1231 | */ |
---|
| 1232 | function proyecto_estrategico_form(&$node, $form_state) { |
---|
| 1233 | return node_content_form($node, $form_state); |
---|
| 1234 | } |
---|
| 1235 | |
---|
| 1236 | /* |
---|
| 1237 | * Implementation of hook_access() |
---|
| 1238 | */ |
---|
| 1239 | function proyecto_estrategico_access($op, $node, $account) { |
---|
| 1240 | global $user; |
---|
| 1241 | if ($op == 'view') { |
---|
| 1242 | return user_access('ver planificador') || user_access('admin planificador'); |
---|
| 1243 | } |
---|
| 1244 | if ($op == 'create') { |
---|
| 1245 | return (user_access('admin planificador')); |
---|
| 1246 | } |
---|
| 1247 | if ($op == 'delete') { |
---|
| 1248 | return (user_access('admin planificador')); |
---|
| 1249 | } |
---|
| 1250 | } |
---|
| 1251 | |
---|
| 1252 | /* |
---|
| 1253 | * hook_form_alter() |
---|
| 1254 | */ |
---|
| 1255 | function proyecto_estrategico_form_alter(&$form, $form_state, $form_id) { |
---|
| 1256 | //impedir que los campos sean borrados con la interfaz |
---|
[44f67f8] | 1257 | if ($form_id == 'content_field_overview_form' && $form['#type_name'] == 'proyecto_estrategico'){ |
---|
[1819be7] | 1258 | $arreglo = array( |
---|
[44f67f8] | 1259 | 'field_estrategico_codigo', |
---|
| 1260 | 'field_estrategico_necesi', |
---|
| 1261 | 'field_estrategico_objetivo', |
---|
| 1262 | 'field_estrategico_producto', |
---|
| 1263 | 'field_estrategico_cantidad', |
---|
| 1264 | 'field_estrategico_unidad', |
---|
| 1265 | 'field_estrategico_ejecucion', |
---|
| 1266 | 'field_estrategico_poblacion', |
---|
| 1267 | 'field_estrategico_institu', |
---|
| 1268 | 'field_estrategico_total', |
---|
| 1269 | 'field_estrategicorespnombre', |
---|
| 1270 | 'field_estrategicoresptelf', |
---|
| 1271 | 'field_estrategicorespemail', |
---|
| 1272 | 'field_estrategicoenlanombre', |
---|
| 1273 | 'field_estrategicoenlatelf', |
---|
| 1274 | 'field_estrategicoenlemail', |
---|
| 1275 | 'field_estrategicoopolinspoa', |
---|
| 1276 | 'field_estrategico_ente', |
---|
| 1277 | 'field_estrategico_anual', |
---|
[1819be7] | 1278 | ); |
---|
| 1279 | foreach ($arreglo as $valor) { |
---|
| 1280 | if (isset($form[$valor]['remove']['#value'])) { |
---|
| 1281 | $form[$valor]['remove']['#value'] = ''; |
---|
| 1282 | } |
---|
| 1283 | } |
---|
| 1284 | } |
---|
[44f67f8] | 1285 | if ($form_id == 'content_field_remove_form' && $form['type_name']['#value'] == 'proyecto_estrategico'){ |
---|
[1819be7] | 1286 | $arreglo = array( |
---|
[44f67f8] | 1287 | 'field_estrategico_codigo', |
---|
| 1288 | 'field_estrategico_necesi', |
---|
| 1289 | 'field_estrategico_objetivo', |
---|
| 1290 | 'field_estrategico_producto', |
---|
| 1291 | 'field_estrategico_cantidad', |
---|
| 1292 | 'field_estrategico_unidad', |
---|
| 1293 | 'field_estrategico_ejecucion', |
---|
| 1294 | 'field_estrategico_poblacion', |
---|
| 1295 | 'field_estrategico_institu', |
---|
| 1296 | 'field_estrategico_total', |
---|
| 1297 | 'field_estrategicorespnombre', |
---|
| 1298 | 'field_estrategicoresptelf', |
---|
| 1299 | 'field_estrategicorespemail', |
---|
| 1300 | 'field_estrategicoenlanombre', |
---|
| 1301 | 'field_estrategicoenlatelf', |
---|
| 1302 | 'field_estrategicoenlemail', |
---|
| 1303 | 'field_estrategicoopolinspoa', |
---|
| 1304 | 'field_estrategico_ente', |
---|
| 1305 | 'field_estrategico_anual', |
---|
[1819be7] | 1306 | ); |
---|
| 1307 | foreach ($arreglo as $valor) { |
---|
| 1308 | if($form['field_name']['#value'] == $valor) { |
---|
| 1309 | $form['actions']['submit']['#access'] = FALSE; |
---|
| 1310 | $form['description']['#value'] = t('Acción no permitida este campo ha sido agregado por un modulo.'); |
---|
| 1311 | } |
---|
| 1312 | } |
---|
| 1313 | } |
---|
[44f67f8] | 1314 | if ($form_id == 'content_field_overview_form' && $form['#type_name'] == 'objetivos_estrategicos'){ |
---|
[1819be7] | 1315 | $arreglo = array( |
---|
[44f67f8] | 1316 | 'field_objetivo_perspectiva', |
---|
| 1317 | 'field_objetivo_indicador', |
---|
| 1318 | 'field_objetivo_medida', |
---|
| 1319 | 'field_objetivo_meta_total', |
---|
| 1320 | 'field_objetivo_meta_anual', |
---|
| 1321 | 'field_objetivo_monto_anual', |
---|
| 1322 | 'field_objetivo_ente', |
---|
| 1323 | 'field_objetivo_proyecto_estra', |
---|
[1819be7] | 1324 | ); |
---|
| 1325 | foreach ($arreglo as $valor) { |
---|
| 1326 | if (isset($form[$valor]['remove']['#value'])) { |
---|
| 1327 | $form[$valor]['remove']['#value'] = ''; |
---|
| 1328 | } |
---|
| 1329 | } |
---|
| 1330 | } |
---|
[44f67f8] | 1331 | if ($form_id == 'content_field_remove_form' && $form['type_name']['#value'] == 'objetivos_estrategicos'){ |
---|
[1819be7] | 1332 | $arreglo = array( |
---|
[44f67f8] | 1333 | 'field_objetivo_perspectiva', |
---|
| 1334 | 'field_objetivo_indicador', |
---|
| 1335 | 'field_objetivo_medida', |
---|
| 1336 | 'field_objetivo_meta_total', |
---|
| 1337 | 'field_objetivo_meta_anual', |
---|
| 1338 | 'field_objetivo_monto_anual', |
---|
| 1339 | 'field_objetivo_ente', |
---|
| 1340 | 'field_objetivo_proyecto_estra', |
---|
[1819be7] | 1341 | ); |
---|
| 1342 | foreach ($arreglo as $valor) { |
---|
| 1343 | if($form['field_name']['#value'] == $valor) { |
---|
| 1344 | $form['actions']['submit']['#access'] = FALSE; |
---|
| 1345 | $form['description']['#value'] = t('Acción no permitida este campo ha sido agregado por un modulo.'); |
---|
| 1346 | } |
---|
| 1347 | } |
---|
| 1348 | } |
---|
| 1349 | } |
---|
| 1350 | |
---|
| 1351 | /** |
---|
| 1352 | * Implementation of hook_form_content_field_edit_form_alter(): content_field_edit_form. |
---|
| 1353 | */ |
---|
| 1354 | function proyecto_estrategico_form_content_field_edit_form_alter(&$form, $form_state) { |
---|
[44f67f8] | 1355 | if ($form['#field']['type_name'] == 'proyecto_estrategico') { |
---|
[1819be7] | 1356 | $arreglo = array( |
---|
[44f67f8] | 1357 | 'db' => t('Datos Básicos'), |
---|
| 1358 | 'pp' => t('Planes y polÃticas'), |
---|
[1819be7] | 1359 | ); |
---|
| 1360 | foreach($arreglo as $id => $value) { |
---|
| 1361 | $form['widget']['datos_institucionales' . $id] = array( |
---|
| 1362 | '#title' => t('Información intitucional (incluir en @value)', array('@value' => $value)), |
---|
| 1363 | '#type' => 'checkbox', |
---|
[44f67f8] | 1364 | '#default_value' => variable_get('proyecto_estrategico_' . $id . $form['#field']['field_name'], FALSE), |
---|
[1819be7] | 1365 | '#return_value' => '1', |
---|
| 1366 | ); |
---|
| 1367 | } |
---|
[44f67f8] | 1368 | $form['#submit'][] = 'proyecto_estrategico_proyecto_content_field_edit_form_submit'; |
---|
[1819be7] | 1369 | } |
---|
| 1370 | |
---|
[44f67f8] | 1371 | if ($form['#field']['type_name'] == 'objetivos_estrategicos') { |
---|
| 1372 | $form['widget']['proyecto_estrategico_oes'] = array( |
---|
| 1373 | '#title' => t('Información intitucional (incluir en @value)', array('@value' => $value)), |
---|
| 1374 | '#type' => 'checkbox', |
---|
| 1375 | '#default_value' => variable_get('proyecto_estrategico_oes_' . $form['#field']['field_name'], FALSE), |
---|
| 1376 | '#return_value' => '1', |
---|
[1819be7] | 1377 | ); |
---|
[44f67f8] | 1378 | $form['#submit'][] = 'datos_institucionales_objetivos_estrategicos_content_field_edit_form_submit'; |
---|
[1819be7] | 1379 | } |
---|
| 1380 | |
---|
| 1381 | } |
---|
| 1382 | |
---|
| 1383 | /** |
---|
[44f67f8] | 1384 | * Implementation of proyecto_estrategico_proyecto_content_field_edit_form_submit() |
---|
[1819be7] | 1385 | */ |
---|
[44f67f8] | 1386 | function proyecto_estrategico_proyecto_content_field_edit_form_submit($form, &$form_state) { |
---|
[1819be7] | 1387 | $arreglo = array( |
---|
[44f67f8] | 1388 | 'db' => t('Datos Básicos'), |
---|
| 1389 | 'pp' => t('Planes y polÃticas'), |
---|
[1819be7] | 1390 | ); |
---|
| 1391 | foreach($arreglo as $id => $value) { |
---|
[44f67f8] | 1392 | variable_set('proyecto_estrategico_' . $id . $form_state['values']['field_name'], $form_state['values']['datos_institucionales' . $id]); |
---|
[1819be7] | 1393 | } |
---|
| 1394 | } |
---|
| 1395 | |
---|
| 1396 | /** |
---|
[44f67f8] | 1397 | * Implementation of datos_institucionales_objetivos_estrategicos_content_field_edit_form_submit() |
---|
[1819be7] | 1398 | */ |
---|
[44f67f8] | 1399 | function datos_institucionales_objetivos_estrategicos_content_field_edit_form_submit($form, &$form_state) { |
---|
| 1400 | variable_set('proyecto_estrategico_oes_' . $id . $form_state['values']['field_name'], $form_state['values']['proyecto_estrategico_oes']); |
---|
| 1401 | } |
---|
| 1402 | |
---|
| 1403 | |
---|
| 1404 | /** |
---|
| 1405 | * Implementation of hook_views_api(). |
---|
| 1406 | */ |
---|
| 1407 | function proyecto_estrategico_views_api() { |
---|
| 1408 | return array( |
---|
| 1409 | 'api' => '2.0', |
---|
| 1410 | 'path' => drupal_get_path('module', 'proyecto_estrategico') . '/views', |
---|
[1819be7] | 1411 | ); |
---|
[44f67f8] | 1412 | } |
---|
| 1413 | |
---|
| 1414 | /** |
---|
| 1415 | * Implementation of hook_planificadores_exportar_alter() |
---|
| 1416 | */ |
---|
| 1417 | function proyecto_estrategico_planificadores_exportar_alter(&$tipos) { |
---|
| 1418 | $tipos['proyecto_estrategico']['title'] = t('Proyecto estrategico'); |
---|
| 1419 | $tipos['proyecto_estrategico']['callback'] = '_proyecto_estrategico_exportar'; |
---|
| 1420 | |
---|
| 1421 | } |
---|
| 1422 | |
---|
| 1423 | /** |
---|
| 1424 | * Implementation of _proyecto_estrategico_exportar() |
---|
| 1425 | */ |
---|
| 1426 | function _proyecto_estrategico_exportar($entes, $ente_planificador) { |
---|
| 1427 | $output = ''; |
---|
| 1428 | drupal_set_title(t('Importar situacion actual preliminar')); |
---|
| 1429 | $sql_query = "SELECT nid FROM {content_type_situacion_actual_preliminar} WHERE field_version_planificador_nid = %d"; |
---|
| 1430 | $explicacion = db_fetch_object(db_query($sql_query, $entes->nid)); |
---|
| 1431 | $tipo_plan = 'proyecto_estrategico_proyectos'; |
---|
| 1432 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador->tipo); |
---|
| 1433 | $proyectos = proyecto_estrategico_obtiene_proyectos($ente_planificador, $mi_fecha); |
---|
| 1434 | if (is_array($proyectos) && count($proyectos)) { |
---|
| 1435 | $explicacion_load = node_load($explicacion->nid); |
---|
| 1436 | $headers_table = array(); |
---|
| 1437 | $headers_table[] = array('data' => t('Proyectos')); |
---|
| 1438 | $row = array(); |
---|
| 1439 | $row[] = array('data' => drupal_get_form('proyecto_estrategico_exportar_proyecto_estrategico_form', $ente_planificador, $proyectos)); |
---|
| 1440 | $rows[] = $row; |
---|
| 1441 | $output .= theme('table', $headers_table, $rows); |
---|
[1819be7] | 1442 | } |
---|
[44f67f8] | 1443 | return $output; |
---|
| 1444 | } |
---|
| 1445 | |
---|
| 1446 | function proyecto_estrategico_exportar_proyecto_estrategico_form($form_state, $ente_planificador, $proyectos = array()) { |
---|
| 1447 | $form = array(); |
---|
| 1448 | $form['#ente_planificador'] = $ente_planificador; |
---|
| 1449 | $form['#proyectos'] = $proyectos; |
---|
| 1450 | if (is_array($proyectos) && count($proyectos)) { |
---|
| 1451 | foreach ($proyectos as $id => $value) { |
---|
| 1452 | $form[$id] = array( |
---|
| 1453 | '#type' => 'checkbox', |
---|
| 1454 | '#title' => $value->title, |
---|
| 1455 | ); |
---|
| 1456 | } |
---|
| 1457 | } |
---|
| 1458 | $form['buttons']['submit'] = array( |
---|
| 1459 | '#type' => 'submit', |
---|
| 1460 | '#value' => t('Submit'), |
---|
| 1461 | '#weight' => 20 |
---|
| 1462 | ); |
---|
| 1463 | return $form; |
---|
| 1464 | } |
---|
| 1465 | |
---|
| 1466 | function proyecto_estrategico_exportar_proyecto_estrategico_form_submit($form, &$form_state) { |
---|
| 1467 | global $user; |
---|
| 1468 | module_load_include('inc', 'node', 'node.pages'); |
---|
| 1469 | $ente_planificador = $form['#ente_planificador']; |
---|
| 1470 | $proyectos = $form['#proyectos']; |
---|
| 1471 | $values = array(); |
---|
| 1472 | $counter = 0; |
---|
| 1473 | if (is_array($proyectos) && count($proyectos)) { |
---|
| 1474 | foreach ($proyectos as $id => $proyecto) { |
---|
| 1475 | if ($form_state['values'][$id]) { |
---|
| 1476 | unset($proyecto->nid); |
---|
| 1477 | unset($proyecto->vid); |
---|
| 1478 | $proyecto->uid = $user->uid; |
---|
| 1479 | $proyecto->field_estrategico_ente[0]['nid'] = $ente_planificador->nid; |
---|
| 1480 | node_save($proyecto); |
---|
| 1481 | $counter++; |
---|
| 1482 | } |
---|
| 1483 | } |
---|
| 1484 | } |
---|
| 1485 | drupal_set_message(t('Se agregaron @counter proyectos al ente @ente_name', array('@counter' => $counter, '@ente_name' => $ente_planificador->title))); |
---|
| 1486 | } |
---|
| 1487 | |
---|
| 1488 | /* |
---|
| 1489 | * Implementation of proyecto_estrategico_mostrar_objetivos() |
---|
| 1490 | */ |
---|
| 1491 | function proyecto_estrategico_mostrar_objetivos($ente_planificador, $proyecto) { |
---|
| 1492 | global $user; |
---|
| 1493 | $output = ''; |
---|
| 1494 | drupal_set_title(t('Ver Proyecto @nombre_proyecto', array('@nombre_proyecto' => $proyecto->title))); |
---|
| 1495 | $ente = usuario_tiene_ente($user->uid); |
---|
| 1496 | $accesso = proyecto_estrategico_obtiene_acceso_proceso('proyecto_estrategico_proyectos', $ente_planificador, $ente); |
---|
| 1497 | $objetivos = array(); |
---|
| 1498 | $headers_table = array(); |
---|
| 1499 | $headers_table[] = array( |
---|
| 1500 | 'data' => t('objetivo estratégico'), |
---|
| 1501 | ); |
---|
| 1502 | $headers_table[] = array( |
---|
| 1503 | 'data' => t('Perspectiva asociada al objetivo estratégico'), |
---|
| 1504 | ); |
---|
| 1505 | $headers_table[] = array( |
---|
| 1506 | 'data' => t('Descripción del indicador'), |
---|
| 1507 | ); |
---|
| 1508 | $headers_table[] = array( |
---|
| 1509 | 'data' => t('Unidad de medida'), |
---|
| 1510 | ); |
---|
| 1511 | $headers_table[] = array( |
---|
| 1512 | 'data' => t('Meta total'), |
---|
| 1513 | ); |
---|
| 1514 | $headers_table[] = array( |
---|
| 1515 | 'data' => t('Meta anual'), |
---|
| 1516 | ); |
---|
| 1517 | $headers_table[] = array( |
---|
| 1518 | 'data' => t('Monto anual'), |
---|
| 1519 | ); |
---|
| 1520 | $count_headers_table = count($headers_table); |
---|
| 1521 | if ($accesso) { |
---|
| 1522 | $count_headers_table += 3; |
---|
| 1523 | $headers_table[] = array( |
---|
| 1524 | 'data' => t('Operación'), |
---|
| 1525 | 'colspan' => '3' |
---|
| 1526 | ); |
---|
| 1527 | } |
---|
| 1528 | $objetivos = proyecto_estrategico_obtiene_datos_objetivos($ente_planificador, $proyecto); |
---|
| 1529 | $rows = array(); |
---|
| 1530 | if (is_array($objetivos) && count($objetivos)) { |
---|
| 1531 | foreach($objetivos as $objetivo_id => $objetivo_value) { |
---|
| 1532 | $row = array(); |
---|
| 1533 | $row[] = array('data' => $objetivo_value->title, ); |
---|
| 1534 | //Perspectiva |
---|
| 1535 | $items = array(); |
---|
| 1536 | foreach($objetivo_value->field_objetivo_perspectiva as $value) { |
---|
| 1537 | $items[] = $value['value']; |
---|
| 1538 | } |
---|
| 1539 | $row[] = array('data' => theme('item_list', $items), ); |
---|
| 1540 | //indicador |
---|
| 1541 | $items = array(); |
---|
| 1542 | foreach($objetivo_value->field_objetivo_indicador as $value) { |
---|
| 1543 | $items[] = $value['value']; |
---|
| 1544 | } |
---|
| 1545 | $row[] = array('data' => theme('item_list', $items), ); |
---|
| 1546 | //Unidad de medida |
---|
| 1547 | $items = array(); |
---|
| 1548 | foreach($objetivo_value->field_objetivo_medida as $value) { |
---|
| 1549 | $items[] = $value['value']; |
---|
| 1550 | } |
---|
| 1551 | $row[] = array('data' => theme('item_list', $items), ); |
---|
| 1552 | //Meta total |
---|
| 1553 | $items = array(); |
---|
| 1554 | foreach($objetivo_value->field_objetivo_meta_total as $value) { |
---|
| 1555 | $items[] = $value['value']; |
---|
| 1556 | } |
---|
| 1557 | $row[] = array('data' => theme('item_list', $items), ); |
---|
| 1558 | //Meta anual |
---|
| 1559 | $items = array(); |
---|
| 1560 | foreach($objetivo_value->field_objetivo_meta_anual as $value) { |
---|
| 1561 | $items[] = $value['value']; |
---|
| 1562 | } |
---|
| 1563 | $row[] = array('data' => theme('item_list', $items), ); |
---|
| 1564 | //'Monto anual |
---|
| 1565 | $items = array(); |
---|
| 1566 | foreach($objetivo_value->field_objetivo_monto_anual as $value) { |
---|
| 1567 | $items[] = $value['value']; |
---|
| 1568 | } |
---|
| 1569 | $row[] = array('data' => theme('item_list', $items), ); |
---|
| 1570 | if ($accesso) { |
---|
| 1571 | $row[] = array( |
---|
| 1572 | 'data' => l( |
---|
| 1573 | t('Modificar'), |
---|
| 1574 | 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto->nid . '/objetivos/' . $objetivo_value->nid . '/modificar', |
---|
| 1575 | array( |
---|
| 1576 | 'query' => array( |
---|
| 1577 | 'destination' => 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico' |
---|
| 1578 | ) |
---|
| 1579 | ) |
---|
| 1580 | ), |
---|
| 1581 | ); |
---|
| 1582 | } |
---|
| 1583 | $row[] = array( |
---|
| 1584 | 'data' => l( |
---|
| 1585 | t('Eliminar'), |
---|
| 1586 | 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $funcion_value->nid . '/eliminar', |
---|
| 1587 | array( |
---|
| 1588 | 'query' => array( |
---|
| 1589 | 'destination' => 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico' |
---|
| 1590 | ) |
---|
| 1591 | ) |
---|
| 1592 | ), |
---|
| 1593 | ); |
---|
| 1594 | $rows[] = $row; |
---|
| 1595 | } |
---|
| 1596 | } |
---|
| 1597 | else { |
---|
| 1598 | $row = array(); |
---|
| 1599 | $row[] = array('data' => t('No se encontraron objetivos estratégicos para este ente'), 'colspan' => $count_headers_table); |
---|
| 1600 | $rows[] = $row; |
---|
| 1601 | } |
---|
| 1602 | $output .= '<div id ="proceso-analisis-objetivo-' . $ente_planificador->nid . '"><h2>' . t('Objetivos Estrategicos') . '</h2>'; |
---|
| 1603 | $output .= theme('table', $headers_table, $rows); |
---|
| 1604 | if ($accesso) { |
---|
| 1605 | $output .= l(t('Registrar un objetivo estratégico'), 'planificacion/' . $ente_planificador->nid . '/proyecto_estrategico/' . $proyecto->nid . '/objetivos/registrar'); |
---|
| 1606 | } |
---|
| 1607 | $output .= '</div>'; |
---|
| 1608 | return $output; |
---|
[1819be7] | 1609 | } |
---|