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 | * @author CENDITEL Merida - Phd Juan Vizcarrondo (Actualizacion de funciones) |
---|
25 | * @date 2016-12-14 // (anno-mes-dia) |
---|
26 | * @version 0.1 |
---|
27 | * |
---|
28 | */ |
---|
29 | |
---|
30 | /* |
---|
31 | * Implementation of _obtener_estados_seguimiento_mes() |
---|
32 | * Obtiene estados del flujo de trabajo para el seguimiento |
---|
33 | */ |
---|
34 | function _obtener_estados_seguimiento_mes() { |
---|
35 | $estados = array(); |
---|
36 | $wid = 0; |
---|
37 | if (module_exists('workflow')) { |
---|
38 | //$wid = workflow_get_workflow_for_type('accion_centralizada'); |
---|
39 | $wid = workflow_get_workflow_for_type('proyectos_operativos'); |
---|
40 | if ($wid){ |
---|
41 | $estados = workflow_get_states($wid); |
---|
42 | } |
---|
43 | } |
---|
44 | return array( |
---|
45 | 'wid' => $wid, |
---|
46 | 'states' => $estados, |
---|
47 | ); |
---|
48 | } |
---|
49 | |
---|
50 | /* |
---|
51 | * Implementation of _obtener_estados_seguimiento_mes() |
---|
52 | * Obtiene estados del flujo de trabajo para seguimiento |
---|
53 | */ |
---|
54 | function _obtener_estados_seguimiento_mes_2() { |
---|
55 | $estados = array(); |
---|
56 | $wid = 0; |
---|
57 | if (module_exists('workflow')) { |
---|
58 | //$wid = workflow_get_workflow_for_type('accion_centralizada'); |
---|
59 | $wid = workflow_get_workflow_for_type('proyectos_operativos'); |
---|
60 | if ($wid){ |
---|
61 | $estados = workflow_get_states($wid); |
---|
62 | } |
---|
63 | } |
---|
64 | foreach($estados as $id => $estado){ |
---|
65 | $estados[$id] = _nombres_estado_seg_mes($estado); |
---|
66 | } |
---|
67 | return array( |
---|
68 | 'wid' => $wid, |
---|
69 | 'states' => $estados, |
---|
70 | ); |
---|
71 | } |
---|
72 | |
---|
73 | /* |
---|
74 | * Transforma los estado de workflow acciones_centralizadas a seguimiento_mes |
---|
75 | */ |
---|
76 | function _nombres_estado_seg_mes($nombre_estado='') { |
---|
77 | return ''; |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | function _nombres_estado_y_transiciones($nombre_estado='') { |
---|
82 | return ''; |
---|
83 | } |
---|
84 | |
---|
85 | //function _obtener_trnsiciones_disponibles($id_estado=0) { |
---|
86 | function _obtener_transiciones_disponibles($node, $mes = 0) { |
---|
87 | global $user; |
---|
88 | $consultaseguimientoactual = _seguimiento_mesactual_partida_ae_deproyecto_load($node, $mes); |
---|
89 | /* |
---|
90 | print '<pre>'; |
---|
91 | print_r($consultaseguimientoactual); |
---|
92 | print '</pre>'; |
---|
93 | */ |
---|
94 | $estado = (isset($consultaseguimientoactual['segmes']['estado'])) ? $consultaseguimientoactual['segmes']['estado'] : -1; |
---|
95 | $states = _obtener_estados_seguimiento_mes(); |
---|
96 | $ente = usuario_tiene_ente($user->uid); |
---|
97 | $roles = array_keys($user->roles); |
---|
98 | if ($user->uid == 1) { |
---|
99 | // Superuser is special. |
---|
100 | $roles_transition = 'ALL'; |
---|
101 | } |
---|
102 | else { |
---|
103 | $roles_transition = $roles; |
---|
104 | if ($user->uid == $consultaseguimientoactual['segmes']['uid']&& $consultaseguimientoactual['segmes']['uid'] > 0) {//verificar si es el autor del seguimiento |
---|
105 | $roles_transition += array('author' => 'author'); |
---|
106 | } |
---|
107 | } |
---|
108 | $transitions = array(); |
---|
109 | if ($states['wid']) { |
---|
110 | $transitions = workflow_allowable_transitions($estado, 'to', $roles_transition); |
---|
111 | } |
---|
112 | |
---|
113 | $TransicionesEstadosDisponibles = array(); |
---|
114 | foreach($transitions as $sid => $estado_i) { |
---|
115 | if ($estado != $sid){//evitando incluir la transicion hacia el mismo estado |
---|
116 | $TransicionesEstadosDisponibles[$sid] = $estado_i; |
---|
117 | } |
---|
118 | } |
---|
119 | $transiciones_disponibles = array( |
---|
120 | 'estado_actual' => $estado, |
---|
121 | 'nombre_estado_actual' => $states['states'][$estado], |
---|
122 | 'transic' => $TransicionesEstadosDisponibles, |
---|
123 | ); |
---|
124 | return $transiciones_disponibles; |
---|
125 | } |
---|
126 | |
---|
127 | function _calcular_color_semaforo_estado_actual($nombre_estado = '') { |
---|
128 | return ''; |
---|
129 | } |
---|
130 | |
---|
131 | function _obtener_nivel_usuario_segun_estado($nombre_estado='') { |
---|
132 | return ''; |
---|
133 | } |
---|
134 | |
---|
135 | function _obtener_rol_y_ente_de_usuario() { |
---|
136 | return ''; |
---|
137 | } |
---|
138 | |
---|
139 | // codificada lunes 22 03 13, por Diego Uzcátegui |
---|
140 | //para proyectos operativos |
---|
141 | function _obtener_transiciones_disponibles_proyecto($node, $mes = 0) { |
---|
142 | global $user; |
---|
143 | $consultaseguimientoactual = _seguimiento_mesactual_proyecto_load($node, $mes); |
---|
144 | $estado = (isset($consultaseguimientoactual['segmes']['estado'])) ? $consultaseguimientoactual['segmes']['estado'] : -1; |
---|
145 | $states = _obtener_estados_seguimiento_mes(); |
---|
146 | $states['states'][-1] = t('Por ingresar'); |
---|
147 | $ente = usuario_tiene_ente($user->uid); |
---|
148 | $roles = array_keys($user->roles); |
---|
149 | if ($user->uid == 1) { |
---|
150 | // Superuser is special. |
---|
151 | $roles_transition = 'ALL'; |
---|
152 | } |
---|
153 | else { |
---|
154 | $roles_transition = $roles; |
---|
155 | if ($user->uid == $consultaseguimientoactual['segmes']['uid'] && $consultaseguimientoactual['segmes']['uid'] > 0) {//verificar si es el autor del seguimiento |
---|
156 | $roles_transition += array('author' => 'author'); |
---|
157 | } |
---|
158 | } |
---|
159 | $transitions = array(); |
---|
160 | if ($states['wid']) { |
---|
161 | $transitions = workflow_allowable_transitions($estado, 'to', $roles_transition); |
---|
162 | } |
---|
163 | $current = workflow_node_current_state($node); |
---|
164 | $TransicionesEstadosDisponibles = array(); |
---|
165 | foreach($transitions as $sid => $estado_i){ |
---|
166 | if ($estado != $sid){//evitando incluir la transicion hacia el mismo estado |
---|
167 | $TransicionesEstadosDisponibles[$sid] = $estado_i; |
---|
168 | } |
---|
169 | } |
---|
170 | $transiciones_disponibles = array( |
---|
171 | 'estado_actual' => $estado, |
---|
172 | 'nombre_estado_actual' => $states['states'][$estado], |
---|
173 | 'transic' => $TransicionesEstadosDisponibles, |
---|
174 | ); |
---|
175 | return $transiciones_disponibles; |
---|
176 | } |
---|