1 | <?php |
---|
2 | /** |
---|
3 | * Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana |
---|
4 | * @file politicas_direccionales.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 2013-12-01 // (año-mes-dia) |
---|
24 | * @version 0.2 // (0.2) |
---|
25 | * |
---|
26 | */ |
---|
27 | |
---|
28 | /** |
---|
29 | * Implementation of hook_theme_registry_alter(). |
---|
30 | * |
---|
31 | * Adaptar la funcionalidad ahah para que funcione con los nuevos elementos |
---|
32 | */ |
---|
33 | function politicas_direccionales_theme_registry_alter(&$theme_registry) { |
---|
34 | if (isset($theme_registry['page'])) { |
---|
35 | if (count($theme_registry['page']['preprocess functions']) > 0) { |
---|
36 | // If jquery_update's preprocess function is there already, remove it. |
---|
37 | if ($key = array_search('politicas_direccionales_preprocess_page', $theme_registry['page']['preprocess functions'])) { |
---|
38 | unset($theme_registry['page']['preprocess functions'][$key]); |
---|
39 | } |
---|
40 | } |
---|
41 | // Now tack it on at the end so it runs after everything else. |
---|
42 | $theme_registry['page']['preprocess functions'][] = 'politicas_direccionales_preprocess_page'; |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | /** |
---|
47 | * Implementation of moduleName_preprocess_hook(). |
---|
48 | * |
---|
49 | * Replace Drupal core's jquery.js with the new one from jQuery Update. |
---|
50 | */ |
---|
51 | function politicas_direccionales_preprocess_page(&$variables) { |
---|
52 | if (!empty($variables['scripts'])) { |
---|
53 | //cambiar el archivo ahah.js para que funcione correctamente los nuevos botones |
---|
54 | $scripts = drupal_add_js(); |
---|
55 | $ahah_path = 'misc/ahah.js'; |
---|
56 | if (isset($scripts['module'][$ahah_path])) { |
---|
57 | $politicas_direccionales_path = drupal_get_path('module', 'politicas_direccionales') .'/replace/ahah.js'; |
---|
58 | $scripts['module'][$politicas_direccionales_path] = $scripts['module'][$ahah_path]; |
---|
59 | unset($scripts['module'][$ahah_path]); |
---|
60 | $variables['scripts'] = drupal_get_js('header', $scripts); |
---|
61 | } |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | /* |
---|
66 | * Implementation of hook_ente_procesos_alter() |
---|
67 | */ |
---|
68 | function politicas_direccionales_ente_procesos_alter(&$procesos, $type) { |
---|
69 | if ($type == 'status') { |
---|
70 | //SE DEFINE EL STATUS DE POLITICAS DIRECCIONALES |
---|
71 | $procesos['politicas_direccionales'] = array( |
---|
72 | 'title' => t('Definición de Póliticas Direccionales'), |
---|
73 | 'description' => t('Definición de Póliticas Direccionales'), |
---|
74 | 'weight' => -9, |
---|
75 | ); |
---|
76 | } |
---|
77 | else { |
---|
78 | // PROCESO DE DEFINIR POSIBLES POLITICAS DIRECCIONALES |
---|
79 | $procesos['posibles'] = array( |
---|
80 | 'title' => t('Planteamiento de posibles Póliticas Direccionales'), |
---|
81 | 'description' => t('Permite agregar, modificar y eliminar posibles póliticas direccionales'), |
---|
82 | 'message' => 'Se podrá registrar y/o modificar los posibles póliticas direccionales desde %fecha hasta la fecha %fecha1', |
---|
83 | 'message_expire' => 'Registrar y/o modificar los posibles póliticas direccionales no se encuentra disponible, se podra realizar desde %fecha hasta la fecha %fecha1)', |
---|
84 | 'weight' => 3, |
---|
85 | 'proceso' => 'politicas_direccionales', |
---|
86 | ); |
---|
87 | /* |
---|
88 | // PROCESO DE IDENTIFICAR INVIABILIDAD POSIBLES POLITICAS DIRECCIONALES |
---|
89 | $procesos['inviabilidad'] = array( |
---|
90 | 'title' => t('Identificar inviabilidad de Póliticas Direccionales'), |
---|
91 | 'description' => t('Permite Identificar inviabilidad de Póliticas Direccionales'), |
---|
92 | 'message' => 'Se podrá registrar y/o modificar Identificar inviabilidad de Póliticas Direccionales desde %fecha hasta la fecha %fecha1', |
---|
93 | 'message_expire' => 'Registrar y/o modificar Identificar inviabilidad de Póliticas Direccionales no se encuentra disponible, se podra realizar desde %fecha hasta la fecha %fecha1)', |
---|
94 | 'weight' => 3, |
---|
95 | 'proceso' => 'politicas_direccionales', |
---|
96 | ); |
---|
97 | // PROCESO DE CONSTRUIR VIABILIDAD POSIBLES POLITICAS DIRECCIONALES |
---|
98 | $procesos['viabilidad'] = array( |
---|
99 | 'title' => t('Construir viabilidad de Póliticas Direccionales'), |
---|
100 | 'description' => t('Permite Construir viabilidad de Póliticas Direccionales'), |
---|
101 | 'message' => 'Se podrá registrar y/o modificar Construir viabilidad de Póliticas Direccionales desde %fecha hasta la fecha %fecha1', |
---|
102 | 'message_expire' => 'Registrar y/o modificar Construir viabilidad de Póliticas Direccionales no se encuentra disponible, se podra realizar desde %fecha hasta la fecha %fecha1)', |
---|
103 | 'weight' => 3, |
---|
104 | 'proceso' => 'politicas_direccionales', |
---|
105 | ); |
---|
106 | */ |
---|
107 | // PROCESO DE SELECCIONAR POLITICAS DIRECCIONALES |
---|
108 | $procesos['posibles_seleccionar'] = array( |
---|
109 | 'title' => t('Seleccionar Póliticas Direccionales'), |
---|
110 | 'description' => t('Permite seleccionar Póliticas Direccionales'), |
---|
111 | 'message' => 'Se podrá registrar y/o modificar la selección de los Póliticas Direccionales desde %fecha hasta la fecha %fecha1', |
---|
112 | 'message_expire' => 'Registrar y/o modificar la selección de los Póliticas Direccionales no se encuentra disponible, se podra realizar desde %fecha hasta la fecha %fecha1)', |
---|
113 | 'weight' => 3, |
---|
114 | 'proceso' => 'politicas_direccionales', |
---|
115 | ); |
---|
116 | /* |
---|
117 | // PROCESO DE DEFINIR ESTRATEGIAS |
---|
118 | $procesos['estrategias'] = array( |
---|
119 | 'title' => t('Definición de Estrategias'), |
---|
120 | 'description' => t('Permite describir Estrategias'), |
---|
121 | 'message' => 'Se podrá registrar y/o modificar la Definición de Estrategias desde %fecha hasta la fecha %fecha1', |
---|
122 | 'message_expire' => 'Registrar y/o modificar Definición de Estrategias no se encuentra disponible, se podra realizar desde %fecha hasta la fecha %fecha1)', |
---|
123 | 'weight' => 3, |
---|
124 | 'proceso' => 'politicas_direccionales', |
---|
125 | ); |
---|
126 | // PROCESO DE DEFINIR ARTICULACION DE ACTORES MICRO EN BASE A ESTRATEGIAS |
---|
127 | $procesos['articulacion_estrategias'] = array( |
---|
128 | 'title' => t('Articulación de actores por estrategias'), |
---|
129 | 'description' => t('Permite articulación de actores por estrategias'), |
---|
130 | 'message' => 'Se podrá registrar y/o modificar la articulación de actores por estrategias desde %fecha hasta la fecha %fecha1', |
---|
131 | 'message_expire' => 'Registrar y/o modificar la articulación de actores por estrategias no se encuentra disponible, se podra realizar desde %fecha hasta la fecha %fecha1)', |
---|
132 | 'weight' => 3, |
---|
133 | 'proceso' => 'politicas_direccionales', |
---|
134 | ); |
---|
135 | |
---|
136 | |
---|
137 | // PROCESO DE REFORMULACION ESTRATEGIAS |
---|
138 | $procesos['reformulacion_estrategias'] = array( |
---|
139 | 'title' => t('Reformulación de Estrategias'), |
---|
140 | 'description' => t('Permite Reformulación Estrategias'), |
---|
141 | 'message' => 'Se podrá registrar y/o modificar la Reformulación de Estrategias desde %fecha hasta la fecha %fecha1', |
---|
142 | 'message_expire' => 'Registrar y/o modificar la Reformulación de Estrategias no se encuentra disponible, se podra realizar desde %fecha hasta la fecha %fecha1)', |
---|
143 | 'weight' => 3, |
---|
144 | 'proceso' => 'politicas_direccionales', |
---|
145 | ); |
---|
146 | |
---|
147 | // PROCESO DE SELECCIONAR ESTRATEGIAS |
---|
148 | $procesos['seleccionar_estrategias'] = array( |
---|
149 | 'title' => t('Seleccionar estrategias'), |
---|
150 | 'description' => t('Permite seleccionar estrategias'), |
---|
151 | 'message' => 'Se podrá registrar y/o modificar la selección estrategias desde %fecha hasta la fecha %fecha1', |
---|
152 | 'message_expire' => 'Registrar y/o modificar la selección estrategias no se encuentra disponible, se podra realizar desde %fecha hasta la fecha %fecha1)', |
---|
153 | 'weight' => 3, |
---|
154 | 'proceso' => 'politicas_direccionales', |
---|
155 | ); |
---|
156 | */ |
---|
157 | } |
---|
158 | } |
---|
159 | |
---|
160 | /* |
---|
161 | * Implementation of hook_menu() |
---|
162 | */ |
---|
163 | function politicas_direccionales_menu() { |
---|
164 | $items = array(); |
---|
165 | // PROCESO DE POSIBLES POLITICAS DIRECCIONALES |
---|
166 | $items['planificacion/%ente_planificador_menu/politicas'] = array( |
---|
167 | 'title' => t('PolÃticas Direccionales'), |
---|
168 | 'page callback' => 'ente_planificador_definir_politicas', |
---|
169 | 'page arguments' => array(1), |
---|
170 | 'access arguments' => array('ver planificador'), |
---|
171 | 'weight' => -7, |
---|
172 | 'type' => MENU_LOCAL_TASK, |
---|
173 | ); |
---|
174 | $items['planificacion/%ente_planificador_menu/politicas/posibles'] = array( |
---|
175 | 'title' => t('Posibles PolÃticas Direccionales'), |
---|
176 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
---|
177 | 'weight' => -10 |
---|
178 | ); |
---|
179 | $items['planificacion/%ente_planificador_menu/politicas/posibles/registrar'] = array( |
---|
180 | 'title' => t('Registrar PolÃticas Direccionales'), |
---|
181 | 'page callback' => 'drupal_get_form', |
---|
182 | 'page arguments' => array('politicas_direccionales_agregar_form', 1), |
---|
183 | 'access callback' => 'ente_planificador_usuario_tiene_politicas_registrar', |
---|
184 | 'access arguments' => array(1), |
---|
185 | 'weight' => -8, |
---|
186 | 'type' => MENU_LOCAL_TASK, |
---|
187 | ); |
---|
188 | $items['planificacion/%ente_planificador_menu/politicas/posibles/%posible_politica/editar'] = array( |
---|
189 | 'title' => t('Modificar PolÃticas Direccionales'), |
---|
190 | 'page callback' => 'drupal_get_form', |
---|
191 | 'page arguments' => array('politicas_direccionales_agregar_form', 1, 4), |
---|
192 | 'access callback' => 'ente_planificador_usuario_tiene_politicas_registrar', |
---|
193 | 'access arguments' => array(1), |
---|
194 | 'weight' => -8, |
---|
195 | 'type' => MENU_LOCAL_TASK, |
---|
196 | ); |
---|
197 | $items['planificacion/%ente_planificador_menu/politicas/posibles/%posible_politica/remove'] = array( |
---|
198 | 'title' => t('Eliminar PolÃticas Direccionales'), |
---|
199 | 'page callback' => 'drupal_get_form', |
---|
200 | 'page arguments' => array('politicas_direccionales_remove_posible_politica_form', 1, 4), |
---|
201 | 'access callback' => 'ente_planificador_usuario_tiene_politicas_registrar', |
---|
202 | 'access arguments' => array(1), |
---|
203 | 'weight' => -4, |
---|
204 | 'type' => MENU_CALLBACK, |
---|
205 | ); |
---|
206 | /* |
---|
207 | $items['planificacion/%ente_planificador_menu/politicas/posibles/buscar'] = array( |
---|
208 | 'title' => t('Buscar Posibles PolÃticas Direccionales'), |
---|
209 | 'page callback' => 'politicas_direccionales_buscar_posibles', |
---|
210 | 'access callback' => 'ente_planificador_usuario_es_macro', |
---|
211 | 'access arguments' => array(1), |
---|
212 | 'weight' => -8, |
---|
213 | 'type' => MENU_LOCAL_TASK, |
---|
214 | ); |
---|
215 | */ |
---|
216 | $items['planificacion/%/politicas/consultar/%'] = array( |
---|
217 | 'title' => t('Consultar PolÃticas Direccionales'), |
---|
218 | 'page callback' => 'politicas_direccionales_consultar', |
---|
219 | 'page arguments' => array(1,4), |
---|
220 | 'access arguments' => array('ver planificador'), |
---|
221 | 'weight' => -8, |
---|
222 | ); |
---|
223 | |
---|
224 | $items['planificacion/%ente_planificador_menu/politicas/posibles/listar'] = array( |
---|
225 | 'title' => t('Consultar PolÃticas Direccionales'), |
---|
226 | 'page callback' => 'ente_planificador_definir_politicas_listar', |
---|
227 | 'page arguments' => array(1), |
---|
228 | 'access arguments' => array('ver planificador'), |
---|
229 | 'weight' => -8, |
---|
230 | 'type' => MENU_LOCAL_TASK, |
---|
231 | ); |
---|
232 | |
---|
233 | // PROCESO DE SELECCIONAR POLITICAS DIRECCIONALES |
---|
234 | $items['planificacion/%ente_planificador_menu/politicas/seleccionar'] = array( |
---|
235 | 'title' => t('PolÃticas Direccionales'), |
---|
236 | 'page callback' => 'ente_planificador_seleccionar_politicas', |
---|
237 | 'page arguments' => array(1), |
---|
238 | 'access arguments' => array('ver planificador'), |
---|
239 | 'weight' => -8, |
---|
240 | 'type' => MENU_LOCAL_TASK, |
---|
241 | ); |
---|
242 | |
---|
243 | $items['planificacion/%ente_planificador_menu/politicas/seleccionar/ver'] = array( |
---|
244 | 'title' => t('PolÃticas Direccionales'), |
---|
245 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
---|
246 | 'weight' => -10 |
---|
247 | ); |
---|
248 | /* |
---|
249 | $items['planificacion/%ente_planificador_menu/politicas/seleccionar/viabilidad'] = array( |
---|
250 | 'title' => t('Identificar inviabilidad de posibles polÃticas'), |
---|
251 | 'page callback' => 'drupal_get_form', |
---|
252 | 'page arguments' => array('politicas_direccionales_indentificar_viabilidad_form', 1), |
---|
253 | 'access callback' => 'ente_planificador_usuario_tiene_identificar_politicas', |
---|
254 | 'access arguments' => array(1), |
---|
255 | 'weight' => -8, |
---|
256 | 'type' => MENU_LOCAL_TASK, |
---|
257 | ); |
---|
258 | $items['planificacion/%ente_planificador_menu/politicas/seleccionar/inviables'] = array( |
---|
259 | 'title' => t('Consultar posibles polÃticas inviables'), |
---|
260 | 'page callback' => 'ente_planificador_definir_politicas_listar_inviables', |
---|
261 | 'page arguments' => array(1), |
---|
262 | 'access arguments' => array('ver planificador'), |
---|
263 | 'weight' => -8, |
---|
264 | 'type' => MENU_LOCAL_TASK, |
---|
265 | ); |
---|
266 | */ |
---|
267 | $items['planificacion/%ente_planificador_menu/politicas/seleccionar/politicas'] = array( |
---|
268 | 'title' => t('Seleccionar polÃticas direccionales'), |
---|
269 | 'page callback' => 'drupal_get_form', |
---|
270 | 'page arguments' => array('politicas_direccionales_seleccionar_politicas_form', 1), |
---|
271 | 'access callback' => 'ente_planificador_usuario_tiene_seleccionar_politicas', |
---|
272 | 'access arguments' => array(1), |
---|
273 | 'weight' => -8, |
---|
274 | 'type' => MENU_LOCAL_TASK, |
---|
275 | ); |
---|
276 | |
---|
277 | /* |
---|
278 | $items['planificacion/%ente_planificador_menu/politicas/seleccionar/consultar'] = array( |
---|
279 | 'title' => t('Consultar posibles polÃticas inviables'), |
---|
280 | 'page callback' => 'politicas_direccionales_seleccionar_politicas_listar', |
---|
281 | 'page arguments' => array(1), |
---|
282 | 'access arguments' => array('ver planificador'), |
---|
283 | 'weight' => -8, |
---|
284 | 'type' => MENU_LOCAL_TASK, |
---|
285 | ); |
---|
286 | */ |
---|
287 | |
---|
288 | $items['planificacion/%ente_planificador_menu/politicas/seleccionar/buscar'] = array( |
---|
289 | 'title' => t('Consultar posibles polÃticas inviables'), |
---|
290 | 'page callback' => 'politicas_direccionales_buscar_seleccion', |
---|
291 | 'page arguments' => array(1), |
---|
292 | 'access callback' => 'ente_planificador_usuario_es_macro', |
---|
293 | 'access arguments' => array(1), |
---|
294 | 'weight' => -8, |
---|
295 | 'type' => MENU_LOCAL_TASK, |
---|
296 | ); |
---|
297 | /* |
---|
298 | $items['planificacion/%ente_planificador_menu/politicas/seleccionar/%posible_politica/editar_accion'] = array( |
---|
299 | 'title' => t('Modificar PolÃticas Direccionales'), |
---|
300 | 'page callback' => 'drupal_get_form', |
---|
301 | 'page arguments' => array('politicas_direccionales_agregar_accion_form', 1, 4), |
---|
302 | 'access callback' => 'ente_planificador_usuario_tiene_politicas_viabilidad', |
---|
303 | 'access arguments' => array(1), |
---|
304 | 'weight' => -8, |
---|
305 | 'type' => MENU_LOCAL_TASK, |
---|
306 | ); |
---|
307 | $items['planificacion/%ente_planificador_menu/politicas/seleccionar/%posible_politica/remove_accion'] = array( |
---|
308 | 'title' => t('Eliminar PolÃticas Direccionales'), |
---|
309 | 'page callback' => 'drupal_get_form', |
---|
310 | 'page arguments' => array('politicas_direccionales_remove_accion_posible_politica_form', 1, 4), |
---|
311 | 'access callback' => 'ente_planificador_usuario_tiene_politicas_viabilidad', |
---|
312 | 'access arguments' => array(1), |
---|
313 | 'weight' => -4, |
---|
314 | 'type' => MENU_CALLBACK, |
---|
315 | ); |
---|
316 | */ |
---|
317 | |
---|
318 | /* PROCESO DE ESTRATEGIAS |
---|
319 | $items['planificacion/%ente_planificador_menu/politicas/estrategias'] = array( |
---|
320 | 'title' => t('Estrategias'), |
---|
321 | 'page callback' => 'ente_planificador_estrategias_politicas', |
---|
322 | 'page arguments' => array(1), |
---|
323 | 'access arguments' => array('ver planificador'), |
---|
324 | 'weight' => -7, |
---|
325 | 'type' => MENU_LOCAL_TASK, |
---|
326 | ); |
---|
327 | $items['planificacion/%ente_planificador_menu/politicas/estrategias/registrar'] = array( |
---|
328 | 'title' => t('Registrar Estrategia'), |
---|
329 | 'page callback' => 'drupal_get_form', |
---|
330 | 'page arguments' => array('politicas_direccionales_agregar_estrategia_form', 1), |
---|
331 | 'access callback' => 'ente_planificador_usuario_tiene_estrategias_politicas_registrar', |
---|
332 | 'access arguments' => array(1), |
---|
333 | 'weight' => -8, |
---|
334 | 'type' => MENU_LOCAL_TASK, |
---|
335 | ); |
---|
336 | $items['planificacion/%ente_planificador_menu/politicas/estrategias/listar'] = array( |
---|
337 | 'title' => t('Posibles Estrategias'), |
---|
338 | 'page callback' => 'politicas_direccionales_estrategias_posibles_listar', |
---|
339 | 'page arguments' => array(1), |
---|
340 | 'access arguments' => array('ver planificador'), |
---|
341 | 'weight' => -8, |
---|
342 | 'type' => MENU_LOCAL_TASK, |
---|
343 | ); |
---|
344 | /* |
---|
345 | $items['planificacion/%ente_planificador_menu/politicas/estrategias/reformular'] = array( |
---|
346 | 'title' => t('Posibles Estrategias'), |
---|
347 | 'page callback' => 'politicas_direccionales_estrategias_posibles_listar_reformular', |
---|
348 | 'page arguments' => array(1), |
---|
349 | 'access callback' => 'ente_planificador_usuario_tiene_estrategias_politicas_reformular', |
---|
350 | 'access arguments' => array(1), |
---|
351 | 'weight' => -8, |
---|
352 | 'type' => MENU_LOCAL_TASK, |
---|
353 | ); |
---|
354 | $items['planificacion/%ente_planificador_menu/politicas/estrategias/%posible_estrategia/reformular'] = array( |
---|
355 | 'title' => t('Modificar estrategia'), |
---|
356 | 'page callback' => 'drupal_get_form', |
---|
357 | 'page arguments' => array('politicas_direccionales_agregar_estrategia_form', 1, 4), |
---|
358 | 'access callback' => 'ente_planificador_usuario_tiene_estrategias_puede_reformular', |
---|
359 | 'access arguments' => array(1, 4), |
---|
360 | 'weight' => -8, |
---|
361 | 'type' => MENU_LOCAL_TASK, |
---|
362 | ); |
---|
363 | */ |
---|
364 | /* |
---|
365 | $items['planificacion/%ente_planificador_menu/politicas/estrategias/identificar'] = array( |
---|
366 | 'title' => t('Identificar posible articulación'), |
---|
367 | 'page callback' => 'politicas_direccionales_estrategias_posibles_identificar', |
---|
368 | 'page arguments' => array(1), |
---|
369 | 'access callback' => 'ente_planificador_usuario_tiene_estrategias_politicas_puede_articular', |
---|
370 | 'access arguments' => array(1), |
---|
371 | 'weight' => -8, |
---|
372 | 'type' => MENU_LOCAL_TASK, |
---|
373 | ); |
---|
374 | $items['planificacion/%ente_planificador_menu/politicas/estrategias/consultar_articulacion'] = array( |
---|
375 | 'title' => t('Identificar posible articulación'), |
---|
376 | 'page callback' => 'politicas_direccionales_estrategias_consultar_articulaciones', |
---|
377 | 'page arguments' => array(1), |
---|
378 | 'access arguments' => array('ver planificador'), |
---|
379 | 'weight' => -8, |
---|
380 | 'type' => MENU_LOCAL_TASK, |
---|
381 | ); |
---|
382 | $items['planificacion/%ente_planificador_menu/politicas/estrategias/consultar_articulacion_micro'] = array( |
---|
383 | 'title' => t('Identificar posible articulación'), |
---|
384 | 'page callback' => 'politicas_direccionales_estrategias_consultar_articulaciones_actores_micro', |
---|
385 | 'page arguments' => array(1), |
---|
386 | 'access callback' => 'ente_planificador_tiene_articulacion', |
---|
387 | 'access arguments' => array(1), |
---|
388 | 'weight' => -8, |
---|
389 | 'type' => MENU_LOCAL_TASK, |
---|
390 | ); |
---|
391 | |
---|
392 | $items['planificacion/%ente_planificador_menu/politicas/estrategias/seleccionar'] = array( |
---|
393 | 'title' => t('Identificar posible articulación'), |
---|
394 | 'page callback' => 'politicas_direccionales_estrategias_seleccionar_estrategias', |
---|
395 | 'page arguments' => array(1), |
---|
396 | 'access callback' => 'ente_planificador_usuario_puede_estrategias_seleccionar', |
---|
397 | 'access arguments' => array(1), |
---|
398 | 'weight' => -8, |
---|
399 | 'type' => MENU_LOCAL_TASK, |
---|
400 | ); |
---|
401 | $items['planificacion/%ente_planificador_menu/politicas/estrategias/pol_estr'] = array( |
---|
402 | 'title' => t('Identificar posible articulación'), |
---|
403 | 'page callback' => 'politicas_direccionales_mostrar_estrategias_por_politicas', |
---|
404 | 'page arguments' => array(1), |
---|
405 | 'access arguments' => array('ver planificador'), |
---|
406 | 'weight' => -8, |
---|
407 | 'type' => MENU_LOCAL_TASK, |
---|
408 | ); |
---|
409 | |
---|
410 | $items['planificacion/%ente_planificador_menu/politicas/estrategias/%politica_seleccionada/seleccionar'] = array( |
---|
411 | 'title' => t('Seleccionar estrategias para la polÃtica'), |
---|
412 | 'page callback' => 'drupal_get_form', |
---|
413 | 'page arguments' => array('politicas_direccionales_seleccionar_estrategias_form', 1, 4), |
---|
414 | 'access callback' => 'ente_planificador_usuario_puede_estrategias_seleccionar_politicas', |
---|
415 | 'access arguments' => array(1, 4), |
---|
416 | 'weight' => -8, |
---|
417 | 'type' => MENU_LOCAL_TASK, |
---|
418 | ); |
---|
419 | $items['planificacion/%ente_planificador_menu/politicas/estrategias/%posible_estrategia/editar'] = array( |
---|
420 | 'title' => t('Modificar estrategia'), |
---|
421 | 'page callback' => 'drupal_get_form', |
---|
422 | 'page arguments' => array('politicas_direccionales_agregar_estrategia_form', 1, 4), |
---|
423 | 'access callback' => 'ente_planificador_usuario_tiene_estrategias_puede_editar', |
---|
424 | 'access arguments' => array(1, 4), |
---|
425 | 'weight' => -8, |
---|
426 | 'type' => MENU_LOCAL_TASK, |
---|
427 | ); |
---|
428 | $items['planificacion/%ente_planificador_menu/politicas/estrategias/%posible_estrategia/remove'] = array( |
---|
429 | 'title' => t('Eliminar estrategia'), |
---|
430 | 'page callback' => 'drupal_get_form', |
---|
431 | 'page arguments' => array('politicas_direccionales_remove_estrategia_posible_politica_form', 1, 4), |
---|
432 | 'access callback' => 'ente_planificador_usuario_tiene_estrategias_puede_editar', |
---|
433 | 'access arguments' => array(1, 4), |
---|
434 | 'weight' => -4, |
---|
435 | 'type' => MENU_CALLBACK, |
---|
436 | ); |
---|
437 | */ |
---|
438 | //MI PLANIFICACION |
---|
439 | $items['mi_ente_planificador/planificacion/politicas'] = array( |
---|
440 | 'title' => t('Politicas Direccionales'), |
---|
441 | 'page callback' => 'mis_entes_planificadores_planificacion_politicas', |
---|
442 | 'access callback' => 'ente_planificador_usuario_ve_ente', |
---|
443 | 'type' => MENU_LOCAL_TASK, |
---|
444 | ); |
---|
445 | $items['politicas_direccionales_agregar_js'] = array( |
---|
446 | 'title' => 'JS utilities', |
---|
447 | 'page callback' => 'politicas_direccionales_agregar_js', |
---|
448 | 'access arguments' => array('ver planificador'), |
---|
449 | 'type' => MENU_CALLBACK, |
---|
450 | ); |
---|
451 | $items['politicas_direccionales_causas_ahah'] = array( |
---|
452 | 'title' => 'JS utilities', |
---|
453 | 'page callback' => 'politicas_direccionales_causas_ahah', |
---|
454 | 'access arguments' => array('ver planificador'), |
---|
455 | 'type' => MENU_CALLBACK, |
---|
456 | ); |
---|
457 | $items['politicas_direccionales_form_add_causas'] = array( |
---|
458 | 'title' => 'JS utilities', |
---|
459 | 'page callback' => 'politicas_direccionales_form_add_causas_ahah', |
---|
460 | 'access arguments' => array('ver planificador'), |
---|
461 | 'type' => MENU_CALLBACK, |
---|
462 | ); |
---|
463 | //configuracion Explicación Situacional |
---|
464 | $items['admin/settings/ente_planificador/politicas_direccionales'] = array( |
---|
465 | 'title' => t('Politicas Direccionales'), |
---|
466 | 'page callback' => 'drupal_get_form', |
---|
467 | 'page arguments' => array('politicas_direccionales_admin_settings'), |
---|
468 | 'access arguments' => array('admin planificador'), |
---|
469 | 'type' => MENU_LOCAL_TASK, |
---|
470 | 'file' => 'politicas_direccionales.admin.inc', |
---|
471 | ); |
---|
472 | $items['admin/settings/ente_planificador/politicas_direccionales/configurar'] = array( |
---|
473 | 'title' => t('Configurar'), |
---|
474 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
---|
475 | ); |
---|
476 | /** ahah para el cambio de vista en el admin **/ |
---|
477 | $items['politicas_direccionales_views_js'] = array( |
---|
478 | 'title' => 'Vista por tipo de proceso', |
---|
479 | 'page callback' => 'politicas_direccionales_views_js', |
---|
480 | 'access arguments' => array('ver planificador'), |
---|
481 | 'type' => MENU_CALLBACK, |
---|
482 | ); |
---|
483 | return $items; |
---|
484 | } |
---|
485 | |
---|
486 | /** |
---|
487 | * Implementation of posible_politica_load(). |
---|
488 | * Leer una posible politica direccional. |
---|
489 | */ |
---|
490 | function posible_politica_load($nid = 0) { |
---|
491 | if ($nid && is_numeric($nid)) { |
---|
492 | $node_load = node_load($nid); |
---|
493 | if ($node_load && $node_load->type == 'politicas_direccionales') { |
---|
494 | return $node_load; |
---|
495 | } |
---|
496 | } |
---|
497 | return FALSE; |
---|
498 | } |
---|
499 | |
---|
500 | /** |
---|
501 | * Implementation of politica_seleccionada_load(). |
---|
502 | * Leer una politica direccional. |
---|
503 | */ |
---|
504 | function politica_seleccionada_load($nid = 0) { |
---|
505 | if ($nid && is_numeric($nid)) { |
---|
506 | $node_load = node_load($nid); |
---|
507 | if ($node_load && $node_load->type == 'politicas_direccionales' && $node_load->field_politicas_seleccionada[0]['value'] = 'SÃ') { |
---|
508 | return $node_load; |
---|
509 | } |
---|
510 | } |
---|
511 | return FALSE; |
---|
512 | } |
---|
513 | |
---|
514 | /** |
---|
515 | * Implementation of posible_estrategia_load(). |
---|
516 | * Leer una posible estrategia. |
---|
517 | */ |
---|
518 | function posible_estrategia_load($nid = 0) { |
---|
519 | if ($nid && is_numeric($nid)) { |
---|
520 | $node_load = node_load($nid); |
---|
521 | if ($node_load && $node_load->type == 'estrategia') { |
---|
522 | return $node_load; |
---|
523 | } |
---|
524 | } |
---|
525 | return FALSE; |
---|
526 | } |
---|
527 | |
---|
528 | /** |
---|
529 | * Implementation of politicas_direccionales_buscar_posibles(). |
---|
530 | * Cargar la vista de buscar posibles politicas direccionales. |
---|
531 | * |
---|
532 | function politicas_direccionales_buscar_posibles() { |
---|
533 | $output = ''; |
---|
534 | $name = 'posibles_politicas'; |
---|
535 | $display_id = 'default'; |
---|
536 | if ($view = views_get_view($name)) { |
---|
537 | if ($view->access($display_id)) { |
---|
538 | $output = $view->execute_display($display_id); |
---|
539 | $view->destroy(); |
---|
540 | } |
---|
541 | $view->destroy(); |
---|
542 | } |
---|
543 | return $output; |
---|
544 | } |
---|
545 | */ |
---|
546 | |
---|
547 | /** |
---|
548 | * Implementation of politicas_direccionales_buscar_seleccion(). |
---|
549 | * Cargar la vista de buscar politicas direccionales. |
---|
550 | */ |
---|
551 | function politicas_direccionales_buscar_seleccion($ente_planificador) { |
---|
552 | $plan = "politicas"; |
---|
553 | $tipo = "politicas"; |
---|
554 | $planns = _politicas_direccionales_get_planns(); |
---|
555 | |
---|
556 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
557 | $breadcrumb[] = l(t('Consulta de PolÃticas Direccionales'), 'planificacion/' . $ente_planificador->nid . '/politicas'); |
---|
558 | // $items['planificacion/%ente_planificador_menu/politicas/posibles/%/consultar'] = array(drupal_set_breadcrumb($breadcrumb)); |
---|
559 | $output = ''; |
---|
560 | $view_id = variable_get('politicas_direccionales_' . $planns[$plan]['plan'] . '_' . $tipo, 0); |
---|
561 | if ($view = views_get_view($view_id)) { |
---|
562 | $display_id = variable_get('politicas_direccionales_display_views_' . $planns[$plan]['plan'] . '_' . $tipo, 'default'); |
---|
563 | $view->set_display($display_id); |
---|
564 | $view->set_arguments(array($ente_planificador->nid)); |
---|
565 | $view->override_path = $_GET['q']; |
---|
566 | $view->pre_execute(); |
---|
567 | $view->execute(); |
---|
568 | $output = $view->render(); |
---|
569 | } |
---|
570 | return $output; |
---|
571 | } |
---|
572 | |
---|
573 | /** |
---|
574 | * View politica |
---|
575 | */ |
---|
576 | function politicas_direccionales_consultar($ente_planificador, $politica) { |
---|
577 | $plan = "politicas"; |
---|
578 | $tipo = "consultar"; |
---|
579 | $planns = _politicas_direccionales_get_planns(); |
---|
580 | |
---|
581 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
582 | $breadcrumb[] = l(t('Definición de PolÃticas Direccionales'), 'planificacion/' . $ente_planificador . '/politicas'); |
---|
583 | drupal_set_breadcrumb($breadcrumb); |
---|
584 | |
---|
585 | $view_id = variable_get('politicas_direccionales_' . $planns[$plan]['plan'] . '_' . $tipo, 0); |
---|
586 | if ($view = views_get_view($view_id)) { |
---|
587 | $display_id = variable_get('politicas_direccionales_display_views_' . $planns[$plan]['plan'] . '_' . $tipo, 'default'); |
---|
588 | $view->set_display($display_id); |
---|
589 | $view->set_arguments(array($politica)); |
---|
590 | $view->override_path = $_GET['q']; |
---|
591 | $view->pre_execute(); |
---|
592 | $view->execute(); |
---|
593 | $output = $view->render(); |
---|
594 | } |
---|
595 | else { |
---|
596 | $output = ''; |
---|
597 | } |
---|
598 | $output .= l(t('Regresar al listado de PolÃticas'), 'planificacion/' . $ente_planificador . '/politicas'); |
---|
599 | return $output; |
---|
600 | } |
---|
601 | |
---|
602 | /* |
---|
603 | * politicas_direccionales_agregar_js |
---|
604 | * Generates AJAX responses of politicas direccionales |
---|
605 | */ |
---|
606 | function politicas_direccionales_agregar_js($tipo = '', $i = 1) { |
---|
607 | // module_load_include('inc', 'node', 'node.pages'); |
---|
608 | // module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
609 | // The AHAH callback function triggered by the user changing the first field, "ahahtestmodule_types" |
---|
610 | $form_state = array('storage' => NULL, 'submitted' => FALSE); |
---|
611 | $form_build_id = $_POST['form_build_id']; |
---|
612 | // Get for the form from the cache |
---|
613 | $form = form_get_cache($form_build_id, $form_state); |
---|
614 | // Get the form set up to process |
---|
615 | $args = $form['#parameters']; |
---|
616 | $form_id = array_shift($args); |
---|
617 | $form_state['post'] = $form['#post'] = $_POST; |
---|
618 | $form['#programmed'] = $form['#redirect'] = FALSE; |
---|
619 | |
---|
620 | if ($tipo == 'ente' && is_numeric($i)) { |
---|
621 | $count = $_POST['cantidad_ente_' . $i]; |
---|
622 | $count++; |
---|
623 | //increment count value |
---|
624 | $form['campo_requerimiento']['politica_' . $i]['actores_' . $cantidad_entes]['cantidad_ente_' . $i] = array('#type' => 'hidden', '#value' => $count); |
---|
625 | } |
---|
626 | else if ($tipo == 'requerimiento') { |
---|
627 | $count = $_POST['cantidad_requerimientos'] ? $_POST['cantidad_requerimientos'] : 1; |
---|
628 | $count++; |
---|
629 | //increment count value |
---|
630 | $form['campo_requerimiento']['cantidad_requerimientos'] = array('#type' => 'hidden', '#value' => $count); |
---|
631 | } |
---|
632 | |
---|
633 | // Process the form with drupal_process_form(), which calls the submit handlers that put whatever was worthy of keeping in the $form_state |
---|
634 | drupal_process_form($form_id, $form, $form_state); |
---|
635 | // Call drupal_rebuild_form(), which destroys $_POST, creates the form again with hook_form, gets the new form cached and processed again |
---|
636 | $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); |
---|
637 | |
---|
638 | // THIS IS WHAT YOU WILL CUSTOMIZE FOR YOUR OWN FORM |
---|
639 | // Choose the field you want to update with AHAH and render it |
---|
640 | if ($tipo == 'ente' && is_numeric($i)) { |
---|
641 | $ahah_form = $form['campo_requerimiento']['politica_' . $i]; |
---|
642 | } |
---|
643 | else if ($tipo == 'requerimiento') { |
---|
644 | $ahah_form = $form['campo_requerimiento']; |
---|
645 | } |
---|
646 | unset($ahah_form['#prefix'], $ahah_form['#suffix']); |
---|
647 | $output = drupal_render($ahah_form); |
---|
648 | $output .= drupal_get_js(); |
---|
649 | // Final rendering callback. |
---|
650 | print drupal_to_js(array('data' => $output, 'status' => true)); |
---|
651 | exit(); |
---|
652 | |
---|
653 | /** |
---|
654 | |
---|
655 | if ($tipo == 'ente' && is_numeric($i)) { |
---|
656 | $count = $_POST['cantidad_ente_' . $i]; |
---|
657 | $count++; |
---|
658 | |
---|
659 | // The AHAH callback function triggered by the user changing the first field, "ahahtestmodule_types" |
---|
660 | $form_state = array('storage' => NULL, 'submitted' => FALSE); |
---|
661 | $form_build_id = $_POST['form_build_id']; |
---|
662 | // Get for the form from the cache |
---|
663 | $form = form_get_cache($form_build_id, $form_state); |
---|
664 | // Get the form set up to process |
---|
665 | $args = $form['#parameters']; |
---|
666 | $form_id = array_shift($args); |
---|
667 | $form_state['post'] = $form['#post'] = $_POST; |
---|
668 | $form['#programmed'] = $form['#redirect'] = FALSE; |
---|
669 | |
---|
670 | //increment count value |
---|
671 | $form['campo_requerimiento']['politica_' . $i]['actores_' . $cantidad_entes]['cantidad_ente_' . $i] = array('#type' => 'hidden', '#value' => $count); |
---|
672 | |
---|
673 | // Process the form with drupal_process_form(), which calls the submit handlers that put whatever was worthy of keeping in the $form_state |
---|
674 | drupal_process_form($form_id, $form, $form_state); |
---|
675 | // Call drupal_rebuild_form(), which destroys $_POST, creates the form again with hook_form, gets the new form cached and processed again |
---|
676 | $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); |
---|
677 | |
---|
678 | // THIS IS WHAT YOU WILL CUSTOMIZE FOR YOUR OWN FORM |
---|
679 | // Choose the field you want to update with AHAH and render it |
---|
680 | $ahah_form = $form['campo_requerimiento']['politica_' . $i]; |
---|
681 | unset($ahah_form['#prefix'], $ahah_form['#suffix']); |
---|
682 | $output = drupal_render($ahah_form); |
---|
683 | // $output .= drupal_get_js(); |
---|
684 | // Final rendering callback. |
---|
685 | print drupal_to_js(array('data' => $output, 'status' => true)); |
---|
686 | exit(); |
---|
687 | } |
---|
688 | elseif ($tipo == 'requerimiento') { |
---|
689 | $count = $_POST['cantidad_requerimientos'] ? $_POST['cantidad_requerimientos'] : 1; |
---|
690 | $count++; |
---|
691 | |
---|
692 | // The AHAH callback function triggered by the user changing the first field, "ahahtestmodule_types" |
---|
693 | $form_state = array('storage' => NULL, 'submitted' => FALSE); |
---|
694 | $form_build_id = $_POST['form_build_id']; |
---|
695 | // Get for the form from the cache |
---|
696 | $form = form_get_cache($form_build_id, $form_state); |
---|
697 | // Get the form set up to process |
---|
698 | $args = $form['#parameters']; |
---|
699 | $form_id = array_shift($args); |
---|
700 | $form_state['post'] = $form['#post'] = $_POST; |
---|
701 | $form['#programmed'] = $form['#redirect'] = FALSE; |
---|
702 | |
---|
703 | //increment count value |
---|
704 | $form['campo_requerimiento']['cantidad_requerimientos'] = array('#type' => 'hidden', '#value' => $count); |
---|
705 | |
---|
706 | // Process the form with drupal_process_form(), which calls the submit handlers that put whatever was worthy of keeping in the $form_state |
---|
707 | drupal_process_form($form_id, $form, $form_state); |
---|
708 | // Call drupal_rebuild_form(), which destroys $_POST, creates the form again with hook_form, gets the new form cached and processed again |
---|
709 | $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); |
---|
710 | |
---|
711 | // THIS IS WHAT YOU WILL CUSTOMIZE FOR YOUR OWN FORM |
---|
712 | // Choose the field you want to update with AHAH and render it |
---|
713 | $ahah_form = $form['campo_requerimiento']; |
---|
714 | unset($ahah_form['#prefix'], $ahah_form['#suffix']); |
---|
715 | $output = drupal_render($ahah_form); |
---|
716 | $output .= drupal_get_js(); |
---|
717 | // Final rendering callback. |
---|
718 | print drupal_to_js(array('data' => $output, 'status' => true)); |
---|
719 | exit(); |
---|
720 | } |
---|
721 | |
---|
722 | print ''; |
---|
723 | exit(); |
---|
724 | **/ |
---|
725 | } |
---|
726 | |
---|
727 | /** |
---|
728 | * Implementation of politicas_direccionales_indentificar_viabilidad_form(). |
---|
729 | * Formulario para identificar viabilidad de posibles politicas direccionales |
---|
730 | */ |
---|
731 | function politicas_direccionales_indentificar_viabilidad_form($form_state, $ente_planificador) { |
---|
732 | global $user; |
---|
733 | drupal_set_title(t('Identificar inviabilidad de posibles polÃticas')); |
---|
734 | $ente = usuario_tiene_ente($user->uid); |
---|
735 | $mi_fecha1 = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
736 | $mi_fecha = ente_planificador_user_acceso_proceso("viabilidad", $ente_planificador); |
---|
737 | $current_time = time(); |
---|
738 | $ente_has_acceso = FALSE; |
---|
739 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
740 | $fecha = TRUE; |
---|
741 | } |
---|
742 | if (!$fecha) { |
---|
743 | muestra_mensaje("viabilidad", $ente_planificador); |
---|
744 | } |
---|
745 | else { |
---|
746 | if ($ente->nid == $ente_planificador->nid) { |
---|
747 | muestra_mensaje("viabilidad", $ente_planificador, 0); |
---|
748 | } |
---|
749 | } |
---|
750 | if ($fecha && (user_access('admin planificador') || $ente->nid == $ente_planificador->nid)) { |
---|
751 | $ente_has_acceso = TRUE; |
---|
752 | } |
---|
753 | if ($ente_planificador->tipo > 1) { |
---|
754 | $ente_has_acceso = FALSE; |
---|
755 | if ($ente_planificador && $ente_planificador->nid && $politica && $politica->nid) { |
---|
756 | if (module_exists('ente_planificador_hierarchical')) { |
---|
757 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
758 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
759 | $ente_has_acceso= TRUE; |
---|
760 | } |
---|
761 | $ente_has_acceso= FALSE; |
---|
762 | } |
---|
763 | } |
---|
764 | } |
---|
765 | $macro = ente_planificador_ente_macro($ente_planificador); |
---|
766 | if ($macro) { |
---|
767 | $ente_planificador = node_load($macro); |
---|
768 | } |
---|
769 | } |
---|
770 | $sql_query = "SELECT c.nid, n.title FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND n.created >= %d AND n.created <= %d AND n.status > 0"; |
---|
771 | $sql_variables = array(); |
---|
772 | $sql_variables[] = $ente_planificador->nid; |
---|
773 | $sql_variables[] = $mi_fecha1[0]; |
---|
774 | $sql_variables[] = $mi_fecha1[1] + 86399; |
---|
775 | $result = db_query($sql_query, $sql_variables); |
---|
776 | $politicas = array(); |
---|
777 | while($politica = db_fetch_object($result)) { |
---|
778 | $politica_Load = node_load($politica->nid); |
---|
779 | |
---|
780 | $politicas[$politica->nid] = $politica_Load->nid? $politica_Load->body: $politica->title; |
---|
781 | } |
---|
782 | $form = array(); |
---|
783 | $form['#ente_planificador'] = $ente_planificador; |
---|
784 | $output_politicas = count($politicas) ? theme('item_list', $politicas) : t('No existen polÃticas registradas.'); |
---|
785 | $form['politicas'] = array( |
---|
786 | '#value' => $output_politicas, |
---|
787 | ); |
---|
788 | $form['#politicas'] = $politicas; |
---|
789 | if ($ente_has_acceso && count($politicas)) { |
---|
790 | $form['buttons'] = array( |
---|
791 | '#prefix' => '<div class="container-inline">', |
---|
792 | '#suffix' => '</div>', |
---|
793 | '#weight' => 100, |
---|
794 | ); |
---|
795 | $form['buttons']['submit'] = array( |
---|
796 | '#type' => 'submit', |
---|
797 | '#value' => t('Submit'), |
---|
798 | '#weight' => 100, |
---|
799 | ); |
---|
800 | $form['buttons']['cancel'] = array( |
---|
801 | '#type' => 'submit', |
---|
802 | '#value' => t('Cancel'), |
---|
803 | '#weight' => 100, |
---|
804 | ); |
---|
805 | } |
---|
806 | $form['#after_build'] = array(); |
---|
807 | $form['#after_build'][] = 'politicas_direccionales_skip_validation_form_after_build'; |
---|
808 | return $form; |
---|
809 | } |
---|
810 | |
---|
811 | /** |
---|
812 | * Implementation of politicas_direccionales_indentificar_viabilidad_form_submit(). |
---|
813 | * Procesar el formulario para identificar viabilidad de posibles politicas direccionales |
---|
814 | */ |
---|
815 | function politicas_direccionales_indentificar_viabilidad_form_submit($form, &$form_state) { |
---|
816 | $export_users = array(); |
---|
817 | if (!$_REQUEST['destination']) { |
---|
818 | $form_state['redirect'] = 'planificacion/' . $form['#ente_planificador']->nid . '/politicas/seleccionar/inviables'; |
---|
819 | } |
---|
820 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
821 | if ($op == t('Cancel')) { |
---|
822 | return; |
---|
823 | } |
---|
824 | if (count($form['#politicas'])) { |
---|
825 | batch_politicas_direccionales_indentificar_viabilidad($form['#ente_planificador'], $form['#politicas'], $form_state['redirect']); |
---|
826 | } |
---|
827 | } |
---|
828 | |
---|
829 | /** |
---|
830 | * Implementation of batch_politicas_direccionales_indentificar_viabilidad(). |
---|
831 | * batch init identificar viabilidad |
---|
832 | */ |
---|
833 | function batch_politicas_direccionales_indentificar_viabilidad($ente_planificador = 0, $politicas = array(), $redirect = ''){ |
---|
834 | if (!is_array($politicas) || !count($politicas)) { |
---|
835 | return FALSE; |
---|
836 | } |
---|
837 | if ($ente_planificador) { |
---|
838 | $step = 1; |
---|
839 | $batch = array( |
---|
840 | 'title' => t('Calculando polÃticas inviables ...'), |
---|
841 | 'operations' => array(), |
---|
842 | 'init_message' => t('Comenzando'), |
---|
843 | 'progress_message' => t('Processed @current out of @total.'), |
---|
844 | 'error_message' => t('An error occurred during processing'), |
---|
845 | 'finished' => '_direct_politicas_direccionales_indentificar_viabilidad_finished', |
---|
846 | ); |
---|
847 | $count_politicas = count($politicas); |
---|
848 | foreach ($politicas as $nid => $politica_title) { |
---|
849 | $batch['operations'][] = array('_politicas_direccionales_indentificar_viabilidad', array($ente_planificador, $nid, $count_politicas)); |
---|
850 | } |
---|
851 | batch_set($batch); |
---|
852 | batch_process($redirect); |
---|
853 | } |
---|
854 | } |
---|
855 | |
---|
856 | /** |
---|
857 | * Implementation of _politicas_direccionales_indentificar_viabilidad(). |
---|
858 | * Batch callback to identificar viabilidad |
---|
859 | */ |
---|
860 | function _politicas_direccionales_indentificar_viabilidad($ente_planificador, $nid, $max, &$context) { |
---|
861 | if ($nid && is_numeric($nid)) { |
---|
862 | $politica = node_load($nid); |
---|
863 | if ($politica->type = 'politicas_direccionales') { |
---|
864 | module_load_include('inc', 'node', 'node.pages'); |
---|
865 | //calcular que la suma de los porcentajes de cada necesidad sume 100 |
---|
866 | politicas_direccionales_load_requerimientos($politica); |
---|
867 | $cantidad_requerimientos = count($politica->requerimientos); |
---|
868 | $req_band = $cantidad_requerimientos ? TRUE : FALSE; |
---|
869 | for ($i = 0; $i < $cantidad_requerimientos; $i++) { |
---|
870 | $suma = 0; |
---|
871 | $cantidad_entes = count($politica->requerimientos[$i]['entes']); |
---|
872 | $cantidad_entes = $cantidad_entes ? $cantidad_entes : 1; |
---|
873 | for ($j = 0; $j < $cantidad_entes; $j++) { |
---|
874 | $suma += $politica->requerimientos[$i]['entes'][$j]['grado']; |
---|
875 | } |
---|
876 | if ($suma < 100) { |
---|
877 | $req_band = FALSE; |
---|
878 | break; |
---|
879 | } |
---|
880 | } |
---|
881 | $politica->field_politicas_viable = array(); |
---|
882 | $politica->field_politicas_viable[] = array('value' => $req_band ? 'SÃ' : 'NO'); |
---|
883 | $politica->field_politicas_seleccionada = array(); |
---|
884 | $politica->field_politicas_seleccionada[] = array('value' => 'NO'); |
---|
885 | node_object_prepare($politica); |
---|
886 | $politica->revision = 1; |
---|
887 | $politica->log = t('Calculo de viabilidad'); |
---|
888 | node_save($politica); |
---|
889 | |
---|
890 | //se agregan los requerimientos a la nueva version del nodo |
---|
891 | db_query("UPDATE {politicas_ente} SET vid = %d WHERE nid = %d", $politica->vid, $politica->nid); |
---|
892 | db_query("UPDATE {politicas_ente_actor} SET vid = %d WHERE nid = %d", $politica->vid, $politica->nid); |
---|
893 | |
---|
894 | $context['results'][] = t('La PolÃtica direccional "@title" se ha calculado su viabilidad (Viable: @calc_viab).', array('@title' => $politica->body, '@calc_viab' => $politica->field_politicas_viable[0]['value'])); |
---|
895 | $context['message'] = t('La PolÃtica direccional "@title" se ha calculado su viabilidad (Viable: @calc_viab).', array('@title' => $politica->body, '@calc_viab' => $politica->field_politicas_viable[0]['value'])); |
---|
896 | } |
---|
897 | else { |
---|
898 | $context['results'][] = t('El nodo "@title" no es una PolÃtica direccional (No se ha calculado su viabilidad).', array('@title' => $politica->body)); |
---|
899 | $context['message'] = t('El nodo "@title" no es una PolÃtica direccional (No se ha calculado su viabilidad).', array('@title' => $politica->body)); |
---|
900 | } |
---|
901 | } |
---|
902 | else { |
---|
903 | $context['results'][] = t('La PolÃtica direccional @nid no existe (No se ha calculado su viabilidad).', array('@nid' => $nid)); |
---|
904 | $context['message'] = t('La PolÃtica direccional @nid no existe (No se ha calculado su viabilidad).', array('@nid' => $nid)); |
---|
905 | } |
---|
906 | } |
---|
907 | |
---|
908 | /** |
---|
909 | * Implementation of _direct_politicas_direccionales_indentificar_viabilidad_finished(). |
---|
910 | * Batch 'finished' callback |
---|
911 | */ |
---|
912 | function _direct_politicas_direccionales_indentificar_viabilidad_finished($success, $results, $operations) { |
---|
913 | if ($success) { |
---|
914 | // Here we do something meaningful with the results. |
---|
915 | $message = t('%count polÃticas direccionales han sido procesadas: !items', array('%count' => count($results), '!items' => theme('item_list', $results))); |
---|
916 | } |
---|
917 | else { |
---|
918 | // An error occurred. |
---|
919 | // $operations contains the operations that remained unprocessed. |
---|
920 | $error_operation = reset($operations); |
---|
921 | $message = t('An error occurred while processing %error_operation with arguments: @arguments', array('%error_operation' => $error_operation[0], '@arguments' => print_r($error_operation[1], TRUE))); |
---|
922 | } |
---|
923 | drupal_set_message(filter_xss($message)); |
---|
924 | } |
---|
925 | |
---|
926 | /** |
---|
927 | * Implementation of politicas_direccionales_seleccionar_politicas_form(). |
---|
928 | * Formulario para seleccionar politicas direccionales |
---|
929 | */ |
---|
930 | function politicas_direccionales_seleccionar_politicas_form($form_state, $ente_planificador) { |
---|
931 | drupal_set_title(t('Seleccionar polÃticas direccionales')); |
---|
932 | global $user; |
---|
933 | $ente = usuario_tiene_ente($user->uid); |
---|
934 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles_seleccionar", $ente_planificador); |
---|
935 | $current_time = time(); |
---|
936 | $ente_has_acceso = FALSE; |
---|
937 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
938 | $fecha = TRUE; |
---|
939 | } |
---|
940 | if (!$fecha) { |
---|
941 | muestra_mensaje("posibles", $ente_planificador); |
---|
942 | } |
---|
943 | else { |
---|
944 | if ($user->entes == $ente_planificador->nid) { |
---|
945 | muestra_mensaje("posibles", $ente_planificador, 0); |
---|
946 | } |
---|
947 | } |
---|
948 | if ($fecha && (user_access('admin planificador') || $fecha && $user->entes == $ente_planificador->nid)) { |
---|
949 | $ente_has_acceso = TRUE; |
---|
950 | } |
---|
951 | |
---|
952 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
953 | $sql_query = "SELECT c.nid, n.title FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND field_politicas_direcc_year_value = %d "; |
---|
954 | $sql_variables = array(); |
---|
955 | $sql_variables[] = $ente_planificador->nid; |
---|
956 | $sql_variables[] = variable_get('situacional_actual_preliminar_anho_creacion', 0); |
---|
957 | |
---|
958 | $result = db_query($sql_query, $sql_variables); |
---|
959 | $politicas = array(); |
---|
960 | $politicas_loads = array(); |
---|
961 | $politicas_no_viables = array(); |
---|
962 | $default = array(); |
---|
963 | while($politica = db_fetch_object($result)) { |
---|
964 | $politica_load = node_load($politica->nid); |
---|
965 | $politicas_loads[$politica_load->nid] = $politica_load; |
---|
966 | $politicas[$politica_load->nid] = $politica_load->body; |
---|
967 | $default[$politica_load->nid] = ($politica_load->field_politicas_seleccionada[0]['value']) ? $politica_load->nid : 0; |
---|
968 | } |
---|
969 | |
---|
970 | $form = array(); |
---|
971 | $form['#ente'] = $ente_planificador; |
---|
972 | $form['#politicas_loads'] = $politicas_loads; |
---|
973 | $form['#politicas_no_viables'] = $politicas_no_viables; |
---|
974 | if ($ente_has_acceso && count($politicas)) { |
---|
975 | $form['politicas_seleccionar'] = array( |
---|
976 | '#type' => 'checkboxes', |
---|
977 | '#title' => t('Seleccionar polÃticas.'), |
---|
978 | '#default_value' => $default, |
---|
979 | '#options' => $politicas, |
---|
980 | '#description' => t('Seleccionar las polÃticas direccionales.'), |
---|
981 | ); |
---|
982 | $form['buttons'] = array( |
---|
983 | '#prefix' => '<div class="container-inline">', |
---|
984 | '#suffix' => '</div>', |
---|
985 | '#weight' => 100, |
---|
986 | ); |
---|
987 | $form['buttons']['submit'] = array( |
---|
988 | '#type' => 'submit', |
---|
989 | '#value' => t('Submit'), |
---|
990 | '#weight' => 100, |
---|
991 | ); |
---|
992 | $form['buttons']['cancel'] = array( |
---|
993 | '#type' => 'submit', |
---|
994 | '#value' => t('Cancel'), |
---|
995 | '#weight' => 100, |
---|
996 | ); |
---|
997 | } |
---|
998 | $form['#after_build'] = array(); |
---|
999 | $form['#after_build'][] = 'politicas_direccionales_skip_validation_form_after_build'; |
---|
1000 | return $form; |
---|
1001 | } |
---|
1002 | |
---|
1003 | /** |
---|
1004 | * Implementation of politicas_direccionales_seleccionar_politicas_form_submit(). |
---|
1005 | * Procesar el formulario para seleccionar politicas direccionales |
---|
1006 | */ |
---|
1007 | function politicas_direccionales_seleccionar_politicas_form_submit($form, &$form_state) { |
---|
1008 | $politicas = array(); |
---|
1009 | if (!$_REQUEST['destination']) { |
---|
1010 | $form_state['redirect'] = 'planificacion/' . $form['#ente']->nid . '/politicas/seleccionar/consultar'; |
---|
1011 | } |
---|
1012 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
1013 | if ($op == t('Cancel')) { |
---|
1014 | return; |
---|
1015 | } |
---|
1016 | |
---|
1017 | if (is_array($form_state['values']['politicas_seleccionar']) && count($form_state['values']['politicas_seleccionar'])) { |
---|
1018 | foreach($form_state['values']['politicas_seleccionar'] as $id => $value) { |
---|
1019 | $politicas[$id] = array( |
---|
1020 | 'node' => $form['#politicas_loads'][$id], |
---|
1021 | 'seleccion' => $value, |
---|
1022 | ); |
---|
1023 | } |
---|
1024 | } |
---|
1025 | //se colocan el resto de politicas como no seleccionada |
---|
1026 | if (count($form['#politicas_no_viables'])) { |
---|
1027 | foreach($form['#politicas_no_viables'] as $id => $value) { |
---|
1028 | $politicas[$id] = array( |
---|
1029 | 'node' => $value, |
---|
1030 | 'seleccion' => 0, |
---|
1031 | ); |
---|
1032 | } |
---|
1033 | } |
---|
1034 | if (count($politicas)) { |
---|
1035 | batch_politicas_direccionales_seleccionar_politicas($form['#ente'], $politicas, $form_state['redirect']); |
---|
1036 | } |
---|
1037 | } |
---|
1038 | |
---|
1039 | /** |
---|
1040 | * Implementation of batch_politicas_direccionales_seleccionar_politicas(). |
---|
1041 | * batch init |
---|
1042 | */ |
---|
1043 | function batch_politicas_direccionales_seleccionar_politicas($ente_planificador = 0, $politicas = array(), $redirect = ''){ |
---|
1044 | if (!is_array($politicas) || !count($politicas)) { |
---|
1045 | return FALSE; |
---|
1046 | } |
---|
1047 | if ($ente_planificador) { |
---|
1048 | $step = 1; |
---|
1049 | $batch = array( |
---|
1050 | 'title' => t('Seleccionando polÃticas direccionales ...'), |
---|
1051 | 'operations' => array(), |
---|
1052 | 'init_message' => t('Comenzando'), |
---|
1053 | 'progress_message' => t('Processed @current out of @total.'), |
---|
1054 | 'error_message' => t('An error occurred during processing'), |
---|
1055 | 'finished' => '_politicas_direccionales_seleccionar_politicas_finished', |
---|
1056 | ); |
---|
1057 | $count_politicas = count($politicas); |
---|
1058 | foreach ($politicas as $politica) { |
---|
1059 | $batch['operations'][] = array('_politicas_direccionales_seleccionar_politicas', array($ente_planificador, $politica, $count_politicas)); |
---|
1060 | } |
---|
1061 | batch_set($batch); |
---|
1062 | batch_process($redirect); |
---|
1063 | } |
---|
1064 | } |
---|
1065 | |
---|
1066 | /** |
---|
1067 | * Implementation of _politicas_direccionales_seleccionar_politicas(). |
---|
1068 | * Batch callback to seleccionar politicas |
---|
1069 | */ |
---|
1070 | function _politicas_direccionales_seleccionar_politicas($ente_planificador, $politica_load, $max, &$context) { |
---|
1071 | if ($politica_load['node'] && $politica_load['node']->nid && $politica_load['node']->type = 'politicas_direccionales') { |
---|
1072 | $politica = node_load($politica_load['node']->nid); |
---|
1073 | if ($politica && $politica->type = 'politicas_direccionales') { |
---|
1074 | module_load_include('inc', 'node', 'node.pages'); |
---|
1075 | $politica->field_politicas_seleccionada = array(); |
---|
1076 | $politica->field_politicas_seleccionada[] = array('value' => ($politica_load['seleccion']) ? 1 : 0); |
---|
1077 | node_object_prepare($politica); |
---|
1078 | $politica->revision = 1; |
---|
1079 | $politica->log = t('PolÃtica seleccionada'); |
---|
1080 | node_save($politica); |
---|
1081 | //se agregan los requerimientos a la nueva version del nodo |
---|
1082 | db_query("UPDATE {politicas_ente} SET vid = %d WHERE nid = %d", $politica->vid, $politica->nid); |
---|
1083 | db_query("UPDATE {politicas_ente_actor} SET vid = %d WHERE nid = %d", $politica->vid, $politica->nid); |
---|
1084 | $context['results'][] = t('La PolÃtica direccional "@title" (ha sido seleccionada: %seleccion).', array('@title' => $politica->body, '%seleccion' => $politica->body)); |
---|
1085 | $context['message'] = t('La PolÃtica direccional "@title" (ha sido seleccionada: %seleccion).', array('@title' => $politica->body, '%seleccion' => $politica->body)); |
---|
1086 | } |
---|
1087 | else { |
---|
1088 | $context['results'][] = t('El nodo "@title" no es una PolÃtica direccional (No ha sido seleccionada).', array('@title' => $politica->body)); |
---|
1089 | $context['message'] = t('El nodo "@title" no es una PolÃtica direccional (No ha sido seleccionada).', array('@title' => $politica->body)); |
---|
1090 | } |
---|
1091 | } |
---|
1092 | else { |
---|
1093 | $context['results'][] = t('La PolÃtica direccional @nid no existe (No ha sido seleccionada).', array('@nid' => $nid)); |
---|
1094 | $context['message'] = t('La PolÃtica direccional @nid no existe (No ha sido seleccionada).', array('@nid' => $nid)); |
---|
1095 | } |
---|
1096 | } |
---|
1097 | |
---|
1098 | /** |
---|
1099 | * Implementation of _politicas_direccionales_seleccionar_politicas_finished(). |
---|
1100 | * Batch 'finished' callback |
---|
1101 | */ |
---|
1102 | function _politicas_direccionales_seleccionar_politicas_finished($success, $results, $operations) { |
---|
1103 | if ($success) { |
---|
1104 | // Here we do something meaningful with the results. |
---|
1105 | $message = t('%count polÃticas direccionales han sido procesadas: !items', array('%count' => count($results), '!items' => theme('item_list', $results))); |
---|
1106 | } |
---|
1107 | else { |
---|
1108 | // An error occurred. |
---|
1109 | // $operations contains the operations that remained unprocessed. |
---|
1110 | $error_operation = reset($operations); |
---|
1111 | $message = t('An error occurred while processing %error_operation with arguments: @arguments', array('%error_operation' => $error_operation[0], '@arguments' => print_r($error_operation[1], TRUE))); |
---|
1112 | } |
---|
1113 | drupal_set_message(filter_xss($message)); |
---|
1114 | } |
---|
1115 | |
---|
1116 | /** |
---|
1117 | * Implementation of politicas_direccionales_remove_posible_politica_form() |
---|
1118 | * Eliminar politica direccional |
---|
1119 | */ |
---|
1120 | function politicas_direccionales_remove_posible_politica_form($form_state, $ente = 0, $politica = 0) { |
---|
1121 | $form = array(); |
---|
1122 | $form['#ente'] = $ente; |
---|
1123 | $form['#politica'] = $politica; |
---|
1124 | $message = t('Esta seguro de eliminar la posible polÃtica @nombre?', array('@nombre' => $form['#politica']->body)); |
---|
1125 | $caption = '<p>'. t('This action cannot be undone.') .'</p>'; |
---|
1126 | $return_path = $_REQUEST['destination'] ? $_REQUEST['destination'] : 'planificacion/' . $form['#ente']->nid . '/politicas/posibles/buscar'; |
---|
1127 | return confirm_form($form, $message, $return_path, $caption, t('Eliminar')); |
---|
1128 | } |
---|
1129 | |
---|
1130 | /** |
---|
1131 | * Implementation of politicas_direccionales_remove_posible_politica_form_submit(). |
---|
1132 | * Procesar funcion eliminar politica direccional. |
---|
1133 | */ |
---|
1134 | function politicas_direccionales_remove_posible_politica_form_submit($form, &$form_state) { |
---|
1135 | global $user; |
---|
1136 | $titulo = $form['#politica']->body; |
---|
1137 | node_delete($form['#politica']->nid); |
---|
1138 | $texto = t('Se elimino la posible polÃtica "@nombre"', array('@nombre' => $form['#politica']->body)); |
---|
1139 | drupal_set_message($texto); |
---|
1140 | if (!$_REQUEST['destination']) { |
---|
1141 | // add redirect |
---|
1142 | $form_state['redirect'] = 'planificacion/' . $form['#ente']->nid . '/politicas/posibles/buscar'; |
---|
1143 | } |
---|
1144 | } |
---|
1145 | |
---|
1146 | /** |
---|
1147 | * Implementation of politicas_direccionales_remove_accion_posible_politica_form() |
---|
1148 | * Eliminar accion posible de politica |
---|
1149 | */ |
---|
1150 | function politicas_direccionales_remove_accion_posible_politica_form($form_state, $ente = 0, $politica = 0) { |
---|
1151 | $form = array(); |
---|
1152 | $form['#ente'] = $ente; |
---|
1153 | $form['#politica'] = $politica; |
---|
1154 | $message = t('Esta seguro de eliminar las acciones de la polÃtica "@nombre"?', array('@nombre' => $form['#politica']->body)); |
---|
1155 | $caption = '<p>'. t('Acciones para Construir Viabilidad:') .'</p>'; |
---|
1156 | $viabilidades = array(); |
---|
1157 | foreach($politica->field_politicas_acciones_viab as $viabilidad) { |
---|
1158 | $viabilidades[] = $viabilidad['value']; |
---|
1159 | } |
---|
1160 | $caption .= theme('item_list', $viabilidades); |
---|
1161 | $return_path = $_REQUEST['destination'] ? $_REQUEST['destination'] : 'planificacion/' . $form['#ente']->nid . '/politicas/seleccionar/inviables'; |
---|
1162 | return confirm_form($form, $message, $return_path, $caption, t('Eliminar')); |
---|
1163 | } |
---|
1164 | |
---|
1165 | /** |
---|
1166 | * Implementation of politicas_direccionales_remove_accion_posible_politica_form_submit(). |
---|
1167 | * Procesar funcion eliminar accion posible de politica. |
---|
1168 | */ |
---|
1169 | function politicas_direccionales_remove_accion_posible_politica_form_submit($form, &$form_state) { |
---|
1170 | global $user; |
---|
1171 | $politica = $form['#politica']; |
---|
1172 | $titulo = $form['#politica']->body; |
---|
1173 | module_load_include('inc', 'node', 'node.pages'); |
---|
1174 | node_object_prepare($politica); |
---|
1175 | $politica->revision = 1; |
---|
1176 | $texto = t('Se eliminarón las acciones para construir la viabilidad de la polÃtica "@politica"', array('@politica' => $titulo)); |
---|
1177 | $politica->log = $texto; |
---|
1178 | $politica->field_politicas_acciones_viab = array(); |
---|
1179 | $politica->field_politicas_acciones_viab[0] = array('value' => ''); |
---|
1180 | node_save($politica); |
---|
1181 | //se agregan los requerimientos a la nueva version del nodo |
---|
1182 | db_query("UPDATE {politicas_ente} SET vid = %d WHERE nid = %d", $politica->vid, $politica->nid); |
---|
1183 | db_query("UPDATE {politicas_ente_actor} SET vid = %d WHERE nid = %d", $politica->vid, $politica->nid); |
---|
1184 | drupal_set_message($texto); |
---|
1185 | if (!$_REQUEST['destination']) { |
---|
1186 | // add redirect |
---|
1187 | $form_state['redirect'] = 'planificacion/' . $form['#ente']->nid . '/politicas/posibles/buscar'; |
---|
1188 | } |
---|
1189 | } |
---|
1190 | |
---|
1191 | /** |
---|
1192 | * Implementation of ente_planificador_usuario_tiene_identificar_politicas(). |
---|
1193 | * Usuario puede identificar politicas. |
---|
1194 | */ |
---|
1195 | function ente_planificador_usuario_tiene_identificar_politicas($ente_planificador) { |
---|
1196 | if($ente_planificador->tipo > 1) { |
---|
1197 | if ($ente_planificador && $ente_planificador->nid && $politica && $politica->nid) { |
---|
1198 | if (module_exists('ente_planificador_hierarchical')) { |
---|
1199 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
1200 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
1201 | return TRUE; |
---|
1202 | } |
---|
1203 | } |
---|
1204 | } |
---|
1205 | } |
---|
1206 | return FALSE; |
---|
1207 | } |
---|
1208 | global $user; |
---|
1209 | $fecha = FALSE; |
---|
1210 | $ente_has_acceso = FALSE; |
---|
1211 | $current_time = time(); |
---|
1212 | $mi_fecha = ente_planificador_user_acceso_proceso("inviabilidad", $ente_planificador); |
---|
1213 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1214 | $fecha = TRUE; |
---|
1215 | } |
---|
1216 | if ($fecha && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
1217 | //se verifica que exista al menos una politica |
---|
1218 | $mi_fecha1 = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
1219 | $sql_query = "SELECT count(c.nid) as numero FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND n.created >= %d AND n.created <= %d AND n.status > 0"; |
---|
1220 | $sql_variables = array(); |
---|
1221 | $sql_variables[] = $ente_planificador->nid; |
---|
1222 | $sql_variables[] = $mi_fecha1[0]; |
---|
1223 | $sql_variables[] = $mi_fecha1[1] + 86399; |
---|
1224 | $result = db_query($sql_query, $sql_variables); |
---|
1225 | $cuenta = db_fetch_object($result); |
---|
1226 | if ($cuenta->numero) { |
---|
1227 | $ente_has_acceso = TRUE; |
---|
1228 | } |
---|
1229 | } |
---|
1230 | return $ente_has_acceso; |
---|
1231 | } |
---|
1232 | |
---|
1233 | /** |
---|
1234 | * Implementation of ente_planificador_usuario_tiene_seleccionar_politicas(). |
---|
1235 | * Usuario puede seleccionar politicas. |
---|
1236 | */ |
---|
1237 | function ente_planificador_usuario_tiene_seleccionar_politicas($ente_planificador) { |
---|
1238 | global $user; |
---|
1239 | $fecha = FALSE; |
---|
1240 | $ente_has_acceso = FALSE; |
---|
1241 | $current_time = time(); |
---|
1242 | |
---|
1243 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles_seleccionar", $ente_planificador); |
---|
1244 | |
---|
1245 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1246 | $fecha = TRUE; |
---|
1247 | } |
---|
1248 | if ($fecha && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
1249 | //se verifica que exista al menos una politica |
---|
1250 | $mi_fecha1 = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
1251 | $sql_query = "SELECT count(c.nid) AS numero FROM content_type_politicas_direccionales AS c INNER JOIN node AS n ON n.nid = c.nid AND n.vid = c.vid LEFT JOIN content_field_politicas_acciones_viab AS v ON v.nid = c.nid AND v.vid = c.vid WHERE c.field_politicas_ente_nid = %d AND (c.field_politicas_seleccionada_value = '1' OR c.field_politicas_seleccionada_value = '0') AND c.field_politicas_direcc_year_value=%d AND n.status > 0"; |
---|
1252 | $sql_variables = array(); |
---|
1253 | $sql_variables[] = $ente_planificador->nid; |
---|
1254 | $sql_variables[] = variable_get('situacional_actual_preliminar_anho_creacion', 0); |
---|
1255 | $result = db_query($sql_query, $sql_variables); |
---|
1256 | $cuenta = db_fetch_object($result); |
---|
1257 | if ($cuenta->numero) { |
---|
1258 | $ente_has_acceso = TRUE; |
---|
1259 | } |
---|
1260 | } |
---|
1261 | return $ente_has_acceso; |
---|
1262 | } |
---|
1263 | |
---|
1264 | /** |
---|
1265 | * Implementation of ente_planificador_usuario_tiene_politicas_viabilidad(). |
---|
1266 | * Usuario puede construir viabilidad politicas. |
---|
1267 | */ |
---|
1268 | function ente_planificador_usuario_tiene_politicas_viabilidad($ente_planificador) { |
---|
1269 | if($ente_planificador->tipo > 1) { |
---|
1270 | if ($ente_planificador && $ente_planificador->nid && $politica && $politica->nid) { |
---|
1271 | if (module_exists('ente_planificador_hierarchical')) { |
---|
1272 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
1273 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
1274 | return TRUE; |
---|
1275 | } |
---|
1276 | } |
---|
1277 | } |
---|
1278 | } |
---|
1279 | return FALSE; |
---|
1280 | } |
---|
1281 | global $user; |
---|
1282 | $fecha = FALSE; |
---|
1283 | $ente_has_acceso = FALSE; |
---|
1284 | $current_time = time(); |
---|
1285 | $mi_fecha = ente_planificador_user_acceso_proceso("viabilidad", $ente_planificador); |
---|
1286 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1287 | $fecha = TRUE; |
---|
1288 | } |
---|
1289 | if ($fecha && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
1290 | $ente_has_acceso = TRUE; |
---|
1291 | } |
---|
1292 | return $ente_has_acceso; |
---|
1293 | } |
---|
1294 | |
---|
1295 | /** |
---|
1296 | * Implementation of ente_planificador_usuario_es_macro(). |
---|
1297 | * Ente planificador es macro. |
---|
1298 | */ |
---|
1299 | function ente_planificador_usuario_es_macro($ente_planificador) { |
---|
1300 | return $ente_planificador->tipo <= 2 ? TRUE : FALSE; |
---|
1301 | } |
---|
1302 | |
---|
1303 | /** |
---|
1304 | * Implementation of ente_planificador_usuario_tiene_politicas_registrar(). |
---|
1305 | * Usuario puede registrar politicas. |
---|
1306 | */ |
---|
1307 | function ente_planificador_usuario_tiene_politicas_registrar($ente_planificador) { |
---|
1308 | global $user; |
---|
1309 | $fecha = FALSE; |
---|
1310 | $ente_has_acceso = FALSE; |
---|
1311 | $current_time = time(); |
---|
1312 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
1313 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1314 | $fecha = TRUE; |
---|
1315 | } |
---|
1316 | if ($fecha && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
1317 | $ente_has_acceso = TRUE; |
---|
1318 | } |
---|
1319 | return $ente_has_acceso; |
---|
1320 | } |
---|
1321 | |
---|
1322 | /** |
---|
1323 | * Implementation of ente_planificador_usuario_tiene_estrategias_politicas_registrar(). |
---|
1324 | * Usuario puede registrar estrategias. |
---|
1325 | */ |
---|
1326 | function ente_planificador_usuario_tiene_estrategias_politicas_registrar($ente_planificador) { |
---|
1327 | if($ente_planificador->tipo == 1) { |
---|
1328 | if ($ente_planificador && $ente_planificador->nid && $politica && $politica->nid) { |
---|
1329 | if (module_exists('ente_planificador_hierarchical')) { |
---|
1330 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
1331 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
1332 | return TRUE; |
---|
1333 | } |
---|
1334 | } |
---|
1335 | } |
---|
1336 | } |
---|
1337 | return FALSE; |
---|
1338 | } |
---|
1339 | global $user; |
---|
1340 | $fecha = FALSE; |
---|
1341 | $ente_has_acceso = FALSE; |
---|
1342 | $current_time = time(); |
---|
1343 | $mi_fecha = ente_planificador_user_acceso_proceso("estrategias", $ente_planificador); |
---|
1344 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1345 | $fecha = TRUE; |
---|
1346 | } |
---|
1347 | if ($fecha && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
1348 | $ente_has_acceso = TRUE; |
---|
1349 | } |
---|
1350 | return $ente_has_acceso; |
---|
1351 | } |
---|
1352 | |
---|
1353 | /** |
---|
1354 | * Implementation of ente_planificador_usuario_tiene_estrategias_politicas_puede_articular(). |
---|
1355 | * Usuario puede articular estrategias. |
---|
1356 | */ |
---|
1357 | function ente_planificador_usuario_tiene_estrategias_politicas_puede_articular($ente_planificador) { |
---|
1358 | if($ente_planificador->tipo == 1) { |
---|
1359 | if ($ente_planificador && $ente_planificador->nid && $politica && $politica->nid) { |
---|
1360 | if (module_exists('ente_planificador_hierarchical')) { |
---|
1361 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
1362 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
1363 | return TRUE; |
---|
1364 | } |
---|
1365 | } |
---|
1366 | } |
---|
1367 | } |
---|
1368 | return FALSE; |
---|
1369 | } |
---|
1370 | global $user; |
---|
1371 | $fecha = FALSE; |
---|
1372 | $ente_has_acceso = FALSE; |
---|
1373 | $current_time = time(); |
---|
1374 | $mi_fecha = ente_planificador_user_acceso_proceso("estrategias", $ente_planificador); |
---|
1375 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1376 | $fecha = TRUE; |
---|
1377 | } |
---|
1378 | //SE VERIFICA QUE EL ENTE TENGA AL MENOS UNA ESTRATEGIA |
---|
1379 | $numero = 0; |
---|
1380 | if ($fecha) { |
---|
1381 | $result = db_query("SELECT COUNT(pd.nid) AS numero FROM {content_type_estrategia} AS pd INNER JOIN {node} AS n On n.nid = pd.nid AND n.vid = pd.vid WHERE pd.field_estrategia_ente_nid = %d AND n.created >= %d AND n.created <= %d", $ente_planificador->nid, $mi_fecha[0], $mi_fecha[1] + 86399); |
---|
1382 | $cantidad_estrategias = db_fetch_object($result); |
---|
1383 | $numero = $cantidad_estrategias->numero; |
---|
1384 | } |
---|
1385 | if ($fecha && $numero && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
1386 | $ente_has_acceso = TRUE; |
---|
1387 | } |
---|
1388 | return $ente_has_acceso; |
---|
1389 | } |
---|
1390 | |
---|
1391 | /** |
---|
1392 | * Implementation of ente_planificador_tiene_articulacion(). |
---|
1393 | * Ente tiene articulación. |
---|
1394 | */ |
---|
1395 | function ente_planificador_tiene_articulacion($ente_planificador){ |
---|
1396 | if($ente_planificador->tipo == 1) { |
---|
1397 | return FALSE; |
---|
1398 | } |
---|
1399 | $mi_fecha = ente_planificador_user_acceso_proceso('articulacion_estrategias', $ente_planificador); |
---|
1400 | $result = db_query('SELECT count(ente) AS numero FROM {politicas_direccionales_estrategias} WHERE ente_art = %d AND creacion >= %d AND creacion <= %d', $ente_planificador->nid, $mi_fecha[0], $mi_fecha[1] + 86399); |
---|
1401 | $cantidad_estrategias = db_fetch_object($result); |
---|
1402 | $ente_has_acceso = FALSE; |
---|
1403 | if ($cantidad_estrategias->numero && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
1404 | $ente_has_acceso = TRUE; |
---|
1405 | } |
---|
1406 | return $ente_has_acceso; |
---|
1407 | } |
---|
1408 | |
---|
1409 | /** |
---|
1410 | * Implementation of ente_planificador_usuario_tiene_estrategias_politicas_reformular(). |
---|
1411 | * Ente puede reformular estrategias. |
---|
1412 | */ |
---|
1413 | function ente_planificador_usuario_tiene_estrategias_politicas_reformular($ente_planificador) { |
---|
1414 | if($ente_planificador->tipo == 1) { |
---|
1415 | return FALSE; |
---|
1416 | } |
---|
1417 | global $user; |
---|
1418 | $fecha = FALSE; |
---|
1419 | $ente_has_acceso = FALSE; |
---|
1420 | $current_time = time(); |
---|
1421 | $mi_fecha = ente_planificador_user_acceso_proceso("reformulacion_estrategias", $ente_planificador); |
---|
1422 | $mi_fecha1 = ente_planificador_user_acceso_proceso("estrategias", $ente_planificador); |
---|
1423 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1424 | $fecha = TRUE; |
---|
1425 | } |
---|
1426 | //SE VERIFICA QUE EL ENTE TENGA AL MENOS UNA ESTRATEGIA |
---|
1427 | $numero = 0; |
---|
1428 | if ($fecha) { |
---|
1429 | $result = db_query("SELECT COUNT(pd.nid) AS numero FROM {content_type_estrategia} AS pd INNER JOIN {node} AS n On n.nid = pd.nid AND n.vid = pd.vid WHERE pd.field_estrategia_ente_nid = %d AND n.created >= %d AND n.created <= %d", $ente_planificador->nid, $mi_fecha1[0], $mi_fecha1[1] + 86399); |
---|
1430 | $cantidad_estrategias = db_fetch_object($result); |
---|
1431 | $numero = $cantidad_estrategias->numero; |
---|
1432 | } |
---|
1433 | if ($fecha && $numero && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
1434 | $ente_has_acceso = TRUE; |
---|
1435 | } |
---|
1436 | return $ente_has_acceso; |
---|
1437 | } |
---|
1438 | |
---|
1439 | /** |
---|
1440 | * Implementation of ente_planificador_usuario_tiene_estrategias_puede_editar(). |
---|
1441 | * Ente puede editar estrategias. |
---|
1442 | */ |
---|
1443 | function ente_planificador_usuario_tiene_estrategias_puede_editar($ente_planificador, $estrategia) { |
---|
1444 | if($ente_planificador->tipo == 1) { |
---|
1445 | return FALSE; |
---|
1446 | } |
---|
1447 | global $user; |
---|
1448 | $fecha = FALSE; |
---|
1449 | $ente_has_acceso = FALSE; |
---|
1450 | $current_time = time(); |
---|
1451 | $mi_fecha = ente_planificador_user_acceso_proceso('estrategias', $ente_planificador); |
---|
1452 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1453 | $fecha = TRUE; |
---|
1454 | } |
---|
1455 | //SE VERIFICA QUE EL ENTE TENGA AL MENOS UNA ESTRATEGIA |
---|
1456 | $numero = 0; |
---|
1457 | if ($fecha) { |
---|
1458 | $result = db_query("SELECT COUNT(pd.nid) AS numero FROM {content_type_estrategia} AS pd INNER JOIN {node} AS n On n.nid = pd.nid AND n.vid = pd.vid WHERE n.nid = %d AND pd.field_estrategia_ente_nid = %d AND n.created >= %d AND n.created <= %d", $estrategia->nid, $ente_planificador->nid, $mi_fecha[0], $mi_fecha[1] + 86399); |
---|
1459 | $cantidad_estrategias = db_fetch_object($result); |
---|
1460 | $numero = $cantidad_estrategias->numero; |
---|
1461 | } |
---|
1462 | if ($fecha && $numero && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
1463 | $ente_has_acceso = TRUE; |
---|
1464 | } |
---|
1465 | return $ente_has_acceso; |
---|
1466 | } |
---|
1467 | |
---|
1468 | /** |
---|
1469 | * Implementation of ente_planificador_usuario_tiene_estrategias_puede_reformular(). |
---|
1470 | * Ente puede reformular una estrategia estrategias. |
---|
1471 | */ |
---|
1472 | function ente_planificador_usuario_tiene_estrategias_puede_reformular($ente_planificador, $estrategia) { |
---|
1473 | if($ente_planificador->tipo == 1) { |
---|
1474 | return FALSE; |
---|
1475 | } |
---|
1476 | global $user; |
---|
1477 | $fecha = FALSE; |
---|
1478 | $ente_has_acceso = FALSE; |
---|
1479 | $current_time = time(); |
---|
1480 | $mi_fecha = ente_planificador_user_acceso_proceso("reformulacion_estrategias", $ente_planificador); |
---|
1481 | $mi_fecha1 = ente_planificador_user_acceso_proceso("estrategias", $ente_planificador); |
---|
1482 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1483 | $fecha = TRUE; |
---|
1484 | } |
---|
1485 | //SE VERIFICA QUE EL ENTE TENGA AL MENOS UNA ESTRATEGIA |
---|
1486 | $numero = 0; |
---|
1487 | if ($fecha) { |
---|
1488 | $result = db_query("SELECT COUNT(pd.nid) AS numero FROM {content_type_estrategia} AS pd INNER JOIN {node} AS n On n.nid = pd.nid AND n.vid = pd.vid WHERE n.nid = %d AND pd.field_estrategia_ente_nid = %d AND n.created >= %d AND n.created <= %d", $estrategia->nid, $ente_planificador->nid, $mi_fecha1[0], $mi_fecha1[1] + 86399); |
---|
1489 | $cantidad_estrategias = db_fetch_object($result); |
---|
1490 | $numero = $cantidad_estrategias->numero; |
---|
1491 | } |
---|
1492 | if ($fecha && $numero && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
1493 | $ente_has_acceso = TRUE; |
---|
1494 | } |
---|
1495 | return $ente_has_acceso; |
---|
1496 | } |
---|
1497 | |
---|
1498 | /** |
---|
1499 | * Implementation of ente_planificador_usuario_puede_estrategias_seleccionar(). |
---|
1500 | * Ente puede seleccionar estrategias. |
---|
1501 | */ |
---|
1502 | function ente_planificador_usuario_puede_estrategias_seleccionar($ente_planificador) { |
---|
1503 | if($ente_planificador->tipo > 1) { |
---|
1504 | return FALSE; |
---|
1505 | } |
---|
1506 | global $user; |
---|
1507 | $fecha = FALSE; |
---|
1508 | $ente_has_acceso = FALSE; |
---|
1509 | $current_time = time(); |
---|
1510 | $mi_fecha = ente_planificador_user_acceso_proceso("seleccionar_estrategias", $ente_planificador); |
---|
1511 | $mi_fecha1 = ente_planificador_user_acceso_proceso("estrategias", $ente_planificador); |
---|
1512 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1513 | $fecha = TRUE; |
---|
1514 | } |
---|
1515 | //SE VERIFICA QUE EL ENTE TENGA AL MENOS UNA ESTRATEGIA |
---|
1516 | $numero = 0; |
---|
1517 | if ($fecha) { |
---|
1518 | $result = db_query("SELECT COUNT(pd.nid) AS numero FROM {content_type_estrategia} AS pd INNER JOIN {node} AS n On n.nid = pd.nid AND n.vid = pd.vid WHERE n.created >= %d AND n.created <= %d", $mi_fecha1[0], $mi_fecha1[1] + 86399); |
---|
1519 | $cantidad_estrategias = db_fetch_object($result); |
---|
1520 | $numero = $cantidad_estrategias->numero; |
---|
1521 | } |
---|
1522 | if ($fecha && $numero && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
1523 | $ente_has_acceso = TRUE; |
---|
1524 | } |
---|
1525 | return $ente_has_acceso; |
---|
1526 | } |
---|
1527 | |
---|
1528 | /** |
---|
1529 | * Implementation of ente_planificador_usuario_puede_estrategias_seleccionar_politicas(). |
---|
1530 | * Ente puede asociar estrategias a politicas. |
---|
1531 | */ |
---|
1532 | function ente_planificador_usuario_puede_estrategias_seleccionar_politicas($ente_planificador, $politica) { |
---|
1533 | if($ente_planificador->tipo > 1) { |
---|
1534 | return FALSE; |
---|
1535 | } |
---|
1536 | global $user; |
---|
1537 | $fecha = FALSE; |
---|
1538 | $ente_has_acceso = FALSE; |
---|
1539 | $current_time = time(); |
---|
1540 | $mi_fecha = ente_planificador_user_acceso_proceso("seleccionar_estrategias", $ente_planificador); |
---|
1541 | $mi_fecha1 = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
1542 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time && $politica->created >= $mi_fecha1[0] && $politica->created <= $mi_fecha1[1] + 86399) { |
---|
1543 | $fecha = TRUE; |
---|
1544 | } |
---|
1545 | $estrategias = leer_estrategias_por_politica($ente_planificador, $politica); |
---|
1546 | if (!count($estrategias)) { |
---|
1547 | return FALSE; |
---|
1548 | } |
---|
1549 | if ($fecha && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
1550 | $ente_has_acceso = TRUE; |
---|
1551 | } |
---|
1552 | return $ente_has_acceso; |
---|
1553 | } |
---|
1554 | |
---|
1555 | /* |
---|
1556 | * Implementation of mis_entes_planificadores_planificacion_politicas() |
---|
1557 | */ |
---|
1558 | function mis_entes_planificadores_planificacion_politicas() { |
---|
1559 | global $user; |
---|
1560 | $output = ''; |
---|
1561 | $ente = usuario_tiene_ente($user->uid); |
---|
1562 | if ($ente->nid) { |
---|
1563 | $adicional = array(); |
---|
1564 | for($i = 3; $i < 7; $i++) { |
---|
1565 | if (arg($i) != '') { |
---|
1566 | $adicional[] = arg($i); |
---|
1567 | } |
---|
1568 | } |
---|
1569 | drupal_goto('planificacion/' . $ente->nid . '/politicas/' . implode('/', $adicional)); |
---|
1570 | } |
---|
1571 | drupal_goto('mi_ente_planificador/planificacion'); |
---|
1572 | return $output; |
---|
1573 | } |
---|
1574 | |
---|
1575 | /* |
---|
1576 | * Implementation of politicas_direccionales_status_planificacion_politicas_direccionales() |
---|
1577 | */ |
---|
1578 | function politicas_direccionales_status_planificacion_politicas_direccionales($ente_planificador, $tipo = 2) { |
---|
1579 | $politicas_direccionales = array(); |
---|
1580 | if ($tipo == 1) { |
---|
1581 | //SE CALCULA SI SE ALMACENO AL MENOS UNA POLITICA |
---|
1582 | $mi_fecha_posible = ente_planificador_user_acceso_proceso("posibles", $tipo); |
---|
1583 | $result = db_query("SELECT COUNT(pd.nid) AS numero FROM {content_type_politicas_direccionales} AS pd INNER JOIN {node} AS n On n.nid = pd.nid AND n.vid = pd.vid WHERE pd.field_politicas_ente_nid = %d AND n.created >= %d AND n.created <= %d", $ente_planificador, $mi_fecha_posible[0], $mi_fecha_posible[1] + 86399); |
---|
1584 | $cantidad_politicas = db_fetch_object($result); |
---|
1585 | $politicas_direccionales['posibles']['value'] = $cantidad_politicas->numero ? 1 : 0; |
---|
1586 | $politicas_direccionales['posibles']['title'] = t('Posibles PolÃticas Direccionales'); |
---|
1587 | $politicas_direccionales['posibles']['link'] = 'planificacion/' . $ente_planificador . '/politicas/posibles/listar'; |
---|
1588 | $politicas_direccionales['posibles']['mylink'] = 'mi_ente_planificador/planificacion/politicas/posibles/listar'; |
---|
1589 | $politicas_direccionales['posibles']['weight'] = 1; |
---|
1590 | /* |
---|
1591 | //SE CALCULA SI SE EXISTE AL MENOS UNA POLITICA VIABLE |
---|
1592 | $result = db_query("SELECT COUNT(pd.nid) AS numero FROM {content_type_politicas_direccionales} AS pd INNER JOIN {node} AS n On n.nid = pd.nid AND n.vid = pd.vid WHERE pd.field_politicas_ente_nid = %d AND pd.field_politicas_viable_value = 'SÃ' AND n.created >= %d AND n.created <= %d", $ente_planificador, $mi_fecha_posible[0], $mi_fecha_posible[1] + 86399); |
---|
1593 | $cantidad_politicas = db_fetch_object($result); |
---|
1594 | $politicas_direccionales['inviabilidad']['value'] = $cantidad_politicas->numero ? 1 : 0; |
---|
1595 | $politicas_direccionales['inviabilidad']['title'] = t('Consultar posibles PolÃticas inviables'); |
---|
1596 | $politicas_direccionales['inviabilidad']['link'] = 'planificacion/' . $ente_planificador . '/politicas/seleccionar/inviables'; |
---|
1597 | $politicas_direccionales['inviabilidad']['mylink'] = 'mi_ente_planificador/planificacion/politicas/seleccionar/inviables'; |
---|
1598 | $politicas_direccionales['inviabilidad']['weight'] = 2; |
---|
1599 | //SE CALCULA SI SE EXISTE AL MENOS UNA ACCION PARA CONSTRUIR VIABILIDAD EN UNA POLITICA INVIABLE |
---|
1600 | $result = db_query("SELECT COUNT(pd.nid) AS numero FROM {content_type_politicas_direccionales} AS pd INNER JOIN {node} AS n On n.nid = pd.nid AND n.vid = pd.vid INNER JOIN {content_field_politicas_acciones_viab} AS v ON v.nid = pd.nid AND v.vid = pd.vid WHERE pd.field_politicas_ente_nid = %d AND n.created >= %d AND n.created <= %d AND (v.field_politicas_acciones_viab_value <> NULL OR v.field_politicas_acciones_viab_value <> '')", $ente_planificador, $mi_fecha_posible[0], $mi_fecha_posible[1] + 86399); |
---|
1601 | $cantidad_politicas = db_fetch_object($result); |
---|
1602 | $politicas_direccionales['viabilidad']['value'] = $cantidad_politicas->numero ? 1 : 0; |
---|
1603 | $politicas_direccionales['viabilidad']['title'] = t('Acciones para construir viabilidad de PolÃticas inviables'); |
---|
1604 | $politicas_direccionales['viabilidad']['link'] = 'planificacion/' . $ente_planificador . '/politicas/seleccionar/inviables'; |
---|
1605 | $politicas_direccionales['viabilidad']['mylink'] = 'mi_ente_planificador/planificacion/politicas/seleccionar/inviables'; |
---|
1606 | $politicas_direccionales['viabilidad']['weight'] = 3; |
---|
1607 | */ |
---|
1608 | //SE CALCULA SI SE EXISTE AL MENOS EXISTE UNA POLITICA SELECCIONADA |
---|
1609 | $result = db_query("SELECT COUNT(pd.nid) AS numero FROM {content_type_politicas_direccionales} AS pd INNER JOIN {node} AS n On n.nid = pd.nid AND n.vid = pd.vid WHERE pd.field_politicas_ente_nid = %d AND pd.field_politicas_seleccionada_value = 'SÃ' AND n.created >= %d AND n.created <= %d", $ente_planificador, $mi_fecha_posible[0], $mi_fecha_posible[1] + 86399); |
---|
1610 | $cantidad_politicas = db_fetch_object($result); |
---|
1611 | $politicas_direccionales['posibles_seleccionar']['value'] = $cantidad_politicas->numero ? 1 : 0; |
---|
1612 | $politicas_direccionales['posibles_seleccionar']['title'] = t('Seleccionar PolÃticas Direccionales'); |
---|
1613 | $politicas_direccionales['posibles_seleccionar']['link'] = 'planificacion/' . $ente_planificador . '/politicas/seleccionar/consultar'; |
---|
1614 | $politicas_direccionales['posibles_seleccionar']['mylink'] = 'mi_ente_planificador/planificacion/politicas/seleccionar/consultar'; |
---|
1615 | $politicas_direccionales['posibles_seleccionar']['weight'] = 4; |
---|
1616 | /* |
---|
1617 | //SE CALCULA QUE EXISTA AL MENOS UNA ESTRATEGIA |
---|
1618 | $mi_fecha_estrategia = ente_planificador_user_acceso_proceso("estrategias", $tipo); |
---|
1619 | $result = db_query("SELECT count(nid) AS numero FROM {node} WHERE type = 'estrategia' AND created >= %d AND created <= %d", $mi_fecha_estrategia[0], $mi_fecha_estrategia[1] + 86399); |
---|
1620 | $cantidad_estrategias = db_fetch_object($result); |
---|
1621 | $politicas_direccionales['estrategias']['value'] = $cantidad_estrategias->numero ? 1 : 0; |
---|
1622 | $politicas_direccionales['estrategias']['title'] = t('Definición de Estrategias'); |
---|
1623 | $politicas_direccionales['estrategias']['link'] = 'planificacion/' . $ente_planificador . '/politicas/estrategias/listar'; |
---|
1624 | $politicas_direccionales['estrategias']['mylink'] = 'mi_ente_planificador/planificacion/politicas/estrategias/listar'; |
---|
1625 | $politicas_direccionales['estrategias']['weight'] = 5; |
---|
1626 | |
---|
1627 | //SE CALCULA LA ARTICULACION DE LOS ACTORES MICROS |
---|
1628 | $mi_fecha_articulacion = ente_planificador_user_acceso_proceso("articulacion_estrategias", $tipo); |
---|
1629 | $result = db_query("SELECT count(estrategia) AS numero FROM {politicas_direccionales_estrategias} WHERE creacion >= %d AND creacion <= %d", $mi_fecha_articulacion[0], $mi_fecha_articulacion[1] + 86399); |
---|
1630 | $cantidad_articulacion = db_fetch_object($result); |
---|
1631 | $politicas_direccionales['articulacion_estrategias']['value'] = $cantidad_articulacion->numero ? 1 : 0; |
---|
1632 | $politicas_direccionales['articulacion_estrategias']['title'] = t('Articulación de actores por estrategias'); |
---|
1633 | $politicas_direccionales['articulacion_estrategias']['link'] = 'planificacion/' . $ente_planificador . '/politicas/estrategias/consultar_articulacion_micro'; |
---|
1634 | $politicas_direccionales['articulacion_estrategias']['mylink'] = 'mi_ente_planificador/planificacion/politicas/estrategias/consultar_articulacion_micro'; |
---|
1635 | $politicas_direccionales['articulacion_estrategias']['weight'] = 6; |
---|
1636 | |
---|
1637 | |
---|
1638 | //SE CALCULA QUE EXISTA AL MENOS UNA ESTRATEGIA REFORMULADA |
---|
1639 | $mi_fecha_reformulacion = ente_planificador_user_acceso_proceso("reformulacion_estrategias", $tipo); |
---|
1640 | $result = db_query("SELECT count(nid) AS numero FROM {node} WHERE type = 'estrategia' AND changed >= %d AND changed <= %d", $mi_fecha_reformulacion[0], $mi_fecha_reformulacion[1] + 86399); |
---|
1641 | $cantidad_estrategias = db_fetch_object($result); |
---|
1642 | $politicas_direccionales['reformulacion_estrategias']['value'] = $cantidad_estrategias->numero ? 1 : 0; |
---|
1643 | $politicas_direccionales['reformulacion_estrategias']['title'] = t('Reformulación de Estrategias'); |
---|
1644 | $politicas_direccionales['reformulacion_estrategias']['link'] = 'planificacion/' . $ente_planificador . '/politicas/estrategias/listar'; |
---|
1645 | $politicas_direccionales['reformulacion_estrategias']['mylink'] = 'mi_ente_planificador/planificacion/politicas/estrategias/listar'; |
---|
1646 | $politicas_direccionales['reformulacion_estrategias']['weight'] = 5; |
---|
1647 | |
---|
1648 | //SE CALCULA QUE AL MENOS UNA ESTRATEGIA ESTE SELECCIONADA EN ALGUNA POLITICA |
---|
1649 | $result = db_query("SELECT COUNT(pd.nid) AS numero from {content_type_politicas_direccionales} AS pd INNER JOIN {node} AS n On n.nid = pd.nid AND n.vid = pd.vid INNER JOIN {content_field_politicas_estrategias} AS v ON v.nid = pd.nid AND v.vid = pd.vid WHERE pd.field_politicas_ente_nid = %d AND n.created >= %d AND n.created <= %d AND (v.field_politicas_estrategias_nid <> NULL OR v.field_politicas_estrategias_nid <> 0)", $ente_planificador, $mi_fecha_posible[0], $mi_fecha_posible[1] + 86399); |
---|
1650 | $cantidad_politicas = db_fetch_object($result); |
---|
1651 | $politicas_direccionales['seleccionar_estrategias']['value'] = $cantidad_politicas->numero ? 1 : 0; |
---|
1652 | $politicas_direccionales['seleccionar_estrategias']['title'] = t('Seleccionar estrategias'); |
---|
1653 | $politicas_direccionales['seleccionar_estrategias']['link'] = 'planificacion/' . $ente_planificador . '/politicas/estrategias/pol_estr'; |
---|
1654 | $politicas_direccionales['seleccionar_estrategias']['mylink'] = 'mi_ente_planificador/planificacion/politicas/estrategias/pol_estr'; |
---|
1655 | $politicas_direccionales['seleccionar_estrategias']['weight'] = 6; |
---|
1656 | */ |
---|
1657 | } |
---|
1658 | else { |
---|
1659 | /* |
---|
1660 | //SE CALCULA QUE EXISTA AL MENOS UNA ESTRATEGIA |
---|
1661 | $mi_fecha_estrategia = ente_planificador_user_acceso_proceso("estrategias", $ente_planificador); |
---|
1662 | $result = db_query("SELECT COUNT(pd.nid) AS numero FROM {content_type_estrategia} AS pd INNER JOIN {node} AS n On n.nid = pd.nid AND n.vid = pd.vid WHERE pd.field_estrategia_ente_nid = %d AND n.created >= %d AND n.created <= %d", $ente_planificador, $mi_fecha_estrategia[0], $mi_fecha_estrategia[1] + 86399); |
---|
1663 | $cantidad_estrategias = db_fetch_object($result); |
---|
1664 | $politicas_direccionales['estrategias']['value'] = $cantidad_estrategias->numero ? 1 : 0; |
---|
1665 | $politicas_direccionales['estrategias']['title'] = t('Definición de Estrategias'); |
---|
1666 | $politicas_direccionales['estrategias']['link'] = 'planificacion/' . $ente_planificador . '/politicas/estrategias/listar'; |
---|
1667 | $politicas_direccionales['estrategias']['mylink'] = 'mi_ente_planificador/planificacion/politicas/estrategias/listar'; |
---|
1668 | $politicas_direccionales['estrategias']['weight'] = 1;/* |
---|
1669 | //SE CALCULA LA ARTICULACION DE LOS ACTORES MICROS |
---|
1670 | $mi_fecha_articulacion = ente_planificador_user_acceso_proceso("articulacion_estrategias", $tipo); |
---|
1671 | $result = db_query("SELECT count(estrategia) AS numero FROM {politicas_direccionales_estrategias} WHERE ente = %d AND creacion >= %d AND creacion <= %d", $ente_planificador, $mi_fecha_articulacion[0], $mi_fecha_articulacion[1] + 86399); |
---|
1672 | $cantidad_articulacion = db_fetch_object($result); |
---|
1673 | $politicas_direccionales['articulacion_estrategias']['value'] = $cantidad_articulacion->numero ? 1 : 0; |
---|
1674 | $politicas_direccionales['articulacion_estrategias']['title'] = t('Articulación de actores por estrategias'); |
---|
1675 | $politicas_direccionales['articulacion_estrategias']['link'] = 'planificacion/' . $ente_planificador . '/politicas/estrategias/identificar'; |
---|
1676 | $politicas_direccionales['articulacion_estrategias']['mylink'] = 'mi_ente_planificador/planificacion/politicas/estrategias/identificar'; |
---|
1677 | $politicas_direccionales['articulacion_estrategias']['weight'] = 2; |
---|
1678 | |
---|
1679 | |
---|
1680 | //SE CALCULA QUE EXISTA AL MENOS UNA ESTRATEGIA REFORMULADA |
---|
1681 | $mi_fecha_reformulacion = ente_planificador_user_acceso_proceso("reformulacion_estrategias", $tipo); |
---|
1682 | $result = db_query("SELECT COUNT(pd.nid) AS numero FROM {content_type_estrategia} AS pd INNER JOIN {node} AS n On n.nid = pd.nid AND n.vid = pd.vid WHERE pd.field_estrategia_ente_nid = %d AND n.changed >= %d AND n.changed <= %d", $ente_planificador, $mi_fecha_reformulacion[0], $mi_fecha_reformulacion[1] + 86399); |
---|
1683 | $cantidad_estrategias = db_fetch_object($result); |
---|
1684 | $politicas_direccionales['reformulacion_estrategias']['value'] = $cantidad_estrategias->numero ? 1 : 0; |
---|
1685 | $politicas_direccionales['reformulacion_estrategias']['title'] = t('Reformulación de Estrategias'); |
---|
1686 | $politicas_direccionales['reformulacion_estrategias']['link'] = 'planificacion/' . $ente_planificador . '/politicas/estrategias/listar'; |
---|
1687 | $politicas_direccionales['reformulacion_estrategias']['mylink'] = 'mi_ente_planificador/planificacion/politicas/estrategias/listar'; |
---|
1688 | $politicas_direccionales['reformulacion_estrategias']['weight'] = 5; |
---|
1689 | */ |
---|
1690 | } |
---|
1691 | return $politicas_direccionales; |
---|
1692 | } |
---|
1693 | |
---|
1694 | /* |
---|
1695 | * Implementation of politicas_direccionales_submenu_interfaz |
---|
1696 | * Add menu items politicas |
---|
1697 | */ |
---|
1698 | function politicas_direccionales_submenu_interfaz($ente_planificador) { |
---|
1699 | $submenu = array(); |
---|
1700 | $smenu = array(); |
---|
1701 | $i = 0; |
---|
1702 | $submenu[$i] = array( |
---|
1703 | 'name'=> t("Posibles PolÃticas"), |
---|
1704 | 'description' => t("Posibles PolÃticas Direccionales"), |
---|
1705 | 'call' => "posibles_politicas" |
---|
1706 | ); |
---|
1707 | $aux_menu = array(); |
---|
1708 | foreach (module_list() as $module) { |
---|
1709 | if ($data = module_invoke($module, 'items_menu_politicas_' . $submenu[$i]['call'], $ente_planificador)) { |
---|
1710 | $aux_menu = array_merge_recursive($data, $aux_menu); |
---|
1711 | } |
---|
1712 | } |
---|
1713 | $smenu[$i] = $aux_menu; |
---|
1714 | return theme('planificacion_submenu_interfaz', $submenu, $smenu); |
---|
1715 | } |
---|
1716 | |
---|
1717 | /* |
---|
1718 | * Implementation of hook_items_menu_politicas_posibles_politicas() |
---|
1719 | * Add menus items in politicas |
---|
1720 | */ |
---|
1721 | function politicas_direccionales_items_menu_politicas_posibles_politicas($ente_planificador) { |
---|
1722 | global $user; |
---|
1723 | $resultado = array(); |
---|
1724 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
1725 | $current_time = time(); |
---|
1726 | $ente_has_acceso = FALSE; |
---|
1727 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1728 | $fecha = TRUE; |
---|
1729 | } |
---|
1730 | if (ente_planificador_usuario_tiene_politicas_registrar($ente_planificador)) { |
---|
1731 | $resultado[] = array( |
---|
1732 | 'name' => t('Registrar Posibles PolÃticas Direccionales'), |
---|
1733 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/posibles/registrar', |
---|
1734 | 'description' => t('Registrar PolÃticas Direccionales') |
---|
1735 | ); |
---|
1736 | } |
---|
1737 | |
---|
1738 | $resultado[] = array( |
---|
1739 | 'name' => t('Consultar Posibles PolÃticas Direccionales'), |
---|
1740 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/posibles/listar', |
---|
1741 | 'description' => t('Consultar PolÃticas Direccionales') |
---|
1742 | ); |
---|
1743 | |
---|
1744 | /* |
---|
1745 | if ($ente_planificador->tipo == 1) { |
---|
1746 | $resultado[] = array( |
---|
1747 | 'name' => t('Buscar Posibles PolÃticas Direccionales'), |
---|
1748 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/posibles/buscar', |
---|
1749 | 'description' => t('Buscar PolÃticas Direccionales') |
---|
1750 | ); |
---|
1751 | } |
---|
1752 | */ |
---|
1753 | return $resultado; |
---|
1754 | } |
---|
1755 | |
---|
1756 | /* |
---|
1757 | * Implementation of hook_items_menu_politicas_seleccionar_politicas() |
---|
1758 | * Add menus items in politicas |
---|
1759 | */ |
---|
1760 | function politicas_direccionales_items_menu_politicas_seleccionar_politicas($ente_planificador) { |
---|
1761 | global $user; |
---|
1762 | $resultado = array(); |
---|
1763 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
1764 | $current_time = time(); |
---|
1765 | $ente_has_acceso = FALSE; |
---|
1766 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1767 | $fecha = TRUE; |
---|
1768 | } |
---|
1769 | |
---|
1770 | /* |
---|
1771 | if (ente_planificador_usuario_tiene_identificar_politicas($ente_planificador)) { |
---|
1772 | $resultado[] = array( |
---|
1773 | 'name' => t('Identificar inviabilidad de posibles polÃticas '), |
---|
1774 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/seleccionar/viabilidad', |
---|
1775 | 'description' => t('Identificar PolÃticas Direccionales') |
---|
1776 | ); |
---|
1777 | } |
---|
1778 | $resultado[] = array( |
---|
1779 | 'name' => t('Consultar PolÃticas Inviables'), |
---|
1780 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/seleccionar/inviables', |
---|
1781 | 'description' => t('Consultar posibles PolÃticas inviables') |
---|
1782 | ); |
---|
1783 | */ |
---|
1784 | |
---|
1785 | if (ente_planificador_usuario_tiene_seleccionar_politicas($ente_planificador)) { |
---|
1786 | $resultado[] = array( |
---|
1787 | 'name' => t('Seleccionar PolÃticas Direccionales'), |
---|
1788 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/seleccionar/politicas', |
---|
1789 | 'description' => t('Seleccionar PolÃticas Direccionales') |
---|
1790 | ); |
---|
1791 | } |
---|
1792 | /* |
---|
1793 | $resultado[] = array( |
---|
1794 | 'name' => t('Consultar PolÃticas Direccionales'), |
---|
1795 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/seleccionar/consultar', |
---|
1796 | 'description' => t('Consultar PolÃticas Direccionales') |
---|
1797 | ); |
---|
1798 | */ |
---|
1799 | if (ente_planificador_usuario_es_macro($ente_planificador)) { |
---|
1800 | $resultado[] = array( |
---|
1801 | 'name' => t('Buscar PolÃticas Direccionales'), |
---|
1802 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/seleccionar/buscar', |
---|
1803 | 'description' => t('Buscar PolÃticas Direccionales') |
---|
1804 | ); |
---|
1805 | } |
---|
1806 | return $resultado; |
---|
1807 | } |
---|
1808 | |
---|
1809 | |
---|
1810 | /* |
---|
1811 | * Implementation of ente_planificador_definir_politicas() |
---|
1812 | * Display default definir politicas |
---|
1813 | */ |
---|
1814 | function ente_planificador_definir_politicas($ente_planificador) { |
---|
1815 | drupal_set_title(t('Definición de posibles PolÃticas Direccionales')); |
---|
1816 | return politicas_direccionales_submenu_interfaz($ente_planificador); |
---|
1817 | } |
---|
1818 | |
---|
1819 | /* |
---|
1820 | * Implementation of ente_planificador_seleccionar_politicas() |
---|
1821 | */ |
---|
1822 | function ente_planificador_seleccionar_politicas($ente_planificador) { |
---|
1823 | drupal_set_title(t('Definición de PolÃticas Direccionales')); |
---|
1824 | return politicas_direccionales_submenu_interfaz2($ente_planificador); |
---|
1825 | } |
---|
1826 | |
---|
1827 | /* |
---|
1828 | * Implementation of politicas_direccionales_submenu_interfaz2 |
---|
1829 | * Add menu items politicas |
---|
1830 | */ |
---|
1831 | function politicas_direccionales_submenu_interfaz2($ente_planificador) { |
---|
1832 | $submenu = array(); |
---|
1833 | $smenu = array(); |
---|
1834 | $i = 0; |
---|
1835 | $submenu[$i] = array( |
---|
1836 | 'name'=> t("PolÃticas Direccionales"), |
---|
1837 | 'description' => t("Gestionar PolÃticas Direccionales"), |
---|
1838 | 'call' => "seleccionar_politicas" |
---|
1839 | ); |
---|
1840 | $aux_menu = array(); |
---|
1841 | foreach (module_list() as $module) { |
---|
1842 | if ($data = module_invoke($module, 'items_menu_politicas_' . $submenu[$i]['call'], $ente_planificador)) { |
---|
1843 | $aux_menu = array_merge_recursive($data, $aux_menu); |
---|
1844 | } |
---|
1845 | } |
---|
1846 | $smenu[$i] = $aux_menu; |
---|
1847 | return theme('planificacion_submenu_interfaz', $submenu, $smenu); |
---|
1848 | } |
---|
1849 | |
---|
1850 | |
---|
1851 | /* |
---|
1852 | * Implementation of ente_planificador_seleccionar_politicas() |
---|
1853 | */ |
---|
1854 | function ente_planificador_estrategias_politicas($ente_planificador) { |
---|
1855 | drupal_set_title(t('Definición de estrategias')); |
---|
1856 | return politicas_direccionales_submenu_interfaz3($ente_planificador); |
---|
1857 | } |
---|
1858 | |
---|
1859 | /* |
---|
1860 | * Implementation of politicas_direccionales_submenu_interfaz2 |
---|
1861 | * Add menu items politicas |
---|
1862 | */ |
---|
1863 | function politicas_direccionales_submenu_interfaz3($ente_planificador) { |
---|
1864 | $submenu = array(); |
---|
1865 | $smenu = array(); |
---|
1866 | $i = 0; |
---|
1867 | $submenu[$i] = array( |
---|
1868 | 'name'=> t("Estrategias de Materialización"), |
---|
1869 | 'description' => t("Gestionar Estrategias de Materialización de PolÃticas Direccionales"), |
---|
1870 | 'call' => "estrategias_politicas" |
---|
1871 | ); |
---|
1872 | $aux_menu = array(); |
---|
1873 | foreach (module_list() as $module) { |
---|
1874 | if ($data = module_invoke($module, 'items_menu_politicas_' . $submenu[$i]['call'], $ente_planificador)) { |
---|
1875 | $aux_menu = array_merge_recursive($data, $aux_menu); |
---|
1876 | } |
---|
1877 | } |
---|
1878 | $smenu[$i] = $aux_menu; |
---|
1879 | return theme('planificacion_submenu_interfaz', $submenu, $smenu); |
---|
1880 | } |
---|
1881 | |
---|
1882 | /* |
---|
1883 | * Implementation of hook_items_menu_politicas_estrategias_politicas() |
---|
1884 | * Add menus items in seleccionar politicas |
---|
1885 | */ |
---|
1886 | function politicas_direccionales_items_menu_politicas_estrategias_politicas($ente_planificador) { |
---|
1887 | global $user; |
---|
1888 | $resultado = array(); |
---|
1889 | if (ente_planificador_usuario_tiene_estrategias_politicas_registrar($ente_planificador)) { |
---|
1890 | $resultado[] = array( |
---|
1891 | 'name' => t('Registrar estrategias'), |
---|
1892 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/estrategias/registrar', |
---|
1893 | 'description' => t('Agregar estrategias de materialización de polÃticas direccionales') |
---|
1894 | ); |
---|
1895 | } |
---|
1896 | $resultado[] = array( |
---|
1897 | 'name' => t('Consultar posibles estrategias'), |
---|
1898 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/estrategias/listar', |
---|
1899 | 'description' => t('Consultar posibles estrategias de materialización de polÃticas direccionales') |
---|
1900 | ); |
---|
1901 | /* |
---|
1902 | if (ente_planificador_usuario_tiene_estrategias_politicas_puede_articular($ente_planificador)) { |
---|
1903 | $resultado[] = array( |
---|
1904 | 'name' => t('Identificar posible articulación'), |
---|
1905 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/estrategias/identificar', |
---|
1906 | 'description' => t('Identificar posible articulación entre actores micro') |
---|
1907 | ); |
---|
1908 | } |
---|
1909 | if (ente_planificador_usuario_es_macro($ente_planificador)) { |
---|
1910 | $resultado[] = array( |
---|
1911 | 'name' => t('Consultar solicitudes de articulación'), |
---|
1912 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/estrategias/consultar_articulacion', |
---|
1913 | 'description' => t('Consultar solicitudes de articulación') |
---|
1914 | ); |
---|
1915 | } |
---|
1916 | if (ente_planificador_tiene_articulacion($ente_planificador)) { |
---|
1917 | $resultado[] = array( |
---|
1918 | 'name' => t('Consultar solicitudes de articulación con Actores Micro'), |
---|
1919 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/estrategias/consultar_articulacion_micro', |
---|
1920 | 'description' => t('Consultar solicitudes de articulación de los Actores Micro') |
---|
1921 | ); |
---|
1922 | } |
---|
1923 | */ |
---|
1924 | /* |
---|
1925 | if (ente_planificador_usuario_tiene_estrategias_politicas_reformular($ente_planificador)) { |
---|
1926 | $resultado[] = array( |
---|
1927 | 'name' => t('Reformulación de posibles estrategias'), |
---|
1928 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/estrategias/reformular', |
---|
1929 | 'description' => t('Reformulación de posibles estrategias') |
---|
1930 | ); |
---|
1931 | } |
---|
1932 | */ |
---|
1933 | if (ente_planificador_usuario_puede_estrategias_seleccionar($ente_planificador)) { |
---|
1934 | $resultado[] = array( |
---|
1935 | 'name' => t('Seleccionar polÃticas direccionales'), |
---|
1936 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/estrategias/seleccionar', |
---|
1937 | 'description' => t('Seleccionar estrategias para materializar polÃticas direccionales.') |
---|
1938 | ); |
---|
1939 | } |
---|
1940 | $resultado[] = array( |
---|
1941 | 'name' => t('Estrategias para materializar polÃticas direccionales'), |
---|
1942 | 'path' => 'planificacion/' . $ente_planificador->nid . '/politicas/estrategias/pol_estr', |
---|
1943 | 'description' => t('Consultar estrategias para materializar polÃticas direccionales.') |
---|
1944 | ); |
---|
1945 | return $resultado; |
---|
1946 | } |
---|
1947 | |
---|
1948 | /* |
---|
1949 | * Implementation of politicas_direccionales_load_requerimientos() |
---|
1950 | * Leer requerimientos de una politica |
---|
1951 | */ |
---|
1952 | function politicas_direccionales_load_requerimientos(&$node){ |
---|
1953 | $sql_query = "SELECT * FROM {politicas_ente} WHERE nid = %d AND vid = %d"; |
---|
1954 | $result = db_query($sql_query, $node->nid, $node->vid); |
---|
1955 | $requerimientos = array(); |
---|
1956 | while($requerimiento = db_fetch_object($result)) { |
---|
1957 | $requerimientos[$requerimiento->delta] = array( |
---|
1958 | 'requerimiento' => $requerimiento->requerimiento, |
---|
1959 | 'tipo' => $requerimiento->tipo, |
---|
1960 | ); |
---|
1961 | } |
---|
1962 | $sql_query = "SELECT * FROM {politicas_ente_actor} WHERE nid = %d AND vid = %d"; |
---|
1963 | $result = db_query($sql_query, $node->nid, $node->vid); |
---|
1964 | while($ente = db_fetch_object($result)) { |
---|
1965 | $requerimientos[$ente->delta]['entes'][$ente->delta1] = array( |
---|
1966 | 'otro_ente' => $ente->otro_ente, |
---|
1967 | 'ente' => $ente->ente, |
---|
1968 | 'grado' => $ente->grado, |
---|
1969 | ); |
---|
1970 | } |
---|
1971 | $node->requerimientos = $requerimientos; |
---|
1972 | } |
---|
1973 | |
---|
1974 | /* |
---|
1975 | * Implementation of politicas_direccionales_agregar_form() |
---|
1976 | * Agregar o editar una politica |
---|
1977 | */ |
---|
1978 | function politicas_direccionales_agregar_form($form_state, $ente_planificador, $politica = 0) { |
---|
1979 | global $user; |
---|
1980 | $ente = usuario_tiene_ente($user->uid); |
---|
1981 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador->nid); |
---|
1982 | $current_time = time(); |
---|
1983 | $ente_has_acceso = FALSE; |
---|
1984 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1985 | $fecha = TRUE; |
---|
1986 | } |
---|
1987 | if (!$fecha) { |
---|
1988 | muestra_mensaje("posibles", $ente_planificador); |
---|
1989 | } |
---|
1990 | else { |
---|
1991 | if ($ente->nid == $ente_planificador->nid) { |
---|
1992 | muestra_mensaje("posibles", $ente_planificador, 0); |
---|
1993 | } |
---|
1994 | } |
---|
1995 | if ($fecha && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
1996 | $ente_has_acceso = TRUE; |
---|
1997 | } |
---|
1998 | |
---|
1999 | if (!$ente_has_acceso) { |
---|
2000 | drupal_goto('planificacion/' . $ente_planificador->nid . '/politicas/posibles'); |
---|
2001 | } |
---|
2002 | |
---|
2003 | $politicas_direccionales_path = drupal_get_path('module', 'politicas_direccionales'); |
---|
2004 | drupal_add_js($politicas_direccionales_path . '/js/politicas_direccionales.js'); |
---|
2005 | $politica_leido = new stdClass(); |
---|
2006 | $politica_leido->type = 'politicas_direccionales'; |
---|
2007 | $politica_leido->title = ''; |
---|
2008 | $politica_leido->body = ''; |
---|
2009 | $politica_leido->nid = 0; |
---|
2010 | $form = array(); |
---|
2011 | |
---|
2012 | //evitar error ajax al validar los campos agregados en $form['#politicas_direccionales_fields'] |
---|
2013 | $form = array( |
---|
2014 | '#cache' => TRUE, |
---|
2015 | '#action' => url('planificacion/' . $ente_planificador->nid . '/politicas/posibles/registrar') |
---|
2016 | ); |
---|
2017 | |
---|
2018 | if ($politica) { |
---|
2019 | $politica_load = $politica; |
---|
2020 | if($politica_load->nid && $politica_load->type == 'politicas_direccionales' && $politica_load->field_politicas_ente[0]['nid'] == $ente_planificador->nid && $mi_fecha[1] + 86399 > $politica_load->created && $mi_fecha[0] < $politica_load->created) { |
---|
2021 | $politica_leido = $politica_load; |
---|
2022 | $form['#titulo_pagina'] = t('Modificar posible polÃtica direccional'); |
---|
2023 | } |
---|
2024 | } |
---|
2025 | if (!isset($form['#titulo_pagina'])) { |
---|
2026 | $form['#titulo_pagina'] = t('Agregar polÃtica direccional'); |
---|
2027 | } |
---|
2028 | drupal_set_title($form['#titulo_pagina']); |
---|
2029 | politicas_direccionales_load_requerimientos($politica_leido); |
---|
2030 | $form['#node'] = $politica_leido; |
---|
2031 | $form['#ente_planificador'] = $ente_planificador; |
---|
2032 | $form['#politica'] = $politica_leido; |
---|
2033 | |
---|
2034 | $options = array(); |
---|
2035 | $year = variable_get('situacional_actual_preliminar_anho_creacion', 0); |
---|
2036 | $causas = array('_none' => t("Ninguno")); |
---|
2037 | |
---|
2038 | $tipo_plan = 'situacion_actual'; |
---|
2039 | $planns = _situacion_actual_preliminar_get_planns(); |
---|
2040 | $plan = $planns[$tipo_plan]; |
---|
2041 | |
---|
2042 | $descriptores = _get_situacion_actual_listar_all_descriptores($ente_planificador->nid, $plan, $year); |
---|
2043 | $seleccionadas = _get_causas_all_causas($form['#ente_planificador']->nid, $plan, $year, 'criticas'); |
---|
2044 | foreach ($descriptores as $descriptor) { |
---|
2045 | foreach ($descriptor['causas'] as $causa) { |
---|
2046 | if ($seleccionadas[$descriptor['nid']][$causa['nid']]) { |
---|
2047 | $causas[$causa['nid']] = $causa['title']; |
---|
2048 | } |
---|
2049 | } |
---|
2050 | } |
---|
2051 | |
---|
2052 | $tipo_plan = 'politicas'; |
---|
2053 | $planns = _politicas_direccionales_get_planns(); |
---|
2054 | $plan = $planns[$tipo_plan]; |
---|
2055 | |
---|
2056 | $form['problema'] = array( |
---|
2057 | '#type' => 'fieldset', |
---|
2058 | '#title' => t('Información requerida para formular la PolÃtica'), |
---|
2059 | '#prefix' => '<div id="politicas_direccionales_form_add_causas' . $plan['plan'] . '">', |
---|
2060 | '#suffix' => '</div>', |
---|
2061 | ); |
---|
2062 | if (isset($form_state['values']['count'])) { |
---|
2063 | $count = $form_state['values']['count']; |
---|
2064 | } |
---|
2065 | else if (count($politica->field_politicas_causas)) { |
---|
2066 | $count = count($politica->field_politicas_causas); |
---|
2067 | } |
---|
2068 | else { |
---|
2069 | $count = 1; |
---|
2070 | } |
---|
2071 | for ($i=0; $i<$count; $i++) { |
---|
2072 | if (isset($form_state['values']['causas_' . $i])) { |
---|
2073 | $exist = true; |
---|
2074 | $default_causa = $form_state['values']['causas_' . $i]; |
---|
2075 | } |
---|
2076 | else if (isset($politica->field_politicas_causas[$i]['nid'])) { |
---|
2077 | $exist = true; |
---|
2078 | $default_causa = $politica->field_politicas_causas[$i]['nid']; |
---|
2079 | } |
---|
2080 | else { |
---|
2081 | $exist = false; |
---|
2082 | $default_causa = $causas['_none']; |
---|
2083 | } |
---|
2084 | |
---|
2085 | $form['problema']['causa_' . $i] = array( |
---|
2086 | '#type' => 'fieldset', |
---|
2087 | '#title' => t('Causa @num', array('@num' => $i + 1)), |
---|
2088 | '#prefix' => '<div id="politicas_direccionales_causa_form_' . $plan['plan'] . '_' . $i . '">', |
---|
2089 | '#suffix' => '</div>', |
---|
2090 | ); |
---|
2091 | $form['problema']['causa_' . $i]['causas_' . $i] = array( |
---|
2092 | '#type' => 'select', |
---|
2093 | '#default_value' => $default_causa, |
---|
2094 | '#options' => $causas, |
---|
2095 | '#title' => t('Seleccione Las causas que se abordara con la polÃtica'), |
---|
2096 | '#ahah' => array( |
---|
2097 | 'event' => 'change', |
---|
2098 | 'path' => 'politicas_direccionales_causas_ahah/' . $plan['plan'] . '/' . $i, |
---|
2099 | 'wrapper' => 'politicas_direccionales_causa_form_' . $plan['plan'] . '_' . $i, |
---|
2100 | 'method' => 'replace', |
---|
2101 | 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), |
---|
2102 | ), |
---|
2103 | '#weight' => -1, |
---|
2104 | ); |
---|
2105 | $tipo = 'causas'; |
---|
2106 | $tipo_plan = 'politicas'; |
---|
2107 | $planns = _politicas_direccionales_get_planns(); |
---|
2108 | $plan = $planns[$tipo_plan]; |
---|
2109 | $view_id = variable_get('politicas_direccionales_' . $plan['plan'] . '_' . $tipo, 0); |
---|
2110 | if ($view_id) { |
---|
2111 | $view = views_get_view($view_id); |
---|
2112 | $display_id = variable_get('politicas_direccionales_display_views_' . $plan['plan'] . '_' . $tipo, 'default'); |
---|
2113 | $view->set_display($display_id); |
---|
2114 | $view->override_path = $_GET['q']; |
---|
2115 | $view->set_arguments(array($default_causa)); |
---|
2116 | $view->pre_execute(); |
---|
2117 | $view->execute(); |
---|
2118 | $output = $view->render(); |
---|
2119 | |
---|
2120 | $form['problema']['causa_' . $i]['group_content-' . $i] = array( |
---|
2121 | '#type' => 'fieldset', |
---|
2122 | '#title' => t('Para conocer los detalles de la PolÃtica Seleccionada haga click aca.'), |
---|
2123 | '#collapsible' => TRUE, |
---|
2124 | '#collapsed' => TRUE, |
---|
2125 | ); |
---|
2126 | $form['problema']['causa_' . $i]['group_content-' . $i]['content_view_' . $i] = array( |
---|
2127 | '#value' => $output, |
---|
2128 | ); |
---|
2129 | } |
---|
2130 | } |
---|
2131 | $form['problema']['count'] = array('#type' => 'hidden', '#value' => $count); |
---|
2132 | $form['problema']['add'] = array( |
---|
2133 | '#type' => 'button', |
---|
2134 | '#value' => t('Agregar otro campo'), |
---|
2135 | '#submit' => array(), |
---|
2136 | '#ahah' => array( |
---|
2137 | 'path' => 'politicas_direccionales_form_add_causas/' . $plan['plan'], |
---|
2138 | 'wrapper' => 'politicas_direccionales_form_add_causas' . $plan['plan'], |
---|
2139 | 'method' => 'replace', |
---|
2140 | 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), |
---|
2141 | ), |
---|
2142 | '#weight' => 9, |
---|
2143 | ); |
---|
2144 | $form['politica'] = array( |
---|
2145 | '#type' => 'fieldset', |
---|
2146 | '#title' => t('Datos Basicos de la Politica'), |
---|
2147 | ); |
---|
2148 | |
---|
2149 | $form['politica']['body'] = array( |
---|
2150 | '#type' => 'textarea', |
---|
2151 | '#title' => t('Nombre de la polÃtica'), |
---|
2152 | '#default_value' => $politica_leido->body, |
---|
2153 | ); |
---|
2154 | |
---|
2155 | $mi_fecha = ente_planificador_user_acceso_proceso("causas", $ente_planificador); |
---|
2156 | $sql_query = "SELECT c.nid FROM {content_type_causas} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_ente_planifiador_nid = %d AND c.field_causa_critica_value = '1' AND n.created >= %d AND n.created <= %d "; |
---|
2157 | $sql_variables[] = $ente_planificador->nid; |
---|
2158 | $sql_variables[] = $mi_fecha[0]; |
---|
2159 | $sql_variables[] = $mi_fecha[1] + 86399; |
---|
2160 | |
---|
2161 | $result = db_query($sql_query, $sql_variables); |
---|
2162 | $causas = array(); |
---|
2163 | $causas_arreglo = array(); |
---|
2164 | $causas_id = array(); |
---|
2165 | $vector = array(); |
---|
2166 | $causas = array('_none' => t('- No aplica -')); |
---|
2167 | while($causa = db_fetch_object($result)) { |
---|
2168 | $causas_id[$causa->nid] = $causa->nid; |
---|
2169 | $causa_load = node_load($causa->nid); |
---|
2170 | $causas[$causa->nid] = $causa_load->title; |
---|
2171 | if (is_array($causa_load->field_causa_solucion) && count($causa_load->field_causa_solucion)) { |
---|
2172 | $vector[$causa_load->nid] = array(); |
---|
2173 | foreach ($causa_load->field_causa_solucion as $valor) { |
---|
2174 | $vector[$causa_load->nid][] = $valor['value']; |
---|
2175 | } |
---|
2176 | } |
---|
2177 | } |
---|
2178 | $form['#causas'] = $causas_id; |
---|
2179 | drupal_add_js(array('causas' => $form['#causas']), 'setting'); |
---|
2180 | |
---|
2181 | $node_type = content_types('politicas_direccionales'); |
---|
2182 | $fields = $node_type['fields']; |
---|
2183 | $field_form = array(); |
---|
2184 | $arreglo = array( |
---|
2185 | 'field_politicas_objetivog' => 'field_politicas_objetivog', |
---|
2186 | 'field_politicas_objetivoe' => 'field_politicas_objetivoe', |
---|
2187 | 'field_politicas_areasimp' => 'field_politicas_areasimp', |
---|
2188 | ); |
---|
2189 | if (is_array($fields) && count($fields)) { |
---|
2190 | foreach($fields as $field_id => $field) { |
---|
2191 | if (array_key_exists($field_id, $arreglo)) { |
---|
2192 | $field_form[] = $field_id; |
---|
2193 | $fields_form[] = $field_id; |
---|
2194 | } |
---|
2195 | elseif (variable_get('politicas_direccionales_ac_di_' . $field_id, FALSE)) { |
---|
2196 | $field_form[] = $field_id; |
---|
2197 | $fields_form[] = $field_id; |
---|
2198 | } |
---|
2199 | } |
---|
2200 | } |
---|
2201 | |
---|
2202 | if (is_array($field_form) && count($field_form)) { |
---|
2203 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
2204 | foreach ($field_form as $field_id) { |
---|
2205 | $field = content_fields($field_id, 'politicas_direccionales'); |
---|
2206 | $form['#field_info'][$field_id] = $field; |
---|
2207 | $form += (array) content_field_form($form, $form_state, $field); |
---|
2208 | } |
---|
2209 | } |
---|
2210 | $form['#politicas_direccionales_fields'] = $fields_form; |
---|
2211 | |
---|
2212 | $sql = "SELECT n.nid as nid, n.title as title from {node} n inner join {ente_planificador} as ent on n.nid=ent.nid, {node_revisions} rv where n.vid = rv.vid AND (n.type in ('ente_planificador')) AND (n.status <> 0) AND (ent.tipo=2)"; |
---|
2213 | $entes = array(); |
---|
2214 | $result = db_query($sql); |
---|
2215 | $entes['otro'] = t('Otro actor planificador'); |
---|
2216 | while($ente = db_fetch_object($result)) { |
---|
2217 | $entes[$ente->nid] = $ente->title; |
---|
2218 | } |
---|
2219 | $grados = array(); |
---|
2220 | $grados['p'] = t('Politico'); |
---|
2221 | $grados['c'] = t('Cognitivo'); |
---|
2222 | $grados['t'] = t('Tecnológico'); |
---|
2223 | $form['#arreglo'] = $arreglo; |
---|
2224 | $form['#grados'] = $grados; |
---|
2225 | $form['#entes'] = $entes; |
---|
2226 | $form['campo_requerimiento'] = array( |
---|
2227 | '#type' => 'fieldset', |
---|
2228 | '#title' => t('Requerimientos de la PolÃtica'), |
---|
2229 | '#prefix' => '<div id="requerimientos">', |
---|
2230 | '#suffix' => '</div>', |
---|
2231 | ); |
---|
2232 | |
---|
2233 | if (isset($form_state['values']['cantidad_requerimientos'])) { |
---|
2234 | $cantidad_requerimientos = $form_state['values']['cantidad_requerimientos']; |
---|
2235 | } |
---|
2236 | else if (count($form['#node']->requerimientos)) { |
---|
2237 | $cantidad_requerimientos = count($form['#node']->requerimientos); |
---|
2238 | } |
---|
2239 | else { |
---|
2240 | $cantidad_requerimientos = 1; |
---|
2241 | } |
---|
2242 | |
---|
2243 | for ($i = 0; $i < $cantidad_requerimientos; $i++) { |
---|
2244 | $form['campo_requerimiento']['politica_' . $i] = array( |
---|
2245 | '#type' => 'fieldset', |
---|
2246 | '#title' => t('Requerimiento %numero', array('%numero' => ($i + 1))), |
---|
2247 | '#prefix' => '<div id="requerimientos-actores-' . $i .'">', |
---|
2248 | '#suffix' => '</div>', |
---|
2249 | ); |
---|
2250 | if (isset($form_state['values']['req_' . $i])) { |
---|
2251 | $valor = $form_state['values']['req_' . $i]; |
---|
2252 | } |
---|
2253 | else if (isset($form['#node']->requerimientos[$i]['requerimiento'])) { |
---|
2254 | $valor = $form['#node']->requerimientos[$i]['requerimiento']; |
---|
2255 | } |
---|
2256 | else { |
---|
2257 | $valor = ''; |
---|
2258 | } |
---|
2259 | $form['campo_requerimiento']['politica_' . $i]['req_' . $i] = array( |
---|
2260 | '#type' => 'textfield', |
---|
2261 | '#title' => t('Requerimiento'), |
---|
2262 | '#required' => FALSE, |
---|
2263 | '#default_value' => $valor, |
---|
2264 | ); |
---|
2265 | if (isset($form_state['values']['tipo_' . $i])) { |
---|
2266 | $valor = $form_state['values']['tipo_' . $i]; |
---|
2267 | } |
---|
2268 | else if (isset($form['#node']->requerimientos[$i]['tipo'])) { |
---|
2269 | $valor = $form['#node']->requerimientos[$i]['tipo']; |
---|
2270 | } |
---|
2271 | else { |
---|
2272 | $valor = ''; |
---|
2273 | } |
---|
2274 | $form['campo_requerimiento']['politica_' . $i]['tipo_' . $i] = array( |
---|
2275 | '#type' => 'select', |
---|
2276 | '#default_value' => $valor, |
---|
2277 | '#options' => $form['#grados'], |
---|
2278 | '#multiple' => FALSE, |
---|
2279 | '#title' => t('Tipo'), |
---|
2280 | ); |
---|
2281 | if (isset($form_state['values']['cantidad_ente_' . $i])) { |
---|
2282 | $cantidad_entes = $form_state['values']['cantidad_ente_' . $i]; |
---|
2283 | } |
---|
2284 | else if (count($form['#node']->requerimientos[$i]['entes'])) { |
---|
2285 | $cantidad_entes = count($form['#node']->requerimientos[$i]['entes']); |
---|
2286 | } |
---|
2287 | else { |
---|
2288 | $cantidad_entes = 1; |
---|
2289 | } |
---|
2290 | for ($j = 0; $j < $cantidad_entes; $j++) { |
---|
2291 | $form['campo_requerimiento']['politica_' . $i]['actores_' . $j] = array( |
---|
2292 | '#type' => 'fieldset', |
---|
2293 | '#title' => t('Actor @num', array('@num' => $j + 1)), |
---|
2294 | ); |
---|
2295 | if (isset($form_state['values']['entes_' . $i . '_' . $j])) { |
---|
2296 | $valor = $form_state['values']['entes_' . $i . '_' . $j]; |
---|
2297 | } |
---|
2298 | else if (isset($form['#node']->requerimientos[$i]['entes'][$j]['ente'])) { |
---|
2299 | $valor = $form['#node']->requerimientos[$i]['entes'][$j]['ente']; |
---|
2300 | } |
---|
2301 | else { |
---|
2302 | $valor = 'otro'; |
---|
2303 | } |
---|
2304 | $form['campo_requerimiento']['politica_' . $i]['actores_' . $j]['entes_' . $i . '_' . $j] = array( |
---|
2305 | '#type' => 'select', |
---|
2306 | '#default_value' => $valor, |
---|
2307 | '#options' => $form['#entes'], |
---|
2308 | '#multiple' => FALSE, |
---|
2309 | '#title' => t('Actor'), |
---|
2310 | '#attributes' => array('class' => 'ente-actores ente-actores-' . $i . '_' . $j . ' actores-requerimientos actores-requerimiento-' . $i, 'requerimiento' => $i, 'cant_actor' => $j), |
---|
2311 | ); |
---|
2312 | if (isset($form_state['values']['otro_' . $i . '_' . $j])) { |
---|
2313 | $valor = $form_state['values']['otro_' . $i . '_' . $j]; |
---|
2314 | } |
---|
2315 | else if ($form['#node']->requerimientos[$i]['entes'][$j]['ente'] == 0) { |
---|
2316 | $valor = $form['#node']->requerimientos[$i]['entes'][$j]['otro_ente']; |
---|
2317 | } |
---|
2318 | else { |
---|
2319 | $valor = ''; |
---|
2320 | } |
---|
2321 | $form['campo_requerimiento']['politica_' . $i]['actores_' . $j]['otro_' . $i . '_' . $j] = array( |
---|
2322 | '#type' => 'textfield', |
---|
2323 | '#title' => t('Nombre del Actor'), |
---|
2324 | '#required' => FALSE, |
---|
2325 | '#default_value' => $valor, |
---|
2326 | '#attributes' => array('class' => 'ente-otros ente-otros-' . $i . '_' . $j . ' otros-requerimientos otros-requerimiento-' . $i, 'requerimiento' => $i, 'cant_actor' => $j), |
---|
2327 | ); |
---|
2328 | } |
---|
2329 | $form['campo_requerimiento']['politica_' . $i]['actores_' . $cantidad_entes]['cantidad_ente_' . $i] = array('#type' => 'hidden', '#value' => $cantidad_entes); |
---|
2330 | $form['campo_requerimiento']['politica_' . $i]['agrega_' . $i] = array( |
---|
2331 | '#type' => 'submit', |
---|
2332 | '#default_value' => t('Agregar otro ente'), |
---|
2333 | '#submit' => array(), |
---|
2334 | '#ahah' => array( |
---|
2335 | 'path' => 'politicas_direccionales_agregar_js/ente/' . $i, |
---|
2336 | 'wrapper' => 'requerimientos-actores-' . $i, |
---|
2337 | 'method' => 'replace', |
---|
2338 | 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), |
---|
2339 | ), |
---|
2340 | ); |
---|
2341 | } |
---|
2342 | |
---|
2343 | $form['campo_requerimiento']['cantidad_requerimientos'] = array('#type' => 'hidden', '#value' => $cantidad_requerimientos); |
---|
2344 | |
---|
2345 | $form['campo_requerimiento']['agregar_req'] = array( |
---|
2346 | '#type' => 'submit', |
---|
2347 | '#default_value' => t('Agregar otro requerimiento'), |
---|
2348 | '#ahah' => array( |
---|
2349 | 'path' => 'politicas_direccionales_agregar_js/requerimiento', |
---|
2350 | 'wrapper' => 'requerimientos', |
---|
2351 | 'method' => 'replace', |
---|
2352 | 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), |
---|
2353 | ), |
---|
2354 | ); |
---|
2355 | |
---|
2356 | |
---|
2357 | $form['buttons'] = array( |
---|
2358 | '#prefix' => '<div class="container-inline">', |
---|
2359 | '#suffix' => '</div>', |
---|
2360 | '#weight' => 100, |
---|
2361 | ); |
---|
2362 | $form['buttons']['submit'] = array( |
---|
2363 | '#type' => 'submit', |
---|
2364 | '#value' => t('Submit'), |
---|
2365 | '#weight' => 100, |
---|
2366 | ); |
---|
2367 | $form['buttons']['cancel'] = array( |
---|
2368 | '#type' => 'submit', |
---|
2369 | '#value' => t('Cancel'), |
---|
2370 | '#weight' => 100, |
---|
2371 | ); |
---|
2372 | $form['#after_build'] = array(); |
---|
2373 | $form['#after_build'][] = 'politicas_direccionales_skip_validation_form_after_build'; |
---|
2374 | |
---|
2375 | return $form; |
---|
2376 | } |
---|
2377 | |
---|
2378 | /* |
---|
2379 | * Implementation of politicas_direccionales_skip_validation_form_after_build() |
---|
2380 | * Agregar funcion para eliminar la validacion cuando se presiona el boton cancel |
---|
2381 | */ |
---|
2382 | function politicas_direccionales_skip_validation_form_after_build($form, &$form_state) { |
---|
2383 | if($form_state['clicked_button']['#value'] == t('Cancel')) { |
---|
2384 | _politicas_direccionales_disable_validation($form); |
---|
2385 | } |
---|
2386 | return $form; |
---|
2387 | } |
---|
2388 | |
---|
2389 | /* |
---|
2390 | * Implementation of _politicas_direccionales_disable_validation() |
---|
2391 | * funcion para eliminar la validacion por defecto de un formulario |
---|
2392 | */ |
---|
2393 | function _politicas_direccionales_disable_validation(&$element) { |
---|
2394 | unset($element['#needs_validation']); |
---|
2395 | foreach(element_children($element) as $key) { |
---|
2396 | _politicas_direccionales_disable_validation($element[$key]); |
---|
2397 | } |
---|
2398 | } |
---|
2399 | |
---|
2400 | /* |
---|
2401 | * Implementation of politicas_direccionales_number_float_validate() |
---|
2402 | * Validar que el texto introducido sea un float |
---|
2403 | */ |
---|
2404 | function politicas_direccionales_number_float_validate($element, &$form_state) { |
---|
2405 | $start = $element['#value']; |
---|
2406 | $value = preg_replace('@[^-0-9\.]@', '', $start); |
---|
2407 | if ($start != $value) { |
---|
2408 | form_set_error($element['#name'], t('Only numbers and decimals are allowed in %field.', array('%field' => $element['#title']))); |
---|
2409 | } |
---|
2410 | elseif ($value < 0) { |
---|
2411 | form_set_error($element['#name'], t('El valor minimo permitido in %field es 0.', array('%field' => $element['#title']))); |
---|
2412 | } |
---|
2413 | elseif ($value > 100) { |
---|
2414 | form_set_error($element['#name'], t('El valor maximo permitido in %field es 100.', array('%field' => $element['#title']))); |
---|
2415 | } |
---|
2416 | } |
---|
2417 | |
---|
2418 | /* |
---|
2419 | * Implementation of politicas_direccionales_agregar_form_validate() |
---|
2420 | */ |
---|
2421 | function politicas_direccionales_agregar_form_validate($form, &$form_state){ |
---|
2422 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
2423 | if ($op == t('Cancel')) { |
---|
2424 | return; |
---|
2425 | } |
---|
2426 | drupal_set_title($form['#titulo_pagina']); |
---|
2427 | if (trim($form_state['values']['body']) == '') { |
---|
2428 | form_set_error('body', t('Debe agregar el titulo de la polÃtica direccional')); |
---|
2429 | } |
---|
2430 | //debe existir al menos un requerimiento |
---|
2431 | $requerimiento = trim(check_plain($form_state['values']['req_0'])); |
---|
2432 | if ($requerimiento == '') { |
---|
2433 | form_set_error('req_0', t('Debe ingresar al menos un requerimiento')); |
---|
2434 | } |
---|
2435 | //debe existir al menos una causa |
---|
2436 | $causas = trim(check_plain($form_state['values']['causas_0'])); |
---|
2437 | if ($causas == '') { |
---|
2438 | form_set_error('causas_0', t('Debe ingresar al menos una causa')); |
---|
2439 | } |
---|
2440 | } |
---|
2441 | |
---|
2442 | |
---|
2443 | /* |
---|
2444 | * Implementation of politicas_direccionales_agregar_form_submit() |
---|
2445 | */ |
---|
2446 | function politicas_direccionales_agregar_form_submit($form, &$form_state){ |
---|
2447 | global $user; |
---|
2448 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
2449 | $ente_planificador = $form['#ente_planificador']; |
---|
2450 | if ($op == t('Cancel')) { |
---|
2451 | drupal_goto('planificacion/' . $ente_planificador->nid . '/politicas/posibles/listar'); |
---|
2452 | return; |
---|
2453 | } |
---|
2454 | else if ($op == t('Enviar')) { //evitar el duplicado de la información al hacerse el ahah |
---|
2455 | $politica = $form['#politica']; |
---|
2456 | module_load_include('inc', 'node', 'node.pages'); |
---|
2457 | $nuevo = FALSE; |
---|
2458 | $field_form = $form['#politicas_direccionales_fields']; |
---|
2459 | $politica->title = 'POlitica ente ' . $ente_planificador->nid; |
---|
2460 | $politica->uid = $user->uid; |
---|
2461 | $politica->body = check_plain($form_state['values']['body']); |
---|
2462 | $form_values = $form_state['values']; |
---|
2463 | if (is_array($field_form) && count($field_form)) { |
---|
2464 | foreach ($field_form as $field_id) { |
---|
2465 | if (isset($form_values[$field_id]) && is_array($form_values[$field_id])) { |
---|
2466 | foreach($form_values[$field_id] as $id => $value) { |
---|
2467 | if (is_numeric($id) && isset($form_values[$field_id][$id]['_error_element'])) { |
---|
2468 | unset($form_values[$field_id][$id]['_error_element']); |
---|
2469 | } |
---|
2470 | } |
---|
2471 | $politica->{$field_id} = $form_values[$field_id]; |
---|
2472 | } |
---|
2473 | } |
---|
2474 | } |
---|
2475 | if (!isset($politica->field_politicas_ente)) { |
---|
2476 | $politica->field_politicas_ente = array(); |
---|
2477 | $politica->field_politicas_ente[] = array('nid' => $form['#ente_planificador']->nid); |
---|
2478 | } |
---|
2479 | $politica->field_politicas_seleccionada = array(); |
---|
2480 | $politica->field_politicas_seleccionada[] = array('value' => 'NO'); |
---|
2481 | $politica->field_politicas_viable = array(); |
---|
2482 | $politica->field_politicas_viable[] = array('value' => 'NO'); |
---|
2483 | $politica->field_politicas_direcc_year[] = array('value' => variable_get('situacional_actual_preliminar_anho_creacion', 0)); |
---|
2484 | node_object_prepare($politica); |
---|
2485 | $politica->revision = 1; |
---|
2486 | $politica->log = $politica->nid ? t('Se modificó la polÃtica') : t('Se agregó la polÃtica'); |
---|
2487 | |
---|
2488 | /* $politica->field_politicas_causas = array(); |
---|
2489 | if (count($form_values['causas_politica'])) { |
---|
2490 | foreach($form_values['causas_politica'] as $causa) { |
---|
2491 | $politica->field_politicas_causas[] = array('nid' => $causa); |
---|
2492 | } |
---|
2493 | } |
---|
2494 | */ |
---|
2495 | //se obtienen los requerimientos y se guardan los campos para facilitar la busqueda |
---|
2496 | $politica->field_politicas_requerimientos = array(); |
---|
2497 | if ($form_values['cantidad_requerimientos']) { |
---|
2498 | for($i = 0; $i < $form_values['cantidad_requerimientos']; $i++) { |
---|
2499 | $requerimiento = trim(check_plain($form_values['req_' . $i])); |
---|
2500 | if ($form_values['cantidad_ente_' . $i] && $requerimiento != '') { |
---|
2501 | $form_values['req_' . $i] = $requerimiento; |
---|
2502 | $politica->field_politicas_requerimientos[] = array('value' => $form_values['req_' . $i]); |
---|
2503 | } |
---|
2504 | } |
---|
2505 | } |
---|
2506 | |
---|
2507 | //se obtienen la causas |
---|
2508 | $politica->field_politicas_causas = array(); |
---|
2509 | if ($form_values['count']) { |
---|
2510 | for($i = 0; $i < $form_values['count']; $i++) { |
---|
2511 | $causa = trim(check_plain($form_values['causas_' . $i])); |
---|
2512 | if ($causa != '') { |
---|
2513 | $politica->field_politicas_causas[] = array('nid' => $causa); |
---|
2514 | } |
---|
2515 | } |
---|
2516 | } |
---|
2517 | // $form['problema']['causa_' . $i]['causas_' . $i] = array( |
---|
2518 | |
---|
2519 | node_save($politica); |
---|
2520 | db_query('DELETE FROM {politicas_ente} WHERE nid = %d', $politica->nid); |
---|
2521 | db_query('DELETE FROM {politicas_ente_actor} WHERE nid = %d', $politica->nid); |
---|
2522 | if ($form_values['cantidad_requerimientos']) { |
---|
2523 | for($i = 0; $i < $form_values['cantidad_requerimientos']; $i++) { |
---|
2524 | if ($form_values['cantidad_ente_' . $i] && $form_values['req_' . $i] != '') { |
---|
2525 | $politica->politicas_ente[$i] = array( |
---|
2526 | 'requerimiento' => $form_values['req_' . $i], |
---|
2527 | 'tipo' => check_plain($form_values['tipo_' . $i]), |
---|
2528 | ); |
---|
2529 | db_query("insert into {politicas_ente} (nid, vid, delta, requerimiento, tipo) values (%d, %d, %d, '%s', '%s')", $politica->nid, $politica->vid, $i, $politica->politicas_ente[$i]['requerimiento'], $politica->politicas_ente[$i]['tipo']); |
---|
2530 | for($j = 0; $j < $form_values['cantidad_ente_' . $i]; $j++) { |
---|
2531 | $politica->politicas_ente[$i]['entes'][$j] = array( |
---|
2532 | 'otro_ente' => $form_values['entes_' . $i . '_' . $j] == 'otro' ? check_plain($form_values['otro_' . $i . '_' . $j]) : '', |
---|
2533 | 'ente' => $form_values['entes_' . $i . '_' . $j] == 'otro' ? 0 : $form_values['entes_' . $i . '_' . $j], |
---|
2534 | 'grado' => $form_values['grado_' . $i . '_' . $j], |
---|
2535 | ); |
---|
2536 | |
---|
2537 | db_query("insert into {politicas_ente_actor} (nid, vid, delta, delta1, otro_ente, ente, grado) values (%d, %d, %d, %d, '%s', %d, %f)", $politica->nid, $politica->vid, $i, $j, $politica->politicas_ente[$i]['entes'][$j]['otro_ente'], $politica->politicas_ente[$i]['entes'][$j]['ente'], $politica->politicas_ente[$i]['entes'][$j]['grado']); |
---|
2538 | } |
---|
2539 | } |
---|
2540 | } |
---|
2541 | } |
---|
2542 | $form['#politica'] = $politica; |
---|
2543 | if ($nuevo) { |
---|
2544 | drupal_set_message(t('Se ha agregado la polÃtica direccional "@politica"', array('@politica' => $politica->title))); |
---|
2545 | } |
---|
2546 | else { |
---|
2547 | drupal_set_message(t('Se ha modificado la polÃtica direccional "@politica"', array('@politica' => $politica->title))); |
---|
2548 | } |
---|
2549 | } |
---|
2550 | if (!$form_state['redirect']){ |
---|
2551 | $form_state['redirect'] = array( |
---|
2552 | 'planificacion/' . $ente_planificador->nid . '/politicas/posibles/listar', |
---|
2553 | ); |
---|
2554 | } |
---|
2555 | } |
---|
2556 | |
---|
2557 | /* |
---|
2558 | * Implementation of politicas_direccionales_agregar_accion_form() |
---|
2559 | */ |
---|
2560 | function politicas_direccionales_agregar_accion_form($form_state, $ente_planificador, $politica = 0) { |
---|
2561 | global $user; |
---|
2562 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
2563 | $current_time = time(); |
---|
2564 | $ente_has_acceso = FALSE; |
---|
2565 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
2566 | $fecha = TRUE; |
---|
2567 | } |
---|
2568 | if (!$fecha) { |
---|
2569 | muestra_mensaje("posibles", $ente_planificador); |
---|
2570 | } |
---|
2571 | else { |
---|
2572 | if ($ente->nid == $ente_planificador->nid) { |
---|
2573 | muestra_mensaje("posibles", $ente_planificador, 0); |
---|
2574 | } |
---|
2575 | } |
---|
2576 | if ($fecha && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
2577 | $ente_has_acceso = TRUE; |
---|
2578 | } |
---|
2579 | if (!$ente_has_acceso || !$politica) { |
---|
2580 | drupal_goto('planificacion/' . $ente_planificador->nid . '/politicas/posibles'); |
---|
2581 | } |
---|
2582 | $form = array(); |
---|
2583 | if ($politica) { |
---|
2584 | $politica_load = $politica; |
---|
2585 | if($politica_load->nid && $politica_load->type == 'politicas_direccionales' && $politica_load->field_politicas_ente[0]['nid'] == $ente_planificador->nid && $mi_fecha[1] + 86399 > $politica_load->created && $mi_fecha[0] < $politica_load->created) { |
---|
2586 | $politica_leido = $politica_load; |
---|
2587 | $form['#titulo_pagina'] = t('Acciones para construir viabilidad para la posible polÃtica "@titulo"', array('@titulo' => $politica_leido->title)); |
---|
2588 | } |
---|
2589 | } |
---|
2590 | if (!isset($form['#titulo_pagina'])) { |
---|
2591 | $form['#titulo_pagina'] = t('Agregar polÃtica direccional'); |
---|
2592 | } |
---|
2593 | drupal_set_title($form['#titulo_pagina']); |
---|
2594 | politicas_direccionales_load_requerimientos($politica_leido); |
---|
2595 | $form['#node'] = $politica_leido; |
---|
2596 | $form['#ente_planificador'] = $ente_planificador; |
---|
2597 | $form['#politica'] = $politica_leido; |
---|
2598 | $node_type = content_types('politicas_direccionales'); |
---|
2599 | $fields = $node_type['fields']; |
---|
2600 | $field_form = array(); |
---|
2601 | $arreglo = array( |
---|
2602 | 'field_politicas_acciones_viab' => 'field_politicas_acciones_viab', |
---|
2603 | ); |
---|
2604 | if (is_array($fields) && count($fields)) { |
---|
2605 | foreach($fields as $field_id => $field) { |
---|
2606 | if (array_key_exists($field_id, $arreglo)) { |
---|
2607 | $field_form[] = $field_id; |
---|
2608 | $fields_form[] = $field_id; |
---|
2609 | } |
---|
2610 | elseif (variable_get('politicas_direccionales_ac_di_' . $field_id, FALSE)) { |
---|
2611 | $field_form[] = $field_id; |
---|
2612 | $fields_form[] = $field_id; |
---|
2613 | } |
---|
2614 | } |
---|
2615 | } |
---|
2616 | if (is_array($field_form) && count($field_form)) { |
---|
2617 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
2618 | foreach ($field_form as $field_id) { |
---|
2619 | $field = content_fields($field_id, 'politicas_direccionales'); |
---|
2620 | $form['#field_info'][$field_id] = $field; |
---|
2621 | $form += (array) content_field_form($form, $form_state, $field); |
---|
2622 | } |
---|
2623 | } |
---|
2624 | $form['#politicas_direccionales_fields'] = $fields_form; |
---|
2625 | $form['buttons'] = array( |
---|
2626 | '#prefix' => '<div class="container-inline">', |
---|
2627 | '#suffix' => '</div>', |
---|
2628 | '#weight' => 100, |
---|
2629 | ); |
---|
2630 | $form['buttons']['submit'] = array( |
---|
2631 | '#type' => 'submit', |
---|
2632 | '#value' => t('Submit'), |
---|
2633 | '#weight' => 100, |
---|
2634 | ); |
---|
2635 | $form['buttons']['cancel'] = array( |
---|
2636 | '#type' => 'submit', |
---|
2637 | '#value' => t('Cancel'), |
---|
2638 | '#weight' => 100, |
---|
2639 | ); |
---|
2640 | $form['#after_build'] = array(); |
---|
2641 | $form['#after_build'][] = 'politicas_direccionales_skip_validation_form_after_build'; |
---|
2642 | return $form; |
---|
2643 | } |
---|
2644 | |
---|
2645 | /* |
---|
2646 | * Implementation of politicas_direccionales_agregar_accion_form_submit() |
---|
2647 | */ |
---|
2648 | function politicas_direccionales_agregar_accion_form_submit($form, &$form_state){ |
---|
2649 | if (!$_REQUEST['destination']) { |
---|
2650 | $form_state['redirect'] = 'planificacion/' . $form['#ente_planificador']->nid . '/politicas/seleccionar/inviables'; |
---|
2651 | } |
---|
2652 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
2653 | $ente_planificador = $form['#ente_planificador']; |
---|
2654 | if ($op == t('Cancel')) { |
---|
2655 | return; |
---|
2656 | } |
---|
2657 | $politica = $form['#politica']; |
---|
2658 | module_load_include('inc', 'node', 'node.pages'); |
---|
2659 | $nuevo = FALSE; |
---|
2660 | $field_form = $form['#politicas_direccionales_fields']; |
---|
2661 | $form_values = $form_state['values']; |
---|
2662 | if (is_array($field_form) && count($field_form)) { |
---|
2663 | foreach ($field_form as $field_id) { |
---|
2664 | if (isset($form_values[$field_id]) && is_array($form_values[$field_id])) { |
---|
2665 | foreach($form_values[$field_id] as $id => $value) { |
---|
2666 | if (is_numeric($id) && isset($form_values[$field_id][$id]['_error_element'])) { |
---|
2667 | unset($form_values[$field_id][$id]['_error_element']); |
---|
2668 | } |
---|
2669 | } |
---|
2670 | $politica->{$field_id} = $form_values[$field_id]; |
---|
2671 | } |
---|
2672 | } |
---|
2673 | } |
---|
2674 | node_object_prepare($politica); |
---|
2675 | $politica->revision = 1; |
---|
2676 | $politica->log = t('Se agregarón las acciones para construir la viabilidad de la polÃtica "@politica"', array('@politica' => $politica->title)); |
---|
2677 | node_save($politica); |
---|
2678 | //se agregan los requerimientos a la nueva version del nodo |
---|
2679 | db_query("UPDATE {politicas_ente} SET vid = %d WHERE nid = %d", $politica->vid, $politica->nid); |
---|
2680 | db_query("UPDATE {politicas_ente_actor} SET vid = %d WHERE nid = %d", $politica->vid, $politica->nid); |
---|
2681 | drupal_set_message(t('Se agregarón las acciones para construir la viabilidad de la polÃtica "@politica"', array('@politica' => $politica->title))); |
---|
2682 | } |
---|
2683 | |
---|
2684 | /* |
---|
2685 | * Implementation of ente_planificador_definir_politicas_listar() |
---|
2686 | * Listar politicas |
---|
2687 | */ |
---|
2688 | function ente_planificador_definir_politicas_listar($ente_planificador) { |
---|
2689 | drupal_set_title(t('Posibles politicas direccionales')); |
---|
2690 | global $user; |
---|
2691 | $ente = usuario_tiene_ente($user->uid); |
---|
2692 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
2693 | |
---|
2694 | $current_time = time(); |
---|
2695 | $ente_has_acceso = FALSE; |
---|
2696 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
2697 | $fecha = TRUE; |
---|
2698 | } |
---|
2699 | if (!$fecha) { |
---|
2700 | muestra_mensaje("posibles", $ente_planificador); |
---|
2701 | } |
---|
2702 | else { |
---|
2703 | if ($user->entes == $ente_planificador->nid) { |
---|
2704 | muestra_mensaje("posibles", $ente_planificador, 0); |
---|
2705 | } |
---|
2706 | } |
---|
2707 | |
---|
2708 | if ($fecha && (user_access('admin planificador') || $fecha && $user->entes == $ente_planificador->nid)) { |
---|
2709 | $ente_has_acceso = TRUE; |
---|
2710 | } |
---|
2711 | |
---|
2712 | if ($ente_planificador->tipo > 2) { |
---|
2713 | $ente_has_acceso = FALSE; |
---|
2714 | $macro = ente_planificador_ente_macro($ente_planificador); |
---|
2715 | if ($macro) { |
---|
2716 | $ente_planificador = node_load($macro); |
---|
2717 | } |
---|
2718 | } |
---|
2719 | $step = 10; |
---|
2720 | $headers_table = array(); |
---|
2721 | $headers_table[] = array( |
---|
2722 | 'data' => t('Nombre de la polÃtica Direccional'), |
---|
2723 | 'sort' => 'asc', |
---|
2724 | 'field' => 'n.title' |
---|
2725 | ); |
---|
2726 | $headers_table[] = array( |
---|
2727 | 'data' => t('Causas CrÃticas'), |
---|
2728 | ); |
---|
2729 | if ($ente_has_acceso) { |
---|
2730 | $headers_table[] = array( |
---|
2731 | 'data' => t('Operación'), |
---|
2732 | ); |
---|
2733 | } |
---|
2734 | $sqlcount = "select count(c.nid) FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND c.field_politicas_direcc_year_value=%d"; |
---|
2735 | $sql_query = "SELECT c.nid, n.title FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND c.field_politicas_direcc_year_value=%d"; |
---|
2736 | $sql_query.= tablesort_sql($headers_table); |
---|
2737 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
2738 | $sql_variables[] = $ente_planificador->nid; |
---|
2739 | $sql_variables[] = variable_get('situacional_actual_preliminar_anho_creacion', 0); |
---|
2740 | $result = pager_query($sql_query, $step, 0, $sqlcount, $sql_variables); |
---|
2741 | $mi_fecha_causas = ente_planificador_user_acceso_proceso("causas", $ente_planificador); |
---|
2742 | $sql_variables1[] = $ente_planificador->nid; |
---|
2743 | $sql_variables1[] = variable_get('situacional_actual_preliminar_anho_creacion', 0); |
---|
2744 | $sql_query1 = "SELECT * FROM {content_type_causas} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_ente_planifiador_nid = %d AND c.field_causa_critica_value = '1' AND c.field_causas_year_value=%d"; |
---|
2745 | $resultado = db_query($sql_query1, $sql_variables1); |
---|
2746 | |
---|
2747 | $causas = array(); |
---|
2748 | $causas_arreglo = array(); |
---|
2749 | $vector = array(); |
---|
2750 | $causas_array = array(); |
---|
2751 | while($causa = db_fetch_object($resultado)) { |
---|
2752 | $causas_array[$causa->nid] = check_plain($causa->title); |
---|
2753 | } |
---|
2754 | while($politica = db_fetch_object($result)) { |
---|
2755 | $politica_load = node_load($politica->nid); |
---|
2756 | $row = array(); |
---|
2757 | $titulo = trim($politica_load->body) != ''? $politica_load->body : $politica_load->title; |
---|
2758 | $row[] = array('data' => $titulo, ); |
---|
2759 | $causas = array(); |
---|
2760 | foreach($politica_load->field_politicas_causas as $causa) { |
---|
2761 | if (isset($causas_array[$causa['nid']]) && $causas_array[$causa['nid']]) { |
---|
2762 | $causas[] = $causas_array[$causa['nid']]; |
---|
2763 | } |
---|
2764 | } |
---|
2765 | $row[] = array('data' => theme('item_list', $causas), ); |
---|
2766 | if ($ente_has_acceso) { |
---|
2767 | $links = array(); |
---|
2768 | $links[] = l(t('Modificar'), 'planificacion/' . $ente_planificador->nid . '/politicas/posibles/' . $politica->nid . '/editar', array('query' => array('destination' => 'planificacion/' . $ente_planificador->nid . '/politicas/posibles/listar'),)); |
---|
2769 | $links[] = l(t('Eliminar'), 'planificacion/' . $ente_planificador->nid . '/politicas/posibles/' . $politica->nid . '/remove', array('query' => array('destination' => 'planificacion/' . $ente_planificador->nid . '/politicas/posibles/listar'),)); |
---|
2770 | $row[] = array('data' => theme('item_list', $links),); |
---|
2771 | } |
---|
2772 | $rows[] = $row; |
---|
2773 | } |
---|
2774 | if (!count($rows)) { |
---|
2775 | $row = array(); |
---|
2776 | $row[] = array('data' => t('No se encontraron PolÃticas Direccionales para este ente'), 'colspan' => '4'); |
---|
2777 | $rows[] = $row; |
---|
2778 | } |
---|
2779 | $output = theme('table', $headers_table, $rows); |
---|
2780 | if ($ente_has_acceso) { |
---|
2781 | $output .= l(t('Registrar Posible PolÃtica Direccional'), 'planificacion/' . $ente_planificador->nid . '/politicas/posibles/registrar'); |
---|
2782 | } |
---|
2783 | $output .= theme('pager', NULL); |
---|
2784 | return $output; |
---|
2785 | } |
---|
2786 | |
---|
2787 | /* |
---|
2788 | * Listar politicas inivables |
---|
2789 | * |
---|
2790 | function ente_planificador_definir_politicas_listar_inviables($ente_planificador) { |
---|
2791 | drupal_set_title(t('Consultar posibles polÃticas inviables')); |
---|
2792 | global $user; |
---|
2793 | $ente = usuario_tiene_ente($user->uid); |
---|
2794 | $mi_fecha = ente_planificador_user_acceso_proceso("viabilidad", $ente_planificador); |
---|
2795 | $current_time = time(); |
---|
2796 | $ente_has_acceso = FALSE; |
---|
2797 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
2798 | $fecha = TRUE; |
---|
2799 | } |
---|
2800 | if (!$fecha) { |
---|
2801 | muestra_mensaje("posibles", $ente_planificador); |
---|
2802 | } |
---|
2803 | else { |
---|
2804 | if ($user->entes == $ente_planificador->nid) { |
---|
2805 | muestra_mensaje("posibles", $ente_planificador, 0); |
---|
2806 | } |
---|
2807 | } |
---|
2808 | if ($fecha && (user_access('admin planificador') || $fecha && $user->entes == $ente_planificador->nid)) { |
---|
2809 | $ente_has_acceso = TRUE; |
---|
2810 | } |
---|
2811 | if ($ente_planificador->tipo > 1) { |
---|
2812 | $ente_has_acceso = FALSE; |
---|
2813 | $macro = ente_planificador_ente_macro($ente_planificador); |
---|
2814 | if ($macro) { |
---|
2815 | $ente_planificador = node_load($macro); |
---|
2816 | } |
---|
2817 | } |
---|
2818 | $step = 10; |
---|
2819 | $headers_table = array(); |
---|
2820 | $headers_table[] = array( |
---|
2821 | 'data' => t('Nombre de la polÃtica Direccional'), |
---|
2822 | 'sort' => 'asc', |
---|
2823 | 'field' => 'n.title' |
---|
2824 | ); |
---|
2825 | $headers_table[] = array( |
---|
2826 | 'data' => t('Acciones para Construir Viabilidad'), |
---|
2827 | ); |
---|
2828 | $puede_viabilidad = ente_planificador_usuario_tiene_politicas_viabilidad($ente_planificador); |
---|
2829 | if ($puede_viabilidad && $ente_has_acceso) { |
---|
2830 | $headers_table[] = array( |
---|
2831 | 'data' => t('Operación'), |
---|
2832 | ); |
---|
2833 | } |
---|
2834 | $sqlcount = "select count(c.nid) FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND c.field_politicas_viable_value = 'NO' AND n.created >= %d AND n.created <= %d"; |
---|
2835 | $sql_query = "SELECT c.nid, n.title FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND c.field_politicas_viable_value = 'NO' AND n.created >= %d AND n.created <= %d "; |
---|
2836 | $sql_query.= tablesort_sql($headers_table); |
---|
2837 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
2838 | $sql_variables[] = $ente_planificador->nid; |
---|
2839 | $sql_variables[] = $mi_fecha[0]; |
---|
2840 | $sql_variables[] = $mi_fecha[1] + 86399; |
---|
2841 | $result = pager_query($sql_query, $step, 0, $sqlcount, $sql_variables); |
---|
2842 | while($politica = db_fetch_object($result)) { |
---|
2843 | $politica_load = node_load($politica->nid); |
---|
2844 | $row = array(); |
---|
2845 | $row[] = array('data' => $politica_load->body, ); |
---|
2846 | $viabilidades = array(); |
---|
2847 | if ($politica_load->field_politicas_acciones_viab[0]['value']){ |
---|
2848 | foreach($politica_load->field_politicas_acciones_viab as $viabilidad) { |
---|
2849 | if (trim($viabilidad['value']) != ''){ |
---|
2850 | $viabilidades[] = $viabilidad['value']; |
---|
2851 | } |
---|
2852 | } |
---|
2853 | } |
---|
2854 | $cuenta = count($viabilidades); |
---|
2855 | $row[] = array('data' => theme('item_list', $viabilidades), ); |
---|
2856 | if ($puede_viabilidad && $ente_has_acceso) { |
---|
2857 | $links = array(); |
---|
2858 | $links[] = l(t('Modificar acciones para construir viabilidad'), 'planificacion/' . $ente_planificador->nid . '/politicas/seleccionar/' . $politica->nid . '/editar_accion', array('query' => array('destination' => 'planificacion/' . $ente_planificador->nid . '/politicas/seleccionar/inviables'),)); |
---|
2859 | $links[] = l(t('Eliminar acciones para construir viabilidad'), 'planificacion/' . $ente_planificador->nid . '/politicas/seleccionar/' . $politica->nid . '/remove_accion', array('query' => array('destination' => 'planificacion/' . $ente_planificador->nid . '/politicas/seleccionar/inviables'),)); |
---|
2860 | $row[] = array('data' => theme('item_list', $links),); |
---|
2861 | } |
---|
2862 | |
---|
2863 | $rows[] = $row; |
---|
2864 | } |
---|
2865 | if (!count($rows)) { |
---|
2866 | $row = array(); |
---|
2867 | $row[] = array('data' => t('No se encontraron PolÃticas Direccionales inviables para este ente'), 'colspan' => '4'); |
---|
2868 | $rows[] = $row; |
---|
2869 | } |
---|
2870 | $output = theme('table', $headers_table, $rows); |
---|
2871 | $output .= theme('pager', NULL); |
---|
2872 | return $output; |
---|
2873 | } |
---|
2874 | */ |
---|
2875 | |
---|
2876 | /* |
---|
2877 | * Implementation of politicas_direccionales_seleccionar_politicas_listar() |
---|
2878 | * Listar politicas direccionales |
---|
2879 | */ |
---|
2880 | function politicas_direccionales_seleccionar_politicas_listar($ente_planificador) { |
---|
2881 | drupal_set_title(t('Consultar polÃticas direccionales')); |
---|
2882 | global $user; |
---|
2883 | $ente = usuario_tiene_ente($user->uid); |
---|
2884 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
2885 | $current_time = time(); |
---|
2886 | $ente_has_acceso = FALSE; |
---|
2887 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
2888 | $fecha = TRUE; |
---|
2889 | } |
---|
2890 | if (!$fecha) { |
---|
2891 | muestra_mensaje("posibles", $ente_planificador); |
---|
2892 | } |
---|
2893 | else { |
---|
2894 | if ($user->entes == $ente_planificador->nid) { |
---|
2895 | muestra_mensaje("posibles", $ente_planificador, 0); |
---|
2896 | } |
---|
2897 | } |
---|
2898 | if ($fecha && (user_access('admin planificador') || $fecha && $user->entes == $ente_planificador->nid)) { |
---|
2899 | $ente_has_acceso = TRUE; |
---|
2900 | } |
---|
2901 | if ($ente_planificador->tipo > 1) { |
---|
2902 | $ente_has_acceso = FALSE; |
---|
2903 | $macro = ente_planificador_ente_macro($ente_planificador); |
---|
2904 | if ($macro) { |
---|
2905 | $ente_planificador = node_load($macro); |
---|
2906 | } |
---|
2907 | } |
---|
2908 | $step = 10; |
---|
2909 | $headers_table = array(); |
---|
2910 | $headers_table[] = array( |
---|
2911 | 'data' => t('Nombre de la polÃtica Direccional'), |
---|
2912 | 'sort' => 'asc', |
---|
2913 | 'field' => 'n.title' |
---|
2914 | ); |
---|
2915 | |
---|
2916 | /* |
---|
2917 | $headers_table[] = array( |
---|
2918 | 'data' => t('Acciones para Construir Viabilidad'), |
---|
2919 | ); |
---|
2920 | */ |
---|
2921 | |
---|
2922 | $sqlcount = "select count(c.nid) FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND c.field_politicas_seleccionada_value = '1' AND c.field_politicas_direcc_year_value=%d"; |
---|
2923 | $sql_query = "SELECT c.nid, n.title FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND c.field_politicas_seleccionada_value = '1' AND c.field_politicas_direcc_year_value= %d "; |
---|
2924 | //$sql_query = "SELECT c.nid, n.title FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND c.field_politicas_direcc_year_value=%d"; |
---|
2925 | |
---|
2926 | |
---|
2927 | $sql_variables[] = $ente_planificador->nid; |
---|
2928 | $sql_query.= tablesort_sql($headers_table); |
---|
2929 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
2930 | $sql_variables[] = variable_get('situacional_actual_preliminar_anho_creacion', 0); |
---|
2931 | |
---|
2932 | $result = pager_query($sql_query, $step, 0, $sqlcount, $sql_variables); |
---|
2933 | while($politica = db_fetch_object($result)) { |
---|
2934 | $politica_load = node_load($politica->nid); |
---|
2935 | $row = array(); |
---|
2936 | $row[] = array('data' => $politica_load->body, ); |
---|
2937 | /* |
---|
2938 | $viabilidades = array(); |
---|
2939 | if ($politica_load->field_politicas_acciones_viab[0]['value']) { |
---|
2940 | foreach($politica_load->field_politicas_acciones_viab as $viabilidad) { |
---|
2941 | if (trim($viabilidad['value']) != ''){ |
---|
2942 | $viabilidades[] = $viabilidad['value']; |
---|
2943 | } |
---|
2944 | } |
---|
2945 | } |
---|
2946 | $cuenta = count($viabilidades); |
---|
2947 | if ($cuenta) { |
---|
2948 | $row[] = array('data' => theme('item_list', $viabilidades), ); |
---|
2949 | } |
---|
2950 | else { |
---|
2951 | $row[] = array('data' => t('No existen acciones para construir viabilidad para esta polÃtica'), ); |
---|
2952 | } |
---|
2953 | */ |
---|
2954 | $rows[] = $row; |
---|
2955 | } |
---|
2956 | if (!count($rows)) { |
---|
2957 | $row = array(); |
---|
2958 | $row[] = array('data' => t('No se encontraron PolÃticas Direccionales para este ente'), 'colspan' => '3'); |
---|
2959 | $rows[] = $row; |
---|
2960 | } |
---|
2961 | $output = theme('table', $headers_table, $rows); |
---|
2962 | $output .= theme('pager', NULL); |
---|
2963 | return $output; |
---|
2964 | } |
---|
2965 | |
---|
2966 | /** |
---|
2967 | * Implementation of hook_theme(). |
---|
2968 | */ |
---|
2969 | function politicas_direccionales_theme() { |
---|
2970 | $politicas_direccionales_path = drupal_get_path('module', 'politicas_direccionales') . '/templates'; |
---|
2971 | return array( |
---|
2972 | 'politicas_direccionales_agregar_form' => array( |
---|
2973 | 'arguments' => array('form' => NULL), |
---|
2974 | ), |
---|
2975 | 'politicas_direccionales_agregar_estrategia_form' => array( |
---|
2976 | 'arguments' => array('form' => NULL), |
---|
2977 | ), |
---|
2978 | 'politicas_direccionales_ver_articulacion' => array( |
---|
2979 | 'arguments' => array( |
---|
2980 | 'articulacion' => array(), |
---|
2981 | ), |
---|
2982 | 'template' => 'politicas-direccionales-ver-articulacion', |
---|
2983 | 'path' => $politicas_direccionales_path, |
---|
2984 | ), |
---|
2985 | 'politicas_direccionales_ver_estrategia' => array( |
---|
2986 | 'arguments' => array( |
---|
2987 | 'politica' => array(), |
---|
2988 | 'estrategia' => array(), |
---|
2989 | ), |
---|
2990 | 'template' => 'politicas-direccionales-ver-estrategia', |
---|
2991 | 'path' => $politicas_direccionales_path, |
---|
2992 | ), |
---|
2993 | ); |
---|
2994 | } |
---|
2995 | |
---|
2996 | /** |
---|
2997 | * Implementation of theme_politicas_direccionales_agregar_form(). |
---|
2998 | * El tema para el formulario de agregar o editar politicas |
---|
2999 | */ |
---|
3000 | function theme_politicas_direccionales_agregar_form($form) { |
---|
3001 | $output = ''; |
---|
3002 | |
---|
3003 | $output .= drupal_render($form['problema']); |
---|
3004 | |
---|
3005 | $output .= drupal_render($form['politica']); |
---|
3006 | // $output .= drupal_render($form['causas_politica']); |
---|
3007 | /* |
---|
3008 | if (count($form['#vector_descriptores'])) { |
---|
3009 | $output .= '<div id ="formas-solucion"><label for="edit-formas-solucion"><b>' . t('Formas de Solución') . ':</b></label>'; |
---|
3010 | foreach($form['#vector_descriptores'] as $nid => $descriptores) { |
---|
3011 | $output .= '<div id ="causas-descriptores-' . $nid . '">'. theme('item_list', $descriptores) . '</div>'; |
---|
3012 | } |
---|
3013 | $output .= '</div>'; |
---|
3014 | } |
---|
3015 | */ |
---|
3016 | |
---|
3017 | $output .= '<fieldset><legend>' . t('Objetivos y Ãrea de Impacto') . '</legend>' . drupal_render($form['field_politicas_objetivog']) . drupal_render($form['field_politicas_objetivoe']); |
---|
3018 | $output .= drupal_render($form['field_politicas_areasimp']) . '</fieldset>'; |
---|
3019 | |
---|
3020 | $output .= drupal_render($form); |
---|
3021 | return $output; |
---|
3022 | } |
---|
3023 | |
---|
3024 | /* |
---|
3025 | * Implementation of hook_node_info() |
---|
3026 | */ |
---|
3027 | function politicas_direccionales_node_info() { |
---|
3028 | return array( |
---|
3029 | 'politicas_direccionales' => array( |
---|
3030 | 'name' => t('PolÃticas Direcionales'), |
---|
3031 | 'description' => t('PolÃticas Direcionales'), |
---|
3032 | 'has_body' => TRUE, |
---|
3033 | 'has_title' => TRUE, |
---|
3034 | 'title_label' => 'Nombre de la PolÃtica', |
---|
3035 | 'body_label' => 'Nombre de la PolÃtica', |
---|
3036 | 'module' => 'politicas_direccionales', |
---|
3037 | ), |
---|
3038 | 'estrategia' => array( |
---|
3039 | 'name' => t('estrategias'), |
---|
3040 | 'description' => t('estrategias'), |
---|
3041 | 'has_body' => TRUE, |
---|
3042 | 'has_title' => TRUE, |
---|
3043 | 'title_label' => 'estrategia', |
---|
3044 | 'body_label' => 'estrategia', |
---|
3045 | 'module' => 'politicas_direccionales', |
---|
3046 | ), |
---|
3047 | ); |
---|
3048 | } |
---|
3049 | |
---|
3050 | /* |
---|
3051 | * Implementation of hook_form() |
---|
3052 | */ |
---|
3053 | function politicas_direccionales_form(&$node, $form_state) { |
---|
3054 | return node_content_form($node, $form_state); |
---|
3055 | } |
---|
3056 | |
---|
3057 | /* |
---|
3058 | * Implementation of hook_access |
---|
3059 | */ |
---|
3060 | function politicas_direccionales_access($op, $node, $account) { |
---|
3061 | global $user; |
---|
3062 | if ($op == 'view') { |
---|
3063 | return user_access('ver planificador'); |
---|
3064 | } |
---|
3065 | if ($op == 'create' || $op == 'edit') { |
---|
3066 | return (user_access('admin planificador')); |
---|
3067 | } |
---|
3068 | if ($node->type == 'estrategia' && $op == 'delete' && $account->uid == $node->uid && user_access('ver planificador')){ |
---|
3069 | return TRUE; |
---|
3070 | } |
---|
3071 | if ( $op == 'delete' && $node->type == 'politicas_direccionales') { |
---|
3072 | return (user_access('admin planificador') || ($user->entes == $node->field_politicas_ente[0]['nid'] && $account->uid == $node->uid)); |
---|
3073 | } |
---|
3074 | } |
---|
3075 | |
---|
3076 | /* |
---|
3077 | * hook_form_alter() |
---|
3078 | */ |
---|
3079 | function politicas_direccionales_form_alter(&$form, $form_state, $form_id) { |
---|
3080 | //impedir que los campos sean borrados con la interfaz |
---|
3081 | if ($form_id == 'content_field_overview_form' && $form['#type_name'] == 'direccionales'){ |
---|
3082 | $arreglo = array('field_direccional_causa', 'field_direccional_ente', 'field_direccional_seleccionado', 'field_direccional_requerimientos', 'field_direccional_actores'); |
---|
3083 | foreach ($arreglo as $valor) { |
---|
3084 | if (isset($form[$valor]['remove']['#value'])) { |
---|
3085 | $form[$valor]['remove']['#value'] = ''; |
---|
3086 | } |
---|
3087 | } |
---|
3088 | } |
---|
3089 | if ($form_id == 'content_field_remove_form' && $form['type_name']['#value'] == 'direccionales'){ |
---|
3090 | $arreglo = array('field_direccional_causa', 'field_direccional_ente', 'field_direccional_seleccionado', 'field_direccional_requerimientos', 'field_direccional_actores'); |
---|
3091 | foreach ($arreglo as $valor) { |
---|
3092 | if($form['field_name']['#value'] == $valor) { |
---|
3093 | $form['actions']['submit']['#access'] = FALSE; |
---|
3094 | $form['description']['#value'] = t('Acción no permitida este campo ha sido agregado por un modulo.'); |
---|
3095 | } |
---|
3096 | } |
---|
3097 | } |
---|
3098 | } |
---|
3099 | |
---|
3100 | /** |
---|
3101 | * Implementation of hook_form_FORM_ID_alter(): content_field_edit_form. |
---|
3102 | */ |
---|
3103 | function politicas_direccionales_form_content_field_edit_form_alter(&$form, $form_state) { |
---|
3104 | if ($form['#field']['type_name'] == 'direccionales') { |
---|
3105 | $form['widget']['ente_planificador'] = array( |
---|
3106 | '#title' => 'ente planificador', |
---|
3107 | '#type' => 'checkbox', |
---|
3108 | '#default_value' => variable_get('ente_planificador_' . $form['#field']['field_name'], FALSE), |
---|
3109 | '#return_value' => '1', |
---|
3110 | ); |
---|
3111 | $form['#submit'][] = 'politicas_direccionales_content_field_edit_form_submit'; |
---|
3112 | } |
---|
3113 | } |
---|
3114 | |
---|
3115 | /* |
---|
3116 | * Implementation of politicas_direccionales_agregar_estrategia_form() |
---|
3117 | */ |
---|
3118 | function politicas_direccionales_content_field_edit_form_submit($form, &$form_state) { |
---|
3119 | variable_set('ente_planificador_' . $form_state['values']['field_name'], $form_state['values']['ente_planificador']); |
---|
3120 | } |
---|
3121 | |
---|
3122 | //ESTRATEGIAS |
---|
3123 | |
---|
3124 | /* |
---|
3125 | * Implementation of politicas_direccionales_agregar_estrategia_form() |
---|
3126 | * |
---|
3127 | function politicas_direccionales_agregar_estrategia_form($form_state, $ente_planificador, $estrategia = 0) { |
---|
3128 | global $user; |
---|
3129 | $proceso = arg(5) == 'reformular' ? 'reformulacion_estrategias' : 'estrategias'; |
---|
3130 | $mi_fecha = ente_planificador_user_acceso_proceso($proceso, $ente_planificador); |
---|
3131 | $current_time = time(); |
---|
3132 | $ente_has_acceso = FALSE; |
---|
3133 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
3134 | $fecha = TRUE; |
---|
3135 | } |
---|
3136 | if (!$fecha) { |
---|
3137 | muestra_mensaje($proceso, $ente_planificador); |
---|
3138 | } |
---|
3139 | else { |
---|
3140 | if ($ente->nid == $ente_planificador->nid) { |
---|
3141 | muestra_mensaje($proceso, $ente_planificador, 0); |
---|
3142 | } |
---|
3143 | } |
---|
3144 | if ($fecha && (user_access('admin planificador') || $user->entes == $ente_planificador->nid)) { |
---|
3145 | $ente_has_acceso = TRUE; |
---|
3146 | } |
---|
3147 | $politicas_direccionales_path = drupal_get_path('module', 'politicas_direccionales'); |
---|
3148 | drupal_add_js($politicas_direccionales_path . '/js/estrategias.js'); |
---|
3149 | $estrategia_leido = new stdClass(); |
---|
3150 | $estrategia_leido->type = 'estrategia'; |
---|
3151 | $estrategia_leido->title = ''; |
---|
3152 | $estrategia_leido->body = ''; |
---|
3153 | $estrategia_leido->nid = 0; |
---|
3154 | $form = array(); |
---|
3155 | if ($estrategia) { |
---|
3156 | $estrategia_load = $estrategia; |
---|
3157 | if($estrategia_load->nid && $estrategia_load->type == 'estrategia' && $estrategia_load->field_estrategia_ente[0]['nid'] == $ente_planificador->nid && $mi_fecha[1] + 86399 > $estrategia_load->created && $mi_fecha[0] < $estrategia_load->created) { |
---|
3158 | $estrategia_leido = $estrategia_load; |
---|
3159 | $form['#titulo_pagina'] = t('Modificar la estrategia'); |
---|
3160 | } |
---|
3161 | } |
---|
3162 | if (!isset($form['#titulo_pagina'])) { |
---|
3163 | $form['#titulo_pagina'] = t('Agregar estrategia'); |
---|
3164 | } |
---|
3165 | $ente_planificador1 = $ente_planificador; |
---|
3166 | if ($ente_planificador->tipo > 1) { |
---|
3167 | $ente_has_acceso = FALSE; |
---|
3168 | if (module_exists('ente_planificador_hierarchical')) { |
---|
3169 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
3170 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
3171 | $ente_has_acceso = TRUE; |
---|
3172 | } |
---|
3173 | } |
---|
3174 | } |
---|
3175 | $macro = ente_planificador_ente_macro($ente_planificador); |
---|
3176 | if ($macro) { |
---|
3177 | $ente_has_acceso = TRUE; |
---|
3178 | $ente_planificador1 = node_load($macro); |
---|
3179 | } |
---|
3180 | } |
---|
3181 | drupal_set_title($form['#titulo_pagina']); |
---|
3182 | $form['#node'] = $estrategia_leido; |
---|
3183 | $form['#proceso'] = $proceso; |
---|
3184 | $form['#ente_planificador'] = $ente_planificador; |
---|
3185 | $form['#estrategia'] = $estrategia_leido; |
---|
3186 | $sql_query = "SELECT c.nid FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND field_politicas_seleccionada_value = 'SÃ' AND n.created >= %d AND n.created <= %d "; |
---|
3187 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador1); |
---|
3188 | $sql_variables[] = $ente_planificador1->nid; |
---|
3189 | $sql_variables[] = $mi_fecha[0]; |
---|
3190 | $sql_variables[] = $mi_fecha[1] + 86399; |
---|
3191 | $result = db_query($sql_query, $sql_variables); |
---|
3192 | $politicas = array(); |
---|
3193 | $politicas_arreglo = array(); |
---|
3194 | $vector = array(); |
---|
3195 | while($politica = db_fetch_object($result)) { |
---|
3196 | $politica_load = node_load($politica->nid); |
---|
3197 | $politicas[$politica_load->nid] = $politica_load->body; |
---|
3198 | if (is_array($politica_load->field_politicas_requerimientos) && count($politica_load->field_politicas_requerimientos)) { |
---|
3199 | $vector[$politica_load->nid] = array(); |
---|
3200 | foreach ($politica_load->field_politicas_requerimientos as $valor) { |
---|
3201 | $vector[$politica_load->nid][] = $valor['value']; |
---|
3202 | } |
---|
3203 | } |
---|
3204 | } |
---|
3205 | |
---|
3206 | $form['#politicas'] = $politicas; |
---|
3207 | drupal_add_js(array('politicas' => $form['#politicas']), 'setting'); |
---|
3208 | $form['#vector_requerimientos'] = $vector; |
---|
3209 | if (!count($politicas)) { |
---|
3210 | drupal_set_message(t('El ente @planificador aun no ha definido las PolÃticas Direccionales', array('@planificador' => check_plain($ente_planificador->title)))); |
---|
3211 | drupal_goto('planificacion/' . $ente_planificador->nid . '/politicas/seleccionar/listar'); |
---|
3212 | } |
---|
3213 | $default_values = array(); |
---|
3214 | |
---|
3215 | if (count($estrategia_load->field_estrategia_politicas_d)) { |
---|
3216 | foreach($estrategia_load->field_estrategia_politicas_d as $politica) { |
---|
3217 | $default_values[] = $politica['nid']; |
---|
3218 | } |
---|
3219 | } |
---|
3220 | $form['estrategia_politica'] = array( |
---|
3221 | '#type' => 'select', |
---|
3222 | '#default_value' => $default_values, |
---|
3223 | '#options' => $politicas, |
---|
3224 | '#multiple' => '1', |
---|
3225 | '#title' => t('PolÃtica que aborda la estrategia'), |
---|
3226 | '#required' => TRUE, |
---|
3227 | ); |
---|
3228 | $form['title'] = array( |
---|
3229 | '#type' => 'textfield', |
---|
3230 | '#title' => t('Nombre de la estrategia'), |
---|
3231 | '#required' => TRUE, |
---|
3232 | '#size' => 40, |
---|
3233 | '#default_value' => $estrategia_leido->title, |
---|
3234 | ); |
---|
3235 | $node_type = content_types('estrategia'); |
---|
3236 | $fields = $node_type['fields']; |
---|
3237 | $field_form = array(); |
---|
3238 | $arreglo = array( |
---|
3239 | 'field_estrategia_area' => 'field_estrategia_area', |
---|
3240 | 'field_estrategia_actores' => 'field_estrategia_actores', |
---|
3241 | ); |
---|
3242 | if (is_array($fields) && count($fields)) { |
---|
3243 | foreach($fields as $field_id => $field) { |
---|
3244 | if (array_key_exists($field_id, $arreglo)) { |
---|
3245 | $field_form[] = $field_id; |
---|
3246 | $fields_form[] = $field_id; |
---|
3247 | } |
---|
3248 | elseif (variable_get('politicas_direccionales_ac_di_' . $field_id, FALSE)) { |
---|
3249 | $field_form[] = $field_id; |
---|
3250 | $fields_form[] = $field_id; |
---|
3251 | } |
---|
3252 | } |
---|
3253 | } |
---|
3254 | if (is_array($field_form) && count($field_form)) { |
---|
3255 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
3256 | foreach ($field_form as $field_id) { |
---|
3257 | $field = content_fields($field_id, 'estrategia'); |
---|
3258 | $form['#field_info'][$field_id] = $field; |
---|
3259 | $form += (array) content_field_form($form, $form_state, $field); |
---|
3260 | } |
---|
3261 | } |
---|
3262 | $form['#estrategias_fields'] = $fields_form; |
---|
3263 | $form['buttons'] = array( |
---|
3264 | '#prefix' => '<div class="container-inline">', |
---|
3265 | '#suffix' => '</div>', |
---|
3266 | '#weight' => 100, |
---|
3267 | ); |
---|
3268 | $form['buttons']['submit'] = array( |
---|
3269 | '#type' => 'submit', |
---|
3270 | '#value' => t('Submit'), |
---|
3271 | '#weight' => 100, |
---|
3272 | ); |
---|
3273 | $form['buttons']['cancel'] = array( |
---|
3274 | '#type' => 'submit', |
---|
3275 | '#value' => t('Cancel'), |
---|
3276 | '#weight' => 100, |
---|
3277 | ); |
---|
3278 | $form['#after_build'] = array(); |
---|
3279 | $form['#after_build'][] = 'politicas_direccionales_skip_validation_form_after_build'; |
---|
3280 | return $form; |
---|
3281 | } |
---|
3282 | */ |
---|
3283 | |
---|
3284 | /* |
---|
3285 | * Implementation of theme_politicas_direccionales_agregar_estrategia_form() |
---|
3286 | * Tema para el formulario de agregar o editar una estrategias |
---|
3287 | */ |
---|
3288 | function theme_politicas_direccionales_agregar_estrategia_form($form) { |
---|
3289 | $output = ''; |
---|
3290 | $output .= drupal_render($form['estrategia_politica']); |
---|
3291 | if (count($form['#vector_requerimientos'])) { |
---|
3292 | $output .= '<div id ="formas-solucion"><label for="edit-formas-solucion"><b>' . t('Requerimientos') . ':</b></label>'; |
---|
3293 | foreach($form['#vector_requerimientos'] as $nid => $requerimientos) { |
---|
3294 | $output .= '<div id ="politicas-requerimientos-' . $nid . '">'. theme('item_list', $requerimientos) . '</div>'; |
---|
3295 | } |
---|
3296 | $output .= '</div>'; |
---|
3297 | } |
---|
3298 | $output .= drupal_render($form['title']); |
---|
3299 | $output .= drupal_render($form); |
---|
3300 | return $output; |
---|
3301 | } |
---|
3302 | |
---|
3303 | /* |
---|
3304 | * Implementation of politicas_direccionales_agregar_estrategia_form_validate() |
---|
3305 | */ |
---|
3306 | function politicas_direccionales_agregar_estrategia_form_validate($form, &$form_state){ |
---|
3307 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
3308 | if ($op == t('Cancel')) { |
---|
3309 | return; |
---|
3310 | } |
---|
3311 | drupal_set_title($form['#titulo_pagina']); |
---|
3312 | if (trim($form_state['values']['title']) == '') { |
---|
3313 | form_set_error('title', t('Debe agregar el nombre de la estrategia')); |
---|
3314 | } |
---|
3315 | } |
---|
3316 | |
---|
3317 | /* |
---|
3318 | * Implementation of politicas_direccionales_agregar_estrategia_form_submit() |
---|
3319 | * |
---|
3320 | function politicas_direccionales_agregar_estrategia_form_submit($form, &$form_state){ |
---|
3321 | global $user; |
---|
3322 | $ente_planificador = $form['#ente_planificador']; |
---|
3323 | if (!$form_state['redirect']) { |
---|
3324 | $form_state['redirect'] = 'planificacion/' . $ente_planificador->nid . '/politicas/estrategias/listar'; |
---|
3325 | } |
---|
3326 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
3327 | $ente_planificador = $form['#ente_planificador']; |
---|
3328 | if ($op == t('Cancel')) { |
---|
3329 | drupal_goto('planificacion/' . $ente_planificador->nid . '/politicas/estrategias/listar'); |
---|
3330 | return; |
---|
3331 | } |
---|
3332 | $estrategia = $form['#estrategia']; |
---|
3333 | module_load_include('inc', 'node', 'node.pages'); |
---|
3334 | $nuevo = FALSE; |
---|
3335 | $field_form = $form['#estrategias_fields']; |
---|
3336 | $estrategia->title = check_plain($form_state['values']['title']); |
---|
3337 | $estrategia->uid = $user->uid; |
---|
3338 | $form_values = $form_state['values']; |
---|
3339 | if (is_array($field_form) && count($field_form)) { |
---|
3340 | foreach ($field_form as $field_id) { |
---|
3341 | if (isset($form_values[$field_id]) && is_array($form_values[$field_id])) { |
---|
3342 | foreach($form_values[$field_id] as $id => $value) { |
---|
3343 | if (is_numeric($id) && isset($form_values[$field_id][$id]['_error_element'])) { |
---|
3344 | unset($form_values[$field_id][$id]['_error_element']); |
---|
3345 | } |
---|
3346 | } |
---|
3347 | $estrategia->{$field_id} = $form_values[$field_id]; |
---|
3348 | } |
---|
3349 | } |
---|
3350 | } |
---|
3351 | if (!isset($estrategia->field_estrategia_ente)) { |
---|
3352 | $estrategia->field_estrategia_ente = array(); |
---|
3353 | $estrategia->field_estrategia_ente[] = array('nid' => $form['#ente_planificador']->nid); |
---|
3354 | } |
---|
3355 | node_object_prepare($estrategia); |
---|
3356 | $estrategia->revision = 1; |
---|
3357 | $estrategia->log = $estrategia->nid ? t('Se modificó la estrategia') : t('Se agregó la estrategia'); |
---|
3358 | $estrategia->field_estrategia_politicas_d = array(); |
---|
3359 | if (count($form_values['estrategia_politica'])) { |
---|
3360 | foreach($form_values['estrategia_politica'] as $politica) { |
---|
3361 | $estrategia->field_estrategia_politicas_d[] = array('nid' => $politica); |
---|
3362 | } |
---|
3363 | } |
---|
3364 | node_save($estrategia); |
---|
3365 | $form['#estrategia'] = $estrategia; |
---|
3366 | if ($nuevo) { |
---|
3367 | drupal_set_message(t('Se ha agregado la estrategia @estrategia', array('@estrategia' => $estrategia->title))); |
---|
3368 | } |
---|
3369 | else { |
---|
3370 | drupal_set_message(t('Se ha modificado la estrategia @estrategia', array('@estrategia' => $estrategia->title))); |
---|
3371 | } |
---|
3372 | if (!$form_state['redirect']){ |
---|
3373 | $form_state['redirect'] = array( |
---|
3374 | 'planificacion/' . $ente_planificador->nid . '/politicas/estrategias/listar', |
---|
3375 | ); |
---|
3376 | } |
---|
3377 | } |
---|
3378 | */ |
---|
3379 | |
---|
3380 | /* |
---|
3381 | * Implementation of leer_estrategias_por_politica() |
---|
3382 | * Leer estrategias dada una politica |
---|
3383 | */ |
---|
3384 | function leer_estrategias_por_politica($ente_planificador, $politica){ |
---|
3385 | $estrategias = array(); |
---|
3386 | $children = FALSE; |
---|
3387 | if ($ente_planificador && $ente_planificador->nid && $politica && $politica->nid) { |
---|
3388 | if (module_exists('ente_planificador_hierarchical')) { |
---|
3389 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
3390 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
3391 | $children = TRUE; |
---|
3392 | } |
---|
3393 | } |
---|
3394 | } |
---|
3395 | if ($ente_planificador->tipo == 1 || $children) { |
---|
3396 | $resultado = db_query("SELECT n.nid, n.title, n.uid, e.field_estrategia_ente_nid FROM {node} AS n INNER JOIN {content_field_estrategia_politicas_d} AS p ON p.nid = n.nid AND p.vid = n.vid INNER JOIN {content_type_estrategia} AS e ON e.nid = n.nid AND e.vid = n.vid WHERE p.field_estrategia_politicas_d_nid = %d ORDER BY n.title", $politica->nid); |
---|
3397 | } |
---|
3398 | else { |
---|
3399 | $resultado = db_query("SELECT n.nid, n.title, n.uid, e.field_estrategia_ente_nid FROM {node} AS n INNER JOIN {content_field_estrategia_politicas_d} AS p ON p.nid = n.nid AND p.vid = n.vid INNER JOIN {content_type_estrategia} AS e ON e.nid = n.nid AND e.vid = n.vid WHERE p.field_estrategia_politicas_d_nid = %d AND e.field_estrategia_ente_nid = %d ORDER BY n.title", $politica->nid, $ente_planificador->nid); |
---|
3400 | } |
---|
3401 | while($estrategia = db_fetch_object($resultado)) { |
---|
3402 | $estrategias[$estrategia->nid] = array( |
---|
3403 | 'title' => $estrategia->title, |
---|
3404 | 'ente' => $estrategia->field_estrategia_ente_nid, |
---|
3405 | 'uid' => $estrategia->uid, |
---|
3406 | ); |
---|
3407 | } |
---|
3408 | } |
---|
3409 | return $estrategias; |
---|
3410 | } |
---|
3411 | |
---|
3412 | /* |
---|
3413 | * Implementation of politicas_direccionales_estrategias_posibles_listar() |
---|
3414 | * Listar posibles estrategias |
---|
3415 | * |
---|
3416 | function politicas_direccionales_estrategias_posibles_listar($ente_planificador) { |
---|
3417 | drupal_set_title(t('Consultar estrategias')); |
---|
3418 | global $user; |
---|
3419 | $ente = usuario_tiene_ente($user->uid); |
---|
3420 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
3421 | $current_time = time(); |
---|
3422 | $ente_has_acceso = FALSE; |
---|
3423 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
3424 | $fecha = TRUE; |
---|
3425 | } |
---|
3426 | if (!$fecha) { |
---|
3427 | muestra_mensaje("posibles", $ente_planificador); |
---|
3428 | } |
---|
3429 | else { |
---|
3430 | if ($user->entes == $ente_planificador->nid) { |
---|
3431 | muestra_mensaje("posibles", $ente_planificador, 0); |
---|
3432 | } |
---|
3433 | } |
---|
3434 | if ($fecha && (user_access('admin planificador') || $fecha && $user->entes == $ente_planificador->nid)) { |
---|
3435 | $ente_has_acceso = TRUE; |
---|
3436 | } |
---|
3437 | $ente_planificador_micro = $ente_planificador; |
---|
3438 | if ($ente_planificador->tipo > 1) { |
---|
3439 | $ente_has_acceso = FALSE; |
---|
3440 | if ($ente_planificador && $ente_planificador->nid && $politica && $politica->nid) { |
---|
3441 | if (module_exists('ente_planificador_hierarchical')) { |
---|
3442 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
3443 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
3444 | $ente_has_acceso = TRUE; |
---|
3445 | } |
---|
3446 | } |
---|
3447 | } |
---|
3448 | } |
---|
3449 | $macro = ente_planificador_ente_macro($ente_planificador); |
---|
3450 | if ($macro) { |
---|
3451 | $ente_has_acceso = TRUE; |
---|
3452 | $ente_planificador = node_load($macro); |
---|
3453 | } |
---|
3454 | } |
---|
3455 | $step = 10; |
---|
3456 | $headers_table = array(); |
---|
3457 | $headers_table[] = array( |
---|
3458 | 'data' => t('Nombre de la polÃtica Direccional'), |
---|
3459 | 'sort' => 'asc', |
---|
3460 | ); |
---|
3461 | $headers_table[] = array( |
---|
3462 | 'data' => t('estrategias'), |
---|
3463 | ); |
---|
3464 | $sqlcount = "select count(c.nid) FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c. field_politicas_ente_nid = %d AND c.field_politicas_seleccionada_value = 'SÃ' AND n.created >= %d AND n.created <= %d"; |
---|
3465 | $sql_query = "SELECT c.nid, n.title FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c. field_politicas_ente_nid = %d AND field_politicas_seleccionada_value = 'SÃ' AND n.created >= %d AND n.created <= %d "; |
---|
3466 | $sql_query.= tablesort_sql($headers_table); |
---|
3467 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
3468 | $sql_variables = array(); |
---|
3469 | $sql_variables[] = $ente_planificador->nid; |
---|
3470 | $sql_variables[] = $mi_fecha[0]; |
---|
3471 | $sql_variables[] = $mi_fecha[1] + 86399; |
---|
3472 | $result = pager_query($sql_query, $step, 0, $sqlcount, $sql_variables); |
---|
3473 | while($politica = db_fetch_object($result)) { |
---|
3474 | $politica_load = node_load($politica->nid); |
---|
3475 | $row = array(); |
---|
3476 | $row[] = array('data' => $politica_load->body, ); |
---|
3477 | $estrategias = leer_estrategias_por_politica($ente_planificador_micro, $politica); |
---|
3478 | $estrategias_f = array(); |
---|
3479 | if (count($estrategias)) { |
---|
3480 | foreach($estrategias as $id => $estrategia) { |
---|
3481 | if ($ente_has_acceso && $estrategia['ente'] == $ente_planificador_micro->nid && $user->uid == $estrategia['uid']) { |
---|
3482 | $links = array(); |
---|
3483 | $links[] = l(t('Modificar'), 'planificacion/' . $ente_planificador_micro->nid . '/politicas/estrategias/' . $id . '/editar'); |
---|
3484 | $links[] = l(t('Eliminar'), 'planificacion/' . $ente_planificador_micro->nid . '/politicas/estrategias/' . $id . '/remove'); |
---|
3485 | $estrategias[$id]['title'] = $estrategia['title'] . ' ' . theme('item_list', $links); |
---|
3486 | } |
---|
3487 | $estrategias_f[] = $estrategias[$id]['title']; |
---|
3488 | } |
---|
3489 | } |
---|
3490 | $row[] = array('data' => theme('item_list', $estrategias_f), ); |
---|
3491 | $rows[] = $row; |
---|
3492 | } |
---|
3493 | if (!count($rows)) { |
---|
3494 | $row = array(); |
---|
3495 | $row[] = array('data' => t('No se encontraron PolÃticas Direccionales para este ente'), 'colspan' => '3'); |
---|
3496 | $rows[] = $row; |
---|
3497 | } |
---|
3498 | $output = theme('table', $headers_table, $rows); |
---|
3499 | $output .= theme('pager', NULL); |
---|
3500 | return $output; |
---|
3501 | } |
---|
3502 | */ |
---|
3503 | |
---|
3504 | /** |
---|
3505 | * Implementation of politicas_direccionales_remove_estrategia_posible_politica_form() |
---|
3506 | * Eliminar estrategia |
---|
3507 | * |
---|
3508 | function politicas_direccionales_remove_estrategia_posible_politica_form($form_state, $ente = 0, $estrategia = 0) { |
---|
3509 | $form = array(); |
---|
3510 | $form['#ente'] = $ente; |
---|
3511 | $form['#estrategia'] = $estrategia; |
---|
3512 | $message = t('Esta seguro de eliminar la estrategia "@nombre"?', array('@nombre' => $form['#estrategia']->title)); |
---|
3513 | $caption = ''; |
---|
3514 | |
---|
3515 | $return_path = $_REQUEST['destination'] ? $_REQUEST['destination'] : 'planificacion/' . $form['#ente']->nid . '/politicas/estrategias/listar'; |
---|
3516 | return confirm_form($form, $message, $return_path, $caption, t('Eliminar')); |
---|
3517 | } |
---|
3518 | */ |
---|
3519 | |
---|
3520 | /** |
---|
3521 | * Implementation of politicas_direccionales_remove_estrategia_posible_politica_form_submit(). |
---|
3522 | * Process funcion delete estrategia. |
---|
3523 | * |
---|
3524 | function politicas_direccionales_remove_estrategia_posible_politica_form_submit($form, &$form_state) { |
---|
3525 | global $user; |
---|
3526 | $estrategia = $form['#estrategia']; |
---|
3527 | $titulo = $form['#estrategia']->title; |
---|
3528 | |
---|
3529 | node_delete($estrategia->nid); |
---|
3530 | $texto = t('Se eliminó la estrategia "@estrategia"', array('@estrategia' => $titulo)); |
---|
3531 | drupal_set_message($texto); |
---|
3532 | if (!$_REQUEST['destination']) { |
---|
3533 | // add redirect |
---|
3534 | $form_state['redirect'] = 'planificacion/' . $form['#ente']->nid . '/politicas/estrategias/listar'; |
---|
3535 | } |
---|
3536 | } |
---|
3537 | */ |
---|
3538 | |
---|
3539 | /* |
---|
3540 | * Implementation of politicas_direccionales_estrategias_posibles_identificar() |
---|
3541 | * Identificar posible articulación |
---|
3542 | * |
---|
3543 | function politicas_direccionales_estrategias_posibles_identificar($ente_planificador, $articular = 0, $nid = 0) { |
---|
3544 | drupal_set_title(t('Consultar estrategias')); |
---|
3545 | global $user; |
---|
3546 | $ente = usuario_tiene_ente($user->uid); |
---|
3547 | $mi_fecha = ente_planificador_user_acceso_proceso("articulacion_estrategias", $ente_planificador); |
---|
3548 | $current_time = time(); |
---|
3549 | $ente_has_acceso = FALSE; |
---|
3550 | $fecha = FALSE; |
---|
3551 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
3552 | $fecha = TRUE; |
---|
3553 | } |
---|
3554 | if (!$fecha) { |
---|
3555 | muestra_mensaje("articulacion_estrategias", $ente_planificador); |
---|
3556 | } |
---|
3557 | else { |
---|
3558 | if ($user->entes == $ente_planificador->nid) { |
---|
3559 | muestra_mensaje("articulacion_estrategias", $ente_planificador, 0); |
---|
3560 | } |
---|
3561 | } |
---|
3562 | if ($fecha && (user_access('admin planificador') || $fecha && $user->entes == $ente_planificador->nid)) { |
---|
3563 | $ente_has_acceso = TRUE; |
---|
3564 | } |
---|
3565 | $ente_planificador_micro = $ente_planificador; |
---|
3566 | if ($ente_planificador->tipo > 1) { |
---|
3567 | $ente_has_acceso = FALSE; |
---|
3568 | if ($ente_planificador && $ente_planificador->nid && $politica && $politica->nid) { |
---|
3569 | if (module_exists('ente_planificador_hierarchical')) { |
---|
3570 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
3571 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
3572 | $ente_has_acceso = TRUE; |
---|
3573 | } |
---|
3574 | } |
---|
3575 | } |
---|
3576 | } |
---|
3577 | $macro = ente_planificador_ente_macro($ente_planificador); |
---|
3578 | if ($macro) { |
---|
3579 | $ente_has_acceso = TRUE; |
---|
3580 | $ente_planificador = node_load($macro); |
---|
3581 | } |
---|
3582 | } |
---|
3583 | $step = 1; |
---|
3584 | $headers_table = array(); |
---|
3585 | $headers_table[] = array( |
---|
3586 | 'data' => t('estrategia'), |
---|
3587 | 'sort' => 'asc', |
---|
3588 | 'field' => 'n.title' |
---|
3589 | ); |
---|
3590 | $headers_table[] = array( |
---|
3591 | 'data' => t('Posible Articulación'), |
---|
3592 | ); |
---|
3593 | $column = 2; |
---|
3594 | if ($articular) { |
---|
3595 | $headers_table[] = array( |
---|
3596 | 'data' => t('estrategia a articular'), |
---|
3597 | ); |
---|
3598 | $column++; |
---|
3599 | } |
---|
3600 | $sqlcount = "select count(c.nid) FROM {content_type_estrategia} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_estrategia_ente_nid = %d AND n.created >= %d AND n.created <= %d"; |
---|
3601 | $sql_query = "SELECT c.nid, n.title FROM {content_type_estrategia} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_estrategia_ente_nid = %d AND n.created >= %d AND n.created <= %d "; |
---|
3602 | $sql_query.= tablesort_sql($headers_table); |
---|
3603 | $mi_fecha = ente_planificador_user_acceso_proceso("estrategias", $ente_planificador_micro); |
---|
3604 | $sql_variables = array(); |
---|
3605 | $sql_variables[] = $ente_planificador_micro->nid; |
---|
3606 | $sql_variables[] = $mi_fecha[0]; |
---|
3607 | $sql_variables[] = $mi_fecha[1] + 86399; |
---|
3608 | $result = pager_query($sql_query, $step, 0, $sqlcount, $sql_variables); |
---|
3609 | $estrategias_f = array(); |
---|
3610 | $articular_found = FALSE; |
---|
3611 | while($estrategia = db_fetch_object($result)) { |
---|
3612 | $estrategia_load = node_load($estrategia->nid); |
---|
3613 | $row = array(); |
---|
3614 | $row[] = array('data' => $estrategia_load->title, ); |
---|
3615 | $articulacion = array(); |
---|
3616 | if ($estrategia_load->field_estrategia_politicas_d[0]['nid']) { |
---|
3617 | foreach($estrategia_load->field_estrategia_politicas_d as $value) { |
---|
3618 | if (!isset($estrategias_f[$value['nid']])) { |
---|
3619 | $estrategias = leer_todas_estrategias_por_politica($ente_planificador_micro, $value['nid']); |
---|
3620 | $estrategias_f[$value['nid']] = $estrategias['neighbour']; |
---|
3621 | } |
---|
3622 | if (count($estrategias_f[$value['nid']])) { |
---|
3623 | foreach($estrategias_f[$value['nid']] as $id => $valor) { |
---|
3624 | if ($ente_has_acceso) { |
---|
3625 | if ($articular && $id == $articular) { |
---|
3626 | $articular_found = TRUE; |
---|
3627 | } |
---|
3628 | $attributes = array(); |
---|
3629 | if (isset($_GET['page'])) { |
---|
3630 | $attributes['query'] = 'page=' . $_GET['page']; |
---|
3631 | } |
---|
3632 | $articulacion[] = $valor['title'] . ' (' . l(t('Registrar solicitud de posible articulación'), 'planificacion/' . $ente_planificador_micro->nid .'/politicas/estrategias/identificar/' . $id . '/' . $estrategia_load->nid, $attributes) . ')'; |
---|
3633 | } |
---|
3634 | else { |
---|
3635 | $articulacion[] = $valor['title']; |
---|
3636 | } |
---|
3637 | } |
---|
3638 | } |
---|
3639 | } |
---|
3640 | } |
---|
3641 | if (count($articulacion)) { |
---|
3642 | $row[] = array('data' => theme('item_list', $articulacion), ); |
---|
3643 | } |
---|
3644 | else { |
---|
3645 | $row[] = array('data' => t('No existen estrategias que articular'), ); |
---|
3646 | } |
---|
3647 | if ($articular_found && $nid == $estrategia_load->nid) { |
---|
3648 | $articular_load = node_load($articular); |
---|
3649 | $output1 = node_view($articular_load); |
---|
3650 | $output1 .= drupal_get_form('politicas_direccionales_agregar_articulacion_form', $ente_planificador_micro, $estrategia_load, $articular_load); |
---|
3651 | $row[] = array('data' => $output1, ); |
---|
3652 | } |
---|
3653 | elseif($articular && is_numeric($articular)) { |
---|
3654 | $row[] = array('data' => '', ); |
---|
3655 | } |
---|
3656 | $rows[] = $row; |
---|
3657 | } |
---|
3658 | if (!count($rows)) { |
---|
3659 | $row = array(); |
---|
3660 | $row[] = array('data' => t('No se encontraron estrategias para este ente'), 'colspan' => $column); |
---|
3661 | $rows[] = $row; |
---|
3662 | } |
---|
3663 | $output = theme('table', $headers_table, $rows); |
---|
3664 | $output .= theme('pager', NULL); |
---|
3665 | return $output; |
---|
3666 | } |
---|
3667 | */ |
---|
3668 | |
---|
3669 | /* |
---|
3670 | * Implementation of leer_todas_estrategias_por_politica() |
---|
3671 | * Leer estrategias por politicas |
---|
3672 | */ |
---|
3673 | function leer_todas_estrategias_por_politica($ente_planificador, $politica){ |
---|
3674 | $estrategias = array(); |
---|
3675 | $estrategias['all'] = array(); |
---|
3676 | $estrategias['own'] = array(); |
---|
3677 | $estrategias['neighbour'] = array(); |
---|
3678 | if ($ente_planificador && $ente_planificador->nid && $politica && is_numeric($politica)) { |
---|
3679 | $resultado = db_query("SELECT n.nid, n.title, e.field_estrategia_ente_nid FROM {node} AS n INNER JOIN {content_field_estrategia_politicas_d} AS p ON p.nid = n.nid AND p.vid = n.vid INNER JOIN {content_type_estrategia} AS e ON e.nid = n.nid AND e.vid = n.vid WHERE p.field_estrategia_politicas_d_nid = %d ORDER BY n.title", $politica); |
---|
3680 | while($estrategia = db_fetch_object($resultado)) { |
---|
3681 | if ($estrategia->field_estrategia_ente_nid == $ente_planificador->nid) { |
---|
3682 | $estrategias['own'][$estrategia->nid] = array( |
---|
3683 | 'title' => $estrategia->title, |
---|
3684 | 'ente' => $estrategia->field_estrategia_ente_nid, |
---|
3685 | ); |
---|
3686 | } |
---|
3687 | else { |
---|
3688 | $estrategias['neighbour'][$estrategia->nid] = array( |
---|
3689 | 'title' => $estrategia->title, |
---|
3690 | 'ente' => $estrategia->field_estrategia_ente_nid, |
---|
3691 | ); |
---|
3692 | } |
---|
3693 | $estrategias['all'][$estrategia->nid] = array( |
---|
3694 | 'title' => $estrategia->title, |
---|
3695 | 'ente' => $estrategia->field_estrategia_ente_nid, |
---|
3696 | ); |
---|
3697 | } |
---|
3698 | } |
---|
3699 | return $estrategias; |
---|
3700 | } |
---|
3701 | |
---|
3702 | /* |
---|
3703 | * Implementation of politicas_direccionales_agregar_articulacion_form() |
---|
3704 | * Formulario para agregar articulacion de actores en base a estrategias |
---|
3705 | * |
---|
3706 | function politicas_direccionales_agregar_articulacion_form($form_state, $ente_planificador = 0, $estrategia = 0, $estrategia_art = 0) { |
---|
3707 | $form = array(); |
---|
3708 | $form['#ente_plan'] = $ente_planificador; |
---|
3709 | $form['#estrategia'] = $estrategia; |
---|
3710 | $form['#estrategia_art'] = $estrategia_art; |
---|
3711 | $form['#estrategia_page'] = isset($_GET['page']) ? $_GET['page'] : 0; |
---|
3712 | $sql_query = "SELECT * FROM {politicas_direccionales_estrategias} WHERE estrategia = %d AND estrategia_art = %d"; |
---|
3713 | $articulacion_load = db_fetch_object(db_query($sql_query, $estrategia->nid, $estrategia_art->nid)); |
---|
3714 | $form['#articulacion_load'] = $articulacion_load; |
---|
3715 | $form['mensaje'] = array( |
---|
3716 | '#type' => 'textarea', |
---|
3717 | '#title' => t('Solicitar Articulación'), |
---|
3718 | '#default_value' => $articulacion_load ? $articulacion_load->mensaje : '', |
---|
3719 | ); |
---|
3720 | $form['buttons'] = array( |
---|
3721 | '#prefix' => '<div class="container-inline">', |
---|
3722 | '#suffix' => '</div>', |
---|
3723 | '#weight' => 100, |
---|
3724 | ); |
---|
3725 | $form['buttons']['submit'] = array( |
---|
3726 | '#type' => 'submit', |
---|
3727 | '#value' => t('Submit'), |
---|
3728 | '#weight' => 100, |
---|
3729 | ); |
---|
3730 | if ($articulacion_load) { |
---|
3731 | $form['buttons']['remove'] = array( |
---|
3732 | '#type' => 'submit', |
---|
3733 | '#value' => t('Remove'), |
---|
3734 | '#weight' => 101, |
---|
3735 | ); |
---|
3736 | } |
---|
3737 | $form['buttons']['cancel'] = array( |
---|
3738 | '#type' => 'submit', |
---|
3739 | '#value' => t('Cancel'), |
---|
3740 | '#weight' => 102, |
---|
3741 | ); |
---|
3742 | return $form; |
---|
3743 | } |
---|
3744 | */ |
---|
3745 | |
---|
3746 | /** |
---|
3747 | * Implementation of politicas_direccionales_agregar_articulacion_form_submit(). |
---|
3748 | * Process funcion agregar articulacion. |
---|
3749 | * |
---|
3750 | function politicas_direccionales_agregar_articulacion_form_submit($form, &$form_state) { |
---|
3751 | global $user; |
---|
3752 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
3753 | $ente_planificador = $form['#ente_planificador']; |
---|
3754 | if ($op == t('Cancel')) { |
---|
3755 | drupal_goto('planificacion/' . $form['#ente_plan']->nid . '/politicas/estrategias/identificar/' . $form['#estrategia_art']->nid . '/' . $form['#estrategia']->nid); |
---|
3756 | return; |
---|
3757 | } |
---|
3758 | db_query("DELETE FROM {politicas_direccionales_estrategias} WHERE estrategia = %d AND estrategia_art = %d", $form['#estrategia']->nid, $form['#estrategia_art']->nid); |
---|
3759 | $mensaje = t('Se eliminó la articulación entre la estrategia "@estrategia" y "@estrate_art"', array('@estrategia' => $form['#estrategia']->title, '@estrate_art' => $form['#estrategia_art']->title)); |
---|
3760 | $ente = $form['#ente_plan']->nid; |
---|
3761 | if ($op == t('Submit')) { |
---|
3762 | db_query("INSERT into {politicas_direccionales_estrategias} (ente, estrategia, ente_art, estrategia_art, mensaje, creacion) values (%d, %d, %d, %d, '%s', %d)", $form['#ente_plan']->nid, $form['#estrategia']->nid, $form['#estrategia_art']->field_estrategia_ente[0]['nid'], $form['#estrategia_art']->nid, check_plain($form_state['values']['mensaje']), time()); |
---|
3763 | $mensaje = t('Se agregó la articulación entre la estrategia "@estrategia" y "@estrate_art"', array('@estrategia' => $form['#estrategia']->title, '@estrate_art' => $form['#estrategia_art']->title)); |
---|
3764 | } |
---|
3765 | drupal_set_message($mensaje); |
---|
3766 | if (!$form_state['redirect']){ |
---|
3767 | $query = array(); |
---|
3768 | if (array_key_exists('page', $_GET) && $_GET['page']) { |
---|
3769 | $query['page'] = $_GET['page']; |
---|
3770 | } |
---|
3771 | $form_state['redirect'] = array( |
---|
3772 | 'planificacion/' . $ente . '/politicas/estrategias/identificar/' . $form['#estrategia_art']->nid . '/' . $form['#estrategia']->nid, |
---|
3773 | $query, |
---|
3774 | ); |
---|
3775 | } |
---|
3776 | } |
---|
3777 | */ |
---|
3778 | |
---|
3779 | /** |
---|
3780 | * Implementation of _politicas_direccionales_articulacion_estrategia(). |
---|
3781 | * Obtener las articulaciones realizadas. |
---|
3782 | * |
---|
3783 | function _politicas_direccionales_articulacion_estrategia($estrategia, $fecha){ |
---|
3784 | $articulaciones = array(); |
---|
3785 | if ($estrategia && $estrategia->nid && $estrategia->type == 'estrategia' && is_array($fecha) && count($fecha)) { |
---|
3786 | $resultado = db_query("SELECT e1.estrategia, e1.ente, n1.title AS estra_titulo, n1.nid AS estra_nid, n2.title AS ente_titulo, e1.mensaje FROM {politicas_direccionales_estrategias} AS e1 INNER JOIN {node} as n1 ON n1.nid = e1.estrategia INNER JOIN {node} AS n2 ON n2.nid = e1.ente WHERE e1.estrategia_art = %d AND creacion >= %d AND creacion <= %d", $estrategia->nid, $fecha[0], $fecha[1]); |
---|
3787 | while($articulacion = db_fetch_object($resultado)) { |
---|
3788 | $articulaciones[$articulacion->estra_nid] = $articulacion; |
---|
3789 | } |
---|
3790 | } |
---|
3791 | return $articulaciones; |
---|
3792 | } |
---|
3793 | */ |
---|
3794 | |
---|
3795 | /* |
---|
3796 | * Implementation of politicas_direccionales_estrategias_consultar_articulaciones() |
---|
3797 | * Consultar artioclaciones |
---|
3798 | * |
---|
3799 | function politicas_direccionales_estrategias_consultar_articulaciones($ente_planificador) { |
---|
3800 | drupal_set_title(t('Consultar Articulación')); |
---|
3801 | global $user; |
---|
3802 | $ente = usuario_tiene_ente($user->uid); |
---|
3803 | $mi_fecha = ente_planificador_user_acceso_proceso("articulacion_estrategias", $ente_planificador); |
---|
3804 | $current_time = time(); |
---|
3805 | $ente_has_acceso = FALSE; |
---|
3806 | $fecha = FALSE; |
---|
3807 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
3808 | $fecha = TRUE; |
---|
3809 | } |
---|
3810 | if (!$fecha) { |
---|
3811 | muestra_mensaje("articulacion_estrategias", $ente_planificador); |
---|
3812 | } |
---|
3813 | else { |
---|
3814 | if ($user->entes == $ente_planificador->nid) { |
---|
3815 | muestra_mensaje("articulacion_estrategias", $ente_planificador, 0); |
---|
3816 | } |
---|
3817 | } |
---|
3818 | if ($fecha && (user_access('admin planificador') || $fecha && $user->entes == $ente_planificador->nid)) { |
---|
3819 | $ente_has_acceso = TRUE; |
---|
3820 | } |
---|
3821 | $ente_planificador_micro = $ente_planificador; |
---|
3822 | if ($ente_planificador->tipo > 1) { |
---|
3823 | $ente_has_acceso = FALSE; |
---|
3824 | if ($ente_planificador && $ente_planificador->nid && $politica && $politica->nid) { |
---|
3825 | if (module_exists('ente_planificador_hierarchical')) { |
---|
3826 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
3827 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
3828 | $ente_has_acceso = TRUE; |
---|
3829 | } |
---|
3830 | } |
---|
3831 | } |
---|
3832 | } |
---|
3833 | $macro = ente_planificador_ente_macro($ente_planificador); |
---|
3834 | if ($macro) { |
---|
3835 | $ente_has_acceso = TRUE; |
---|
3836 | $ente_planificador = node_load($macro); |
---|
3837 | } |
---|
3838 | } |
---|
3839 | $step = 10; |
---|
3840 | $headers_table = array(); |
---|
3841 | $headers_table[] = array( |
---|
3842 | 'data' => t('estrategia'), |
---|
3843 | 'sort' => 'asc', |
---|
3844 | 'field' => 'n.title' |
---|
3845 | ); |
---|
3846 | $headers_table[] = array( |
---|
3847 | 'data' => t('Posible Articulación'), |
---|
3848 | ); |
---|
3849 | $column = 2; |
---|
3850 | $sqlcount = "select count(c.nid) FROM {content_type_estrategia} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_estrategia_ente_nid = %d AND n.created >= %d AND n.created <= %d"; |
---|
3851 | $sql_query = "SELECT c.nid, n.title, n.type FROM {content_type_estrategia} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_estrategia_ente_nid = %d AND n.created >= %d AND n.created <= %d "; |
---|
3852 | $sql_query.= tablesort_sql($headers_table); |
---|
3853 | $mi_fecha1 = ente_planificador_user_acceso_proceso("estrategias", $ente_planificador_micro); |
---|
3854 | $sql_variables = array(); |
---|
3855 | $sql_variables[] = $ente_planificador_micro->nid; |
---|
3856 | $sql_variables[] = $mi_fecha1[0]; |
---|
3857 | $sql_variables[] = $mi_fecha1[1] + 86399; |
---|
3858 | $result = pager_query($sql_query, $step, 0, $sqlcount, $sql_variables); |
---|
3859 | while($estrategia = db_fetch_object($result)) { |
---|
3860 | $estrategia_load = node_load($estrategia->nid); |
---|
3861 | $row = array(); |
---|
3862 | $row[] = array('data' => $estrategia_load->title, ); |
---|
3863 | $mi_fecha[1] += 86399; |
---|
3864 | $articulacion = _politicas_direccionales_articulacion_estrategia($estrategia, $mi_fecha); |
---|
3865 | $articulaciones = array(); |
---|
3866 | if (count($articulacion)){ |
---|
3867 | foreach($articulacion as $arti) { |
---|
3868 | $articulaciones[] = theme('politicas_direccionales_ver_articulacion', $arti); |
---|
3869 | } |
---|
3870 | } |
---|
3871 | if (count($articulaciones)) { |
---|
3872 | $row[] = array('data' => theme('item_list', $articulaciones), ); |
---|
3873 | } |
---|
3874 | else { |
---|
3875 | $row[] = array('data' => t('No existe articulación para esta estrategia.'), ); |
---|
3876 | } |
---|
3877 | $rows[] = $row; |
---|
3878 | } |
---|
3879 | if (!count($rows)) { |
---|
3880 | $row = array(); |
---|
3881 | $row[] = array('data' => t('No se encontraron estrategias para este ente'), 'colspan' => $column); |
---|
3882 | $rows[] = $row; |
---|
3883 | } |
---|
3884 | $output = theme('table', $headers_table, $rows); |
---|
3885 | $output .= theme('pager', NULL); |
---|
3886 | return $output; |
---|
3887 | } |
---|
3888 | */ |
---|
3889 | |
---|
3890 | /* |
---|
3891 | * Implementation of politicas_direccionales_estrategias_consultar_articulaciones_actores_micro() |
---|
3892 | * Identificar posible articulación |
---|
3893 | * |
---|
3894 | function politicas_direccionales_estrategias_consultar_articulaciones_actores_micro($ente_planificador, $articular = 0, $nid = 0) { |
---|
3895 | drupal_set_title(t('Consultar posibles articulaciones entre actores micro')); |
---|
3896 | global $user; |
---|
3897 | $ente = usuario_tiene_ente($user->uid); |
---|
3898 | $mi_fecha = ente_planificador_user_acceso_proceso("articulacion_estrategias", $ente_planificador); |
---|
3899 | $current_time = time(); |
---|
3900 | $ente_has_acceso = FALSE; |
---|
3901 | $fecha = FALSE; |
---|
3902 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
3903 | $fecha = TRUE; |
---|
3904 | } |
---|
3905 | if (!$fecha) { |
---|
3906 | muestra_mensaje("articulacion_estrategias", $ente_planificador); |
---|
3907 | } |
---|
3908 | else { |
---|
3909 | if ($user->entes == $ente_planificador->nid) { |
---|
3910 | muestra_mensaje("articulacion_estrategias", $ente_planificador, 0); |
---|
3911 | } |
---|
3912 | } |
---|
3913 | if ($fecha && (user_access('admin planificador') || $fecha && $user->entes == $ente_planificador->nid)) { |
---|
3914 | $ente_has_acceso = TRUE; |
---|
3915 | } |
---|
3916 | $ente_planificador_micro = $ente_planificador; |
---|
3917 | if ($ente_planificador->tipo > 1) { |
---|
3918 | $ente_has_acceso = FALSE; |
---|
3919 | if ($ente_planificador && $ente_planificador->nid && $politica && $politica->nid) { |
---|
3920 | if (module_exists('ente_planificador_hierarchical')) { |
---|
3921 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
3922 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
3923 | $ente_has_acceso = TRUE; |
---|
3924 | } |
---|
3925 | } |
---|
3926 | } |
---|
3927 | } |
---|
3928 | $macro = ente_planificador_ente_macro($ente_planificador); |
---|
3929 | if ($macro) { |
---|
3930 | $ente_has_acceso = TRUE; |
---|
3931 | $ente_planificador = node_load($macro); |
---|
3932 | } |
---|
3933 | } |
---|
3934 | $step = 10; |
---|
3935 | $headers_table = array(); |
---|
3936 | $headers_table[] = array( |
---|
3937 | 'data' => t('Ente Planificador'), |
---|
3938 | 'sort' => 'asc', |
---|
3939 | 'field' => 'e1.title' |
---|
3940 | ); |
---|
3941 | $headers_table[] = array( |
---|
3942 | 'data' => t('estrategia'), |
---|
3943 | 'field' => 'es2.title' |
---|
3944 | ); |
---|
3945 | $headers_table[] = array( |
---|
3946 | 'data' => t('Ente Articulador'), |
---|
3947 | 'field' => 'ea.title' |
---|
3948 | ); |
---|
3949 | $headers_table[] = array( |
---|
3950 | 'data' => t('estrategia Articuladora'), |
---|
3951 | 'field' => 'es1.title' |
---|
3952 | ); |
---|
3953 | $headers_table[] = array( |
---|
3954 | 'data' => t('Mensaje'), |
---|
3955 | ); |
---|
3956 | $sqlcount = "select count(a.ente) FROM {politicas_direccionales_estrategias} AS a INNER JOIN {node} AS ea ON ea.nid = a.ente INNER JOIN {node} AS e1 ON e1.nid = a.ente_art INNER JOIN {node} AS es1 ON es1.nid = a.estrategia INNER JOIN {node} AS es2 ON es2.nid = a.estrategia_art AND a.creacion >= %d AND a.creacion <= %d"; |
---|
3957 | $sql_query = "SELECT ea.title AS ente_articular, e1.title AS ente, es1.title AS estrategia_art, es2.title AS estrategia, a.mensaje FROM {politicas_direccionales_estrategias} AS a INNER JOIN {node} AS ea ON ea.nid = a.ente INNER JOIN {node} AS e1 ON e1.nid = a.ente_art INNER JOIN {node} AS es1 ON es1.nid = a.estrategia INNER JOIN {node} AS es2 ON es2.nid = a.estrategia_art AND a.creacion >= %d AND a.creacion <= %d"; |
---|
3958 | $sql_query.= tablesort_sql($headers_table); |
---|
3959 | $sql_variables = array(); |
---|
3960 | $sql_variables[] = $mi_fecha[0]; |
---|
3961 | $sql_variables[] = $mi_fecha[1] + 86399; |
---|
3962 | $result = pager_query($sql_query, $step, 0, $sqlcount, $sql_variables); |
---|
3963 | while($estrategia = db_fetch_object($result)) { |
---|
3964 | $row = array(); |
---|
3965 | $row[] = array('data' => $estrategia->ente, ); |
---|
3966 | $row[] = array('data' => $estrategia->estrategia, ); |
---|
3967 | $row[] = array('data' => $estrategia->ente_articular, ); |
---|
3968 | $row[] = array('data' => $estrategia->estrategia_art, ); |
---|
3969 | $row[] = array('data' => $estrategia->mensaje, ); |
---|
3970 | $rows[] = $row; |
---|
3971 | } |
---|
3972 | if (!count($rows)) { |
---|
3973 | $row = array(); |
---|
3974 | $row[] = array('data' => t('No se encontraron estrategias ha articular'), 'colspan' => 5); |
---|
3975 | $rows[] = $row; |
---|
3976 | } |
---|
3977 | $output = theme('table', $headers_table, $rows); |
---|
3978 | $output .= theme('pager', NULL); |
---|
3979 | return $output; |
---|
3980 | } |
---|
3981 | */ |
---|
3982 | |
---|
3983 | /* |
---|
3984 | * Implementation of politicas_direccionales_estrategias_posibles_listar_reformular() |
---|
3985 | * Listar posibles estrategias para reformular |
---|
3986 | * |
---|
3987 | function politicas_direccionales_estrategias_posibles_listar_reformular($ente_planificador) { |
---|
3988 | drupal_set_title(t('Consultar estrategias')); |
---|
3989 | global $user; |
---|
3990 | $ente = usuario_tiene_ente($user->uid); |
---|
3991 | $mi_fecha = ente_planificador_user_acceso_proceso('reformulacion_estrategias', $ente_planificador); |
---|
3992 | $current_time = time(); |
---|
3993 | $ente_has_acceso = FALSE; |
---|
3994 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
3995 | $fecha = TRUE; |
---|
3996 | } |
---|
3997 | if (!$fecha) { |
---|
3998 | muestra_mensaje('reformulacion_estrategias', $ente_planificador); |
---|
3999 | } |
---|
4000 | else { |
---|
4001 | if ($user->entes == $ente_planificador->nid) { |
---|
4002 | muestra_mensaje('reformulacion_estrategias', $ente_planificador, 0); |
---|
4003 | } |
---|
4004 | } |
---|
4005 | if ($fecha && (user_access('admin planificador') || $fecha && $user->entes == $ente_planificador->nid)) { |
---|
4006 | $ente_has_acceso = TRUE; |
---|
4007 | } |
---|
4008 | $ente_planificador_micro = $ente_planificador; |
---|
4009 | if ($ente_planificador->tipo > 1) { |
---|
4010 | $ente_has_acceso = FALSE; |
---|
4011 | if ($ente_planificador && $ente_planificador->nid && $politica && $politica->nid) { |
---|
4012 | if (module_exists('ente_planificador_hierarchical')) { |
---|
4013 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
4014 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
4015 | $ente_has_acceso = TRUE; |
---|
4016 | } |
---|
4017 | } |
---|
4018 | } |
---|
4019 | } |
---|
4020 | $macro = ente_planificador_ente_macro($ente_planificador); |
---|
4021 | if ($macro) { |
---|
4022 | $ente_has_acceso = TRUE; |
---|
4023 | $ente_planificador = node_load($macro); |
---|
4024 | } |
---|
4025 | } |
---|
4026 | $step = 10; |
---|
4027 | $headers_table = array(); |
---|
4028 | $headers_table[] = array( |
---|
4029 | 'data' => t('Nombre de la polÃtica Direccional'), |
---|
4030 | 'sort' => 'asc', |
---|
4031 | ); |
---|
4032 | $headers_table[] = array( |
---|
4033 | 'data' => t('estrategias'), |
---|
4034 | ); |
---|
4035 | $sqlcount = "select count(c.nid) FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND c.field_politicas_seleccionada_value = 'SÃ' AND n.created >= %d AND n.created <= %d"; |
---|
4036 | $sql_query = "SELECT c.nid, n.title FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND field_politicas_seleccionada_value = 'SÃ' AND n.created >= %d AND n.created <= %d "; |
---|
4037 | $sql_query.= tablesort_sql($headers_table); |
---|
4038 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
4039 | $sql_variables = array(); |
---|
4040 | $sql_variables[] = $ente_planificador->nid; |
---|
4041 | $sql_variables[] = $mi_fecha[0]; |
---|
4042 | $sql_variables[] = $mi_fecha[1] + 86399; |
---|
4043 | $result = pager_query($sql_query, $step, 0, $sqlcount, $sql_variables); |
---|
4044 | while($politica = db_fetch_object($result)) { |
---|
4045 | $politica_load = node_load($politica->nid); |
---|
4046 | $row = array(); |
---|
4047 | $row[] = array('data' => $politica_load->body, ); |
---|
4048 | $estrategias = leer_estrategias_por_politica($ente_planificador_micro, $politica); |
---|
4049 | $estrategias_f = array(); |
---|
4050 | if (count($estrategias)) { |
---|
4051 | foreach($estrategias as $id => $estrategia) { |
---|
4052 | if ($ente_has_acceso && $estrategia['ente'] == $ente_planificador_micro->nid) { |
---|
4053 | $links = array(); |
---|
4054 | $links[] = l(t('Reformular'), 'planificacion/' . $ente_planificador_micro->nid . '/politicas/estrategias/' . $id . '/reformular'); |
---|
4055 | $estrategias[$id]['title'] = $estrategia['title'] . ' ' . theme('item_list', $links); |
---|
4056 | } |
---|
4057 | $estrategias_f[] = $estrategias[$id]['title']; |
---|
4058 | } |
---|
4059 | } |
---|
4060 | $row[] = array('data' => theme('item_list', $estrategias_f), ); |
---|
4061 | $rows[] = $row; |
---|
4062 | } |
---|
4063 | if (!count($rows)) { |
---|
4064 | $row = array(); |
---|
4065 | $row[] = array('data' => t('No se encontraron PolÃticas Direccionales para este ente'), 'colspan' => '3'); |
---|
4066 | $rows[] = $row; |
---|
4067 | } |
---|
4068 | $output = theme('table', $headers_table, $rows); |
---|
4069 | $output .= theme('pager', NULL); |
---|
4070 | return $output; |
---|
4071 | } |
---|
4072 | */ |
---|
4073 | |
---|
4074 | /* |
---|
4075 | * Implementation of politicas_direccionales_estrategias_seleccionar_estrategias() |
---|
4076 | * Seleccionar estrategias |
---|
4077 | * |
---|
4078 | function politicas_direccionales_estrategias_seleccionar_estrategias($ente_planificador) { |
---|
4079 | drupal_set_title(t('Seleccionar estrategias')); |
---|
4080 | global $user; |
---|
4081 | $ente = usuario_tiene_ente($user->uid); |
---|
4082 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
4083 | $current_time = time(); |
---|
4084 | $ente_has_acceso = FALSE; |
---|
4085 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
4086 | $fecha = TRUE; |
---|
4087 | } |
---|
4088 | if (!$fecha) { |
---|
4089 | muestra_mensaje("posibles", $ente_planificador); |
---|
4090 | } |
---|
4091 | else { |
---|
4092 | if ($user->entes == $ente_planificador->nid) { |
---|
4093 | muestra_mensaje("posibles", $ente_planificador, 0); |
---|
4094 | } |
---|
4095 | } |
---|
4096 | if ($fecha && (user_access('admin planificador') || $fecha && $user->entes == $ente_planificador->nid)) { |
---|
4097 | $ente_has_acceso = TRUE; |
---|
4098 | } |
---|
4099 | $ente_planificador_micro = $ente_planificador; |
---|
4100 | if ($ente_planificador->tipo > 1) { |
---|
4101 | $ente_has_acceso = FALSE; |
---|
4102 | if ($ente_planificador && $ente_planificador->nid && $politica && $politica->nid) { |
---|
4103 | if (module_exists('ente_planificador_hierarchical')) { |
---|
4104 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
4105 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
4106 | $ente_has_acceso = TRUE; |
---|
4107 | } |
---|
4108 | } |
---|
4109 | } |
---|
4110 | } |
---|
4111 | $macro = ente_planificador_ente_macro($ente_planificador); |
---|
4112 | if ($macro) { |
---|
4113 | $ente_has_acceso = TRUE; |
---|
4114 | $ente_planificador = node_load($macro); |
---|
4115 | } |
---|
4116 | } |
---|
4117 | $step = 10; |
---|
4118 | $headers_table = array(); |
---|
4119 | $headers_table[] = array( |
---|
4120 | 'data' => t('Nombre de la polÃtica Direccional'), |
---|
4121 | 'sort' => 'asc', |
---|
4122 | ); |
---|
4123 | $headers_table[] = array( |
---|
4124 | 'data' => t('Posibles estrategias'), |
---|
4125 | ); |
---|
4126 | $headers_table[] = array( |
---|
4127 | 'data' => t('estrategias Seleccionadas'), |
---|
4128 | ); |
---|
4129 | $sqlcount = "select count(c.nid) FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND c.field_politicas_seleccionada_value = 'SÃ' AND n.created >= %d AND n.created <= %d"; |
---|
4130 | $sql_query = "SELECT c.nid, n.title FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND field_politicas_seleccionada_value = 'SÃ' AND n.created >= %d AND n.created <= %d "; |
---|
4131 | $sql_query.= tablesort_sql($headers_table); |
---|
4132 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
4133 | $sql_variables = array(); |
---|
4134 | $sql_variables[] = $ente_planificador->nid; |
---|
4135 | $sql_variables[] = $mi_fecha[0]; |
---|
4136 | $sql_variables[] = $mi_fecha[1] + 86399; |
---|
4137 | $result = pager_query($sql_query, $step, 0, $sqlcount, $sql_variables); |
---|
4138 | while($politica = db_fetch_object($result)) { |
---|
4139 | $politica_load = node_load($politica->nid); |
---|
4140 | $row = array(); |
---|
4141 | $row[] = array('data' => $politica_load->body, ); |
---|
4142 | $estrategias = leer_estrategias_por_politica($ente_planificador_micro, $politica); |
---|
4143 | $estrategias_f = array(); |
---|
4144 | $estrategias_s = array(); |
---|
4145 | if ($politica_load->field_politicas_estrategias[0]['nid']) { |
---|
4146 | foreach($politica_load->field_politicas_estrategias as $est) { |
---|
4147 | if ($est['nid']) { |
---|
4148 | $estrategias_s[$est['nid']] = $est['nid']; |
---|
4149 | } |
---|
4150 | } |
---|
4151 | } |
---|
4152 | if (count($estrategias)) { |
---|
4153 | foreach($estrategias as $id => $estrategia) { |
---|
4154 | $estrategias_f[] = $estrategia['title']; |
---|
4155 | if (array_key_exists($id, $estrategias_s)) { |
---|
4156 | $estrategias_s[$id] = $estrategia['title']; |
---|
4157 | } |
---|
4158 | } |
---|
4159 | } |
---|
4160 | $count_f = count($estrategias_f); |
---|
4161 | if ($count_f) { |
---|
4162 | $texto_estrategia = theme('item_list', $estrategias_f); |
---|
4163 | } |
---|
4164 | else { |
---|
4165 | $texto_estrategia = t('La polÃtica no tiene estrategias registradas'); |
---|
4166 | } |
---|
4167 | $row[] = array('data' => $texto_estrategia, ); |
---|
4168 | $count_s = count($estrategias_s); |
---|
4169 | $links = array(); |
---|
4170 | if ($count_s) { |
---|
4171 | $texto_estrategia = theme('item_list', $estrategias_s); |
---|
4172 | } |
---|
4173 | else { |
---|
4174 | $texto_estrategia = t('La polÃtica no tiene estrategias seleccionadas'); |
---|
4175 | } |
---|
4176 | if ($ente_has_acceso && $count_f) { |
---|
4177 | $links[] = l(t('Seleccionar estrategias para esta polÃtica'), 'planificacion/' . $ente_planificador_micro->nid . '/politicas/estrategias/'. $politica_load->nid . '/seleccionar', array('query' => array('destination' => 'planificacion/' . $ente_planificador->nid . '/politicas/estrategias/seleccionar'))); |
---|
4178 | } |
---|
4179 | $texto_estrategia .= theme('item_list', $links); |
---|
4180 | $row[] = array('data' => $texto_estrategia, ); |
---|
4181 | $rows[] = $row; |
---|
4182 | } |
---|
4183 | if (!count($rows)) { |
---|
4184 | $row = array(); |
---|
4185 | $row[] = array('data' => t('No se encontraron PolÃticas Direccionales para este ente'), 'colspan' => '3'); |
---|
4186 | $rows[] = $row; |
---|
4187 | } |
---|
4188 | $output = theme('table', $headers_table, $rows); |
---|
4189 | $output .= theme('pager', NULL); |
---|
4190 | return $output; |
---|
4191 | } |
---|
4192 | */ |
---|
4193 | |
---|
4194 | /* |
---|
4195 | * Implementation of politicas_direccionales_seleccionar_estrategias_form() |
---|
4196 | * Formulario para seleccionar estrategias |
---|
4197 | * |
---|
4198 | function politicas_direccionales_seleccionar_estrategias_form($form_state, $ente_planificador = 0, $politica = 0) { |
---|
4199 | $form = array(); |
---|
4200 | $form['#ente_plan'] = $ente_planificador; |
---|
4201 | $form['#politica'] = $politica; |
---|
4202 | $estrategias = leer_estrategias_por_politica($ente_planificador, $politica); |
---|
4203 | $estrategias_f = array(); |
---|
4204 | if (count($estrategias)) { |
---|
4205 | foreach($estrategias as $id => $estrategia) { |
---|
4206 | $estrategias_f[$id] = $estrategia['title']; |
---|
4207 | } |
---|
4208 | } |
---|
4209 | $default = array(); |
---|
4210 | if ($politica->field_politicas_estrategias[0]['nid']) { |
---|
4211 | foreach($politica->field_politicas_estrategias as $est) { |
---|
4212 | if ($est['nid']) { |
---|
4213 | $default[$est['nid']] = $est['nid']; |
---|
4214 | } |
---|
4215 | } |
---|
4216 | } |
---|
4217 | $form['estrategias_seleccionar'] = array( |
---|
4218 | '#type' => 'checkboxes', |
---|
4219 | '#title' => t('Seleccionar estrategias'), |
---|
4220 | '#default_value' => $default, |
---|
4221 | '#options' => $estrategias_f, |
---|
4222 | '#required' => TRUE, |
---|
4223 | '#description' => t('Seleccionar las estrategias para la polÃtica direccionale.'), |
---|
4224 | ); |
---|
4225 | $form['buttons'] = array( |
---|
4226 | '#prefix' => '<div class="container-inline">', |
---|
4227 | '#suffix' => '</div>', |
---|
4228 | '#weight' => 100, |
---|
4229 | ); |
---|
4230 | $form['buttons']['submit'] = array( |
---|
4231 | '#type' => 'submit', |
---|
4232 | '#value' => t('Submit'), |
---|
4233 | '#weight' => 100, |
---|
4234 | ); |
---|
4235 | $form['buttons']['cancel'] = array( |
---|
4236 | '#type' => 'submit', |
---|
4237 | '#value' => t('Cancel'), |
---|
4238 | '#weight' => 102, |
---|
4239 | ); |
---|
4240 | $form['#after_build'] = array(); |
---|
4241 | $form['#after_build'][] = 'politicas_direccionales_skip_validation_form_after_build'; |
---|
4242 | return $form; |
---|
4243 | } |
---|
4244 | */ |
---|
4245 | |
---|
4246 | /* |
---|
4247 | * Implementation of politicas_direccionales_seleccionar_estrategias_form_submit() |
---|
4248 | * |
---|
4249 | function politicas_direccionales_seleccionar_estrategias_form_submit($form, &$form_state){ |
---|
4250 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
4251 | $ente_planificador = $form['#ente_plan']; |
---|
4252 | if ($op == t('Cancel')) { |
---|
4253 | drupal_goto('planificacion/' . $ente_planificador->nid . '/politicas/estrategias/seleccionar'); |
---|
4254 | return; |
---|
4255 | } |
---|
4256 | $politica = $form['#politica']; |
---|
4257 | module_load_include('inc', 'node', 'node.pages'); |
---|
4258 | $nuevo = FALSE; |
---|
4259 | $form_values = $form_state['values']; |
---|
4260 | node_object_prepare($politica); |
---|
4261 | $politica->revision = 1; |
---|
4262 | $politica->log = t('Se agregarón estrategias a la polÃtica direccional'); |
---|
4263 | $politica->field_politicas_estrategias = array(); |
---|
4264 | if (count($form_values['estrategias_seleccionar'])) { |
---|
4265 | foreach($form_values['estrategias_seleccionar'] as $estrategia) { |
---|
4266 | if ($estrategia) { |
---|
4267 | $politica->field_politicas_estrategias[] = array('nid' => $estrategia); |
---|
4268 | } |
---|
4269 | } |
---|
4270 | } |
---|
4271 | node_save($politica); |
---|
4272 | //se agregan los requerimientos a la nueva version del nodo |
---|
4273 | db_query("UPDATE {politicas_ente} SET vid = %d WHERE nid = %d", $politica->vid, $politica->nid); |
---|
4274 | db_query("UPDATE {politicas_ente_actor} SET vid = %d WHERE nid = %d", $politica->vid, $politica->nid); |
---|
4275 | drupal_set_message(t('Se agregarón las estrategias a la polÃtica direccional "%politica"', array('%politica' => $politica->title))); |
---|
4276 | if (!$form_state['redirect']){ |
---|
4277 | $form_state['redirect'] = array( |
---|
4278 | 'planificacion/' . $ente_planificador->nid . '/politicas/estrategias/seleccionar', |
---|
4279 | ); |
---|
4280 | } |
---|
4281 | } |
---|
4282 | */ |
---|
4283 | |
---|
4284 | /* |
---|
4285 | * Implementation of politicas_direccionales_mostrar_estrategias_por_politicas() |
---|
4286 | * Mostrar politicas y estrategias seleccionadas |
---|
4287 | * |
---|
4288 | function politicas_direccionales_mostrar_estrategias_por_politicas($ente_planificador, $politica = 0, $estrategia = 0) { |
---|
4289 | drupal_set_title(t('Estrategias para materializar polÃticas direccionales')); |
---|
4290 | $output = ''; |
---|
4291 | $ente_planificador_micro = $ente_planificador; |
---|
4292 | $children = FALSE; |
---|
4293 | if ($ente_planificador && $ente_planificador->nid && $politica && $politica->nid) { |
---|
4294 | if (module_exists('ente_planificador_hierarchical')) { |
---|
4295 | if ($ente_planificador->tipo <= variable_get('situacion_actual_preliminar_hierarchical_count', 2)) { |
---|
4296 | if (count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
4297 | $children= TRUE; |
---|
4298 | } |
---|
4299 | } |
---|
4300 | } |
---|
4301 | } |
---|
4302 | if ($ente_planificador->tipo > 1 || $children) { |
---|
4303 | $macro = ente_planificador_ente_macro($ente_planificador); |
---|
4304 | if ($macro) { |
---|
4305 | $ente_has_acceso = TRUE; |
---|
4306 | $ente_planificador = node_load($macro); |
---|
4307 | } |
---|
4308 | } |
---|
4309 | if (!$politica && !$estrategia) { |
---|
4310 | $links = array(); |
---|
4311 | $output .= t('Seleccione la polÃtica:'); |
---|
4312 | $sql_query = "SELECT c.nid, n.title FROM {content_type_politicas_direccionales} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_politicas_ente_nid = %d AND field_politicas_seleccionada_value = 'SÃ' AND n.created >= %d AND n.created <= %d "; |
---|
4313 | $mi_fecha = ente_planificador_user_acceso_proceso("posibles", $ente_planificador); |
---|
4314 | $sql_variables = array(); |
---|
4315 | $sql_variables[] = $ente_planificador->nid; |
---|
4316 | $sql_variables[] = $mi_fecha[0]; |
---|
4317 | $sql_variables[] = $mi_fecha[1] + 86399; |
---|
4318 | $result = db_query($sql_query, $sql_variables); |
---|
4319 | while ($politica = db_fetch_object($result)) { |
---|
4320 | $politica_load = node_load($politica->nid); |
---|
4321 | if ($politica_load->field_politicas_estrategias[0]['nid']) { |
---|
4322 | $links[] = l($politica_load->body, 'planificacion/' . $ente_planificador_micro->nid . '/politicas/estrategias/pol_estr/' . $politica_load->nid); |
---|
4323 | } |
---|
4324 | else { |
---|
4325 | $links[] = t('%politica_nombre (No existen estrategias seleccionadas para esta polÃtica)', array('%politica_nombre' => $politica_load->body)); |
---|
4326 | } |
---|
4327 | } |
---|
4328 | $output .= theme('item_list', $links); |
---|
4329 | } |
---|
4330 | elseif ($politica && is_numeric($politica) && !$estrategia) { |
---|
4331 | $links = array(); |
---|
4332 | $politica_load = node_load($politica); |
---|
4333 | if ($politica_load->field_politicas_seleccionada[0]['value'] != 'SÃ') { |
---|
4334 | drupal_set_message(t('No existe la polÃtica direccional')); |
---|
4335 | drupal_goto('planificacion/' . $ente_planificador_micro->nid . '/politicas/estrategias/pol_estr'); |
---|
4336 | return ''; |
---|
4337 | } |
---|
4338 | $output .= t('Seleccione la estrategia:'); |
---|
4339 | $estrategias = leer_estrategias_por_politica($ente_planificador, $politica_load); |
---|
4340 | if ($politica_load->field_politicas_estrategias[0]['nid']) { |
---|
4341 | foreach($politica_load->field_politicas_estrategias as $estrategia) { |
---|
4342 | if (array_key_exists($estrategia['nid'], $estrategias)) { |
---|
4343 | $links[] = l($estrategias[$estrategia['nid']]['title'], 'planificacion/' . $ente_planificador_micro->nid . '/politicas/estrategias/pol_estr/' . $politica_load->nid . '/' . $estrategia['nid']); |
---|
4344 | } |
---|
4345 | } |
---|
4346 | } |
---|
4347 | $output .= theme('item_list', $links); |
---|
4348 | $output .= l(t('Regresar al listado de estrategias'), 'planificacion/' . $ente_planificador_micro->nid . '/politicas/estrategias/pol_estr'); |
---|
4349 | } |
---|
4350 | elseif ($politica && is_numeric($politica) && $estrategia && is_numeric($estrategia)) { |
---|
4351 | $politica_load = node_load($politica); |
---|
4352 | $estrategia_load = node_load($estrategia); |
---|
4353 | if ($politica_load->field_politicas_seleccionada[0]['value'] != 'SÃ') { |
---|
4354 | drupal_set_message(t('No existe la polÃtica direccional')); |
---|
4355 | drupal_goto('planificacion/' . $ente_planificador_micro->nid . '/politicas/estrategias/pol_estr'); |
---|
4356 | } |
---|
4357 | $found = FALSE; |
---|
4358 | if ($politica_load->field_politicas_estrategias[0]['nid']) { |
---|
4359 | foreach($politica_load->field_politicas_estrategias as $estrategia_n) { |
---|
4360 | if ($estrategia_n['nid'] == $estrategia_load->nid) { |
---|
4361 | $found = TRUE; |
---|
4362 | } |
---|
4363 | } |
---|
4364 | } |
---|
4365 | if (!$found) { |
---|
4366 | drupal_set_message(t('No existe la estrategia')); |
---|
4367 | drupal_goto('planificacion/' . $ente_planificador_micro->nid . '/politicas/estrategias/pol_estr'); |
---|
4368 | } |
---|
4369 | $output .= theme('politicas_direccionales_ver_estrategia', $politica_load, $estrategia_load); |
---|
4370 | $output .= l(t('Regresar al listado de estrategias'), 'planificacion/' . $ente_planificador_micro->nid . '/politicas/estrategias/pol_estr/' . $politica_load->nid); |
---|
4371 | } |
---|
4372 | else { |
---|
4373 | drupal_set_message(t('Ocurrio un error al intentar cargar la página')); |
---|
4374 | drupal_goto('planificacion/' . $ente_planificador_micro->nid . '/politicas/estrategias/'); |
---|
4375 | } |
---|
4376 | return $output; |
---|
4377 | } |
---|
4378 | */ |
---|
4379 | |
---|
4380 | /* |
---|
4381 | * Implementation of _situacion_actual_preliminar_get_planns() |
---|
4382 | * Obtiene los tipos de planes en la interpretacion |
---|
4383 | */ |
---|
4384 | function _politicas_direccionales_get_planns() { |
---|
4385 | //permitir version preliminar del tipo de ente menores o iguales a $entes_version |
---|
4386 | //En este caso $entes_version_min = 1 y $entes_version_max = 2, solo los entes tipos >= 1 y <= 2 tienen version preliminar |
---|
4387 | $entes_version_min = 1; |
---|
4388 | $entes_version_max = 2; |
---|
4389 | //permitir situacion actual del tipo de ente menores o iguales a $entes_situacion_actual |
---|
4390 | //En este caso $entes_situacion_actual_min = 1 y $entes_situacion_actual_max = 2, solo los entes tipos >= 1 y <= 2 tienen situacion actual |
---|
4391 | $entes_situacion_actual_min = 1; |
---|
4392 | $entes_situacion_actual_max = 2; |
---|
4393 | //permitir interpretacion del tipo de ente mayores o iguales a $entes_interpretacion |
---|
4394 | //En este caso $entes_version_min = 2 y $entes_version_max = 0, solo los entes tipos >= 2 tienen interpretacion |
---|
4395 | $entes_interpretacion_min = 3; |
---|
4396 | $entes_interpretacion_max = 0; |
---|
4397 | $planns = array( |
---|
4398 | 'politicas' => array( |
---|
4399 | 'plan' => 'politicas', |
---|
4400 | 'short' => 'vp', |
---|
4401 | 'title' => t('Politicas Direccionales'), |
---|
4402 | 'description' => t('Los entes macros añaden las politicas direccionales'), |
---|
4403 | 'title_long' => t('Posibles Politicas direccionales'), |
---|
4404 | 'title_ente' => t('Posibles Politicas direccionales de @ente'), |
---|
4405 | 'hierarchical' => 'fathers', |
---|
4406 | 'hierarchical_ente' => -1, |
---|
4407 | 'ente_type' => array(), |
---|
4408 | ), |
---|
4409 | ); |
---|
4410 | //se obtienen todos los tipos de entes |
---|
4411 | $hierarchical = variable_get('ente_planificador_hierarchical_count', 2); |
---|
4412 | for($i = 1; $i < $hierarchical + 1; $i++) { |
---|
4413 | if ((!$entes_version_min || $i >= $entes_version_min) && (!$entes_version_max || $i <= $entes_version_max)) { |
---|
4414 | $planns['politicas']['ente_type'][$i] = $i; |
---|
4415 | } |
---|
4416 | } |
---|
4417 | return $planns; |
---|
4418 | } |
---|
4419 | |
---|
4420 | /** |
---|
4421 | * Genera el ahah para el display de cada vista |
---|
4422 | */ |
---|
4423 | function politicas_direccionales_views_js($proceso, $tipo) { |
---|
4424 | $form_state = array('submitted' => FALSE); |
---|
4425 | $form_build_id = $_POST['form_build_id']; |
---|
4426 | // Add the new element to the stored form. Without adding the element to the |
---|
4427 | // form, Drupal is not aware of this new elements existence and will not |
---|
4428 | // process it. We retreive the cached form, add the element, and resave. |
---|
4429 | $form = form_get_cache($form_build_id, $form_state); |
---|
4430 | |
---|
4431 | $view_name = $_POST['politicas_direccionales_' . $proceso . '_' . $tipo]; |
---|
4432 | $options = array('_none' => 'Ninguna'); |
---|
4433 | $view = views_get_view($view_name); |
---|
4434 | foreach ($view->display as $key => $display) { |
---|
4435 | $options[$key] = $display->display_title; |
---|
4436 | } |
---|
4437 | |
---|
4438 | $form['politicas_direccionales_views']['politicas_direccionales_display_views_' . $proceso . '_' . $tipo] = array( |
---|
4439 | '#title' => t("Seleccione el display de la vista"), |
---|
4440 | '#type' => 'select', |
---|
4441 | '#default_value' => variable_get('politicas_direccionales_display_views_' . $proceso . '_' . $tipo, 0), |
---|
4442 | '#options' => $options, |
---|
4443 | '#requerid' => TRUE, |
---|
4444 | ); |
---|
4445 | |
---|
4446 | |
---|
4447 | form_set_cache($form_build_id, $form, $form_state); |
---|
4448 | $form += array( |
---|
4449 | '#post' => $_POST, |
---|
4450 | '#programmed' => FALSE, |
---|
4451 | ); |
---|
4452 | // Rebuild the form. |
---|
4453 | $form = form_builder($_POST['form_id'], $form, $form_state); |
---|
4454 | |
---|
4455 | $new_form = array(); |
---|
4456 | |
---|
4457 | unset($form['politicas_direccionales_views']['politicas_direccionales_display_views_' . $proceso . '_' . $tipo]['#prefix']); |
---|
4458 | unset($form['politicas_direccionales_views']['politicas_direccionales_display_views_' . $proceso . '_' . $tipo]['#suffix']); |
---|
4459 | $new_form['politicas_direccionales_views']['politicas_direccionales_display_views_' . $proceso . '_' . $tipo] = $form['politicas_direccionales_views']['politicas_direccionales_display_views_' . $proceso . '_' . $tipo]; |
---|
4460 | |
---|
4461 | $output = drupal_render($new_form); |
---|
4462 | print drupal_to_js(array('data' => $output, 'status' => true)); |
---|
4463 | exit(); |
---|
4464 | } |
---|
4465 | |
---|
4466 | /** |
---|
4467 | * Implementation of hook_views_api(). |
---|
4468 | */ |
---|
4469 | function politicas_direccionales_views_api() { |
---|
4470 | return array( |
---|
4471 | 'api' => '2.0', |
---|
4472 | 'path' => drupal_get_path('module', 'politicas_direccionales') . '/views', |
---|
4473 | ); |
---|
4474 | } |
---|
4475 | |
---|
4476 | /** |
---|
4477 | * Genera el ahah para el display de cada vista |
---|
4478 | */ |
---|
4479 | function politicas_direccionales_causas_ahah($plan, $i=1) { |
---|
4480 | |
---|
4481 | $form_state = array('submitted' => FALSE); |
---|
4482 | $form_build_id = $_POST['form_build_id']; |
---|
4483 | // Add the new element to the stored form. Without adding the element to the |
---|
4484 | // form, Drupal is not aware of this new elements existence and will not |
---|
4485 | // process it. We retreive the cached form, add the element, and resave. |
---|
4486 | $form = form_get_cache($form_build_id, $form_state); |
---|
4487 | $tipo_plan = 'politicas'; |
---|
4488 | $planns = _politicas_direccionales_get_planns(); |
---|
4489 | $plan = $planns[$tipo_plan]; |
---|
4490 | $tipo = 'causas'; |
---|
4491 | if ($view_id = variable_get('politicas_direccionales_' . $plan['plan'] . '_' . $tipo, 0)) { |
---|
4492 | $view = views_get_view($view_id); |
---|
4493 | $display_id = variable_get('politicas_direccionales_display_views_' . $plan['plan'] . '_' . $tipo, 'default'); |
---|
4494 | $view->set_display($display_id); |
---|
4495 | $view->override_path = $_GET['q']; |
---|
4496 | $view->set_arguments(array($_POST['causas_' . $i])); |
---|
4497 | $view->pre_execute(); |
---|
4498 | $view->execute(); |
---|
4499 | $output = $view->render(); |
---|
4500 | /* $form['problema']['causa_' . $i]['content_view_' . $i] = array( |
---|
4501 | '#value' => $output, |
---|
4502 | ); |
---|
4503 | */ |
---|
4504 | $form['problema']['causa_' . $i]['group_content-' . $i] = array( |
---|
4505 | '#type' => 'fieldset', |
---|
4506 | '#title' => t('Para conocer los detalles de la PolÃtica Seleccionada haga click aca.'), |
---|
4507 | '#collapsible' => TRUE, |
---|
4508 | '#collapsed' => TRUE, |
---|
4509 | ); |
---|
4510 | $form['problema']['causa_' . $i]['group_content-' . $i]['content_view_' . $i] = array( |
---|
4511 | '#value' => $output, |
---|
4512 | ); |
---|
4513 | } |
---|
4514 | |
---|
4515 | form_set_cache($form_build_id, $form, $form_state); |
---|
4516 | $form += array( |
---|
4517 | '#post' => $_POST, |
---|
4518 | '#programmed' => FALSE, |
---|
4519 | ); |
---|
4520 | $form_state['post'] = $_POST; |
---|
4521 | |
---|
4522 | // Rebuild the form. |
---|
4523 | $form = form_builder($_POST['form_id'], $form, $form_state); |
---|
4524 | |
---|
4525 | $new_form = array(); |
---|
4526 | unset($form['problema']['causa_' . $i]['#prefix']); |
---|
4527 | unset($form['problema']['causa_' . $i]['#suffix']); |
---|
4528 | $new_form['problema']['causa_' . $i] = $form['problema']['causa_' . $i]; |
---|
4529 | |
---|
4530 | $output = drupal_render($new_form); |
---|
4531 | // Final rendering callback. |
---|
4532 | print drupal_to_js(array('data' => $output, 'status' => true)); |
---|
4533 | exit(); |
---|
4534 | } |
---|
4535 | |
---|
4536 | /** |
---|
4537 | * Genera el ahah para agregar un nuevo elemento en el formulario |
---|
4538 | */ |
---|
4539 | function politicas_direccionales_form_add_causas_ahah($tipo_plan) { |
---|
4540 | $count = $_POST['count'] ? $_POST['count'] : 1; |
---|
4541 | $count++; |
---|
4542 | |
---|
4543 | // The AHAH callback function triggered by the user changing the first field, "ahahtestmodule_types" |
---|
4544 | $form_state = array('storage' => NULL, 'submitted' => FALSE); |
---|
4545 | $form_build_id = $_POST['form_build_id']; |
---|
4546 | // Get for the form from the cache |
---|
4547 | $form = form_get_cache($form_build_id, $form_state); |
---|
4548 | // Get the form set up to process |
---|
4549 | $args = $form['#parameters']; |
---|
4550 | $form_id = array_shift($args); |
---|
4551 | $form_state['post'] = $form['#post'] = $_POST; |
---|
4552 | $form['#programmed'] = $form['#redirect'] = FALSE; |
---|
4553 | |
---|
4554 | //increment count value |
---|
4555 | $form['problema']['count'] = array('#type' => 'hidden', '#value' => $count); |
---|
4556 | |
---|
4557 | // Process the form with drupal_process_form(), which calls the submit handlers that put whatever was worthy of keeping in the $form_state |
---|
4558 | drupal_process_form($form_id, $form, $form_state); |
---|
4559 | // Call drupal_rebuild_form(), which destroys $_POST, creates the form again with hook_form, gets the new form cached and processed again |
---|
4560 | $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); |
---|
4561 | |
---|
4562 | // THIS IS WHAT YOU WILL CUSTOMIZE FOR YOUR OWN FORM |
---|
4563 | // Choose the field you want to update with AHAH and render it |
---|
4564 | $ahah_form = $form['problema']; |
---|
4565 | unset($ahah_form['#prefix'], $ahah_form['#suffix']); |
---|
4566 | $output = drupal_render($ahah_form); |
---|
4567 | $output .= drupal_get_js(); |
---|
4568 | // Final rendering callback. |
---|
4569 | print drupal_to_js(array('data' => $output, 'status' => true)); |
---|
4570 | exit(); |
---|
4571 | } |
---|