1 | <?php |
---|
2 | /** |
---|
3 | * Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana |
---|
4 | * @file accion_especifica_de_proyecto_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 | |
---|
28 | /** |
---|
29 | * Pagina que carga el seguimiento por partidas de una accion especifica en un mes |
---|
30 | */ |
---|
31 | function seguimiento_accion_especifica_deproyecto_partidaspormes_page($proyecto, $ae, $mes = 0) { |
---|
32 | global $user; |
---|
33 | $meses = array( |
---|
34 | 0 => t('January'), |
---|
35 | 1 => t('February'), |
---|
36 | 2 => t('March'), |
---|
37 | 3 => t('April'), |
---|
38 | 4 => t('May'), |
---|
39 | 5 => t('June'), |
---|
40 | 6 => t('July'), |
---|
41 | 7 => t('August'), |
---|
42 | 8 => t('September'), |
---|
43 | 9 => t('Octuber'), |
---|
44 | 10 => t('November'), |
---|
45 | 11 => t('December'), |
---|
46 | ); |
---|
47 | |
---|
48 | drupal_set_title(t('Seguimiento y Control de Acción EspecÃfica de Proyecto '.' (Partidas en Mes de '.$meses[$mes].')')); |
---|
49 | |
---|
50 | $output = ''; |
---|
51 | $output .= '<br>'; |
---|
52 | $output .= _mostrar_segaepartidas($proyecto, $ae, $mes); |
---|
53 | |
---|
54 | $output .= _mostrarleyendazonacritica(); |
---|
55 | |
---|
56 | return $output; |
---|
57 | } |
---|
58 | |
---|
59 | /** |
---|
60 | * Pagina que carga la tabla de seguimiento por partidas de una accion especifica en un mes |
---|
61 | */ |
---|
62 | function _mostrar_segaepartidas($proyecto, $ae, $mes) { |
---|
63 | |
---|
64 | //reformulaciones aprobadas |
---|
65 | $ref_aprob = _seguimiento_mesactual_partida_ae_deproyecto_reformulaciones_load($ae, $mes); |
---|
66 | $format_number = array( |
---|
67 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
68 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
69 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
70 | ); |
---|
71 | $output = ''; |
---|
72 | $meses = array( |
---|
73 | 0 => t('January'), |
---|
74 | 1 => t('February'), |
---|
75 | 2 => t('March'), |
---|
76 | 3 => t('April'), |
---|
77 | 4 => t('May'), |
---|
78 | 5 => t('June'), |
---|
79 | 6 => t('July'), |
---|
80 | 7 => t('August'), |
---|
81 | 8 => t('September'), |
---|
82 | 9 => t('Octuber'), |
---|
83 | 10 => t('November'), |
---|
84 | 11 => t('December'), |
---|
85 | ); |
---|
86 | $ftypes = array( |
---|
87 | 'value' => t('January'), |
---|
88 | 'value_1' => t('February'), |
---|
89 | 'value_2' => t('March'), |
---|
90 | 'value_3' => t('April'), |
---|
91 | 'value_4' => t('May'), |
---|
92 | 'value_5' => t('June'), |
---|
93 | 'value_6' => t('July'), |
---|
94 | 'value_7' => t('August'), |
---|
95 | 'value_8' => t('September'), |
---|
96 | 'value_9' => t('Octuber'), |
---|
97 | 'value_10' => t('November'), |
---|
98 | 'value_11' => t('December'), |
---|
99 | ); |
---|
100 | |
---|
101 | $header = array(); |
---|
102 | $header[] = array('data' => t('Partida')); |
---|
103 | $header[] = array('data' => t('Asignado')); |
---|
104 | $header[] = array('data' => t('Comprometido')); |
---|
105 | $header[] = array('data' => t('Causado')); |
---|
106 | $header[] = array('data' => t('Pagado')); |
---|
107 | $header[] = array('data' => t('% de Inversión')); |
---|
108 | $header[] = array('data' => t('Estatus de la Inversión')); |
---|
109 | |
---|
110 | $consultaseguimientoactual = _seguimiento_mesactual_partida_ae_deproyecto_load($ae, $mes); |
---|
111 | |
---|
112 | $partidas_accion_especifica = $ae->field_accion_esp_programacion; |
---|
113 | foreach ($partidas_accion_especifica as $partida) { |
---|
114 | if ($partida['tid']) { |
---|
115 | |
---|
116 | //calcular la variacion si existe |
---|
117 | $variacion_por_ref = 0; |
---|
118 | foreach ($ref_aprob as $id => $ref_aprob_i){ |
---|
119 | if(($ref_aprob_i['partida'] == $partida['tid'])&&($ref_aprob_i['tomado_en_cuenta'] == 0)){ |
---|
120 | $variacion_por_ref += $ref_aprob_i['asignado_mes']; |
---|
121 | $ref_aprob[$id]['tomado_en_cuenta'] = 1; |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | $term = taxonomy_get_term($partida['tid']); |
---|
126 | // If this term's vocabulary supports localization. |
---|
127 | if (module_exists('i18ntaxonomy') && i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_LOCALIZE) { |
---|
128 | $term->name = tt("taxonomy:term:$term->tid:name", $term->name); |
---|
129 | } |
---|
130 | $valor = $mes > 0 ? 'value_' . $mes : 'value'; |
---|
131 | |
---|
132 | $asignadov = $partida[$valor] + $variacion_por_ref; |
---|
133 | $acumuladoAsignado += $asignadov; |
---|
134 | |
---|
135 | foreach ($consultaseguimientoactual['segmespartidas'] as $consultapartida) {//colocando valor en consulta |
---|
136 | if($partida['tid']==$consultapartida['partida']){ |
---|
137 | $comprometidov = isset($consultapartida['comprometido']) && $consultapartida['comprometido'] > 0? $consultapartida['comprometido'] : 0; |
---|
138 | $causadov = isset($consultapartida['causado']) && $consultapartida['causado'] > 0 ? $consultapartida['causado'] : 0; |
---|
139 | $pagadov = isset($consultapartida['pagado']) && $consultapartida['pagado'] > 0 ? $consultapartida['pagado'] : 0; |
---|
140 | |
---|
141 | $acumuladoComprometido += $comprometidov; |
---|
142 | $acumuladoCausado += $causadov; |
---|
143 | $acumuladoPagado += $pagadov; |
---|
144 | } |
---|
145 | } |
---|
146 | $comprometidov = isset($comprometidov) && $asignadov > 0? $comprometidov : 0; |
---|
147 | $causadov = isset($causadov) && $asignadov > 0? $causadov : 0; |
---|
148 | $pagadov = isset($pagadov) && $asignadov > 0? $pagadov : 0; |
---|
149 | |
---|
150 | $estatus_ejecucion = _calcularzonacritica($asignadov, $causadov); |
---|
151 | $porczonacritica = $estatus_ejecucion['porczonacritica']; |
---|
152 | $textozona = $estatus_ejecucion['textozona']; |
---|
153 | $colorzona = $estatus_ejecucion['colorzona']; |
---|
154 | $colorfontzona = $estatus_ejecucion['colorfontzona']; |
---|
155 | |
---|
156 | $row = array(); |
---|
157 | $row[] = array('data' => $term->name,); |
---|
158 | $row[] = array('data' => number_format($asignadov, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']),); |
---|
159 | $row[] = array('data' => number_format($comprometidov, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']),); |
---|
160 | $row[] = array('data' => number_format($causadov, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']),); |
---|
161 | $row[] = array('data' => number_format($pagadov, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']),); |
---|
162 | $row[] = array('data' => $porczonacritica,); |
---|
163 | $row[] = array('data' => $textozona, 'style' => 'font-weight: bold;background:' . $colorzona . '; color:' . $colorfontzona); |
---|
164 | $rows[] = $row; |
---|
165 | } |
---|
166 | } |
---|
167 | |
---|
168 | //colocar partidas nuevas por reformulacion ********************************************************************************** |
---|
169 | foreach ($ref_aprob as $id_0 => $ref_aprob_i_0){ |
---|
170 | if($ref_aprob_i_0['tomado_en_cuenta']==0){ |
---|
171 | $ref_aprob[$id_0]['tomado_en_cuenta']=1; |
---|
172 | //buscar todas las reformulaciones sobre esa partida |
---|
173 | $variacion_por_ref = $ref_aprob_i_0['asignado_mes']; |
---|
174 | $partida_actual = $ref_aprob_i_0['partida']; |
---|
175 | |
---|
176 | foreach ($ref_aprob as $id => $ref_aprob_i){ |
---|
177 | if(($ref_aprob_i['partida']==$partida_actual)&&($ref_aprob_i['tomado_en_cuenta']==0)){ |
---|
178 | $variacion_por_ref += $ref_aprob_i['asignado_mes']; |
---|
179 | $ref_aprob[$id]['tomado_en_cuenta']=1; |
---|
180 | } |
---|
181 | } |
---|
182 | |
---|
183 | $term = taxonomy_get_term($partida_actual); |
---|
184 | // If this term's vocabulary supports localization. |
---|
185 | if (module_exists('i18ntaxonomy') && i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_LOCALIZE) { |
---|
186 | $term->name = tt("taxonomy:term:$term->tid:name", $term->name); |
---|
187 | } |
---|
188 | |
---|
189 | $asignadov = $variacion_por_ref; |
---|
190 | $acumuladoAsignado += $asignadov; |
---|
191 | |
---|
192 | foreach ($consultaseguimientoactual['segmespartidas'] as $consultapartida) {//colocando valor en consulta |
---|
193 | if($partida_actual==$consultapartida['partida']){ |
---|
194 | $comprometidov = isset($consultapartida['comprometido']) && $consultapartida['comprometido'] > 0? $consultapartida['comprometido'] : 0; |
---|
195 | $causadov = isset($consultapartida['causado']) && $consultapartida['causado'] > 0 ? $consultapartida['causado'] : 0; |
---|
196 | $pagadov = isset($consultapartida['pagado']) && $consultapartida['pagado'] > 0 ? $consultapartida['pagado'] : 0; |
---|
197 | |
---|
198 | $acumuladoComprometido += $comprometidov; |
---|
199 | $acumuladoCausado += $causadov; |
---|
200 | $acumuladoPagado += $pagadov; |
---|
201 | } |
---|
202 | } |
---|
203 | $comprometidov = isset($comprometidov) && $asignadov > 0? $comprometidov : 0; |
---|
204 | $causadov = isset($causadov) && $asignadov > 0? $causadov : 0; |
---|
205 | $pagadov = isset($pagadov) && $asignadov > 0? $pagadov : 0; |
---|
206 | |
---|
207 | $estatus_ejecucion = _calcularzonacritica($asignadov, $causadov); |
---|
208 | $porczonacritica = $estatus_ejecucion['porczonacritica']; |
---|
209 | $textozona = $estatus_ejecucion['textozona']; |
---|
210 | $colorzona = $estatus_ejecucion['colorzona']; |
---|
211 | $colorfontzona = $estatus_ejecucion['colorfontzona']; |
---|
212 | |
---|
213 | $row = array(); |
---|
214 | $row[] = array('data' => $term->name,); |
---|
215 | $row[] = array('data' => number_format($asignadov, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']),); |
---|
216 | $row[] = array('data' => number_format($comprometidov, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']),); |
---|
217 | $row[] = array('data' => number_format($causadov, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']),); |
---|
218 | $row[] = array('data' => number_format($pagadov, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']),); |
---|
219 | $row[] = array('data' => $porczonacritica,); |
---|
220 | $row[] = array('data' => $textozona, 'style' => 'font-weight: bold;background:' . $colorzona . '; color:' . $colorfontzona); |
---|
221 | $rows[] = $row; |
---|
222 | } |
---|
223 | } |
---|
224 | |
---|
225 | $row = array(); |
---|
226 | $row[] = array('data' => t('Acumulado'),); |
---|
227 | $row[] = array('data' => number_format($acumuladoAsignado, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']),); |
---|
228 | $row[] = array('data' => number_format($acumuladoComprometido, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']),); |
---|
229 | $row[] = array('data' => number_format($acumuladoCausado, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']),); |
---|
230 | $row[] = array('data' => number_format($acumuladoPagado, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']),); |
---|
231 | $row[] = array('data' => '', 'colspan' => 2); |
---|
232 | $rows[] = $row; |
---|
233 | $output = ''; |
---|
234 | |
---|
235 | $grupo = explode('-', $grupos_fields['label']); |
---|
236 | |
---|
237 | //cargar el nodo del proyecto al que pertenece |
---|
238 | |
---|
239 | |
---|
240 | $output .= '<fieldset><legend>' . t('Datos del Proyecto al que pertenece la Acción EspecÃfica') . '</legend>'; |
---|
241 | $output .= '<b>' . t('Código del Proyecto') . ':</b> ' . $proyecto->field_proyecto_codigo[0]['value'] . '<br>'; |
---|
242 | $output .= '<b>' . t('Nombre del Proyecto') . ':</b> ' . $proyecto->titulo_asignado . '<br>'; |
---|
243 | $output .= '</fieldset>'; |
---|
244 | |
---|
245 | $output .= '<fieldset><legend>' . t('Datos de la Acción EspecÃfica') . '</legend>' . '<div class="field-label"><b>' . t('Nombre de la Acción EspecÃfica:') .'</b> ' . $ae->titulo_asignado . '</div>'. '</fieldset>'; |
---|
246 | $output .= '<fieldset><legend>' . t('Seguimiento de partidas de la Acción EspecÃfica') . '</legend>' . '<div class="field-label"><b>' . t('Mes de Seguimiento Actual:') . '</b> ' . $meses[$mes] . '</div><br>' . theme('table', $header, $rows) ; |
---|
247 | |
---|
248 | $infocomplementaria_financiera = isset($consultaseguimientoactual['segmes']['infocomplementaria_metafinanciera']) ? $consultaseguimientoactual['segmes']['infocomplementaria_metafinanciera'] : ''; |
---|
249 | |
---|
250 | $output .= '<br><div class="field-label"><b>' . t('Información Complementaria sobre la Meta Financiera:') . '</b> ' . $infocomplementaria_financiera . '</div>'; |
---|
251 | $output .= '</fieldset>'; |
---|
252 | |
---|
253 | $texto = array(); |
---|
254 | $mes_final = variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 0); |
---|
255 | if($mes > 0 && $mes <= $mes_final) { |
---|
256 | $texto[] = l(t('<< Consultar mes anterior'), 'proyectosop/' . $proyecto->nid . '/seguimiento/ae/' . $ae->nid . '/' . ($mes - 1) . '/view'); |
---|
257 | if ($mes < $mes_final) { |
---|
258 | $texto[] = l(t('Consultar mes próximo >>'), 'proyectosop/' . $proyecto->nid . '/seguimiento/ae/' . $ae->nid . '/' . ($mes + 1) . '/view'); |
---|
259 | } |
---|
260 | } |
---|
261 | elseif ($mes == 0) { |
---|
262 | $texto[] = l(t('Consultar mes próximo>>'), 'proyectosop/' . $proyecto->nid . '/seguimiento/ae/' . $ae->nid . '/' . ($mes + 1) . '/view'); |
---|
263 | } |
---|
264 | $output .= '<p align="center">' . implode(' | ', $texto) . "</p>"; |
---|
265 | |
---|
266 | return $output; |
---|
267 | } |
---|