1 | <?php |
---|
2 | /** |
---|
3 | * Sistema Integral de Planificación y Presupuesto (SIPP) |
---|
4 | * @file reportes_sipp.module |
---|
5 | * Drupal part Module to Sistema Integral de Planificación y Presupuesto (SIPP) |
---|
6 | * Copyright 2013 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 Uzcátegui (diego.uzc [at] gmail [dot] com) |
---|
23 | * @date 2013-05-01 // (año-mes-dia) |
---|
24 | * @version 0.1 // (0.1) |
---|
25 | * |
---|
26 | */ |
---|
27 | |
---|
28 | /* |
---|
29 | * Pagina que muestra el reporte de matriz de procesos |
---|
30 | * Implementado por: Ing. Diego Uzcátegui, |
---|
31 | * Inicio de codificación: 25-04-13 |
---|
32 | */ |
---|
33 | |
---|
34 | function matriz_de_procesos_reporte_trimestral_page(){ |
---|
35 | |
---|
36 | drupal_set_title(t('Matriz de procesos - Trimestral')); |
---|
37 | |
---|
38 | $output = '<br>'; |
---|
39 | |
---|
40 | $output .= drupal_get_form('consulta_matriz_de_procesos_reporte_trimestral_form'); |
---|
41 | |
---|
42 | $output .= '<br><br>'; |
---|
43 | |
---|
44 | //**************************************************************************** |
---|
45 | $trimestre_seleccionado_para_reporte = isset($_SESSION['datos_para_generar_reporte_mp_trimestral']['trimestre']) ? $_SESSION['datos_para_generar_reporte_mp_trimestral']['trimestre'] : 0; |
---|
46 | $trimestres_disponibles = array(t('1er Trimestre'), t('2do Trimestre'), t('3er Trimestre'), t('4to Trimestre')); |
---|
47 | $trimestre_selecc = isset($trimestres_disponibles[$trimestre_seleccionado_para_reporte])? $trimestres_disponibles[$trimestre_seleccionado_para_reporte] : 'Todos'; |
---|
48 | |
---|
49 | $ente_seleccionado_para_reporte = isset($_SESSION['datos_para_generar_reporte_mp_trimestral']) && isset($_SESSION['datos_para_generar_reporte_mp_trimestral']['ente']) ? $_SESSION['datos_para_generar_reporte_mp_trimestral']['ente'] : 0; |
---|
50 | if($ente_seleccionado_para_reporte > 0){ |
---|
51 | $nodo_ente = node_load($ente_seleccionado_para_reporte); |
---|
52 | $ente_selecc = l($nodo_ente->title, 'node/' . $nodo_ente->nid); |
---|
53 | }else{ |
---|
54 | $ente_selecc = 'Todos'; |
---|
55 | } |
---|
56 | |
---|
57 | $anno_seleccionado_para_reporte = isset($_SESSION['datos_para_generar_reporte_mp_trimestral']) && isset($_SESSION['datos_para_generar_reporte_mp_trimestral']['anho']) ? $_SESSION['datos_para_generar_reporte_mp_trimestral']['anho'] : date('Y'); |
---|
58 | if($anno_seleccionado_para_reporte > 0){ |
---|
59 | $anho_selecc = $anno_seleccionado_para_reporte; |
---|
60 | }else{ |
---|
61 | $anho_selecc = 'Todos'; |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | $header = array(); |
---|
66 | |
---|
67 | $rows1 = array(); |
---|
68 | |
---|
69 | $row1 = array(); |
---|
70 | $row1[] = array('data' => 'Año', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
71 | $row1[] = array('data' => $anho_selecc, 'bgcolor' => 'FCFCFC',); |
---|
72 | $rows1[] = $row1; |
---|
73 | |
---|
74 | $row1 = array(); |
---|
75 | $row1[] = array('data' => 'Trimestre(es)', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
76 | $row1[] = array('data' => $trimestre_selecc, 'bgcolor' => 'FCFCFC',); |
---|
77 | $rows1[] = $row1; |
---|
78 | |
---|
79 | $row1 = array(); |
---|
80 | $row1[] = array('data' => 'Ente Planificador', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
81 | $row1[] = array('data' => $ente_selecc, 'bgcolor' => 'FCFCFC',); |
---|
82 | $rows1[] = $row1; |
---|
83 | |
---|
84 | $output .= theme('table', $header, $rows1); |
---|
85 | $output .= '<br><br>'; |
---|
86 | |
---|
87 | //**************************************************************************** |
---|
88 | $inputs = array(); |
---|
89 | $sql = ''; |
---|
90 | |
---|
91 | $header = array(); |
---|
92 | $row_header = array(); |
---|
93 | $header[] = array('data' => t('Año')); |
---|
94 | $row_header[] = array('data' => '', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
95 | $header[] = array('data' => t('Ente.')); |
---|
96 | $row_header[] = array('data' => '', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
97 | $cab = 2; |
---|
98 | |
---|
99 | $header[] = array('data' => t('Datos del Proyecto'), 'colspan' => 3, ); |
---|
100 | $row_header[] = array('data' => 'Nombre', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
101 | $row_header[] = array('data' => 'Código', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
102 | $row_header[] = array('data' => 'DirectrÃz PNDES', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
103 | $cab += 3; |
---|
104 | |
---|
105 | $row_header[] = array('data' => 'Unidad de Medida', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
106 | $cab += 1; |
---|
107 | |
---|
108 | //colocar cabceras correspondientes avance fisico y financiero para el proyecto en el mes actual |
---|
109 | if($trimestre_seleccionado_para_reporte == 4){//todos los meses |
---|
110 | |
---|
111 | $header[] = array('data' => t('Meta FÃsica hasta ahora'), 'colspan' => 2,); |
---|
112 | $row_header[] = array('data' => t('Cantidad'), 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
113 | $header[] = array('data' => t('Presupuesto del año') ); |
---|
114 | $row_header[] = array('data' => '', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
115 | $header[] = array('data' => t('Beneficiarios hasta ahora') ); |
---|
116 | $row_header[] = array('data' => '', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
117 | $cab = $cab + 3; |
---|
118 | |
---|
119 | foreach($trimestres_disponibles as $trimestre_i){ |
---|
120 | $header[] = array('data' => $trimestre_i, 'colspan' => 2, ); |
---|
121 | $row_header[] = array('data' => '% Avance FÃsico', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
122 | $row_header[] = array('data' => '% Ejecución Financiera', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
123 | $cab = $cab + 2; |
---|
124 | } |
---|
125 | }else{ |
---|
126 | |
---|
127 | //solo un trimestre |
---|
128 | $header[] = array('data' => t('Meta FÃsica en el trimestre') , 'colspan' => 2,); |
---|
129 | $row_header[] = array('data' => t('Cantidad'), 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
130 | $header[] = array('data' => t('Presupuesto del año').'<br>' ); |
---|
131 | $row_header[] = array('data' => '', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
132 | $header[] = array('data' => t('Beneficiarios en el trimestre') ); |
---|
133 | $row_header[] = array('data' => '', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
134 | $cab = $cab + 3; |
---|
135 | |
---|
136 | $header[] = array('data' => $trimestres_disponibles[$trimestre_seleccionado_para_reporte], 'colspan' => 2, ); |
---|
137 | $row_header[] = array('data' => '% Avance FÃsico', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
138 | $row_header[] = array('data' => '% Ejecución Financiera', 'bgcolor' => 'E6E6E6', 'style' => 'font-weight: bold;'); |
---|
139 | $cab = $cab + 2; |
---|
140 | |
---|
141 | } |
---|
142 | |
---|
143 | //proyectos operativos con estado aprobado |
---|
144 | $sql1 = "SELECT n.nid, n.title, po.year, po.ente, wn.sid FROM {proyectos_operativos} po, {node} n, {workflow_node} AS wn WHERE po.nid = n.nid AND wn.nid = n.nid AND wn.sid = %d "; |
---|
145 | $inputs[] = variable_get('proyectos_operativos_state_aprobado', NULL); |
---|
146 | |
---|
147 | //verificar filtro de ente planificador |
---|
148 | $ente_seleccionado_para_reporte = isset($_SESSION['datos_para_generar_reporte_mp_trimestral']) && isset($_SESSION['datos_para_generar_reporte_mp_trimestral']['ente']) ? $_SESSION['datos_para_generar_reporte_mp_trimestral']['ente'] : 0; |
---|
149 | if($ente_seleccionado_para_reporte > 0){ |
---|
150 | $sql1 .= "AND po.ente = %d "; |
---|
151 | $inputs[] = $ente_seleccionado_para_reporte; |
---|
152 | } |
---|
153 | |
---|
154 | //verificar filtro de anho |
---|
155 | $anno_seleccionado_para_reporte = isset($_SESSION['datos_para_generar_reporte_mp_trimestral']) && isset($_SESSION['datos_para_generar_reporte_mp_trimestral']['anho']) ? $_SESSION['datos_para_generar_reporte_mp_trimestral']['anho'] : date('Y'); |
---|
156 | if($anno_seleccionado_para_reporte > 0){ |
---|
157 | $sql1 .= "AND po.year = %d "; |
---|
158 | $inputs[] = $anno_seleccionado_para_reporte; |
---|
159 | } |
---|
160 | |
---|
161 | $queryResult1 = db_query ( $sql1, $inputs); |
---|
162 | $rows = array(); |
---|
163 | $rows[] = $row_header; |
---|
164 | while ($proyectos = db_fetch_array ( $queryResult1 ) ){ |
---|
165 | $row = array(); |
---|
166 | $row[] = array('data' => $proyectos['year'],); |
---|
167 | |
---|
168 | //cargar nodo para mostrar otros datos |
---|
169 | $ente_planificador = node_load($proyectos['ente']); |
---|
170 | $row[] = array('data' => l($ente_planificador->title, 'node/' . $proyectos['ente']),); |
---|
171 | |
---|
172 | $row[] = array('data' => l($proyectos['title'], 'proyectosop/' . $proyectos['nid']),); |
---|
173 | |
---|
174 | //cargar nodo para mostrar otros datos |
---|
175 | $nodo_proyecto = node_load($proyectos['nid']); |
---|
176 | $row[] = array('data' => $nodo_proyecto->field_proyecto_codigo[0]['value'] ); |
---|
177 | $term = taxonomy_get_term($nodo_proyecto->field_proyecto_pndes[0]['value']); |
---|
178 | $row[] = array('data' => $term->name ); |
---|
179 | $term = taxonomy_get_term($nodo_proyecto->field_proyecto_unidadm[0]['value']); |
---|
180 | $row[] = array('data' => $term->name ); |
---|
181 | |
---|
182 | //calcular avance fisico y financiero para el proyecto en el trimestre actual |
---|
183 | if($trimestre_seleccionado_para_reporte == 4){ |
---|
184 | |
---|
185 | //calcular cantidad de meta fisica y de beneficiarios |
---|
186 | module_load_include('inc', 'reportes_sipp' , 'includes/matriz_de_procesos_reporte_mensual.pages'); |
---|
187 | $datos_mf_benef_monto = _calcular_cantmf_beneficiarios_montoref_total($nodo_proyecto); |
---|
188 | $row[] = array('data' => $datos_mf_benef_monto['cant_ejecut_metafisica'] ); |
---|
189 | $row[] = array('data' => $datos_mf_benef_monto['monto_total_proyecto'] ); |
---|
190 | $row[] = array('data' => $datos_mf_benef_monto['cant_beneficiarios_mes'] ); |
---|
191 | |
---|
192 | //calcular todos los trimestres |
---|
193 | foreach($trimestres_disponibles as $id => $trimestre_i){ |
---|
194 | $porcentajes_avance = _calcular_porcentaje_avance_para_trimestre($nodo_proyecto, $id); |
---|
195 | $porczonacritica_mf = $porcentajes_avance['avance_fisico'] != 'N/A' ? number_format($porcentajes_avance['avance_fisico'], 2, '.', ',').'%' : 'N/A'; |
---|
196 | $row[] = array('data' => $porczonacritica_mf ); |
---|
197 | $porczonacritica_financiera = $porcentajes_avance['ejecucion_financiera'] != 'N/A' ? number_format($porcentajes_avance['ejecucion_financiera'], 2, '.', ',').'%' : 'N/A'; |
---|
198 | $row[] = array('data' => $porczonacritica_financiera ); |
---|
199 | } |
---|
200 | |
---|
201 | }else{ |
---|
202 | |
---|
203 | //calcular trimestre actual |
---|
204 | $porcentajes_avance = _calcular_porcentaje_avance_para_trimestre($nodo_proyecto, $trimestre_seleccionado_para_reporte); |
---|
205 | $row[] = array('data' => $porcentajes_avance['valores_particulares']['mf_ejecutado_trimestre'] ); |
---|
206 | |
---|
207 | //calcular cantidad de meta fisica y de beneficiarios |
---|
208 | $datos_mf_benef_monto = _calcular_cantmf_beneficiarios_montoref_para_trimestre($nodo_proyecto, $trimestre_seleccionado_para_reporte); |
---|
209 | $row[] = array('data' => $datos_mf_benef_monto['monto_total_proyecto'] ); |
---|
210 | $row[] = array('data' => $datos_mf_benef_monto['cant_beneficiarios_mes'] ); |
---|
211 | |
---|
212 | $porczonacritica_mf = $porcentajes_avance['avance_fisico'] != 'N/A' ? number_format($porcentajes_avance['avance_fisico'], 2, '.', ',').'%' : 'N/A'; |
---|
213 | $row[] = array('data' => $porczonacritica_mf ); |
---|
214 | $porczonacritica_financiera = $porcentajes_avance['ejecucion_financiera'] != 'N/A' ? number_format($porcentajes_avance['ejecucion_financiera'], 2, '.', ',').'%' : 'N/A'; |
---|
215 | $row[] = array('data' => $porczonacritica_financiera ); |
---|
216 | } |
---|
217 | |
---|
218 | $rows[] = $row; |
---|
219 | } |
---|
220 | |
---|
221 | if (!(count($rows)>1)) { |
---|
222 | $row[] = array('data' => t('No hay resultados para la consulta actual'), 'colspan' => $cab); |
---|
223 | $rows[] = $row; |
---|
224 | } |
---|
225 | |
---|
226 | $output .= theme('table', $header, $rows); |
---|
227 | |
---|
228 | return $output; |
---|
229 | } |
---|
230 | |
---|
231 | /** |
---|
232 | * Implementation of consulta_matriz_de_procesos_reporte_trimestral_form(). |
---|
233 | * Formulario de busqueda de proyecto. |
---|
234 | */ |
---|
235 | function consulta_matriz_de_procesos_reporte_trimestral_form($form_state) { |
---|
236 | $form = array(); |
---|
237 | |
---|
238 | //entes planificadores |
---|
239 | $entes = array(); |
---|
240 | $result = db_query('SELECT e.nid, n.title FROM {ente_planificador} AS e INNER JOIN {node} AS n ON n.nid = e.nid WHERE n.status = 1 AND e.tipo = 2 '); |
---|
241 | while($ente = db_fetch_object($result)) { |
---|
242 | $entes[$ente->nid] = $ente->title; |
---|
243 | } |
---|
244 | $entes[0] = 'Todos'; |
---|
245 | $ente_seleccionado_para_reporte = isset($_SESSION['datos_para_generar_reporte_mp_trimestral']) && isset($_SESSION['datos_para_generar_reporte_mp_trimestral']['ente']) ? $_SESSION['datos_para_generar_reporte_mp_trimestral']['ente'] : 0; |
---|
246 | $form['ente_seleccionado_para_reporte'] = array( |
---|
247 | '#title' => t('Ente Planificador'), |
---|
248 | '#type' => 'select', |
---|
249 | '#default_value' => $ente_seleccionado_para_reporte, |
---|
250 | '#options' => $entes, |
---|
251 | ); |
---|
252 | |
---|
253 | //años disponibles |
---|
254 | $anno_actual = date("Y"); |
---|
255 | for($i = $anno_actual - 10; $i <= $anno_actual; $i++) { |
---|
256 | $annos[$i] = $i; |
---|
257 | } |
---|
258 | $annos[0] = 'Todos'; |
---|
259 | $anno_seleccionado_para_reporte = isset($_SESSION['datos_para_generar_reporte_mp_trimestral']) && isset($_SESSION['datos_para_generar_reporte_mp_trimestral']['anho']) ? $_SESSION['datos_para_generar_reporte_mp_trimestral']['anho'] : date('Y'); |
---|
260 | $form['anno_seleccionado_para_reporte'] = array( |
---|
261 | '#title' => t('Consultar para el año'), |
---|
262 | '#type' => 'select', |
---|
263 | '#default_value' => $anno_seleccionado_para_reporte, |
---|
264 | '#options' => $annos, |
---|
265 | ); |
---|
266 | |
---|
267 | //tipo de periodo |
---|
268 | $tipo_periodo = t('Trimestral'); |
---|
269 | //subopciones de periodo |
---|
270 | $sub_opciones = array(t('1er Trimestre'), t('2do Trimestre'), t('3er Trimestre'), t('4to Trimestre'), t('Todos')); |
---|
271 | $trimestre_seleccionado_para_reporte = isset($_SESSION['datos_para_generar_reporte_mp_trimestral']) && isset($_SESSION['datos_para_generar_reporte_mp_trimestral']['trimestre']) ? $_SESSION['datos_para_generar_reporte_mp_trimestral']['trimestre'] : 0; |
---|
272 | $form['trimestre_seleccionado_para_reporte'] = array( |
---|
273 | '#title' => t('Trimestre(s)'), |
---|
274 | '#type' => 'select', |
---|
275 | '#default_value' => $trimestre_seleccionado_para_reporte, |
---|
276 | '#options' => $sub_opciones, |
---|
277 | ); |
---|
278 | |
---|
279 | //boton de enviar consulta |
---|
280 | $form['buttons'] = array( |
---|
281 | '#prefix' => '<div class="container-inline">', |
---|
282 | '#suffix' => '</div>', |
---|
283 | ); |
---|
284 | $form['buttons']['submit'] = array( |
---|
285 | '#type' => 'submit', |
---|
286 | '#value' => t('Consultar'), |
---|
287 | ); |
---|
288 | return $form; |
---|
289 | } |
---|
290 | |
---|
291 | /** |
---|
292 | * Implementation of consulta_matriz_de_procesos_reporte_trimestral_form_submit(). |
---|
293 | * cambia el filtro de busqueda de proyectos. |
---|
294 | */ |
---|
295 | function consulta_matriz_de_procesos_reporte_trimestral_form_submit($form, &$form_state) { |
---|
296 | $_SESSION['datos_para_generar_reporte_mp_trimestral'] = array(); |
---|
297 | |
---|
298 | $_SESSION['datos_para_generar_reporte_mp_trimestral']['ente'] = $form_state['values']['ente_seleccionado_para_reporte']; |
---|
299 | $_SESSION['datos_para_generar_reporte_mp_trimestral']['anho'] = $form_state['values']['anno_seleccionado_para_reporte']; |
---|
300 | $_SESSION['datos_para_generar_reporte_mp_trimestral']['trimestre'] = $form_state['values']['trimestre_seleccionado_para_reporte']; |
---|
301 | } |
---|
302 | |
---|
303 | |
---|
304 | /** |
---|
305 | * Implementation of _calcular_porcentaje_avance_para_trimestre(). |
---|
306 | * calcula el porcentaje de avance fisico y financiero para un mes particular |
---|
307 | */ |
---|
308 | function _calcular_porcentaje_avance_para_trimestre($node, $trimestre){ |
---|
309 | |
---|
310 | $cant_meses = 0; |
---|
311 | |
---|
312 | $seg_metafisica_todos = _seguimiento_metafisica_todosmes_proyecto_load_solo_datos_aprobados($node); |
---|
313 | $seguimiento_todos_meses_financiero = _seguimiento_financiero_todosmes_proyecto_load_solo_datos_aprobados($node); |
---|
314 | |
---|
315 | $planificadoTrimestre = 0; |
---|
316 | $EjecutadoTrimestre = 0; |
---|
317 | $asignadoTrimestre = 0; |
---|
318 | $totalComprometidoTrimestre = 0; |
---|
319 | $totalCausadoTrimestre = 0; |
---|
320 | $totalPagadoTrimestre = 0; |
---|
321 | |
---|
322 | //identificando meses abarcados en el trimestre |
---|
323 | $v_inicial = $trimestre * 3; |
---|
324 | $v_final = $v_inicial + 3; |
---|
325 | for($i=$v_inicial; $i < $v_final; $i++){ |
---|
326 | |
---|
327 | if(_mes_dentro_de_duracion_proyecto($node, $i)){ |
---|
328 | $cant_meses += 1; |
---|
329 | |
---|
330 | //calcular planificado y ejecutado de los meses |
---|
331 | $variacion_planificado_mes = _seguimiento_mesactual_metafisica_proyecto_reformulaciones_load($node, $i);//calcular variacion por reformulacion |
---|
332 | $planificadoMes = $seg_metafisica_todos['seguimiento_metafisica_todosmes'][$i]['planificadoMes'] + $variacion_planificado_mes; |
---|
333 | $EjecutadoMes = $seg_metafisica_todos['seguimiento_metafisica_todosmes'][$i]['ejecutadoMes']; |
---|
334 | $planificadoTrimestre += $planificadoMes; |
---|
335 | $EjecutadoTrimestre += $EjecutadoMes; |
---|
336 | |
---|
337 | //calcular asignado y causado de los meses |
---|
338 | $variacion_total_ref_asignado = _seguimiento_mesactual_total_proyecto_reformulaciones_load($node, $i);//calcular variación por reformulación |
---|
339 | $asignadoMes = $seguimiento_todos_meses_financiero['seguimiento_financiero_todosmes'][$i]['asignadoMes'] + $variacion_total_ref_asignado; |
---|
340 | $totalComprometidoMes = $seguimiento_todos_meses_financiero['seguimiento_financiero_todosmes'][$i]['comprometidoMes']; |
---|
341 | $totalCausadoMes = $seguimiento_todos_meses_financiero['seguimiento_financiero_todosmes'][$i]['causadoMes']; |
---|
342 | $totalPagadoMes = $seguimiento_todos_meses_financiero['seguimiento_financiero_todosmes'][$i]['pagadoMes']; |
---|
343 | $asignadoTrimestre += $asignadoMes; |
---|
344 | $totalComprometidoTrimestre += $totalComprometidoMes; |
---|
345 | $totalCausadoTrimestre += $totalCausadoMes; |
---|
346 | $totalPagadoTrimestre += $totalPagadoMes; |
---|
347 | } |
---|
348 | |
---|
349 | } |
---|
350 | |
---|
351 | //calcular porcentajes |
---|
352 | $porc_avance_fisico = $planificadoTrimestre ? (($EjecutadoTrimestre/$planificadoTrimestre) *100) . '%' : 'N/A'; |
---|
353 | $porc_ejecucion_financiera = $asignadoTrimestre ? (($totalCausadoTrimestre/$asignadoTrimestre) *100) . '%' : 'N/A'; |
---|
354 | |
---|
355 | if($cant_meses == 0){ |
---|
356 | $porc_avance_fisico = 'N/A'; |
---|
357 | $porc_ejecucion_financiera = 'N/A'; |
---|
358 | } |
---|
359 | |
---|
360 | $valores_particulares = array( |
---|
361 | 'mf_planificado_trimestre' => $planificadoTrimestre,//meta fisica planificada con reformulaciones aprobadas |
---|
362 | 'mf_ejecutado_trimestre' => $EjecutadoTrimestre,//meta fisica ejecutada |
---|
363 | 'financiera_asignado_trimestre' => $asignadoTrimestre,//asignado financiero con reformulaciones aprobadas |
---|
364 | 'financiera_comprometido_trimestre' => $totalComprometidoTrimestre,//comprometido financiero |
---|
365 | 'financiera_causado_trimestre' => $totalCausadoTrimestre,//causado financiero |
---|
366 | 'financiera_pagado_trimestre' => $totalPagadoTrimestre,//pagado financiero |
---|
367 | ); |
---|
368 | |
---|
369 | $porcentajes_avance = array( |
---|
370 | 'avance_fisico' => $porc_avance_fisico, |
---|
371 | 'ejecucion_financiera' => $porc_ejecucion_financiera, |
---|
372 | 'valores_particulares' => $valores_particulares, |
---|
373 | ); |
---|
374 | |
---|
375 | return $porcentajes_avance; |
---|
376 | } |
---|
377 | |
---|
378 | /** |
---|
379 | * Implementation of _calcular_cantmf_beneficiarios_montoref_para_trimestre(). |
---|
380 | * calcula el porcentaje de avance fisico y financiero para un trimestre particular (cant ejecutado y beneficiarios) |
---|
381 | */ |
---|
382 | function _calcular_cantmf_beneficiarios_montoref_para_trimestre($node, $trimestre){ |
---|
383 | |
---|
384 | $cant_meses = 0; |
---|
385 | |
---|
386 | //ejecutado meta fÃsica |
---|
387 | $seg_metafisica_todos = _seguimiento_metafisica_todosmes_proyecto_load_solo_datos_aprobados($node); |
---|
388 | $cant_ejecut_metafisica = 0; |
---|
389 | |
---|
390 | //beneficiarios |
---|
391 | $seguimiento_todos_meses_beneficiario = _seguimiento_beneficiario_todosmes_proyecto_load_solo_datos_aprobados($node); |
---|
392 | $cant_beneficiarios_mes = 0; |
---|
393 | |
---|
394 | //identificando meses abarcados en el trimestre |
---|
395 | $v_inicial = $trimestre * 3; |
---|
396 | $v_final = $v_inicial + 3; |
---|
397 | for($i=$v_inicial; $i < $v_final; $i++){ |
---|
398 | |
---|
399 | if(_mes_dentro_de_duracion_proyecto($node, $i)){ |
---|
400 | $cant_meses += 1; |
---|
401 | |
---|
402 | //cantidad ejecutado meta fisica |
---|
403 | $cant_ejecut_mf_mes = $seg_metafisica_todos['seguimiento_metafisica_todosmes'][$i]['ejecutadoMes']; |
---|
404 | $cant_ejecut_metafisica += $cant_ejecut_mf_mes; |
---|
405 | |
---|
406 | //beneficiarios |
---|
407 | foreach($seguimiento_todos_meses_beneficiario as $seg_benef){ |
---|
408 | if(_mes_dentro_de_duracion_proyecto($node, $i)){ |
---|
409 | $cant_beneficiarios_mes += $seg_benef['cant_meses'][$i]; |
---|
410 | } |
---|
411 | } |
---|
412 | |
---|
413 | } |
---|
414 | } |
---|
415 | |
---|
416 | if($cant_meses == 0){ |
---|
417 | $cant_ejecut_metafisica = 'N/A'; |
---|
418 | $cant_beneficiarios_mes = 'N/A'; |
---|
419 | } |
---|
420 | |
---|
421 | //monto total del año |
---|
422 | $monto_total_inicial = $node->field_proyecto_monto_anual[0]['value']; |
---|
423 | $variacion_total_aprobada = _variacion_monto_total_por_reformulaciones_proyecto_load($node); |
---|
424 | $monto_total_proyecto = number_format($monto_total_inicial + $variacion_total_aprobada, 0, '.', ' ').' Bs'; |
---|
425 | |
---|
426 | $datos_mf_benef_monto = array( |
---|
427 | 'cant_ejecut_metafisica' => $cant_ejecut_metafisica, |
---|
428 | 'cant_beneficiarios_mes' => $cant_beneficiarios_mes, |
---|
429 | 'monto_total_proyecto' => $monto_total_proyecto, |
---|
430 | ); |
---|
431 | |
---|
432 | return $datos_mf_benef_monto; |
---|
433 | } |
---|