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