1 | <?php |
---|
2 | /** |
---|
3 | * Modulo para la gestión de los entes planificadores por sectores sociales |
---|
4 | * Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana |
---|
5 | * @file ente_planificador_sector.module |
---|
6 | * Drupal part Module to code ente planificador module |
---|
7 | * Copyright 2011 Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana (CENDITEL) |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or modify |
---|
10 | * it under the terms of the GNU General Public License as published by |
---|
11 | * the Free Software Foundation; either version 2 of the License, or |
---|
12 | * (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
22 | * |
---|
23 | * @author Cenditel Merida - Ing. Jose Puentes |
---|
24 | * @date 2014-11-03 // (año-mes-dia) |
---|
25 | * @version 0.2 // (0.1) |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | /* |
---|
30 | * Agrega los cuatro niveles de planificacion. |
---|
31 | * Lista los niveles de Planificacion. |
---|
32 | */ |
---|
33 | function ente_planificador_sector_nivel_planificacion($nivel = 0) { |
---|
34 | $nivels = array( |
---|
35 | 0 => t('Seleccione.'), |
---|
36 | 1 => t('Organismo rector en planificación.'), |
---|
37 | 2 => t('Organismo público.'), |
---|
38 | 3 => t('Ente adscrito a un organismo público.'), |
---|
39 | 4 => t('Ente adscrito a otro ente adscrito (sub-ente adscrito).'), |
---|
40 | ); |
---|
41 | drupal_alter('obtiene_tipos', $nivels); |
---|
42 | if ($nivel && is_numeric($nivel) && $nivels[$nivel]) { |
---|
43 | return $nivels[$nivel]; |
---|
44 | } |
---|
45 | elseif($nivel) { |
---|
46 | return FALSE; |
---|
47 | } |
---|
48 | return $nivels; |
---|
49 | } |
---|
50 | |
---|
51 | /* |
---|
52 | * Agrega los cuatro roles de planificacion. |
---|
53 | * Lista los roles de Planificacion. |
---|
54 | */ |
---|
55 | function ente_planificador_sector_roles_planificacion($rol= 0) { |
---|
56 | $roles = array( |
---|
57 | 0 => t('Seleccione.'), |
---|
58 | 1 => t('Control.'), |
---|
59 | 2 => t('Enlace Formulador.'), |
---|
60 | 3 => t('Enlace Revisor.'), |
---|
61 | 4 => t('Supervisor.'), |
---|
62 | ); |
---|
63 | if ($rol && is_numeric($rol) && $roles[$rol]) { |
---|
64 | return $roles[$rol]; |
---|
65 | } |
---|
66 | elseif($rol) { |
---|
67 | return FALSE; |
---|
68 | } |
---|
69 | return $roles; |
---|
70 | } |
---|
71 | |
---|
72 | /* |
---|
73 | * Seleciona el rol de planificacion del usuario |
---|
74 | */ |
---|
75 | function ente_planificador_sector_mi_rol_planificacion($uid = 0) { |
---|
76 | $query = db_query("SELECT rol_planificacion FROM ente_user_planificador WHERE usuario=%d", $uid); |
---|
77 | $row = db_fetch_object($query); |
---|
78 | return $row->rol_planificacion; |
---|
79 | } |
---|
80 | |
---|
81 | /* |
---|
82 | * Implementation of hook_menu() |
---|
83 | */ |
---|
84 | function ente_planificador_sector_menu() { |
---|
85 | $items = array(); |
---|
86 | $items['fechas_planificacion/notificacion/sector'] = array( |
---|
87 | 'title' => 'Modificar Fechas por sectores.', |
---|
88 | 'page callback' => 'fecha_procesos_sector_notificacion', |
---|
89 | 'access arguments' => array('admin planificador'), |
---|
90 | 'type' => MENU_LOCAL_TASK, |
---|
91 | ); |
---|
92 | $items['fechas_planificacion/notificacion/ambito'] = array( |
---|
93 | 'title' => 'Modificar Fechas por Ambito.', |
---|
94 | 'page callback' => 'fecha_procesos_ambito_notificacion', |
---|
95 | 'access arguments' => array('admin planificador'), |
---|
96 | 'type' => MENU_LOCAL_TASK, |
---|
97 | ); |
---|
98 | $items['fechas_planificacion/edit/sector'] = array( |
---|
99 | 'title' => 'Modificar las fechas para los procesos de planificación por Sectores.', |
---|
100 | 'page callback' => 'fecha_procesos_sector_fecha_planificacion_edit', |
---|
101 | 'access arguments' => array('admin planificador'), |
---|
102 | 'type' => MENU_CALLBACK, |
---|
103 | ); |
---|
104 | $items['fechas_planificacion/edit/ambito'] = array( |
---|
105 | 'title' => 'Modificar las fechas para los procesos de planificación por Sectores.', |
---|
106 | 'page callback' => 'fecha_procesos_ambito_fecha_planificacion_edit', |
---|
107 | 'access arguments' => array('admin planificador'), |
---|
108 | 'type' => MENU_CALLBACK, |
---|
109 | ); |
---|
110 | $items['fechas_planificacion/sectores/edit/%/%'] = array( |
---|
111 | 'title' => 'Modificar las fechas para los procesos de planificación por Sectores.', |
---|
112 | 'page callback' => 'fecha_procesos_sector_notificacion_edit_form_sectores_planificacion', |
---|
113 | 'access arguments' => array('admin planificador'), |
---|
114 | 'page arguments' => array(3,4), |
---|
115 | 'type' => MENU_CALLBACK, |
---|
116 | ); |
---|
117 | $items['fechas_planificacion/ambitos_sector/edit/%/%'] = array( |
---|
118 | 'title' => 'Modificar las fechas para los procesos de planificación por Ambito.', |
---|
119 | 'page callback' => 'fecha_procesos_sector_notificacion_edit_form_planificacion_by_ambitos', |
---|
120 | 'access arguments' => array('admin planificador'), |
---|
121 | 'page arguments' => array(3,4), |
---|
122 | 'type' => MENU_CALLBACK, |
---|
123 | ); |
---|
124 | //opcion de configuracion del ambito |
---|
125 | $items['admin/settings/ente_planificador/agregar_ambitos'] = array( |
---|
126 | 'title' => t('Agregar Ambitos'), |
---|
127 | 'page callback' => 'drupal_get_form', |
---|
128 | 'page arguments' => array('ente_planificador_sector_form_ambito'), |
---|
129 | 'access arguments' => array('admin planificador'), |
---|
130 | 'weight' => -6, |
---|
131 | 'type' => MENU_LOCAL_TASK, |
---|
132 | ); |
---|
133 | //lista de los ambitos registrados |
---|
134 | $items['lista_ambitos_y_sectores_asociados'] = array( |
---|
135 | 'title' => t('Lista de los Ambitos y Sectores Asociados'), |
---|
136 | 'page callback' => 'ente_planificador_sector_lista_ambito', |
---|
137 | 'access arguments' => array('admin planificador'), |
---|
138 | 'weight' => -6, |
---|
139 | 'type' => MENU_LOCAL_TASK, |
---|
140 | ); |
---|
141 | //lista de los ambitos registrados |
---|
142 | $items['admin/settings/ente_planificador/lista_sectores/%'] = array( |
---|
143 | 'title' => t('Lista Sectores Asociados a un ambito'), |
---|
144 | 'page callback' => 'ente_planificador_sector_lista_sectores', |
---|
145 | 'access arguments' => array('admin planificador'), |
---|
146 | 'page arguments' => array(4), |
---|
147 | 'weight' => -6, |
---|
148 | ); |
---|
149 | //lista de los ambitos registrados |
---|
150 | $items['admin/settings/ente_planificador/agregar_sectores'] = array( |
---|
151 | 'title' => t('Agregar Sectores'), |
---|
152 | 'page callback' => 'drupal_get_form', |
---|
153 | 'page arguments' => array('ente_planificador_sector_form_sector'), |
---|
154 | 'access arguments' => array('admin planificador'), |
---|
155 | 'weight' => -6, |
---|
156 | 'type' => MENU_LOCAL_TASK, |
---|
157 | ); |
---|
158 | $items['ente_planificador_sector_util'] = array( |
---|
159 | 'title' => 'JS utilities form', |
---|
160 | 'page callback' => 'ente_planificador_sector_js_util', |
---|
161 | 'access arguments' => array('admin planificador'), |
---|
162 | 'type' => MENU_CALLBACK, |
---|
163 | ); |
---|
164 | return $items; |
---|
165 | } |
---|
166 | |
---|
167 | /** |
---|
168 | * Crea una tabla de opciones para modificar las fechas de notificacion por ambito |
---|
169 | */ |
---|
170 | function fecha_procesos_ambito_notificacion() { |
---|
171 | drupal_set_title(t('Modificar las Fecha de los Procesos por Ambitos')); |
---|
172 | $view = FALSE; |
---|
173 | if (user_access('admin planificador')) { |
---|
174 | $view = TRUE; |
---|
175 | } |
---|
176 | $header = array(); |
---|
177 | $header[] = array('data' => t('Listado de los procesos de planificación')); |
---|
178 | $procesos_status = ente_planificador_procesos('status'); |
---|
179 | $procesos = ente_planificador_procesos(); |
---|
180 | $procesos_ordenados = ente_planificador_ordena_procesos($procesos_status, $procesos); |
---|
181 | $procesos_status = $procesos_ordenados['status']; |
---|
182 | $nuevo_proceso = $procesos_ordenados['normal']; |
---|
183 | $rows = array(); |
---|
184 | if (is_array($procesos_status) && count($procesos_status)) { |
---|
185 | foreach ($procesos_status as $id => $valores) { |
---|
186 | $row = array(); |
---|
187 | $row[] = array('data' => '<b>' . $procesos_status[$id]['title'] . '</b>', 'colspan' => 1, 'align' => 'center'); |
---|
188 | $rows[] = $row; |
---|
189 | if (is_array($nuevo_proceso[$id]) && count($nuevo_proceso[$id])) { |
---|
190 | $items = array(); |
---|
191 | $item = array(); |
---|
192 | foreach ($nuevo_proceso[$id] as $type_url_str => $proceso) { |
---|
193 | if ($view) { |
---|
194 | $item[] = array( |
---|
195 | 'data'=> l(t('Modificar la fecha de inicio para %name', array('%name' => $proceso['title'])), 'fechas_planificacion/edit/ambito/' . $type_url_str, array('html' => true, 'query' => 'destination=fechas_planificacion/notificacion/ambito')), |
---|
196 | ); |
---|
197 | } |
---|
198 | } |
---|
199 | if (sizeof($item)) { |
---|
200 | $items[] = theme('item_list', $item); |
---|
201 | $rows[] = $items; |
---|
202 | } |
---|
203 | else { |
---|
204 | $row[] = array( |
---|
205 | 'data' => t('No se encontrarón Procesos'), |
---|
206 | ); |
---|
207 | } |
---|
208 | } |
---|
209 | } |
---|
210 | } |
---|
211 | if (sizeof($rows)) { |
---|
212 | $output.= '<br>'.theme('table', $header, $rows); |
---|
213 | $output .= theme('pager', NULL); |
---|
214 | } |
---|
215 | else { |
---|
216 | $row[] = array( |
---|
217 | 'data' => t('No se encontrarón Procesos'), |
---|
218 | ); |
---|
219 | } |
---|
220 | return $output; |
---|
221 | } |
---|
222 | |
---|
223 | /** |
---|
224 | * Editar las fechas de planificacion por sectores |
---|
225 | */ |
---|
226 | function fecha_procesos_sector_notificacion_edit_form_planificacion_by_ambitos($term = 0, $type_node = '') { |
---|
227 | $procesos = ente_planificador_procesos(); |
---|
228 | if (isset($procesos[$type_node])) { |
---|
229 | return drupal_get_form('fecha_procesos_sector_notificacion_edit_form_ambitos_planificacion', $term, $type_node); |
---|
230 | } |
---|
231 | return NULL; |
---|
232 | } |
---|
233 | |
---|
234 | |
---|
235 | /* |
---|
236 | * Lista los sectores por ambito para modificar los procesos que la componen |
---|
237 | */ |
---|
238 | function fecha_procesos_sector_notificacion_edit_form_ambitos_planificacion($form_state, $ambito = 0, $type_node = '') { |
---|
239 | $view = FALSE; |
---|
240 | $form = array(); |
---|
241 | $procesos = ente_planificador_procesos(); |
---|
242 | $procesos_status = ente_planificador_procesos('status'); |
---|
243 | $procesos_ordenados = ente_planificador_ordena_procesos($procesos_status, $procesos); |
---|
244 | $procesos_status = $procesos_ordenados['status']; |
---|
245 | $nuevo_proceso = $procesos_ordenados['normal']; |
---|
246 | $tid = variable_get('ente_planificador_sector_Ambitos', 0); |
---|
247 | if(is_numeric($ambito)) { |
---|
248 | $termino = taxonomy_get_term($ambito); |
---|
249 | } |
---|
250 | |
---|
251 | $terms = taxonomy_get_children($termino->tid); |
---|
252 | drupal_set_title(t('Modificar las Fecha para %proceso', array('%proceso' => $procesos[$type_node]['title']))); |
---|
253 | |
---|
254 | if (user_access('admin planificador')) { |
---|
255 | $view = TRUE; |
---|
256 | } |
---|
257 | if (!(is_numeric($ambito)) && ($ambito == 'administrador')) { |
---|
258 | $FIPM = variable_get('ente_planificador_' . $type_node . '_admin_from', $now); |
---|
259 | $FFPM = variable_get('ente_planificador_' . $type_node . '_admin_until', $now); |
---|
260 | $name_ambito = 'Especial del usuario Administrador'; |
---|
261 | } |
---|
262 | if (!(is_numeric($ambito)) && ($ambito == 'control')) { |
---|
263 | $FIPM = variable_get('ente_planificador_' . $type_node . '_control_from', $now); |
---|
264 | $FFPM = variable_get('ente_planificador_' . $type_node . '_control_until', $now); |
---|
265 | $name_ambito = 'Especial del usuario Control'; |
---|
266 | } |
---|
267 | //agregando el formulrio para editar las fechas |
---|
268 | $now = time(); |
---|
269 | if ($view) { |
---|
270 | if (is_numeric($ambito)) { |
---|
271 | $term = taxonomy_get_term($ambito); |
---|
272 | drupal_set_title(t('Fecha de Planificación para el Ambito %ambito', array('%ambito' => $term->name))); |
---|
273 | $FIPM = variable_get('ente_planificador_' . $type_node . '_all_from_' . $termino->tid, $now); |
---|
274 | $FFPM = variable_get('ente_planificador_' . $type_node . '_all_until_' . $termino->tid, $now); |
---|
275 | $name_ambito = $term->name; |
---|
276 | } |
---|
277 | $form['fechas'] = array( |
---|
278 | '#type' => 'fieldset', |
---|
279 | '#title' => t(' Modificar la fecha de inicio para %proceso del ambito %ambito',array('%proceso' => $procesos[$type_node]['title'], '%ambito' => $name_ambito )), |
---|
280 | '#collapsible' => FALSE, |
---|
281 | '#collapsed' => TRUE, |
---|
282 | ); |
---|
283 | |
---|
284 | $f1 = explode("-", format_date($FIPM, 'custom', 'Y-m-d')); |
---|
285 | settype($f1[0], "integer"); |
---|
286 | settype($f1[1], "integer"); |
---|
287 | settype($f1[2], "integer"); |
---|
288 | $f2 = explode("-", format_date($FFPM, 'custom', 'Y-m-d')); |
---|
289 | settype($f2[0], "integer"); |
---|
290 | settype($f2[1], "integer"); |
---|
291 | settype($f2[2], "integer"); |
---|
292 | |
---|
293 | $form['fechas']['from'] = array( |
---|
294 | '#type' => 'date', |
---|
295 | '#title' => t('Fecha de Inicio'), |
---|
296 | '#default_value' => array( |
---|
297 | 'day' => $f1[2], |
---|
298 | 'month' => $f1[1], |
---|
299 | 'year' => $f1[0], |
---|
300 | ), |
---|
301 | '#description' => t('Seleccione la fecha de inicio'), |
---|
302 | ); |
---|
303 | $form['fechas']['until'] = array( |
---|
304 | '#type' => 'date', |
---|
305 | '#title' => t('Fecha de Fin'), |
---|
306 | '#default_value' => array( |
---|
307 | 'day' => $f2[2], |
---|
308 | 'month' => $f2[1], |
---|
309 | 'year' => $f2[0], |
---|
310 | ), |
---|
311 | '#description' => t('Seleccione la fecha de culminación'), |
---|
312 | ); |
---|
313 | if ((is_numeric($ambito)) && (($ambito != 'administrador') || ($ambito != 'control'))) { |
---|
314 | $form['fechas']['term'] = array( |
---|
315 | '#type' => 'hidden', |
---|
316 | '#default_value' => $termino->tid, |
---|
317 | ); |
---|
318 | |
---|
319 | } |
---|
320 | if (!(is_numeric($ambito)) && ($ambito == 'administrador')) { |
---|
321 | $form['fechas']['term'] = array( |
---|
322 | '#type' => 'hidden', |
---|
323 | '#default_value' => $ambito, |
---|
324 | ); |
---|
325 | } |
---|
326 | if (!(is_numeric($ambito)) && ($ambito == 'control')) { |
---|
327 | $form['fechas']['term'] = array( |
---|
328 | '#type' => 'hidden', |
---|
329 | '#default_value' => $ambito, |
---|
330 | ); |
---|
331 | } |
---|
332 | $form['fechas']['proceso'] = array( |
---|
333 | '#type' => 'hidden', |
---|
334 | '#default_value' => $type_node, |
---|
335 | ); |
---|
336 | $form['submit'] = array( |
---|
337 | '#type' => 'submit', |
---|
338 | '#default_value' => t("Guardar"), |
---|
339 | '#validate' => array('ente_planificador_sector_fecha_planificacion_edit_notificacion_validate'), |
---|
340 | '#submit' => array('fecha_procesos_sector_notificacion_edit_form_ambito_submit'), |
---|
341 | ); |
---|
342 | $enlace = base_path() . 'fechas_planificacion/edit/ambito/'.$type_node; |
---|
343 | $form['cancel'] = array( |
---|
344 | '#type' => 'submit', |
---|
345 | '#attributes' => array('onClick' => 'window.location="' . $enlace . '"; return false;'), |
---|
346 | '#value' => t('Cancel'), |
---|
347 | ); |
---|
348 | if ((is_numeric($ambito)) && ($ambito != 'administrador') && ($ambito != 'control')) { |
---|
349 | $form['fechas']['help'] = array( |
---|
350 | '#value' => t('Esta acción Afectara todas las fechas especificadas para el proceso de registro por Sectores del ambito %ambito' , array('%ambito' => $term->name)), |
---|
351 | '#prefix' => '<div class="warning">', |
---|
352 | '#suffix' => '</div>', |
---|
353 | ); |
---|
354 | } |
---|
355 | } |
---|
356 | if ((is_numeric($ambito)) && ($ambito != 'administrador') && ($ambito != 'control')) { |
---|
357 | $header = array(); |
---|
358 | $header[] = array('data' => t('Lista de los Sectores para el ambito %ambito', array('%ambito' => $termino->name)), 'colspan' => 1, 'align' => 'center'); |
---|
359 | $header[] = array('data' => t('Fecha de Inicio'), 'colspan' => 1, 'align' => 'center'); |
---|
360 | $header[] = array('data' => t('Fecha de Culminación'), 'colspan' => 1, 'align' => 'center'); |
---|
361 | $now = time(); |
---|
362 | foreach ($terms as $term) { |
---|
363 | $FIPMI = variable_get('ente_planificador_' . $type_node . '_from_' . $term->tid, $now); |
---|
364 | $FFPMF = variable_get('ente_planificador_' . $type_node . '_until_' . $term->tid, $now); |
---|
365 | $row = array(); |
---|
366 | $row[] = array( |
---|
367 | 'data'=> t('%sector', array('%sector' => $term->name)), |
---|
368 | ); |
---|
369 | $row[] = array( |
---|
370 | 'data'=> format_date($FIPMI, 'long'), |
---|
371 | ); |
---|
372 | $row[] = array( |
---|
373 | 'data'=> format_date($FFPMF), |
---|
374 | ); |
---|
375 | $rows[] = $row; |
---|
376 | } |
---|
377 | if (sizeof($rows)) { |
---|
378 | $output.= '<br>'.theme('table', $header, $rows); |
---|
379 | $output .= theme('pager', NULL); |
---|
380 | } |
---|
381 | else { |
---|
382 | $row[] = array( |
---|
383 | 'data' => t('No se encontrarón Sectores Asociados'), |
---|
384 | 'colspan' => 3, |
---|
385 | ); |
---|
386 | $rows[] = $row; |
---|
387 | $output.= '<br>'.theme('table', $header, $rows); |
---|
388 | $output .= theme('pager', NULL); |
---|
389 | } |
---|
390 | } |
---|
391 | //anadiendo las fechas de los sectores para su visualizacion |
---|
392 | $form['sectores_hidden'] = array( |
---|
393 | '#value' => '<br>' . $output, |
---|
394 | ); |
---|
395 | //$form['#submit'][] = 'fecha_procesos_sector_notificacion_edit_form_ambito_submit'; |
---|
396 | return $form; |
---|
397 | } |
---|
398 | |
---|
399 | /* |
---|
400 | * agrega las fechas de planificacion por ambito, aplicandola a todos los hijos que la conforman |
---|
401 | */ |
---|
402 | function fecha_procesos_sector_notificacion_edit_form_ambito_submit($form, &$form_state) { |
---|
403 | |
---|
404 | $fi = mktime( |
---|
405 | 0, |
---|
406 | 0, |
---|
407 | 0, |
---|
408 | $form_state['values']['from']['month'], |
---|
409 | $form_state['values']['from']['day'], |
---|
410 | $form_state['values']['from']['year'] |
---|
411 | ); |
---|
412 | $ff = mktime( |
---|
413 | 0, |
---|
414 | 0, |
---|
415 | 0, |
---|
416 | $form_state['values']['until']['month'], |
---|
417 | $form_state['values']['until']['day'], |
---|
418 | $form_state['values']['until']['year'] |
---|
419 | ); |
---|
420 | //estableciendo las fechas para cada sector |
---|
421 | $ambito = $form_state['values']['term']; |
---|
422 | $proceso = $form_state['values']['proceso']; |
---|
423 | if (is_numeric($ambito)) { |
---|
424 | $ambito = taxonomy_get_term($ambito); |
---|
425 | $terms = taxonomy_get_children($ambito->tid, $ambito->vid); |
---|
426 | if ($terms) { |
---|
427 | foreach ($terms as $term) { |
---|
428 | variable_set('ente_planificador_' . $proceso . '_all_from_' . $ambito->tid, $fi); |
---|
429 | variable_set('ente_planificador_' . $proceso . '_all_until_' . $ambito->tid, $ff); |
---|
430 | //actualizando las fechas por sector social |
---|
431 | variable_set('ente_planificador_' . $proceso . '_from_' . $term->tid, $fi); |
---|
432 | variable_set('ente_planificador_' . $proceso . '_until_' . $term->tid, $ff); |
---|
433 | drupal_set_message(t('Se han guardado los cambios para el sector %sector' , array('%sector' => $term->name))); |
---|
434 | } |
---|
435 | } |
---|
436 | else { |
---|
437 | variable_set('ente_planificador_' . $proceso . '_all_from_' . $ambito->tid, $fi); |
---|
438 | variable_set('ente_planificador_' . $proceso . '_all_until_' . $ambito->tid, $ff); |
---|
439 | } |
---|
440 | drupal_set_message(t('Se han guardado los cambios para el Ambito %sector' , array('%sector' => $ambito->name))); |
---|
441 | } |
---|
442 | if (!(is_numeric($ambito)) && ($ambito == 'administrador')) { |
---|
443 | variable_set('ente_planificador_' . $proceso . '_admin_from', $fi); |
---|
444 | variable_set('ente_planificador_' . $proceso . '_admin_until', $ff); |
---|
445 | drupal_set_message(t('Se han guardado las fechas del ambito especial del usuario administrador')); |
---|
446 | } |
---|
447 | if (!(is_numeric($ambito)) && ($ambito == 'control')) { |
---|
448 | variable_set('ente_planificador_' . $proceso . '_control_from', $fi); |
---|
449 | variable_set('ente_planificador_' . $proceso . '_control_until', $ff); |
---|
450 | drupal_set_message(t('Se han guardado las fechas del ambito especial del usuario Control')); |
---|
451 | } |
---|
452 | |
---|
453 | } |
---|
454 | |
---|
455 | /** |
---|
456 | * Crea una tabla de las fechas validas de los procesos de planificacion por ambito |
---|
457 | */ |
---|
458 | function fecha_procesos_ambito_fecha_planificacion_edit($type_node = '') { |
---|
459 | $procesos = ente_planificador_procesos(); |
---|
460 | $view = FALSE; |
---|
461 | $items = array(); |
---|
462 | $item = array(); |
---|
463 | if (user_access('admin planificador')) { |
---|
464 | $view = TRUE; |
---|
465 | } |
---|
466 | drupal_set_title(t('Modificar la fecha de inicio para %proceso por Ambitos', array('%proceso' => $procesos[$type_node]['title']))); |
---|
467 | $now = time(); |
---|
468 | if (isset($procesos[$type_node])) { |
---|
469 | $header = array(); |
---|
470 | $header[] = array('data' => t('Ambito'), 'sort' => 'asc'); |
---|
471 | $header[] = array('data' => t('Fecha de Inicio'), 'sort' => 'asc'); |
---|
472 | $header[] = array('data' => t('Fecha de Fin'), 'sort' => 'asc'); |
---|
473 | if ($view) { |
---|
474 | $header[] = array('data' => t('Modificar'), ); |
---|
475 | } |
---|
476 | //recorer todos los ambitos |
---|
477 | $tid = variable_get('ente_planificador_sector_Ambitos', 0); |
---|
478 | $terms = taxonomy_get_tree($tid); |
---|
479 | foreach ($terms as $term) { |
---|
480 | $row = array(); |
---|
481 | if ($term->depth == 0) { //si el termino es padre (AMBITO) |
---|
482 | $fechas[0] = variable_get('ente_planificador_' . $type_node . '_all_from_' . $term->tid, $now); |
---|
483 | $fechas[1] = variable_get('ente_planificador_' . $type_node . '_all_until_' . $term->tid, $now); |
---|
484 | $FIPM = $fechas[0]; |
---|
485 | $FFPM = $fechas[1]; |
---|
486 | $row[] = array( |
---|
487 | 'data'=> t('%ambito', array('%ambito' => $term->name)), |
---|
488 | ); |
---|
489 | $row[] = format_date($FIPM); |
---|
490 | $row[] = format_date($FFPM); |
---|
491 | if ($view) { |
---|
492 | $row[] = l(t('Modificar'), 'fechas_planificacion/ambitos_sector/edit/'.$term->tid.'/'.$type_node, array('html' => true, 'query' => 'destination=fechas_planificacion/edit/ambito/'.$type_node)); |
---|
493 | } |
---|
494 | } |
---|
495 | $rows[] = $row; |
---|
496 | } |
---|
497 | // fin de la estructura de repeticion |
---|
498 | if (!count($rows)) { |
---|
499 | $row = array(); |
---|
500 | $row[] = array('data' => t('No se encontrarón Sectores'), 'colspan' => 3); |
---|
501 | $rows[] = $row; |
---|
502 | $fechas_display = FALSE; |
---|
503 | } |
---|
504 | $aux = ""; |
---|
505 | if (module_exists('proyectos_operativos_mail')) { |
---|
506 | $aux = l(t("Enviar Correo Electrónico a los entes planificadores por Ambito Social."), 'fechas_planificacion/notificacion/envia_email/ambito/' . $type_node); |
---|
507 | } |
---|
508 | if (user_access('admin planificador')) { |
---|
509 | $FIPMA = variable_get('ente_planificador_' . $type_node . '_admin_from', $now); |
---|
510 | $FFPMA = variable_get('ente_planificador_' . $type_node . '_admin_until', $now); |
---|
511 | $header2 = array(); |
---|
512 | $header2[] = array('data' => t('Ambito'), 'sort' => 'asc'); |
---|
513 | $header2[] = array('data' => t('Fecha de Inicio'), 'sort' => 'asc'); |
---|
514 | $header2[] = array('data' => t('Fecha de Fin'), 'sort' => 'asc'); |
---|
515 | $header2[] = array('data' => t('Modificar'), ); |
---|
516 | $row2 = array(); |
---|
517 | $row2[] = t('Ambito Especial'); |
---|
518 | $row2[] = format_date($FIPMA); |
---|
519 | $row2[] = format_date($FFPMA); |
---|
520 | $row2[] = '<br>' . l(t("Mofidicar"), 'fechas_planificacion/ambitos_sector/edit/administrador/'. $type_node , array('html' => true, 'query' => 'destination=fechas_planificacion/edit/ambito/'.$type_node)); |
---|
521 | $rows2[] = $row2; |
---|
522 | if (!count($rows2)) { |
---|
523 | $row2 = array(); |
---|
524 | $row2[] = array('data' => t('No se han establecido Fechas'), 'colspan' => 3); |
---|
525 | $rows2[] = $row; |
---|
526 | $fechas_display = FALSE; |
---|
527 | } |
---|
528 | $aux .= '<h2>' . t('Modificar la fecha de inicio para %proceso para el usuario Administrador', array('%proceso' => $procesos[$type_node]['title'])).'</h2>'; |
---|
529 | $aux .= theme('table', $header2, $rows2); |
---|
530 | } |
---|
531 | if (user_access('admin planificador')) { //si es control |
---|
532 | $FIPMA = variable_get('ente_planificador_' . $type_node . '_control_from', $now); |
---|
533 | $FFPMA = variable_get('ente_planificador_' . $type_node . '_control_until', $now); |
---|
534 | $header3 = array(); |
---|
535 | $header3[] = array('data' => t('Ambito'), 'sort' => 'asc'); |
---|
536 | $header3[] = array('data' => t('Fecha de Inicio'), 'sort' => 'asc'); |
---|
537 | $header3[] = array('data' => t('Fecha de Fin'), 'sort' => 'asc'); |
---|
538 | $header3[] = array('data' => t('Modificar'), ); |
---|
539 | $row3 = array(); |
---|
540 | $row3[] = t('Ambito Especial'); |
---|
541 | $row3[] = format_date($FIPMA); |
---|
542 | $row3[] = format_date($FFPMA); |
---|
543 | $row3[] = '<br>' . l(t("Mofidicar"), 'fechas_planificacion/ambitos_sector/edit/control/'. $type_node , array('html' => true, 'query' => 'destination=fechas_planificacion/edit/ambito/'.$type_node)); |
---|
544 | $rows3[] = $row3; |
---|
545 | if (!count($rows3)) { |
---|
546 | $row3 = array(); |
---|
547 | $row3[] = array('data' => t('No se han establecido Fechas'), 'colspan' => 3); |
---|
548 | $rows3[] = $row; |
---|
549 | $fechas_display = FALSE; |
---|
550 | } |
---|
551 | $aux .= '<h2>' . t('Modificar la fecha de inicio para %proceso para el usuario Control', array('%proceso' => $procesos[$type_node]['title'])).'</h2>'; |
---|
552 | $aux .= theme('table', $header3, $rows3); |
---|
553 | } |
---|
554 | return theme('table', $header, $rows) . $aux; |
---|
555 | } |
---|
556 | } |
---|
557 | |
---|
558 | /* |
---|
559 | * Crea una tabla de opciones para modificar las Fecha de notificacion por sectores |
---|
560 | */ |
---|
561 | function fecha_procesos_sector_notificacion() { |
---|
562 | drupal_set_title(t('Modificar las Fecha de los Procesos por Sectores')); |
---|
563 | $view = FALSE; |
---|
564 | if (user_access('admin planificador')) { |
---|
565 | $view = TRUE; |
---|
566 | } |
---|
567 | $header = array(); |
---|
568 | $header[] = array('data' => t('Listado de los procesos de planificación')); |
---|
569 | $procesos_status = ente_planificador_procesos('status'); |
---|
570 | $procesos = ente_planificador_procesos(); |
---|
571 | $procesos_ordenados = ente_planificador_ordena_procesos($procesos_status, $procesos); |
---|
572 | $procesos_status = $procesos_ordenados['status']; |
---|
573 | $nuevo_proceso = $procesos_ordenados['normal']; |
---|
574 | $rows = array(); |
---|
575 | if (is_array($procesos_status) && count($procesos_status)) { |
---|
576 | foreach ($procesos_status as $id => $valores) { |
---|
577 | $row = array(); |
---|
578 | $row[] = array('data' => '<b>' . $procesos_status[$id]['title'] . '</b>', 'colspan' => 1, 'align' => 'center'); |
---|
579 | $rows[] = $row; |
---|
580 | if (is_array($nuevo_proceso[$id]) && count($nuevo_proceso[$id])) { |
---|
581 | $items = array(); |
---|
582 | $item = array(); |
---|
583 | foreach ($nuevo_proceso[$id] as $type_url_str => $proceso) { |
---|
584 | if ($view) { |
---|
585 | $item[] = array( |
---|
586 | 'data'=> l(t('Modificar la fecha de inicio para %name', array('%name' => $proceso['title'])), 'fechas_planificacion/edit/sector/' . $type_url_str, array('html' => true, 'query' => 'destination=fechas_planificacion/notificacion/sector')), |
---|
587 | ); |
---|
588 | } |
---|
589 | } |
---|
590 | if (sizeof($item)) { |
---|
591 | $items[] = theme('item_list', $item); |
---|
592 | $rows[] = $items; |
---|
593 | } |
---|
594 | else { |
---|
595 | $row[] = array( |
---|
596 | 'data' => t('No se encontrarón Procesos'), |
---|
597 | ); |
---|
598 | } |
---|
599 | } |
---|
600 | } |
---|
601 | } |
---|
602 | if (sizeof($rows)) { |
---|
603 | $output.= '<br>'.theme('table', $header, $rows); |
---|
604 | $output .= theme('pager', NULL); |
---|
605 | } |
---|
606 | else { |
---|
607 | $row[] = array( |
---|
608 | 'data' => t('No se encontrarón Procesos'), |
---|
609 | ); |
---|
610 | } |
---|
611 | return $output; |
---|
612 | } |
---|
613 | |
---|
614 | /* |
---|
615 | * ente_planificador_fecha_planificacion_edit |
---|
616 | * Editar una fecha de planificacion |
---|
617 | */ |
---|
618 | function fecha_procesos_sector_fecha_planificacion_edit($type_node = '') { |
---|
619 | $procesos = ente_planificador_procesos(); |
---|
620 | $view = FALSE; |
---|
621 | if (user_access('admin planificador')) { |
---|
622 | $view = TRUE; |
---|
623 | } |
---|
624 | drupal_set_title(t('Modificar la fecha de inicio para %proceso por Sectores', array('%proceso' => $procesos[$type_node]['title']))); |
---|
625 | if (isset($procesos[$type_node])) { |
---|
626 | $header = array(); |
---|
627 | $header[] = array('data' => t('Sector'), 'sort' => 'asc'); |
---|
628 | $header[] = array('data' => t('Fecha de Inicio'), 'sort' => 'asc'); |
---|
629 | $header[] = array('data' => t('Fecha de Fin'), 'sort' => 'asc'); |
---|
630 | if ($view) { |
---|
631 | $header[] = array('data' => t('Modificar'), ); |
---|
632 | } |
---|
633 | $tid = variable_get('ente_planificador_sector_Ambitos', 0); |
---|
634 | $terms = taxonomy_get_tree($tid); |
---|
635 | foreach ($terms as $term) { |
---|
636 | if ($term->depth == 1) { //si el termino es use sector (nivel 1) |
---|
637 | $fechas[0] = variable_get('ente_planificador_' . $type_node . '_from_'.$term->tid, date('Y/M/D')); |
---|
638 | $fechas[1] = variable_get('ente_planificador_' . $type_node . '_until_'.$term->tid, date('Y/M/D')); |
---|
639 | $row[0] = $term->name; |
---|
640 | $row[1] = format_date($fechas[0]); |
---|
641 | $row[2] = format_date($fechas[1]); |
---|
642 | if ($view) { |
---|
643 | $row[3] = l(t('modificar'), 'fechas_planificacion/sectores/edit/' . $term->tid . '/' . $type_node, array('html' => true, 'query' => 'destination=fechas_planificacion/edit/sector/' . $type_node)); |
---|
644 | } |
---|
645 | $rows[] = array('data' => $row); |
---|
646 | } |
---|
647 | } |
---|
648 | if (!count($rows)) { |
---|
649 | $row = array(); |
---|
650 | $row[] = array('data' => t('No se encontrarón Sectores'), 'colspan' => 3); |
---|
651 | $rows[] = $row; |
---|
652 | $fechas_display = FALSE; |
---|
653 | } |
---|
654 | if (module_exists('proyectos_operativos_mail')) { |
---|
655 | $aux = l(t("Enviar Correo Electrónico a los entes planificadores por Sector Social."), 'fechas_planificacion/notificacion/envia_email/sector/' . $type_node); |
---|
656 | } |
---|
657 | return theme('table', $header, $rows) . $aux; |
---|
658 | } |
---|
659 | } |
---|
660 | |
---|
661 | /** |
---|
662 | * editar las fechas de planificacion por sectores |
---|
663 | */ |
---|
664 | function fecha_procesos_sector_notificacion_edit_form_sectores_planificacion($term = 0, $type_node = '') { |
---|
665 | $procesos = ente_planificador_procesos(); |
---|
666 | if (isset($procesos[$type_node])) { |
---|
667 | return drupal_get_form('fecha_procesos_sector_notificacion_edit_form', $term, $type_node); |
---|
668 | } |
---|
669 | return NULL; |
---|
670 | } |
---|
671 | |
---|
672 | /* |
---|
673 | * Modifica la fecha por sector social |
---|
674 | */ |
---|
675 | function fecha_procesos_sector_notificacion_edit_form(&$form_state, $sector = 0, $type_node = NULL) { |
---|
676 | $procesos = ente_planificador_procesos(); |
---|
677 | $term= taxonomy_get_term($sector); |
---|
678 | drupal_set_title(t('Fecha de Planificación para el Sector %sector', array('%sector' => $term->name))); |
---|
679 | $form = array(); |
---|
680 | $form['fechas'] = array( |
---|
681 | '#type' => 'fieldset', |
---|
682 | '#title' => t(' Modificar la fecha de inicio para %proceso del Sector %sector',array('%proceso' => $procesos[$type_node]['title'], '%sector' => $term->name)), |
---|
683 | '#collapsible' => FALSE, |
---|
684 | '#collapsed' => TRUE, |
---|
685 | ); |
---|
686 | $now = time(); |
---|
687 | $FIPM = variable_get('ente_planificador_' . $type_node . '_from_' . $term->tid); |
---|
688 | $FIPM = $FIPM ? $FIPM : $now; |
---|
689 | $f1 = explode("-", format_date($FIPM, 'custom', 'Y-m-d')); |
---|
690 | settype($f1[0], "integer"); |
---|
691 | settype($f1[1], "integer"); |
---|
692 | settype($f1[2], "integer"); |
---|
693 | |
---|
694 | $FFPM = variable_get('ente_planificador_' . $type_node . '_until_' . $term->tid); |
---|
695 | $FFPM = $FFPM ? $FFPM : $now; |
---|
696 | $f2 = explode("-", format_date($FFPM, 'custom', 'Y-m-d')); |
---|
697 | settype($f2[0], "integer"); |
---|
698 | settype($f2[1], "integer"); |
---|
699 | settype($f2[2], "integer"); |
---|
700 | |
---|
701 | $form['fechas']['from'] = array( |
---|
702 | '#type' => 'date', |
---|
703 | '#title' => t('Fecha de Inicio'), |
---|
704 | '#default_value' => array( |
---|
705 | 'day' => $f1[2], |
---|
706 | 'month' => $f1[1], |
---|
707 | 'year' => $f1[0], |
---|
708 | ), |
---|
709 | '#description' => t('Seleccione la fecha de inicio'), |
---|
710 | ); |
---|
711 | $form['fechas']['until'] = array( |
---|
712 | '#type' => 'date', |
---|
713 | '#title' => t('Fecha de Culminación'), |
---|
714 | '#default_value' => array( |
---|
715 | 'day' => $f2[2], |
---|
716 | 'month' => $f2[1], |
---|
717 | 'year' => $f2[0], |
---|
718 | ), |
---|
719 | '#description' => t('Seleccione la fecha de culminación'), |
---|
720 | ); |
---|
721 | $form['fechas']['term'] = array( |
---|
722 | '#type' => 'hidden', |
---|
723 | '#default_value' => $term->tid, |
---|
724 | ); |
---|
725 | $form['fechas']['proceso'] = array( |
---|
726 | '#type' => 'hidden', |
---|
727 | '#default_value' => $type_node, |
---|
728 | ); |
---|
729 | $form['submit'] = array( |
---|
730 | '#type' => 'submit', |
---|
731 | '#default_value' => t("Guardar"), |
---|
732 | '#validate' => array('ente_planificador_sector_fecha_planificacion_edit_notificacion_validate'), |
---|
733 | '#submit' => array('fecha_procesos_sector_notificacion_edit_form_submit'), |
---|
734 | ); |
---|
735 | $enlace = base_path() . 'fechas_planificacion'; |
---|
736 | $form['cancel'] = array( |
---|
737 | '#type' => 'submit', |
---|
738 | '#weight'=>'8615', |
---|
739 | '#attributes' => array('onClick' => 'window.location="' . $enlace . '"; return false;'), |
---|
740 | '#value' => t('Cancel'), |
---|
741 | ); |
---|
742 | return $form; |
---|
743 | } |
---|
744 | |
---|
745 | /* |
---|
746 | * ente_planificador_fecha_planificacion_edit_notificacion_validate |
---|
747 | * Validar la informacion de modificar las fechas de notificacion de planificacion |
---|
748 | */ |
---|
749 | function ente_planificador_sector_fecha_planificacion_edit_notificacion_validate($form, &$form_state){ |
---|
750 | $fi = mktime( |
---|
751 | 0, |
---|
752 | 0, |
---|
753 | 0, |
---|
754 | $form_state['values']['from']['month'], |
---|
755 | $form_state['values']['from']['day'], |
---|
756 | $form_state['values']['from']['year'] |
---|
757 | ); |
---|
758 | $ff = mktime( |
---|
759 | 0, |
---|
760 | 0, |
---|
761 | 0, |
---|
762 | $form_state['values']['until']['month'], |
---|
763 | $form_state['values']['until']['day'], |
---|
764 | $form_state['values']['until']['year'] |
---|
765 | ); |
---|
766 | $term = $form_state['values']['term']; |
---|
767 | $proceso = $form_state['values']['proceso']; |
---|
768 | $term = taxonomy_get_term($term); |
---|
769 | $fathers = taxonomy_get_parents($term->tid); |
---|
770 | $tipo = 'Sector Social'; |
---|
771 | foreach ($fathers as $tid => $terms) { |
---|
772 | $father = $terms; |
---|
773 | $tipo = 'Ambito'; |
---|
774 | } |
---|
775 | if ($fi > $ff) { |
---|
776 | form_set_error('from', |
---|
777 | t('La fecha de notificación (@fi) para el ' . $tipo . ' %sector debe ser Menor a la fecha de culminación (@ff)', array( |
---|
778 | '@fi' => format_date($fi, 'custom', 'Y-m-d'), |
---|
779 | '%sector' => $term->name, |
---|
780 | '@ff' => format_date($ff, 'custom', 'Y-m-d'), |
---|
781 | )) |
---|
782 | ); |
---|
783 | } |
---|
784 | if ($father) { |
---|
785 | $FIPMI = variable_get('ente_planificador_' . $proceso . '_all_from_' . $father->tid); |
---|
786 | $FIPMF = variable_get('ente_planificador_' . $proceso . '_all_until_' . $father->tid); |
---|
787 | if ($fi < $FIPMI) { |
---|
788 | form_set_error('from', |
---|
789 | t('La fecha de notificación para el sector %sector (@fi_s) debe ser Mayor a la fecha de notificación del ambito %ambito (@fi_a)', array( |
---|
790 | '%sector' => $term->name, |
---|
791 | '@fi_s' => format_date($fi, 'custom', 'Y-m-d'), |
---|
792 | '%ambito' => $father->name, |
---|
793 | '@fi_a' => format_date($FIPMI, 'custom', 'Y-m-d'), |
---|
794 | )) |
---|
795 | ); |
---|
796 | } |
---|
797 | if ($ff > $FIPMF) { |
---|
798 | form_set_error('until', |
---|
799 | t('La fecha de notificación para el sector %sector (@ff_s) debe ser Menor a la fecha de notificación del ambito %ambito (@ff_a)', array( |
---|
800 | '%sector' => $term->name, |
---|
801 | '@ff_s' => format_date($ff, 'custom', 'Y-m-d'), |
---|
802 | '%ambito' => $father->name, |
---|
803 | '@ff_a' => format_date($FIPMF, 'custom', 'Y-m-d'), |
---|
804 | )) |
---|
805 | ); |
---|
806 | } |
---|
807 | } |
---|
808 | } |
---|
809 | |
---|
810 | /* |
---|
811 | * agrega las fechas de planificacion por sectores |
---|
812 | */ |
---|
813 | function fecha_procesos_sector_notificacion_edit_form_submit($form, &$form_state) { |
---|
814 | $fi = mktime( |
---|
815 | 0, |
---|
816 | 0, |
---|
817 | 0, |
---|
818 | $form_state['values']['from']['month'], |
---|
819 | $form_state['values']['from']['day'], |
---|
820 | $form_state['values']['from']['year'] |
---|
821 | ); |
---|
822 | $ff = mktime( |
---|
823 | 0, |
---|
824 | 0, |
---|
825 | 0, |
---|
826 | $form_state['values']['until']['month'], |
---|
827 | $form_state['values']['until']['day'], |
---|
828 | $form_state['values']['until']['year'] |
---|
829 | ); |
---|
830 | $term = $form_state['values']['term']; |
---|
831 | $term = taxonomy_get_term($term); |
---|
832 | $proceso = $form_state['values']['proceso']; |
---|
833 | variable_set('ente_planificador_' . $proceso . '_from_' . $term->tid, $fi); |
---|
834 | variable_set('ente_planificador_' . $proceso . '_until_' . $term->tid, $ff); |
---|
835 | drupal_set_message(t('Se han guardado los cambios para el Sector %sector' , array('%sector' => $term->name))); |
---|
836 | } |
---|
837 | |
---|
838 | /* |
---|
839 | * Impletations of hook_form_alter() |
---|
840 | */ |
---|
841 | function ente_planificador_sector_form_alter(&$form, $form_state, $form_id) { |
---|
842 | if (($form_id == 'views_exposed_form') && ($form['#id'] == 'views-exposed-form-lista-de-los-actores-planificado-page-1')) { |
---|
843 | global $user; |
---|
844 | if ($form['ambito'] && ($ente_planificador->tipo == 1)) { |
---|
845 | $rolesa = variable_get('roles_exclude_ambito', 0); |
---|
846 | if ($rolesa) { |
---|
847 | foreach ($rolesa as $keya => $rola) { |
---|
848 | if (($user->roles[$keya])) { |
---|
849 | $form['#info']['filter-ambito']['label'] = t('Ambito del ente Planificador'); |
---|
850 | $form['ambito']['#access'] = 1; |
---|
851 | } |
---|
852 | else { |
---|
853 | $form['#info']['filter-ambito']['label'] = 0; |
---|
854 | $form['ambito']['#access'] = 0; |
---|
855 | } |
---|
856 | } |
---|
857 | } |
---|
858 | } |
---|
859 | global $user; |
---|
860 | $ente_planificador = node_load($user->entes); |
---|
861 | if ($form['organismo'] && ($ente_planificador->tipo == 2)) { |
---|
862 | $roles2 = variable_get('roles_exclude_organismo', 0); |
---|
863 | if ($roles2) { |
---|
864 | foreach ($roles2 as $key2 => $rol2) { |
---|
865 | if ($user->roles[$key2]) { |
---|
866 | $form['#info']['filter-organismo']['label'] = 0; |
---|
867 | $form['organismo']['#access'] = 0; |
---|
868 | $form['#info']['filter-sector']['label'] = 0; |
---|
869 | $form['sector']['#access'] = 0; |
---|
870 | $form['#info']['filter-sub_sector']['label'] = 0; |
---|
871 | $form['sub_sector']['#access'] = 0; |
---|
872 | $form['#info']['filter-ambito']['label'] = 0; |
---|
873 | $form['ambito']['#access'] = 0; |
---|
874 | } |
---|
875 | } |
---|
876 | } |
---|
877 | } |
---|
878 | if ($form['sector'] && ($ente_planificador->tipo == 1)) { |
---|
879 | $roless = variable_get('roles_exclude_sector_social', 0); |
---|
880 | if ($roless) { |
---|
881 | foreach ($roless as $keys => $rols) { |
---|
882 | if (($user->roles[$keys])) { |
---|
883 | $form['#info']['filter-sector']['label'] = t('Sector Social del Ente Planificador'); |
---|
884 | $form['sector']['#access'] = 1; |
---|
885 | } |
---|
886 | } |
---|
887 | } |
---|
888 | } |
---|
889 | if ($form['sub_sector'] && ($ente_planificador->tipo == 1)) { |
---|
890 | $roless = variable_get('roles_exclude_sub_sector_social', 0); |
---|
891 | if ($rolesb) { |
---|
892 | foreach ($rolesb as $keysb => $rolsb) { |
---|
893 | if (($user->roles[$keysb])) { |
---|
894 | $form['#info']['filter-sub_sector']['label'] = t('Sub-Sector Social del Ente Planificador'); |
---|
895 | $form['sub_sector']['#access'] = 1; |
---|
896 | } |
---|
897 | } |
---|
898 | } |
---|
899 | } |
---|
900 | } |
---|
901 | |
---|
902 | if ($form_id == "proyectos_operativos_admin_settings") { |
---|
903 | $options = array( |
---|
904 | 'ambito' => t('Fechas por Ambitos'), |
---|
905 | 'sector' => t('Fechas por Sector Social'), |
---|
906 | ); |
---|
907 | $form['days']['ente_planificador_sector_optiones_fecha'] = array( |
---|
908 | '#type' => 'radios', |
---|
909 | '#title' => t('Tipo de Fechas de Proceso de Planificación'), |
---|
910 | '#description' => t('Seleccione la Opción para establecer las fechas de los procesos de Planificación'), |
---|
911 | '#options' => $options, |
---|
912 | '#required' => 1, |
---|
913 | '#default_value' => variable_get('ente_planificador_sector_optiones_fecha', 'ambito'), |
---|
914 | ); |
---|
915 | } |
---|
916 | if ($form_id == "ente_planificador_node_form") { |
---|
917 | drupal_add_js(drupal_get_path('module', 'ente_planificador_sector') . '/js/ente_planificador_sector.js'); |
---|
918 | |
---|
919 | //anadiendo el campo nivel de planificacion |
---|
920 | $nivel_planificacion = ente_planificador_sector_nivel_planificacion(); |
---|
921 | //SOLO DEJE A UN ENTE SER ENTE PLANIFICADOR MACRO |
---|
922 | if (db_result(db_query("SELECT nid FROM {ente_planificador} where tipo = '1'")) > 0) { |
---|
923 | unset($nivel_planificacion[1]); |
---|
924 | } |
---|
925 | $default = array(0); |
---|
926 | if ($form['#node']->nid) { |
---|
927 | $nid = $form['#node']->nid; |
---|
928 | $query =db_query("SELECT tipo FROM {ente_planificador} WHERE nid = %d", $nid); |
---|
929 | $entes = db_fetch_object($query); |
---|
930 | $default = $entes->tipo; |
---|
931 | } |
---|
932 | $form['nivel'] = array( |
---|
933 | '#type' => 'fieldset', |
---|
934 | '#prefix' => '<div id="ente-planificador-sector-wrapper">', |
---|
935 | '#suffix' => '</div>', |
---|
936 | ); |
---|
937 | $form['tipo'] = array( |
---|
938 | '#type' => 'select', |
---|
939 | '#title' => t('Nivel de Planificación'), |
---|
940 | '#default_value' => $default, |
---|
941 | '#options' => $nivel_planificacion, |
---|
942 | '#description' => t("Seleccione el nivel de Planificación en el que se encuentra el Ente Planificador."), |
---|
943 | '#required' => TRUE, |
---|
944 | '#weight' => -1, |
---|
945 | '#ahah' => array( |
---|
946 | 'event' => 'change', |
---|
947 | 'path' => 'ente_planificador_sector_util', |
---|
948 | 'wrapper' => 'ente-planificador-sector-wrapper', |
---|
949 | 'method' => 'replace', |
---|
950 | 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), |
---|
951 | ), |
---|
952 | '#prefix' => '<div id="nivel">', |
---|
953 | '#suffix' => '</div>', |
---|
954 | ); |
---|
955 | |
---|
956 | //anadiendo el campo sector |
---|
957 | $options = array(); |
---|
958 | if ($form['#node']->nid) { |
---|
959 | $nid = $form['#node']->nid; |
---|
960 | $query = db_query("SELECT sector FROM {ente_planificador} WHERE nid = %d", $nid); |
---|
961 | $entes = db_fetch_object($query); |
---|
962 | $default = $entes->sector; |
---|
963 | } |
---|
964 | $tid = variable_get('ente_planificador_sector_Ambitos', 0); |
---|
965 | $terms = taxonomy_get_tree($tid); |
---|
966 | $options['0']= "seleccione"; |
---|
967 | foreach ($terms as $term) { |
---|
968 | if ($term->depth == 1) { //si el termino es padre |
---|
969 | $options[$term->tid] .= $term->name; |
---|
970 | } |
---|
971 | } |
---|
972 | $form['nivel']['sector'] = array( |
---|
973 | '#type' => 'select', |
---|
974 | '#title' => t('Sector Social'), |
---|
975 | '#default_value' => $default, |
---|
976 | '#required' => TRUE, |
---|
977 | '#options' => $options, |
---|
978 | '#prefix' => '<div id="sector_ente_planificador">', |
---|
979 | '#suffix' => '</div>', |
---|
980 | ); |
---|
981 | //anadiendo el campo organismos_publicos |
---|
982 | $options = array(); |
---|
983 | $options[0] = "seleccione"; |
---|
984 | $tid = variable_get('ente_planificador_sector_organismos', 0); |
---|
985 | $terms = taxonomy_get_tree($tid); |
---|
986 | $default = 0; |
---|
987 | if ($form['#node']->nid) { |
---|
988 | $default = db_result(db_query("SELECT organismo FROM {ente_planificador} WHERE nid = %d", $form['#node']->nid)); |
---|
989 | } |
---|
990 | foreach ($terms as $term) { |
---|
991 | $options[$term->tid] = $term->name; |
---|
992 | } |
---|
993 | $form['nivel']['ente_adscrito'] = array( |
---|
994 | '#type' => 'select', |
---|
995 | '#title' => t('Organismo Publico al que se esta adscrito'), |
---|
996 | '#default_value' => $default, |
---|
997 | '#required' => TRUE, |
---|
998 | '#options' => $options, |
---|
999 | '#prefix' => '<div id="organismo">', |
---|
1000 | '#suffix' => '</div>', |
---|
1001 | ); |
---|
1002 | //anadiendo el campo sub-ente |
---|
1003 | $options = array(); |
---|
1004 | $options['0']= "seleccione"; |
---|
1005 | $result = db_query("SELECT n.nid, n.title FROM {node} AS n INNER JOIN {ente_planificador} AS e ON n.nid = e.nid WHERE e.ente_adscrito != 0"); |
---|
1006 | while ($rows = db_fetch_object($result)) { |
---|
1007 | $options[$rows->nid] = $rows->title; |
---|
1008 | } |
---|
1009 | $default = 0; |
---|
1010 | if ($form['#node']->nid) { |
---|
1011 | $default = db_result(db_query("SELECT sub_ente FROM {ente_planificador} WHERE nid = %d", $form['#node']->nid)); |
---|
1012 | } |
---|
1013 | $form['nivel']['sub_ente'] = array( |
---|
1014 | '#type' => 'select', |
---|
1015 | '#title' => t('Ente al cual se esta adscrito'), |
---|
1016 | '#default_value' => $default, |
---|
1017 | '#required' => TRUE, |
---|
1018 | '#options' => $options, |
---|
1019 | '#prefix' => '<div id="sub_ente">', |
---|
1020 | '#suffix' => '</div>', |
---|
1021 | ); |
---|
1022 | } |
---|
1023 | /*if ($form_id == 'ente_planificador_datos_basicos_forma') { |
---|
1024 | //anadiendo el campo sector |
---|
1025 | $options = array(); |
---|
1026 | $tid = variable_get('ente_planificador_sector_Ambitos', 0); |
---|
1027 | $terms = taxonomy_get_tree($tid); |
---|
1028 | $options['0']= "seleccione"; |
---|
1029 | foreach ($terms as $term) { |
---|
1030 | if ($term->depth == 1) { //si el termino es padre |
---|
1031 | $options[$term->tid] .= $term->name; |
---|
1032 | } |
---|
1033 | } |
---|
1034 | $ente_planificador = NULL; |
---|
1035 | $nid = $form['ente_planificador_nid']['#default_value']; |
---|
1036 | if (is_numeric($nid)) { |
---|
1037 | $ente_planificador = ente_planificador_leer_ente_planificadores($nid); |
---|
1038 | } |
---|
1039 | if ($ente_planificador && $ente_planificador->tipo == 2) { |
---|
1040 | $form['nivel'] = array( |
---|
1041 | '#type' => 'fieldset', |
---|
1042 | '#prefix' => '<div id="ente-planificador-sector-wrapper">', |
---|
1043 | '#suffix' => '</div>', |
---|
1044 | ); |
---|
1045 | $form['nivel']['sector'] = array( |
---|
1046 | '#type' => 'select', |
---|
1047 | '#title' => t('Sector Social'), |
---|
1048 | '#default_value' => $ente_planificador->sector, |
---|
1049 | '#required' => TRUE, |
---|
1050 | '#options' => $options, |
---|
1051 | '#prefix' => '<div id="sector_ente_planificador">', |
---|
1052 | '#suffix' => '</div>', |
---|
1053 | ); |
---|
1054 | $form['#submit'][] = 'ente_planificador_sector_datos_basicos_forma_submit'; |
---|
1055 | } |
---|
1056 | }*/ |
---|
1057 | } |
---|
1058 | |
---|
1059 | /** |
---|
1060 | * |
---|
1061 | * |
---|
1062 | function ente_planificador_sector_datos_basicos_forma_submit($form, &$form_state) { |
---|
1063 | $terms = taxonomy_get_parents($form_state['values']['sector']); |
---|
1064 | foreach ($terms as $tid => $term) { |
---|
1065 | $tid = $term->tid; |
---|
1066 | } |
---|
1067 | $node_load = node_load($form_state['values']['ente_planificador_nid']); |
---|
1068 | if ($tid) { |
---|
1069 | $node_load->ambito = $tid; |
---|
1070 | $node_load->sector = $form_state['values']['sector']; |
---|
1071 | $node_load->revision = 1; |
---|
1072 | node_save($node_load); |
---|
1073 | } |
---|
1074 | }*/ |
---|
1075 | |
---|
1076 | /* |
---|
1077 | * Agregar los ambitos |
---|
1078 | */ |
---|
1079 | function ente_planificador_sector_form_ambito(&$form_state) { |
---|
1080 | $form = array(); |
---|
1081 | $form['ente_planificador'] = array( |
---|
1082 | '#type' => 'fieldset', |
---|
1083 | '#title' => t('Configuración del Ambito'), |
---|
1084 | '#collapsible' => TRUE, |
---|
1085 | '#collapsed' => FALSE, |
---|
1086 | ); |
---|
1087 | $form['ente_planificador']['ente_planificador_ambito'] = array( |
---|
1088 | '#type' => 'textfield', |
---|
1089 | '#title' => t('Nombre del Ambito'), |
---|
1090 | '#required' => TRUE, |
---|
1091 | ); |
---|
1092 | //lista de ambitos |
---|
1093 | $header = array(); |
---|
1094 | $header[] = array('data' => t('Lista por Ambitos'), 'colspan' => 3); |
---|
1095 | $tid = variable_get('ente_planificador_sector_Ambitos', 0); |
---|
1096 | $terms = taxonomy_get_tree($tid); |
---|
1097 | foreach ($terms as $term) { |
---|
1098 | $row = array(); |
---|
1099 | $items = array(); |
---|
1100 | $item = array(); |
---|
1101 | $hij = 0; |
---|
1102 | $hijos = taxonomy_get_children($term->tid, $term->vid); |
---|
1103 | foreach ($hijos as $hijo) { |
---|
1104 | $hij = 1; |
---|
1105 | } |
---|
1106 | if ($hij == 1) { |
---|
1107 | if ($term->depth == 0) { //si el termino es padre (AMBITO) |
---|
1108 | $row[] = array('data' => '<b>' . l(t($term->name), 'admin/settings/ente_planificador/lista_sectores/'.$term->tid, array('html' => true, 'query' => 'destination=lista_ambitos_y_sectores_asociados')) . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1109 | $row[] = array('data' => '<b>' . l(t('Consultar Sectores'), 'admin/settings/ente_planificador/lista_sectores/'.$term->tid, array('html' => true, 'query' => 'destination=lista_ambitos_y_sectores_asociados')) . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1110 | } |
---|
1111 | } |
---|
1112 | else { |
---|
1113 | if ($term->depth == 0) { //si el termino es padre (AMBITO) |
---|
1114 | $row[] = array('data' => '<b>' . t($term->name) . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1115 | $row[] = array('data' => '<b>' . t('No posee Sectores asociados') . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1116 | } |
---|
1117 | } |
---|
1118 | $rows[] = $row; |
---|
1119 | if (sizeof($item)) { |
---|
1120 | $items[] = theme('item_list', $item); |
---|
1121 | $rows[] = $items; |
---|
1122 | } |
---|
1123 | else { |
---|
1124 | $row[] = array( |
---|
1125 | 'data' => t('No se encontrarón Sectores Asociados'), |
---|
1126 | ); |
---|
1127 | } |
---|
1128 | } |
---|
1129 | if (sizeof($rows)) { |
---|
1130 | $output.= '<br>'.theme('table', $header, $rows); |
---|
1131 | $output .= theme('pager', NULL); |
---|
1132 | } |
---|
1133 | else { |
---|
1134 | $output.= '<p>' . t('No se encontrarón Ambitos Registrados') .'</p>'; |
---|
1135 | } |
---|
1136 | $form['ente_planificador']['marcador'] = array( |
---|
1137 | '#value' => $output, |
---|
1138 | ); |
---|
1139 | $form['submit'] = array( |
---|
1140 | '#type' => 'submit', |
---|
1141 | '#default_value' => t("Guardar"), |
---|
1142 | ); |
---|
1143 | return $form; |
---|
1144 | } |
---|
1145 | |
---|
1146 | /* |
---|
1147 | * Agregar los sectores |
---|
1148 | */ |
---|
1149 | function ente_planificador_sector_form_sector(&$form_state) { |
---|
1150 | $form = array(); |
---|
1151 | $form['ente_planificador'] = array( |
---|
1152 | '#type' => 'fieldset', |
---|
1153 | '#title' => t('Configuración del Sector'), |
---|
1154 | '#collapsible' => TRUE, |
---|
1155 | '#collapsed' => FALSE, |
---|
1156 | ); |
---|
1157 | $form['ente_planificador']['sector'] = array( |
---|
1158 | '#type' => 'textfield', |
---|
1159 | '#title' => t('Nombre del Sector'), |
---|
1160 | '#description' => t('Nombre del sector al que pertenece el ambito.'), |
---|
1161 | '#required' => TRUE, |
---|
1162 | ); |
---|
1163 | $form['ente_planificador']['tid'] = array( |
---|
1164 | '#type' => 'hierarchical_select', |
---|
1165 | '#config' => array( |
---|
1166 | 'module' => 'hs_content_taxonomy', |
---|
1167 | 'params' => array( |
---|
1168 | 'vid' => variable_get('ente_planificador_sector_Ambitos', 0), |
---|
1169 | 'tid' => 0, |
---|
1170 | 'depth' => 1, |
---|
1171 | ), |
---|
1172 | 'level_labels' => array( |
---|
1173 | 'status' => 1, |
---|
1174 | 'labels' => array( |
---|
1175 | 0 => t('Ambito'), |
---|
1176 | ), |
---|
1177 | ), |
---|
1178 | ), |
---|
1179 | '#required' => TRUE, |
---|
1180 | '#description' => t('Nombre del ambito al que pertenece el sector.'), |
---|
1181 | ); |
---|
1182 | |
---|
1183 | $header = array(); |
---|
1184 | $header[] = array('data' => t('Lista por Ambitos'), 'colspan' => 3); |
---|
1185 | $tid = variable_get('ente_planificador_sector_Ambitos', 0); |
---|
1186 | $terms = taxonomy_get_tree($tid); |
---|
1187 | foreach ($terms as $term) { |
---|
1188 | $row = array(); |
---|
1189 | $items = array(); |
---|
1190 | $item = array(); |
---|
1191 | $hij = 0; |
---|
1192 | $hijos = taxonomy_get_children($term->tid, $term->vid); |
---|
1193 | foreach ($hijos as $hijo) { |
---|
1194 | $hij = 1; |
---|
1195 | } |
---|
1196 | if ($hij == 1) { |
---|
1197 | if ($term->depth == 0) { //si el termino es padre (AMBITO) |
---|
1198 | $row[] = array('data' => '<b>' . l(t($term->name), 'admin/settings/ente_planificador/lista_sectores/'.$term->tid, array('html' => true, 'query' => 'destination=lista_ambitos_y_sectores_asociados')) . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1199 | $row[] = array('data' => '<b>' . l(t('Consultar Sectores'), 'admin/settings/ente_planificador/lista_sectores/'.$term->tid, array('html' => true, 'query' => 'destination=lista_ambitos_y_sectores_asociados')) . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1200 | } |
---|
1201 | } |
---|
1202 | else { |
---|
1203 | if ($term->depth == 0) { //si el termino es padre (AMBITO) |
---|
1204 | $row[] = array('data' => '<b>' . t($term->name) . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1205 | $row[] = array('data' => '<b>' . t('No posee Sectores asociados') . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1206 | } |
---|
1207 | } |
---|
1208 | $rows[] = $row; |
---|
1209 | if (sizeof($item)) { |
---|
1210 | $items[] = theme('item_list', $item); |
---|
1211 | $rows[] = $items; |
---|
1212 | } |
---|
1213 | else { |
---|
1214 | $row[] = array( |
---|
1215 | 'data' => t('No se encontrarón Sectores Asociados'), |
---|
1216 | ); |
---|
1217 | } |
---|
1218 | } |
---|
1219 | if (sizeof($rows)) { |
---|
1220 | $output.= '<br>'.theme('table', $header, $rows); |
---|
1221 | $output .= theme('pager', NULL); |
---|
1222 | } |
---|
1223 | else { |
---|
1224 | $output.= '<p>' . t('No se encontrarón Ambitos Registrados') .'</p>'; |
---|
1225 | } |
---|
1226 | $form['ente_planificador']['marcador'] = array( |
---|
1227 | '#value' => $output, |
---|
1228 | ); |
---|
1229 | $form['submit'] = array( |
---|
1230 | '#type' => 'submit', |
---|
1231 | '#default_value' => t("Guardar"), |
---|
1232 | '#submit' => array('ente_planificador_sector_form_sectores_submit'), |
---|
1233 | ); |
---|
1234 | return $form; |
---|
1235 | } |
---|
1236 | |
---|
1237 | |
---|
1238 | /** |
---|
1239 | * Implementation of ente_planificador_agregar_ambitos_form_submit(). |
---|
1240 | * Save ambitos values |
---|
1241 | */ |
---|
1242 | function ente_planificador_sector_form_ambito_submit($form, &$form_state) { |
---|
1243 | $vocabulary = taxonomy_vocabulary_load(variable_get('ente_planificador_sector_Ambitos', 0)); |
---|
1244 | $term1 = array( |
---|
1245 | 'vid' => $vocabulary->vid, // Voacabulary ID |
---|
1246 | 'name' => check_plain($form_state['values']['ente_planificador_ambito']), // Term Name |
---|
1247 | ); |
---|
1248 | taxonomy_save_term($term1); |
---|
1249 | drupal_set_message(t('El Ambito %ambito ha sido agregado', array('%ambito' => $tem1->name))); |
---|
1250 | $form_state['redirect'] = 'admin/settings/ente_planificador/agregar_ambitos'; |
---|
1251 | } |
---|
1252 | |
---|
1253 | /* |
---|
1254 | * Lista todas los ambitos y sectores asociados |
---|
1255 | */ |
---|
1256 | function ente_planificador_sector_lista_ambito() { |
---|
1257 | drupal_set_title(t('Lista de ambitos')); |
---|
1258 | $view = FALSE; |
---|
1259 | if (user_access('admin planificador')) { |
---|
1260 | $view = TRUE; |
---|
1261 | } |
---|
1262 | $header = array(); |
---|
1263 | $header[] = array('data' => t('Lista por Ambitos'), 'colspan' => 3); |
---|
1264 | $procesos_status = ente_planificador_procesos('status'); |
---|
1265 | $procesos = ente_planificador_procesos(); |
---|
1266 | $procesos_ordenados = ente_planificador_ordena_procesos($procesos_status, $procesos); |
---|
1267 | $procesos_status = $procesos_ordenados['status']; |
---|
1268 | $nuevo_proceso = $procesos_ordenados['normal']; |
---|
1269 | $tid = variable_get('ente_planificador_sector_Ambitos', 0); |
---|
1270 | $terms = taxonomy_get_tree($tid); |
---|
1271 | foreach ($terms as $term) { |
---|
1272 | $row = array(); |
---|
1273 | $items = array(); |
---|
1274 | $item = array(); |
---|
1275 | $hij = 0; |
---|
1276 | $hijos = taxonomy_get_children($term->tid, $term->vid); |
---|
1277 | foreach ($hijos as $hijo) { |
---|
1278 | $hij = 1; |
---|
1279 | } |
---|
1280 | if ($hij == 1) { |
---|
1281 | if ($term->depth == 0) { //si el termino es padre (AMBITO) |
---|
1282 | $row[] = array('data' => '<b>' . l(t($term->name), 'admin/settings/ente_planificador/lista_sectores/' . $term->tid, array('html' => true, 'query' => 'destination=lista_ambitos_y_sectores_asociados')) . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1283 | $row[] = array('data' => '<b>' . l(t('Consultar Sectores'), 'admin/settings/ente_planificador/lista_sectores/' . $term->tid, array('html' => true, 'query' => 'destination=lista_ambitos_y_sectores_asociados')) . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1284 | $row[] = array('data' => l(t('Modificar Ambito'), 'admin/content/taxonomy/edit/term/' . $term->tid, array('html' => true, 'query' => 'destination=lista_ambitos_y_sectores_asociados')) . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1285 | } |
---|
1286 | } |
---|
1287 | else { |
---|
1288 | if ($term->depth == 0) { //si el termino es padre (AMBITO) |
---|
1289 | $row[] = array('data' => '<b>' . t($term->name) . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1290 | $row[] = array('data' => '<b>' . t('No posee Sectores asociados') . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1291 | $row[] = array('data' => l(t('Modificar Ambito'), 'admin/content/taxonomy/edit/term/' . $term->tid, array('html' => true, 'query' => 'destination=lista_ambitos_y_sectores_asociados')) . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1292 | } |
---|
1293 | } |
---|
1294 | $rows[] = $row; |
---|
1295 | if (sizeof($item)) { |
---|
1296 | $items[] = theme('item_list', $item); |
---|
1297 | $rows[] = $items; |
---|
1298 | } |
---|
1299 | else { |
---|
1300 | $row[] = array( |
---|
1301 | 'data' => t('No se encontrarón Sectores Asociados'), |
---|
1302 | ); |
---|
1303 | } |
---|
1304 | } |
---|
1305 | if (sizeof($rows)) { |
---|
1306 | $output.= '<br>'.theme('table', $header, $rows); |
---|
1307 | $output .= theme('pager', NULL); |
---|
1308 | } |
---|
1309 | else { |
---|
1310 | $output.= '<p>' . t('No se encontrarón Ambitos Registrados') .'</p>'; |
---|
1311 | } |
---|
1312 | return $output; |
---|
1313 | } |
---|
1314 | |
---|
1315 | /* |
---|
1316 | * Lista todas los ambitos y sectores asociados |
---|
1317 | */ |
---|
1318 | function ente_planificador_sector_lista_sectores($ambito = 0) { |
---|
1319 | $view = FALSE; |
---|
1320 | if (user_access('admin planificador')) { |
---|
1321 | $view = TRUE; |
---|
1322 | } |
---|
1323 | $term = taxonomy_get_term($ambito); |
---|
1324 | drupal_set_title(t("Lista de Sectores asociados al ambito %ambito", array('%ambito' => $term->name))); |
---|
1325 | $terms = taxonomy_get_children($term->tid, $term->vid); |
---|
1326 | $header = array(); |
---|
1327 | $header[] = array('data' => t('Lista de los Sectores Asociados al Ambito '. $term->name), 'colspan' => 2, 'align' => 'center'); |
---|
1328 | |
---|
1329 | foreach ($terms as $term) { |
---|
1330 | $row = array(); |
---|
1331 | $items = array(); |
---|
1332 | $item = array(); |
---|
1333 | $hij = 0; |
---|
1334 | $hijos = taxonomy_get_children($term->tid, $term->vid); |
---|
1335 | foreach ($hijos as $hijo) { //anadiendo los hijos del sector |
---|
1336 | $item[] = array( |
---|
1337 | 'data'=> t('%sector', array('%sector' => $hijo->name)), |
---|
1338 | ); |
---|
1339 | $hij = 1; |
---|
1340 | } |
---|
1341 | if ($hij == 0) { //no posee hijos |
---|
1342 | $row[] = array('data' => '<b>' . t($term->name) . theme('item_list', $item) . '</b>' , 'colspan' => 1, 'align' => 'left'); |
---|
1343 | } |
---|
1344 | else { |
---|
1345 | $row[] = array('data' => '<b>' . l(t($term->name) . theme('item_list', $item), 'admin/settings/ente_planificador/lista_sectores/'.$term->tid, array('html' => true, 'query' => 'destination=lista_ambitos_y_sectores_asociados')) . '</b>' , 'colspan' => 1, 'align' => 'left'); |
---|
1346 | } |
---|
1347 | $row[] = array('data' => '<b>' . l(t('Modificar Sector'), 'admin/content/taxonomy/edit/term/'.$term->tid, array('html' => true, 'query' => 'destination=admin/settings/ente_planificador/lista_sectores/'.$ambito)) . '</b>', 'colspan' => 1, 'align' => 'left'); |
---|
1348 | $rows[] = $row; |
---|
1349 | } |
---|
1350 | if (sizeof($rows)) { |
---|
1351 | $output.= '<br>'.theme('table', $header, $rows); |
---|
1352 | $output .= theme('pager', NULL); |
---|
1353 | } |
---|
1354 | else { |
---|
1355 | $output.= '<p>' . t('No se encontrarón Sectores Registrados') .'</p>'; |
---|
1356 | } |
---|
1357 | return $output; |
---|
1358 | } |
---|
1359 | |
---|
1360 | /** |
---|
1361 | * Implementation of ente_planificador_agregar_ambitos_form_submit(). |
---|
1362 | * Save ambitos values |
---|
1363 | */ |
---|
1364 | function ente_planificador_sector_form_sectores_submit($form, &$form_state) { |
---|
1365 | $tems = taxonomy_get_term($form_state['values']['tid']); |
---|
1366 | $vocabulary = taxonomy_vocabulary_load(variable_get('ente_planificador_sector_Ambitos', 0)); |
---|
1367 | $tems = taxonomy_get_term($tems->tid); |
---|
1368 | $term1 = array( |
---|
1369 | 'vid' => $vocabulary->vid, // Voacabulary ID |
---|
1370 | 'name' => check_plain($form_state['values']['sector']), |
---|
1371 | 'parent' => array($tems->tid), |
---|
1372 | ); |
---|
1373 | taxonomy_save_term($term1); |
---|
1374 | drupal_set_message(t('El Ambito %ambito y los sectores han sido agregados', array('%ambito' => $tem1->name))); |
---|
1375 | $form_state['redirect'] = 'admin/settings/ente_planificador/agregar_sectores'; |
---|
1376 | } |
---|
1377 | |
---|
1378 | /** |
---|
1379 | * Implementation of hook_views_api(). |
---|
1380 | */ |
---|
1381 | function ente_planificador_sector_views_api() { |
---|
1382 | return array( |
---|
1383 | 'api' => '2.0', |
---|
1384 | 'path' => drupal_get_path('module', 'ente_planificador_sector') . '/includes/views', |
---|
1385 | ); |
---|
1386 | } |
---|
1387 | |
---|
1388 | /* |
---|
1389 | * Implementation of hook_nodeapi() |
---|
1390 | */ |
---|
1391 | function ente_planificador_sector_nodeapi(&$node, $op, $arg = 0) { |
---|
1392 | //tipo de contenido ente planificador |
---|
1393 | if ($node->type == 'ente_planificador') { |
---|
1394 | //agregando el sector a la vista del nodo |
---|
1395 | if ($op == 'presave') { |
---|
1396 | $level = 0; |
---|
1397 | $hierarchical = variable_get('ente_planificador_hierarchical_count', 2); |
---|
1398 | for($i = 1; $i < $hierarchical + 1; $i++) { |
---|
1399 | if (!$level && isset($node->{'ente_planificador_hierarchical_father_' . $i})) { |
---|
1400 | //level found |
---|
1401 | $level_lower = $i - 1; |
---|
1402 | $father = $node->{'ente_planificador_hierarchical_father_' . $i}; |
---|
1403 | if ($father == 0) { |
---|
1404 | $level = $i; |
---|
1405 | $ente_planificador_hierarchical[$i] = $father; |
---|
1406 | break; |
---|
1407 | } |
---|
1408 | $ente_planificador_hierarchical[$i] = $father; |
---|
1409 | } |
---|
1410 | } |
---|
1411 | if (($level) > 2) { |
---|
1412 | if (!$node->ambito) { |
---|
1413 | $level_lower = $level - 1; |
---|
1414 | $father = $node->{'ente_planificador_hierarchical_father_' . $level_lower}; |
---|
1415 | $node_father = node_load($father); |
---|
1416 | $node->ambito = $node_father->ambito; |
---|
1417 | $node->sector = $node_father->sector; |
---|
1418 | } |
---|
1419 | } |
---|
1420 | } |
---|
1421 | if ($op == 'view') { |
---|
1422 | if ($node->content['title1']) { |
---|
1423 | $node->content['name_ente'] = array( |
---|
1424 | '#prefix'=>'<p align="left">', |
---|
1425 | '#value' => "<b>" . t('Nombre del ente planificador:') . "</b> " . check_plain($node->title) . "<br>", |
---|
1426 | '#weight' => 0, |
---|
1427 | '#suffix'=>'</p>', |
---|
1428 | ); |
---|
1429 | } |
---|
1430 | if ($node->sector) { |
---|
1431 | $tid = check_plain($node->sector); |
---|
1432 | $term = taxonomy_get_term($tid); |
---|
1433 | $node->content['sector'] = array( |
---|
1434 | '#prefix'=>'<p align="left">', |
---|
1435 | '#value' => "<b>" . t('Sector Social:') . "</b> " . $term->name . "<br>", |
---|
1436 | '#weight' => 1, |
---|
1437 | '#suffix'=>'</p>', |
---|
1438 | ); |
---|
1439 | $terms = taxonomy_get_parents($tid); |
---|
1440 | foreach ($terms as $tid => $term) { |
---|
1441 | $name = $term->name; |
---|
1442 | } |
---|
1443 | $node->content['ambito'] = array( |
---|
1444 | '#prefix'=>'<p align="left">', |
---|
1445 | '#value' => "<b>" . t('Ambito:') . "</b> " . $name . "<br>", |
---|
1446 | '#weight' => 1, |
---|
1447 | '#suffix'=>'</p>', |
---|
1448 | ); |
---|
1449 | } |
---|
1450 | if ($node->tipo) { |
---|
1451 | $node->content['tipo'] = array( |
---|
1452 | '#prefix'=>'<p align="left">', |
---|
1453 | '#value' => "<b>" . t('Nivel de Planificación: ') . "</b>" . ente_planificador_sector_nivel_planificacion($node->tipo) . "<br>", |
---|
1454 | '#weight' => 2, |
---|
1455 | '#suffix'=>'</p>', |
---|
1456 | ); |
---|
1457 | } |
---|
1458 | if ($node->organismo) { |
---|
1459 | $term = taxonomy_get_term($node->organismo); |
---|
1460 | $node->content['organismo'] = array( |
---|
1461 | '#prefix'=>'<p align="left">', |
---|
1462 | '#value' => "<b>" . t('Organismo Público: ') . "</b>" . $term->name . "<br>", |
---|
1463 | '#weight' => 3, |
---|
1464 | '#suffix'=>'</p>', |
---|
1465 | ); |
---|
1466 | } |
---|
1467 | if ($node->sub_ente) { |
---|
1468 | $result = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $node->sub_ente)); |
---|
1469 | $node->content['sub_ente'] = array( |
---|
1470 | '#prefix'=>'<p align="left">', |
---|
1471 | '#value' => "<b>" . t('Ente al cual se está adscrito: ') . "</b>" . $result . "<br>", |
---|
1472 | '#weight' => 5, |
---|
1473 | '#suffix'=>'</p>', |
---|
1474 | ); |
---|
1475 | } |
---|
1476 | $node->content['link_add_ente'] = array( |
---|
1477 | '#prefix'=>'<p align="left">', |
---|
1478 | '#value' => "<b>" . l(t('Agregar un nuevo Ente planificador'),'node/add/ente-planificador'), |
---|
1479 | '#weight' => 999999, |
---|
1480 | '#suffix'=>'</p>', |
---|
1481 | ); |
---|
1482 | } |
---|
1483 | //anadiendo el sector al que pertence el ente planificador |
---|
1484 | if ($op == 'insert' || $op == 'update') { |
---|
1485 | db_query("UPDATE {ente_planificador} set ambito = %d, sector = %d WHERE nid = %d", $node->ambito, $node->sector, $node->nid); |
---|
1486 | if ($node->tipo == 1) { //Organismo público. |
---|
1487 | db_query("UPDATE {ente_planificador} set organismo = %d, ente_adscrito = %d, sub_ente = %d WHERE nid = %d", 0, 0, 0, $node->nid); |
---|
1488 | } |
---|
1489 | if ($node->tipo == 2) { //Organismo público. |
---|
1490 | $vocabulary = taxonomy_vocabulary_load(variable_get('ente_planificador_sector_organismos', 0)); |
---|
1491 | if ($op == 'update') { |
---|
1492 | $organismo = db_result(db_query("SELECT organismo FROM {ente_planificador} WHERE nid = %d", $node->nid)); |
---|
1493 | $term = array( |
---|
1494 | 'vid' => $vocabulary->vid, // Voacabulary ID |
---|
1495 | 'name' => $node->title, // Term Name |
---|
1496 | 'tid' => $organismo, |
---|
1497 | ); |
---|
1498 | } |
---|
1499 | if ($op == 'insert') { |
---|
1500 | $term = array( |
---|
1501 | 'vid' => $vocabulary->vid, // Voacabulary ID |
---|
1502 | 'name' => $node->title, // Term Name |
---|
1503 | ); |
---|
1504 | } |
---|
1505 | taxonomy_save_term($term); |
---|
1506 | $organismo = $term['tid']; |
---|
1507 | db_query("UPDATE {ente_planificador} set organismo = %d, ente_adscrito = %d, sub_ente = %d WHERE nid = %d", $organismo, 0, 0, $node->nid); |
---|
1508 | } |
---|
1509 | if ($node->ente_adscrito && $node->tipo == 3) { //Ente adscrito a un organismo público. |
---|
1510 | $ente_adscrito = $node->ente_adscrito; |
---|
1511 | db_query("UPDATE {ente_planificador} set ente_adscrito = %d, sub_ente = %d, organismo = %d WHERE nid = %d", $ente_adscrito, 0, $ente_adscrito, $node->nid); |
---|
1512 | } |
---|
1513 | if ($node->sub_ente && $node->tipo == 4) { //Ente adscrito a otro ente adscrito (sub-ente adscrito). |
---|
1514 | $sub_ente = $node->sub_ente; |
---|
1515 | $result = db_query("SELECT organismo FROM {ente_planificador} WHERE nid = %d", $node->sub_ente); |
---|
1516 | $row = db_fetch_object($result); |
---|
1517 | if ($row) { |
---|
1518 | db_query("UPDATE {ente_planificador} set sub_ente = %d, ente_adscrito = %d, organismo = %d WHERE nid = %d", $sub_ente, $sub_ente, $row->organismo, $node->nid); |
---|
1519 | } |
---|
1520 | } |
---|
1521 | } |
---|
1522 | } |
---|
1523 | } |
---|
1524 | |
---|
1525 | /* |
---|
1526 | * Implementation of hook_views_default_views_alter(). |
---|
1527 | */ |
---|
1528 | function ente_planificador_sector_views_default_views_alter(&$views) { |
---|
1529 | foreach ($views as $view) { |
---|
1530 | if ($view->name == 'planificacionM') { //modificacion de la vista Consultar datos de los actores planificadores (APM/APMS) |
---|
1531 | //style options sector |
---|
1532 | $view->display['default']->display_options['filters']['sector'] = array( |
---|
1533 | 'operator' => 'or', |
---|
1534 | 'value' => NULL, |
---|
1535 | 'group' => '0', |
---|
1536 | 'exposed' => TRUE, |
---|
1537 | 'expose' => array( |
---|
1538 | 'use_operator' => 0, |
---|
1539 | 'operator' => 'sector_op', |
---|
1540 | 'identifier' => 'sector', |
---|
1541 | 'label' => 'Sector Social', |
---|
1542 | 'optional' => 1, |
---|
1543 | 'single' => 1, |
---|
1544 | 'remember' => 0, |
---|
1545 | 'reduce' => 0, |
---|
1546 | ), |
---|
1547 | 'id' => 'sector', |
---|
1548 | 'table' => 'ente_planificador', |
---|
1549 | 'field' => 'sector', |
---|
1550 | 'override' => array( |
---|
1551 | 'button' => 'Override', |
---|
1552 | ), |
---|
1553 | ); |
---|
1554 | //definition field sector |
---|
1555 | $sector = array( |
---|
1556 | 'label' => 'Sector Social', |
---|
1557 | 'alter' => array( |
---|
1558 | 'alter_text' => 0, |
---|
1559 | 'text' => '', |
---|
1560 | 'make_link' => 0, |
---|
1561 | 'path' => '', |
---|
1562 | 'link_class' => '', |
---|
1563 | 'alt' => '', |
---|
1564 | 'prefix' => '', |
---|
1565 | 'suffix' => '', |
---|
1566 | 'target' => '', |
---|
1567 | 'help' => '', |
---|
1568 | 'trim' => 0, |
---|
1569 | 'max_length' => '', |
---|
1570 | 'word_boundary' => 1, |
---|
1571 | 'ellipsis' => 1, |
---|
1572 | 'html' => 0, |
---|
1573 | 'strip_tags' => 0, |
---|
1574 | ), |
---|
1575 | 'empty' => '', |
---|
1576 | 'hide_empty' => 0, |
---|
1577 | 'empty_zero' => 0, |
---|
1578 | 'exclude' => 0, |
---|
1579 | 'link_to_node' => 0, |
---|
1580 | 'id' => 'estado', |
---|
1581 | 'table' => 'ente_planificador', |
---|
1582 | 'field' => 'sector', |
---|
1583 | 'relationship' => 'none', |
---|
1584 | ); |
---|
1585 | //ordenando el campo |
---|
1586 | $view->display['default']->display_options['style_options']['columns']['sector'] = 'sector'; |
---|
1587 | $sort = array( |
---|
1588 | 'sortable' => 1, |
---|
1589 | 'separator' => "", |
---|
1590 | ); |
---|
1591 | $style = array_pop($view->display['default']->display_options['style_options']); |
---|
1592 | $view->display['default']->display_options['style_options']['info']['sector'] = $sort; |
---|
1593 | $view->display['default']->display_options['style_options']['nothing'] = $style; |
---|
1594 | // add field |
---|
1595 | $nothing = array_pop($view->display['default']->display_options['fields']); |
---|
1596 | $view->display['default']->display_options['fields']['sector'] = $sector; |
---|
1597 | $view->display['default']->display_options['fields']['nothing'] = $nothing; |
---|
1598 | } //end find view planificacionM |
---|
1599 | } |
---|
1600 | } |
---|
1601 | |
---|
1602 | /** |
---|
1603 | * Implmentations of hook_menu_alter |
---|
1604 | */ |
---|
1605 | |
---|
1606 | function ente_planificador_menu_alter(&$items) { |
---|
1607 | // $items['administrar/entes_planificadores']['page callback'] = 'ente_planificador_sector_lista_entes_redirect'; |
---|
1608 | // $items['administrar_usuarios']['page callback'] = 'ente_planificador_sector_lista_usuarios_redirect'; |
---|
1609 | } |
---|
1610 | |
---|
1611 | /** |
---|
1612 | * Redirigir a la vista lista de los entes planificadores |
---|
1613 | */ |
---|
1614 | function ente_planificador_sector_lista_entes_redirect() { |
---|
1615 | drupal_goto('administrar/entes_planificadores/lista'); |
---|
1616 | } |
---|
1617 | |
---|
1618 | /** |
---|
1619 | * Redirigir a la vista lista de los usuarios |
---|
1620 | */ |
---|
1621 | function ente_planificador_sector_lista_usuarios_redirect() { |
---|
1622 | drupal_goto('administrar_usuarios/lista'); |
---|
1623 | } |
---|
1624 | |
---|
1625 | /** |
---|
1626 | * genera el ahah alregistrar los entes planificadores |
---|
1627 | */ |
---|
1628 | function ente_planificador_sector_js_util() { |
---|
1629 | $tipo = 'nivel'; |
---|
1630 | $form_state = array('submitted' => FALSE); |
---|
1631 | $form_build_id = $_POST['form_build_id']; |
---|
1632 | // Add the new element to the stored form. Without adding the element tothe |
---|
1633 | // form, Drupal is not aware of this new elements existence and will not |
---|
1634 | // process it. We retreive the cached form, add the element, and resave. |
---|
1635 | $form = form_get_cache($form_build_id, $form_state); |
---|
1636 | if ($_POST['tipo'] != 1) { |
---|
1637 | $new_form['nivel'] = array( |
---|
1638 | '#type' => 'fieldset', |
---|
1639 | ); |
---|
1640 | } |
---|
1641 | if ($_POST['tipo'] == 2) { |
---|
1642 | $options = array(); |
---|
1643 | $tid = variable_get('ente_planificador_sector_Ambitos', 0); |
---|
1644 | $terms = taxonomy_get_tree($tid); |
---|
1645 | $options['0']= "seleccione"; |
---|
1646 | foreach ($terms as $term) { |
---|
1647 | if ($term->depth == 1) { //si el termino es padre |
---|
1648 | $options[$term->tid] = $term->name; |
---|
1649 | } |
---|
1650 | } |
---|
1651 | $new_form['nivel']['sector'] = array( |
---|
1652 | '#title' => t('Sector Social'), |
---|
1653 | '#type' => 'select', |
---|
1654 | '#required' => TRUE, |
---|
1655 | '#options' => $options, |
---|
1656 | '#prefix' => '<div id="sector_ente_planificador">', |
---|
1657 | '#suffix' => '</div>', |
---|
1658 | ); |
---|
1659 | $form[$tipo]['sector'] = $new_form['sector']; |
---|
1660 | } |
---|
1661 | if ($_POST['tipo'] == 3) { |
---|
1662 | $options = array(); |
---|
1663 | $options[0] = "seleccione"; |
---|
1664 | $tid = variable_get('ente_planificador_sector_organismos', 0); |
---|
1665 | $terms = taxonomy_get_tree($tid); |
---|
1666 | foreach ($terms as $term) { |
---|
1667 | $options[$term->tid] = $term->name; |
---|
1668 | } |
---|
1669 | $new_form['nivel']['ente_adscrito'] = array( |
---|
1670 | '#type' => 'select', |
---|
1671 | '#title' => t('Organismo Publico al que se esta adscrito'), |
---|
1672 | '#required' => TRUE, |
---|
1673 | '#options' => $options, |
---|
1674 | '#prefix' => '<div id="organismo">', |
---|
1675 | '#suffix' => '</div>', |
---|
1676 | ); |
---|
1677 | $form[$tipo]['ente_adscrito'] = $new_form['ente_adscrito']; |
---|
1678 | } |
---|
1679 | if ($_POST['tipo'] == 4) { |
---|
1680 | $options = array(); |
---|
1681 | $options['0']= "seleccione"; |
---|
1682 | $result = db_query("SELECT n.nid, n.title FROM {node} AS n INNER JOIN {ente_planificador} AS e ON n.nid = e.nid WHERE e.ente_adscrito != 0"); |
---|
1683 | while ($rows = db_fetch_object($result)) { |
---|
1684 | $options[$rows->nid] = $rows->title; |
---|
1685 | } |
---|
1686 | $new_form['nivel']['sub_ente'] = array( |
---|
1687 | '#type' => 'select', |
---|
1688 | '#title' => t('Ente al cual se esta adscrito'), |
---|
1689 | '#required' => TRUE, |
---|
1690 | '#options' => $options, |
---|
1691 | '#prefix' => '<div id="sub_ente">', |
---|
1692 | '#suffix' => '</div>', |
---|
1693 | ); |
---|
1694 | $form[$tipo]['sub_ente'] = $new_form['sub_ente']; |
---|
1695 | } |
---|
1696 | $form[$tipo] = $new_form; |
---|
1697 | form_set_cache($form_build_id, $form, $form_state); |
---|
1698 | $form += array( |
---|
1699 | '#post' => $_POST, |
---|
1700 | '#programmed' => FALSE, |
---|
1701 | ); |
---|
1702 | // Rebuild the form. |
---|
1703 | $form = form_builder($_POST['form_id'], $form, $form_state); |
---|
1704 | // Render the new output. |
---|
1705 | $new_form = $form[$tipo]; |
---|
1706 | unset($new_form['#prefix'], $new_form['#suffix']); // Prevent duplicate wrappers. |
---|
1707 | |
---|
1708 | |
---|
1709 | // Rebuild the form. |
---|
1710 | $form = form_builder($_POST['form_id'], $form, $form_state); |
---|
1711 | // Render the new output. |
---|
1712 | $new_form = array(); |
---|
1713 | |
---|
1714 | $output = drupal_render($new_form); |
---|
1715 | print drupal_to_js(array('data' => $output, 'status' => true)); |
---|
1716 | exit(); |
---|
1717 | } |
---|
1718 | |
---|
1719 | |
---|
1720 | /** |
---|
1721 | * Implementation of hook_ente_planificador_proceso_user_acceso_alter |
---|
1722 | */ |
---|
1723 | function ente_planificador_sector_ente_planificador_proceso_user_acceso_alter(&$fechas, $conf) { |
---|
1724 | $ente_planificador = $conf['ente_planificador']; |
---|
1725 | $type_proceso = $conf['proceso']; |
---|
1726 | $now = time(); |
---|
1727 | global $user; |
---|
1728 | $rol_macro = variable_get('ActorPlanificadorMacro', 0); |
---|
1729 | $options = variable_get('ente_planificador_sector_optiones_fecha', 'ambito'); |
---|
1730 | if ($type_proceso) { |
---|
1731 | if ((is_object($ente_planificador))) { |
---|
1732 | if ($ente_planificador->ambito) { |
---|
1733 | if ($options == 'sector') { |
---|
1734 | $term = taxonomy_get_term($ente_planificador->sector); |
---|
1735 | $FIPMI = variable_get('ente_planificador_' . $type_proceso . '_from_' . $term->tid, $now); |
---|
1736 | $FIPMF = variable_get('ente_planificador_' . $type_proceso . '_until_' . $term->tid, $now); |
---|
1737 | } |
---|
1738 | if ($options == 'ambito') { |
---|
1739 | $term = taxonomy_get_term($ente_planificador->ambito); |
---|
1740 | $FIPMI = variable_get('ente_planificador_' . $type_proceso . '_all_from_' . $term->tid, $now); |
---|
1741 | $FIPMF = variable_get('ente_planificador_' . $type_proceso . '_all_until_' . $term->tid, $now); |
---|
1742 | } |
---|
1743 | } |
---|
1744 | } |
---|
1745 | if (is_numeric($ente_planificador) || user_access('admin all planificador')) { //si es el administrador se aplica la fecha especial |
---|
1746 | $FIPMI = variable_get('ente_planificador_' . $type_proceso . '_admin_from', $now); |
---|
1747 | $FIPMF = variable_get('ente_planificador_' . $type_proceso . '_admin_until', $now); |
---|
1748 | } |
---|
1749 | if (in_array($rol_macro, array_keys($user->roles))) { //es usuario control |
---|
1750 | $FIPMI = variable_get('ente_planificador_' . $type_proceso . '_control_from', $now); |
---|
1751 | $FIPMF = variable_get('ente_planificador_' . $type_proceso . '_control_until', $now); |
---|
1752 | } |
---|
1753 | if ($FIPMI) { |
---|
1754 | $fechas[0] = $FIPMI; |
---|
1755 | } |
---|
1756 | if ($FIPMF) { |
---|
1757 | $fechas[1] = $FIPMF; |
---|
1758 | } |
---|
1759 | } |
---|
1760 | } |
---|
1761 | |
---|
1762 | /** |
---|
1763 | * Implementation of hook_ente_planificador_muestra_mensaje_alter |
---|
1764 | */ |
---|
1765 | function ente_planificador_sector_ente_planificador_muestra_mensaje_alter(&$new_mensaje, $conf) { |
---|
1766 | $type_proceso = $conf['plan_tipo']; |
---|
1767 | $procesos = ente_planificador_procesos(); |
---|
1768 | $ente_planificador = $conf['ente_planificador']; |
---|
1769 | $ambito_text = "Ambito Especial de Administración"; |
---|
1770 | $sector_text = "Sector Especial"; |
---|
1771 | $now = time(); |
---|
1772 | global $user; |
---|
1773 | $rol_macro = variable_get('ActorPlanificadorMacro', 0); |
---|
1774 | $expire = $conf['expire']; |
---|
1775 | if ($type_proceso) { |
---|
1776 | if (is_object($ente_planificador)) { |
---|
1777 | $sector = taxonomy_get_term($ente_planificador->sector); |
---|
1778 | $ambito = taxonomy_get_term($ente_planificador->ambito); |
---|
1779 | $mi_fecha = array( |
---|
1780 | variable_get('ente_planificador_' . $type_proceso . '_all_from_' . $ambito->tid, $now), |
---|
1781 | variable_get('ente_planificador_' . $type_proceso . '_all_until_' . $ambito->tid, $now), |
---|
1782 | ); |
---|
1783 | if ($expire) { |
---|
1784 | $new_mensaje = t("Registrar y/o modificar los Proyectos Operativos para el Ambito %ambito en el Sector %sector no se encuentra disponible, se podra realizar desde el %fechaI hasta %fechaF", array('%ambito' => strtoupper($ambito->name), '%sector' => strtoupper($sector->name), '%fechaI' => format_date($mi_fecha[0]), '%fechaF' => format_date($mi_fecha[1]))); |
---|
1785 | } |
---|
1786 | else { |
---|
1787 | $new_mensaje = t("Se podrá registrar y/o modificar los Proyectos Operativos para el Ambito %ambito en el Sector %sector desde el %fechaI hasta %fechaF", array('%ambito' => strtoupper($ambito->name), '%sector' => strtoupper($sector->name), '%fechaI' => format_date($mi_fecha[0]), '%fechaF' => format_date($mi_fecha[1]))); |
---|
1788 | } |
---|
1789 | } |
---|
1790 | if (is_numeric($ente_planificador) || user_access('admin all planificador')) { //si es el administrador se aplica la fecha especial |
---|
1791 | $mi_fecha = array( |
---|
1792 | variable_get('ente_planificador_' . $type_proceso . '_admin_from', $now), |
---|
1793 | variable_get('ente_planificador_' . $type_proceso . '_admin_until', $now), |
---|
1794 | ); |
---|
1795 | $new_mensaje = t("Como usuario administrador puede acceder desde %fechaI hasta %fechaF", array('%fechaI' => format_date($mi_fecha[0]), '%fechaF' => format_date($mi_fecha[1]))); |
---|
1796 | } |
---|
1797 | if (in_array($rol_macro, array_keys($user->roles))) { //es usuario control |
---|
1798 | $mi_fecha = array( |
---|
1799 | variable_get('ente_planificador_' . $type_proceso . '_control_from', $now), |
---|
1800 | variable_get('ente_planificador_' . $type_proceso . '_control_until', $now), |
---|
1801 | ); |
---|
1802 | $new_mensaje = t("Como usuario Control puede acceder desde %fechaI hasta %fechaF", array('%fechaI' => format_date($mi_fecha[0]), '%fechaF' => format_date($mi_fecha[1]))); |
---|
1803 | } |
---|
1804 | } |
---|
1805 | } |
---|