1 | <?php |
---|
2 | /** |
---|
3 | * Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana |
---|
4 | * @file proyecto_operativo_seguimiento.module |
---|
5 | * Drupal part Module to code proyectos operativos module |
---|
6 | * Copyright 2012 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 - Ing. Diego Uzcategui |
---|
23 | * @date 2013-02-07 // (anno-mes-dia) |
---|
24 | * @version 0.1 |
---|
25 | * |
---|
26 | */ |
---|
27 | $meses = array( |
---|
28 | 0 => t('January'), |
---|
29 | 1 => t('February'), |
---|
30 | 2 => t('March'), |
---|
31 | 3 => t('April'), |
---|
32 | 4 => t('May'), |
---|
33 | 5 => t('June'), |
---|
34 | 6 => t('July'), |
---|
35 | 7 => t('August'), |
---|
36 | 8 => t('September'), |
---|
37 | 9 => t('Octuber'), |
---|
38 | 10 => t('November'), |
---|
39 | 11 => t('December'), |
---|
40 | ); |
---|
41 | define('MESES', json_encode($meses)); |
---|
42 | |
---|
43 | /* |
---|
44 | * Implementation of hook_help() |
---|
45 | */ |
---|
46 | function proyecto_operativo_seguimiento_help($path, $arg) { |
---|
47 | switch ($path) { |
---|
48 | case "admin/help/aeproyectoseguimiento": |
---|
49 | $output = '<p>'. t("Este modulo se encarga de la gestión del seguimiento de proyectos operativos") .'</p>'; |
---|
50 | break; |
---|
51 | } |
---|
52 | return $output; |
---|
53 | } // function proyecto_operativo_seguimiento_help |
---|
54 | |
---|
55 | /* |
---|
56 | * Implementation of hook_menu() |
---|
57 | */ |
---|
58 | function proyecto_operativo_seguimiento_menu() { |
---|
59 | $items = array(); |
---|
60 | $items['proyectosop/seguimiento/workflow_ahah/callback'] = array( |
---|
61 | 'page callback' => 'ahah_proyectosop_seguimiento_workflow_callback', |
---|
62 | 'access callback' => TRUE, |
---|
63 | 'type' => MENU_CALLBACK, |
---|
64 | 'file' => 'includes/proyecto/cambiodeestado_seg_proyecto_paginaconfirmacion.forms.inc', |
---|
65 | ); |
---|
66 | //----------------------------------------------------------------------------Seguimiento de acciones especÃficas de proyectos operativos |
---|
67 | $items['proyectosop/%proyectosop/seguimiento'] = array( |
---|
68 | 'title' => 'Seguimiento', |
---|
69 | 'type' => MENU_LOCAL_TASK, |
---|
70 | 'access callback' => '_proyectooperativo_esta_aprobado_acceso', |
---|
71 | 'access arguments' => array(1), |
---|
72 | 'file' => 'includes/proyecto/seguimiento_proyecto.pages.inc', |
---|
73 | 'page callback' => 'seguimiento_proyecto_y_aes_lista_page', |
---|
74 | 'page arguments' => array(1), |
---|
75 | 'weight' => 2, |
---|
76 | ); |
---|
77 | $items['proyectosop/%proyectosop/seguimiento/view'] = array( |
---|
78 | 'title' => 'Seguimiento', |
---|
79 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
---|
80 | 'weight' => -10 |
---|
81 | ); |
---|
82 | $items['proyectosop/%proyectosop/seguimiento/workflow'] = array( |
---|
83 | 'title' => 'Enviar Seguimiento', |
---|
84 | 'type' => MENU_LOCAL_TASK, |
---|
85 | 'access callback' => '_proyecto_seguimiento_mes_mover_group_estado_access', |
---|
86 | 'access arguments' => array(1), |
---|
87 | 'page callback' => 'drupal_get_form', |
---|
88 | 'page arguments' => array('cambiodeestado_seg_proyecto_paginaconfirmacion_form', 1), |
---|
89 | 'file' => 'includes/proyecto/cambiodeestado_seg_proyecto_paginaconfirmacion.forms.inc', |
---|
90 | 'weight' => 2, |
---|
91 | ); |
---|
92 | /* |
---|
93 | $items['proyectosop/%proyectosop/seguimiento/proyecto_aes/%'] = array( |
---|
94 | 'title' => 'Proyecto y AE', |
---|
95 | 'type' => MENU_LOCAL_TASK, |
---|
96 | 'access callback' => '_fasedeseguimiento_proyecto_y_ae_access', |
---|
97 | 'access arguments' => array(1), |
---|
98 | 'file' => 'includes/fase_de_seguimiento_proyecto_y_aes.pages.inc', |
---|
99 | 'page callback' => 'fase_de_seguimiento_proyecto_y_aes_page', |
---|
100 | 'page arguments' => array(1), |
---|
101 | 'weight' => 3, |
---|
102 | ); |
---|
103 | */ |
---|
104 | $items['proyectosop/%proyectosop/seguimiento/proyecto'] = array( |
---|
105 | 'title' => 'Proyecto', |
---|
106 | 'type' => MENU_LOCAL_TASK, |
---|
107 | 'access callback' => '_proyectooperativo_esta_aprobado_acceso', |
---|
108 | 'access arguments' => array(1), |
---|
109 | 'file' => 'includes/proyecto/seguimiento_proyecto.pages.inc', |
---|
110 | 'page callback' => 'seguimiento_proyecto_page', |
---|
111 | 'page arguments' => array(1), |
---|
112 | 'weight' => 2, |
---|
113 | ); |
---|
114 | |
---|
115 | $items['proyectosop/%proyectosop/seguimiento/proyecto/%messeg/edit/%'] = array( |
---|
116 | 'title' => 'Seguimiento', |
---|
117 | 'type' => MENU_LOCAL_TASK, |
---|
118 | 'access callback' => '_proyecto_operativo_seguimiento_modificar_mes_access', |
---|
119 | 'access arguments' => array(1, 4), |
---|
120 | 'file' => 'includes/proyecto/seguimiento_proyecto_datospormes_modificar.forms.inc', |
---|
121 | 'page callback' => 'drupal_get_form', |
---|
122 | 'page arguments' => array('seguimiento_proyecto_datospormes_modificar_form', 1, 4,6), |
---|
123 | 'weight' => 2, |
---|
124 | ); |
---|
125 | |
---|
126 | /*----------------------------------------------------------------------------workflow |
---|
127 | $items['proyectosop/%proyectosop/seguimiento/proyecto/%messeg/workflow'] = array( |
---|
128 | 'title' => 'Seguimiento', |
---|
129 | 'type' => MENU_LOCAL_TASK, |
---|
130 | 'access callback' => '_proyecto_seguimiento_mes_mover_estado_access', |
---|
131 | 'access arguments' => array(1, 4), |
---|
132 | 'file' => 'includes/proyecto/cambiodeestado_seg_proyecto_paginaconfirmacion.forms.inc', |
---|
133 | 'page callback' => 'drupal_get_form', |
---|
134 | 'page arguments' => array('cambiodeestado_seg_proyecto_paginaconfirmacion_form', 1, 4), |
---|
135 | 'weight' => 2, |
---|
136 | ); |
---|
137 | */ |
---|
138 | |
---|
139 | $items['proyectosop/%proyectosop/seguimiento/workflowhis'] = array( |
---|
140 | 'title' => 'Historial Seguimiento', |
---|
141 | 'type' => MENU_LOCAL_TASK, |
---|
142 | 'access callback' => '_proyectooperativo_esta_aprobado_acceso', |
---|
143 | 'access arguments' => array(1), |
---|
144 | 'file' => 'includes/proyecto/historial_cambiodeestado_seg_proyecto.pages.inc', |
---|
145 | 'page callback' => 'historial_cambiodeestado_seg_proyecto_page', |
---|
146 | 'page arguments' => array(1), |
---|
147 | 'weight' => 2, |
---|
148 | ); |
---|
149 | // 'proyectosop/%proyectosop/seguimiento/proyecto/%year/%messegaepartida/workflow/historial' |
---|
150 | //----------------------------------------------------------------------------Fase de Seguimiento de proyectos operativos y sus acciones especificas |
---|
151 | /* |
---|
152 | $items['proyectosop/%proyectosop/fase_de_seguimiento_proyecto_y_aes'] = array( |
---|
153 | 'title' => 'Proyecto y AE', |
---|
154 | 'type' => MENU_LOCAL_TASK, |
---|
155 | 'access callback' => '_fasedeseguimiento_proyecto_y_ae_access', |
---|
156 | 'access arguments' => array(1), |
---|
157 | 'file' => 'includes/fase_de_seguimiento_proyecto_y_aes.pages.inc', |
---|
158 | 'page callback' => 'fase_de_seguimiento_proyecto_y_aes_page', |
---|
159 | 'page arguments' => array(1), |
---|
160 | 'weight' => 2, |
---|
161 | ); |
---|
162 | */ |
---|
163 | return $items; |
---|
164 | } |
---|
165 | |
---|
166 | //************************************************************************************************************************************************** |
---|
167 | //permisos de acceso a las paginas |
---|
168 | |
---|
169 | /** |
---|
170 | * verificar que el nodo que desea se evaluado sea de tipo 'proyectos_operativos' |
---|
171 | */ |
---|
172 | |
---|
173 | function _proyecto_operativo_seguimiento_access($proyecto = 0) { |
---|
174 | return _proyectooperativo_esta_aprobado($node); |
---|
175 | } // function _proyecto_operativo_seguimiento_access |
---|
176 | |
---|
177 | /** |
---|
178 | * verificar que el nodo que desea se evaluado sea de tipo 'proyectos_operativos', que el mes este dentro dentro del periodo de duracion, mes habilitado para seg, y periodo de seguimiento activo |
---|
179 | */ |
---|
180 | function _proyecto_operativo_seguimiento_modificar_mes_access($proyecto = 0, $mes = 0) { |
---|
181 | global $user; |
---|
182 | $mes_o = $mes; |
---|
183 | //esta fuera del mes de seguimiento actual |
---|
184 | if (!_mes_habilitado_para_seguimiento($mes)) { |
---|
185 | return FALSE; |
---|
186 | } |
---|
187 | |
---|
188 | $mes_final = variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 1); |
---|
189 | //esta fuera del anho de seguimiento actual |
---|
190 | if ($proyecto->anhoproyectos_operativos != variable_get('accion_especifica_de_proyecto_seguimiento_anho_seguimiento', 0)) { |
---|
191 | return FALSE; |
---|
192 | } |
---|
193 | $anno = variable_get('accion_especifica_de_proyecto_seguimiento_anho_seguimiento', 0); |
---|
194 | $fecha = explode('-', $proyecto->field_proyecto_fecha_i[0]['value']); |
---|
195 | $mes_inicio = (int) $fecha[1]; |
---|
196 | $year_inicio = (int) $fecha[0]; |
---|
197 | $fecha = explode('-', $proyecto->field_proyecto_fecha_f[0]['value']); |
---|
198 | $mes_fin = (int) $fecha[1]; |
---|
199 | $year_fin = (int) $fecha[0]; |
---|
200 | |
---|
201 | if (($anno == $year_inicio && $mes_inicio > $mes) || ($anno == $year_fin && $mes_fin < $mes) && $mes_final<=$m_fin) { //se establecio la condicion de años como falsa |
---|
202 | return FALSE; |
---|
203 | } |
---|
204 | //se valida el acceso al plan |
---|
205 | $current_time = time(); |
---|
206 | $tipo_plan = 'proyecto_y_accionesespecificas_seguimiento'; |
---|
207 | $fecha = FALSE; |
---|
208 | $ente = usuario_tiene_ente($user->uid); |
---|
209 | $ente_planificador = ente_planificador_leer_ente_planificadores($proyecto->field_proyecto_ente[0]['nid']); |
---|
210 | if ($ente_planificador->nid != $ente->nid && !user_access('admin planificador')) { |
---|
211 | return FALSE; |
---|
212 | } |
---|
213 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
214 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
215 | $fecha = TRUE; |
---|
216 | } |
---|
217 | if ($fecha) { |
---|
218 | if ($ente->nid == $ente_planificador->nid ) { |
---|
219 | $fecha = TRUE; |
---|
220 | } |
---|
221 | elseif (!user_access('admin planificador')) { |
---|
222 | $fecha = FALSE; |
---|
223 | } |
---|
224 | } |
---|
225 | //si no posee la transición del seguimiento no puede editar |
---|
226 | $transiciones = _obtener_transiciones_disponibles_proyecto($proyecto, $mes_o); |
---|
227 | if (!count($transiciones['transic']) && $transiciones['estado_actual']>0) { |
---|
228 | return FALSE; |
---|
229 | } |
---|
230 | |
---|
231 | $roles_perm = TRUE; |
---|
232 | if (module_exists('workflow') && $fecha && !user_access('admin planificador')) { |
---|
233 | $estado = 0; |
---|
234 | $wid = workflow_get_workflow_for_type('proyectos_operativos'); |
---|
235 | $states = workflow_get_states($wid); |
---|
236 | $roles_perm = FALSE; |
---|
237 | foreach ($states as $sid => $state) { |
---|
238 | $roles_allow = variable_get('proyectos_operativos_state_s_' . $sid, array()); |
---|
239 | $roles = array_keys($user->roles); |
---|
240 | if (count($roles)) { |
---|
241 | foreach ($roles as $rol) { |
---|
242 | if ($roles_allow[$rol]) { |
---|
243 | $roles_perm = TRUE; |
---|
244 | } |
---|
245 | elseif ($rol == -1 && $node->uid == $user->uid) { |
---|
246 | $roles_perm = TRUE; |
---|
247 | } |
---|
248 | } |
---|
249 | } |
---|
250 | } |
---|
251 | } |
---|
252 | return $fecha && $roles_perm; |
---|
253 | } |
---|
254 | |
---|
255 | /** |
---|
256 | * acceso a workflow accion_especifica_de_proyecto_seguimiento.module |
---|
257 | */ |
---|
258 | function _proyecto_seguimiento_mes_mover_group_estado_access($node) { |
---|
259 | $meses = json_decode(MESES); |
---|
260 | for ($i=1; $i<=count($meses); $i++) { |
---|
261 | if (in_array($i, variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 1))) { |
---|
262 | if (_proyecto_seguimiento_mes_mover_estado_access($node, $i)) { |
---|
263 | $mesesL[$i] = $meses[$i]; |
---|
264 | } |
---|
265 | } |
---|
266 | } |
---|
267 | return count($mesesL); |
---|
268 | } |
---|
269 | |
---|
270 | /** |
---|
271 | * acceso a workflow accion_especifica_de_proyecto_seguimiento.module |
---|
272 | */ |
---|
273 | function _proyecto_seguimiento_mes_mover_estado_access($node, $mes = 0, $message = false) { |
---|
274 | global $user; |
---|
275 | $mesI = $mes; |
---|
276 | $meses = json_decode(MESES); |
---|
277 | |
---|
278 | $seguimiento = _seguimiento_mesactual_proyecto_load($node, $mes); |
---|
279 | // si no estan separadas el seguimiento de las AE con los proyectos |
---|
280 | $acciones = array(); |
---|
281 | if (!variable_get('accion_especifica_de_proyecto_seguimiento_aesep', 0)) { |
---|
282 | //se verifica que se haya ingresado todo el seguimiento de las acciones especificas |
---|
283 | $cuenta = 0; |
---|
284 | $count = 0; |
---|
285 | $acciones_estado = array(); |
---|
286 | $count_proyect = 0; |
---|
287 | |
---|
288 | |
---|
289 | foreach($node->field_proyecto_accion_esp as $accion) { |
---|
290 | $accion_load = (object) $accion; |
---|
291 | //se busca manejar la cantidad total de acciones disponibles por mes, exluir las restantes |
---|
292 | $accion_load = node_load($accion['nid']); |
---|
293 | |
---|
294 | //obtener la cantidad total de las transiciones disponibles de todas las acciones para todos los meses |
---|
295 | |
---|
296 | $acciones_estado[$accion['nid']] = _seguimiento_mesactual_partida_ae_deproyecto_load($accion_load, $mes); |
---|
297 | if (is_numeric($acciones_estado[$accion['nid']]['segmes']['mes'])) { |
---|
298 | $mes_accion[$accion['nid']][$mes] = $acciones_estado[$accion['nid']]['segmes']['mes']; |
---|
299 | $accion_content[$mes][$accion['nid']] = $mes; |
---|
300 | } |
---|
301 | if ($transiciones_dispoP = _obtener_transiciones_disponibles_proyecto($node, $mes)) { |
---|
302 | if ((count($transiciones_dispoP['transic']) && !$transiciones_dispoP['estado_actual']) || (!count($transiciones_dispoP['transic']) && $transiciones_dispoP['estado_actual'])) { |
---|
303 | return false; |
---|
304 | } |
---|
305 | elseif (!($transiciones_dispoP['estado_actual']) || !$transiciones_dispoP['nombre_estado_actual']) { |
---|
306 | return false; |
---|
307 | } |
---|
308 | } |
---|
309 | $transiciones = _obtener_transiciones_disponibles($accion_load, $mes); |
---|
310 | |
---|
311 | if ((count($transiciones['transic']) && !$transiciones['estado_actual']) || (!count($transiciones['transic']) && $transiciones['estado_actual'])) { |
---|
312 | return FALSE; |
---|
313 | } |
---|
314 | elseif (!($transiciones['estado_actual']) || !$transiciones['nombre_estado_actual']) { |
---|
315 | return false; |
---|
316 | } |
---|
317 | } |
---|
318 | } |
---|
319 | |
---|
320 | |
---|
321 | //esta fuera del mes de seguimiento actual |
---|
322 | if (!_mes_habilitado_para_seguimiento($mes) && !(in_array($mes, variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 1) ))) { |
---|
323 | return FALSE; |
---|
324 | } |
---|
325 | |
---|
326 | //esta fuera del anho de seguimiento actual |
---|
327 | $anno = variable_get('accion_especifica_de_proyecto_seguimiento_anho_seguimiento', 0); |
---|
328 | if ($node->anhoproyectos_operativos != $anno) { |
---|
329 | return FALSE; |
---|
330 | } |
---|
331 | $fecha = explode('-', $node->field_proyecto_fecha_i[0]['value']); |
---|
332 | $mes_inicio = (int) $fecha[1]; |
---|
333 | $anno_inicio = (int) $fecha[0]; |
---|
334 | $fecha = explode('-', $node->field_proyecto_fecha_f[0]['value']); |
---|
335 | $mes_fin = (int) $fecha[1]; |
---|
336 | $anno_fin = (int) $fecha[0]; |
---|
337 | //el mes esta fuera del rango del proyecto |
---|
338 | if (($anno == $anno_inicio && $mes_inicio > $mes) || ($anno == $anno_fin && $mes_fin < $mes)) { |
---|
339 | return FALSE; |
---|
340 | } |
---|
341 | |
---|
342 | |
---|
343 | $ente = usuario_tiene_ente($user->uid); |
---|
344 | $ente_planificador = ente_planificador_leer_ente_planificadores($node->field_proyecto_ente[0]['nid']); |
---|
345 | |
---|
346 | $current_time = time(); |
---|
347 | $tipo_plan = 'proyecto_y_accionesespecificas_seguimiento'; |
---|
348 | $fecha = FALSE; |
---|
349 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
350 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
351 | $fecha = TRUE; |
---|
352 | } |
---|
353 | if ($fecha) { |
---|
354 | if (user_access('admin planificador')) { |
---|
355 | $fecha = TRUE; |
---|
356 | } |
---|
357 | elseif ($ente->nid == $ente_planificador->nid && !user_access('admin planificador')) { |
---|
358 | $fecha = TRUE; |
---|
359 | } |
---|
360 | elseif (module_exists('ente_planificador_hierarchical')) { |
---|
361 | $fathers = _ente_planificador_hierarchical_get_descbyid($ente_planificador->nid, 1); |
---|
362 | $fecha = isset($fathers[$ente->nid]) ? TRUE : FALSE; |
---|
363 | } |
---|
364 | } |
---|
365 | |
---|
366 | return $fecha; |
---|
367 | } |
---|
368 | |
---|
369 | /** |
---|
370 | * verificar que el nodo que desea se evaluado sea de tipo 'proyectos_operativos' |
---|
371 | */ |
---|
372 | function _fasedeseguimiento_proyecto_y_ae_access($proyecto) { |
---|
373 | $mes = variable_get('accion_especifica_de_proyecto_seguimiento_mes_seguimiento', 0); |
---|
374 | $fecha = explode('-', $proyecto->field_proyecto_fecha_i[0]['value']); |
---|
375 | $mes_inicio = (int) $fecha[1]; |
---|
376 | $fecha = explode('-', $proyecto->field_proyecto_fecha_f[0]['value']); |
---|
377 | $mes_fin = (int) $fecha[1]; |
---|
378 | return (user_access('ver planificador') && (($mes_inicio <= $mes)||($mes_fin >= $mes)) && _proyectooperativo_esta_aprobado($proyecto)) && $proyecto->anhoproyectos_operativos == variable_get('accion_especifica_de_proyecto_seguimiento_anho_seguimiento', 0); |
---|
379 | } // function _fasedeseguimiento_proyecto_y_ae_access |
---|
380 | |
---|
381 | //************************************************************************************************************************************************** |
---|
382 | |
---|
383 | /** |
---|
384 | * verificar que el nodo que desea se evaluado sea de tipo 'proyectos_operativos' |
---|
385 | */ |
---|
386 | function _es_tipo_proyectooperativo($node) { |
---|
387 | return ($node->type == 'proyectos_operativos'); |
---|
388 | } // function _proyecto_operativo_seguimiento_access |
---|
389 | |
---|
390 | /** |
---|
391 | * Return access |
---|
392 | */ |
---|
393 | function _proyectooperativo_esta_aprobado_acceso($node) { |
---|
394 | return user_access('ver planificador') && _proyectooperativo_esta_aprobado($node); |
---|
395 | } |
---|
396 | |
---|
397 | /** |
---|
398 | * verificar proyecto operativo este aprobado |
---|
399 | */ |
---|
400 | function _proyectooperativo_esta_aprobado($node) { |
---|
401 | |
---|
402 | $meses = json_decode(MESES); |
---|
403 | $mes_fase_seg = _obtener_mes_fase_seguimiento_proyecto($node); |
---|
404 | $mes_seguimiento_proyecto_y_aes = variable_get('accion_especifica_de_proyecto_seguimiento_mes_seguimiento', 0); |
---|
405 | $nodo_proyecto = node_load($node->nid); |
---|
406 | |
---|
407 | $anno = variable_get('accion_especifica_de_proyecto_seguimiento_anho_seguimiento', 0); |
---|
408 | $fecha = explode('-', $nodo_proyecto->field_proyecto_fecha_i[0]['value']); |
---|
409 | $mes_inicio = (int) $fecha[1]; |
---|
410 | $year_inicio = (int) $fecha[0]; |
---|
411 | |
---|
412 | //exluir el link de la tabla de proyectos |
---|
413 | if (($year_inicio < $anno) || ($year_inicio == $anno) && in_array($mes_inicio, variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 1))) { |
---|
414 | $estado_aprobado = variable_get('proyectos_operativos_state_aprobado', NULL); |
---|
415 | if($node->type =='proyectos_operativos'){ |
---|
416 | return ($node->_workflow == $estado_aprobado); |
---|
417 | }elseif($node->type =='accion_especifica'){ |
---|
418 | $nodo_proyecto = node_load($node->field_accion_esp_proyecto[0]['nid']); |
---|
419 | return ($nodo_proyecto->_workflow == $estado_aprobado); |
---|
420 | } |
---|
421 | } |
---|
422 | return FALSE; |
---|
423 | } // function _proyecto_operativo_seguimiento_access |
---|
424 | |
---|
425 | /** |
---|
426 | * verificar si un mes dado esta dentro del periodo de duracion de una accion especifica o de un proyecto operativo, dependiendo del tipo de nodo |
---|
427 | */ |
---|
428 | function _mes_dentro_de_duracion_proyecto($node, $mes=0) { |
---|
429 | |
---|
430 | $mes = $mes+1;//colocando parametro entre 1 y 12 |
---|
431 | $resp = FALSE; |
---|
432 | |
---|
433 | //Proyecto |
---|
434 | if ($node->type == 'proyectos_operativos'){ |
---|
435 | $fechayhora_inicio = $node->field_proyecto_fecha_i[0]['value']; |
---|
436 | list($fecha_inicio, $hora_inicio) = split('[ ]', $fechayhora_inicio); |
---|
437 | list($anno_inicio, $mes_inicio, $dia_inicio) = split('[/.-]', $fecha_inicio); |
---|
438 | $m_inicio = intval($mes_inicio); |
---|
439 | |
---|
440 | $fechayhora_fin = $node->field_proyecto_fecha_f[0]['value']; |
---|
441 | list($fecha_fin, $hora_fin) = split('[ ]', $fechayhora_fin); |
---|
442 | list($anno_fin, $mes_fin, $dia_fin) = split('[/.-]', $fecha_fin); |
---|
443 | $m_fin = intval($mes_fin); |
---|
444 | |
---|
445 | if(($m_inicio<=$mes)&&($m_fin>=$mes)){ |
---|
446 | $resp = TRUE; |
---|
447 | }else{ |
---|
448 | $resp = FALSE; |
---|
449 | } |
---|
450 | |
---|
451 | } |
---|
452 | |
---|
453 | return $resp; |
---|
454 | } |
---|
455 | |
---|
456 | function _permiso_para_realizar_transicion_estado_proyecto($node, $mes = 0, $estadonuevo = 0){ |
---|
457 | |
---|
458 | $consultaseguimientoactual = _seguimiento_mesactual_proyecto_load($node, $mes); |
---|
459 | |
---|
460 | //estado |
---|
461 | $estado = ((isset($consultaseguimientoactual['segmes']['estado'])) && ($consultaseguimientoactual['segmes']['estado'] > 0) )? $consultaseguimientoactual['segmes']['estado'] : -1; |
---|
462 | |
---|
463 | if($estado == $estadonuevo){ |
---|
464 | return FALSE; |
---|
465 | } |
---|
466 | |
---|
467 | $states = _obtener_estados_seguimiento_mes(); |
---|
468 | |
---|
469 | $estado_aprobado = variable_get('acciones_centralizadas_state_aprobado', NULL); |
---|
470 | $estado_naprobado = variable_get('acciones_centralizadas_state_naprobado', NULL); |
---|
471 | |
---|
472 | global $user; |
---|
473 | $ente = usuario_tiene_ente($user->uid); |
---|
474 | |
---|
475 | $roles = array_keys($user->roles); |
---|
476 | if ($user->uid == 1) { |
---|
477 | // Superuser is special. |
---|
478 | $roles_transition = 'ALL'; |
---|
479 | }else { |
---|
480 | $roles_transition = $roles; |
---|
481 | if ($user->uid == $consultaseguimientoactual['segmes']['uid']&& $consultaseguimientoactual['segmes']['uid'] > 0) {//verificar si es el autor del seguimiento |
---|
482 | $roles_transition += array('author' => 'author'); |
---|
483 | } |
---|
484 | } |
---|
485 | |
---|
486 | $transitions = array(); |
---|
487 | if ($states['wid']) { |
---|
488 | $transitions = workflow_allowable_transitions($estado, 'to', $roles_transition); |
---|
489 | } |
---|
490 | |
---|
491 | if (isset($transitions[$estadonuevo])) { |
---|
492 | return TRUE; |
---|
493 | } |
---|
494 | return FALSE; |
---|
495 | } |
---|
496 | |
---|
497 | |
---|
498 | function _seg_esta_aprobado_proyecto($node, $mes=0){ |
---|
499 | |
---|
500 | $transiciones_dispo = _obtener_transiciones_disponibles_proyecto($node, $mes); |
---|
501 | $estado = $transiciones_dispo['estado_actual']; |
---|
502 | |
---|
503 | $estado_aprobado = variable_get('acciones_centralizadas_state_aprobado', NULL); |
---|
504 | |
---|
505 | if ($estado == $estado_aprobado) { |
---|
506 | return TRUE; |
---|
507 | } |
---|
508 | return FALSE; |
---|
509 | } |
---|
510 | |
---|
511 | /* |
---|
512 | * verificar nivel de usuario para modificar |
---|
513 | */ |
---|
514 | |
---|
515 | function _estado_seg_en_nivel_de_usuario_proyecto($node, $mes=0) { |
---|
516 | |
---|
517 | //calcular el estado |
---|
518 | $transiciones_dispo = _obtener_transiciones_disponibles_proyecto($node, $mes); |
---|
519 | |
---|
520 | $nivel_usuario = _obtener_nivel_usuario_segun_estado($transiciones_dispo['nombre_estado_actual']); |
---|
521 | |
---|
522 | $rol_ente_usuario = _obtener_rol_y_ente_de_usuario(); |
---|
523 | |
---|
524 | if(($transiciones_dispo['estado_actual'] < 0)&&($rol_ente_usuario['rol']=='enlace'||$rol_ente_usuario['rol']=='administrador')){ |
---|
525 | return true; |
---|
526 | } |
---|
527 | |
---|
528 | if(($nivel_usuario == $rol_ente_usuario['rol'])||$rol_ente_usuario['rol']=='administrador'){//nivel de usuario == rol actor |
---|
529 | return TRUE; |
---|
530 | } |
---|
531 | return FALSE; |
---|
532 | } |
---|
533 | |
---|
534 | /* |
---|
535 | * verificar que sea el mismo ente, tanto para el proyecto como para el usuario (si es enlace o supervisor) |
---|
536 | */ |
---|
537 | |
---|
538 | function _es_elmismo_ente_proyecto_y_usuario_proyecto($node){ |
---|
539 | |
---|
540 | $rol_ente_usuario = _obtener_rol_y_ente_de_usuario(); |
---|
541 | |
---|
542 | if($rol_ente_usuario['rol']=='enlace'||$rol_ente_usuario['rol']=='supervisor'){//enlace o supervisor |
---|
543 | //$nodo_proyecto = node_load($node->field_accion_esp_proyecto[0]['nid']); |
---|
544 | if($rol_ente_usuario['id_ente'] == $node->field_proyecto_ente[0]['nid']){//deben ser del mismo ente que el proyecto |
---|
545 | return TRUE; |
---|
546 | }else{ |
---|
547 | return FALSE; |
---|
548 | } |
---|
549 | } |
---|
550 | return TRUE; |
---|
551 | } |
---|
552 | |
---|
553 | //************************************************************************************************************************************************** |
---|
554 | //pagina de formulario |
---|
555 | |
---|
556 | module_load_include('inc', 'accion_especifica_de_proyecto_seguimiento', 'includes/proyecto/seguimiento_proyecto_datospormes_modificar.forms'); |
---|
557 | |
---|
558 | //************************************************************************************************************************************************** |
---|
559 | //funciones para consultas a base de datos |
---|
560 | |
---|
561 | module_load_include('inc', 'accion_especifica_de_proyecto_seguimiento', 'includes/proyecto/funciones_consulta_bd_proyecto.pages'); |
---|
562 | |
---|
563 | //************************************************************************************************************************************************** |
---|
564 | //fase de seguimiento |
---|
565 | module_load_include('inc', 'accion_especifica_de_proyecto_seguimiento', 'includes/fase_de_seguimiento_proyecto_y_aes.pages'); |
---|
566 | |
---|
567 | //colcar el enlace haci la fase de seguimiento del proyecto y sus acciones |
---|
568 | |
---|
569 | /* |
---|
570 | * Implementation of hook_acciones_obtiene_links_alter() |
---|
571 | */ |
---|
572 | function proyecto_operativo_seguimiento_proyecto_obtiene_links_alter(&$links, $proyecto, $acceso = FALSE) { |
---|
573 | $meses = json_decode(MESES); |
---|
574 | $mes_fase_seg = _obtener_mes_fase_seguimiento_proyecto($proyecto); |
---|
575 | $mes_seguimiento_proyecto_y_aes = variable_get('accion_especifica_de_proyecto_seguimiento_mes_seguimiento', 0); |
---|
576 | $cnt = variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 1); |
---|
577 | $nodo_proyecto = node_load($proyecto->nid); |
---|
578 | |
---|
579 | $anno = variable_get('accion_especifica_de_proyecto_seguimiento_anho_seguimiento', 0); |
---|
580 | $fecha = explode('-', $proyecto->field_proyecto_fecha_i[0]['value']); |
---|
581 | $mes_inicio = (int) $fecha[1]; |
---|
582 | $year_inicio = (int) $fecha[0]; |
---|
583 | |
---|
584 | //exluir el link de la tabla de proyectos |
---|
585 | if (($year_inicio < $anno) || ($year_inicio == $anno && in_array($mes_fase_seg, variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 1)))) { |
---|
586 | if($nodo_proyecto->anhoproyectos_operativos == variable_get('accion_especifica_de_proyecto_seguimiento_anho_seguimiento', 0) && _proyectooperativo_esta_aprobado($nodo_proyecto)){ |
---|
587 | $links[] = array( |
---|
588 | 'data' => l(t('Fase de Seguimiento'), 'proyectosop/' . $nodo_proyecto->nid . '/seguimiento'), |
---|
589 | 'class' => 'proyectos-operativos-faseseguimiento', |
---|
590 | ); |
---|
591 | } |
---|
592 | } |
---|
593 | } |
---|
594 | |
---|
595 | /** |
---|
596 | * Implementation of hook_node_load |
---|
597 | */ |
---|
598 | function proyecto_operativo_seguimiento_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
---|
599 | switch ($op) { |
---|
600 | case 'load': |
---|
601 | if ($node->type == 'proyectos_operativos') { |
---|
602 | $additions = db_fetch_object(db_query('SELECT acumulativo FROM {seguimiento_proyecto} WHERE nid = %d', $node->nid)); |
---|
603 | $node->es_acumulativo = $additions->acumulativo; |
---|
604 | } |
---|
605 | break; |
---|
606 | } |
---|
607 | } |
---|
608 | |
---|
609 | /** |
---|
610 | * Implementation of hook_views_api(). |
---|
611 | */ |
---|
612 | function proyecto_operativo_seguimiento_views_api() { |
---|
613 | return array( |
---|
614 | 'api' => '2.0', |
---|
615 | 'path' => drupal_get_path('module', 'proyecto_operativo_seguimiento') . '/views', |
---|
616 | ); |
---|
617 | } |
---|