source: sipes/0.3-modules/proyectos_operativos_seguimiento/includes/ae_proyecto/seguimiento_accion_especifica_deproyecto_partidaspormes.pages.inc @ 650248d

stable
Last change on this file since 650248d was 669d26e, checked in by Sipes Apn <root@…>, 7 años ago

se realizaron las correciones relacionadas al contador de fechas

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