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 | * Modificado |
---|
25 | * @author CENDITEL Merida - Msc. Juan Vizcarrondo |
---|
26 | * @date 2013-11-19 // (anno-mes-dia) |
---|
27 | * Correccion de meses y formato numerico |
---|
28 | * @version 0.1 |
---|
29 | * |
---|
30 | */ |
---|
31 | |
---|
32 | /** |
---|
33 | * Definicion del Formulario |
---|
34 | */ |
---|
35 | function seguimiento_proyecto_datospormes_modificar_form($form_state, $node, $mes = 0, $field = 'full') { |
---|
36 | if (!_mes_habilitado_para_seguimiento($mes)) { |
---|
37 | return FALSE; |
---|
38 | } |
---|
39 | |
---|
40 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
41 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
42 | $modulo_seguimiento_proyecto_y_aes_path = drupal_get_path('module', 'accion_especifica_de_proyecto_seguimiento'); |
---|
43 | drupal_add_js($modulo_seguimiento_proyecto_y_aes_path . '/js/seg_proyecto_validaciones_original.js'); |
---|
44 | $settings['accion_especifica_de_proyecto_seguimiento'] = _cargarconfiguracioncolorimetria(); |
---|
45 | drupal_add_js($settings, 'setting'); |
---|
46 | $format_number = array( |
---|
47 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
48 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
49 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
50 | ); |
---|
51 | $form['#format_number'] = array('format_number' => $format_number); |
---|
52 | drupal_add_js($form['#format_number'], 'setting'); |
---|
53 | $meses = json_decode(MESES); |
---|
54 | |
---|
55 | drupal_set_title(t('Seguimiento y Control de Proyecto Operativo'.' (mes de '.$meses[$mes -1].')')); |
---|
56 | $form = array(); |
---|
57 | |
---|
58 | $campo = ''; |
---|
59 | $form['#node'] = $node; |
---|
60 | $form['#mes'] = $mes; |
---|
61 | |
---|
62 | $form['#ftypes'] = array( |
---|
63 | 'value' => t('January'), |
---|
64 | 'value_1' => t('February'), |
---|
65 | 'value_2' => t('March'), |
---|
66 | 'value_3' => t('April'), |
---|
67 | 'value_4' => t('May'), |
---|
68 | 'value_5' => t('June'), |
---|
69 | 'value_6' => t('July'), |
---|
70 | 'value_7' => t('August'), |
---|
71 | 'value_8' => t('September'), |
---|
72 | 'value_9' => t('Octuber'), |
---|
73 | 'value_10' => t('November'), |
---|
74 | 'value_11' => t('December'), |
---|
75 | ); |
---|
76 | $output = ''; |
---|
77 | |
---|
78 | $consultaseguimientoactual = _seguimiento_mesactual_proyecto_load($node, $mes); |
---|
79 | |
---|
80 | //estado |
---|
81 | $estado = ((isset($consultaseguimientoactual['segmes']['estado'])) && ($consultaseguimientoactual['segmes']['estado'] > 0) )? $consultaseguimientoactual['segmes']['estado'] : -1; |
---|
82 | $form['#state_creation'] = $estado; |
---|
83 | //get first state |
---|
84 | if ($estado == -1 && module_exists('workflow')) { |
---|
85 | $wid = workflow_get_workflow_for_type('proyectos_operativos'); |
---|
86 | if ($wid) { |
---|
87 | $form['#state_creation'] = _workflow_creation_state($wid); |
---|
88 | } |
---|
89 | } |
---|
90 | $fecha = explode('-', $node->field_proyecto_fecha_i[0]['value']); |
---|
91 | $mes_inicio = (int) $fecha[1]; |
---|
92 | if (in_array($mes_inicio, variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 1))) { |
---|
93 | $form['es_acumulativo'] = array( |
---|
94 | '#type' => 'select', |
---|
95 | '#options' => array('No', 'Si'), |
---|
96 | '#default_value' => ($node->es_acumulativo) ? 1 : 0, |
---|
97 | ); |
---|
98 | } |
---|
99 | |
---|
100 | $header = array(); |
---|
101 | $header[] = array('data' => t('Partida')); |
---|
102 | $header[] = array('data' => t('Asignado')); |
---|
103 | $header[] = array('data' => t('Comprometido')); |
---|
104 | $header[] = array('data' => t('Causado')); |
---|
105 | $header[] = array('data' => t('Pagado')); |
---|
106 | $header[] = array('data' => t('% de Inversión')); |
---|
107 | $header[] = array('data' => t('Estatus de la Inversión')); |
---|
108 | $header[] = array('data' => t('Información Complementaria')); |
---|
109 | |
---|
110 | //calcular variacion por reformulacion |
---|
111 | $mesi = $mes -1; |
---|
112 | $variacion_planificado_mes = _seguimiento_mesactual_metafisica_proyecto_reformulaciones_load($node, $mes); |
---|
113 | $valor_texto = $mesi > 0 ? 'value_' . $mesi : 'value'; |
---|
114 | |
---|
115 | $cant_metafisica_planif = $node->field_proyecto_meta_fisica[0][$valor_texto] + $variacion_planificado_mes; |
---|
116 | $disabled = $cant_metafisica_planif == 0 ? TRUE : FALSE; |
---|
117 | $form['#metafisica_con_planificado_cero'] = $cant_metafisica_planif == 0 ? 1 : 0; |
---|
118 | |
---|
119 | $form['cantidad_metafisica_planificado'] = array( |
---|
120 | //'#title' => t('Ejecutado Meta Fisica'), |
---|
121 | '#type' => 'textfield', |
---|
122 | '#size' => 15, |
---|
123 | '#default_value' => $cant_metafisica_planif, |
---|
124 | '#attributes' => array('class' => 'number campo-asignado'), |
---|
125 | ); |
---|
126 | |
---|
127 | $seg_proyecto_path = drupal_get_path('module', 'accion_especifica_de_proyecto_seguimiento'); |
---|
128 | drupal_add_js($seg_proyecto_path . '/js/seguimiento_proyecto.js'); |
---|
129 | |
---|
130 | $cant_metafisica_ej = isset($consultaseguimientoactual['segmes']['ejecutadometafisica']) ? $consultaseguimientoactual['segmes']['ejecutadometafisica'] : 0; |
---|
131 | //op field show |
---|
132 | $form['#op_fields'] = $field; |
---|
133 | |
---|
134 | if ($field == 'comentario_metafisica' || $field == 'full') { |
---|
135 | $form['cantidad_metafisica_ejecutado'] = array( |
---|
136 | //'#title' => t('Ejecutado Meta Fisica'), |
---|
137 | '#type' => 'textfield', |
---|
138 | '#size' => 15, |
---|
139 | '#default_value' => $cant_metafisica_ej, |
---|
140 | // '#disabled' => $disabled, |
---|
141 | '#attributes' => array('class' => 'number', 'onchange' => "valpositivo('" . 'cantidad-metafisica-ejecutado' . "');calculaporc_metafisica('" . "');valenterometafisica('cantidad-metafisica-ejecutado')"), |
---|
142 | ); |
---|
143 | |
---|
144 | $zonacritica1 = $cant_metafisica_planif ? $cant_metafisica_ej/$cant_metafisica_planif : -1; |
---|
145 | // $porczonacritica1 = $zonacritica1 >= 0 ? ($zonacritica1 * 100) . '%' : 'N/A'; |
---|
146 | $porczonacritica1 = $zonacritica1 >= 0 ? ($zonacritica1 * 100) . '%' : $cant_metafisica_ej ? 'N/D' : 'N/A'; |
---|
147 | $form['cantidad_metafisica_porcen'] = array( |
---|
148 | '#type' => 'textfield', |
---|
149 | '#default_value' => $porczonacritica1, |
---|
150 | '#size' => 15, |
---|
151 | '#disabled' => TRUE, |
---|
152 | '#attributes' => array('class' => 'number',), |
---|
153 | ); |
---|
154 | |
---|
155 | $infocomplementaria_fisica = isset($consultaseguimientoactual['segmes']['infocomplementaria_metafisica']) ? $consultaseguimientoactual['segmes']['infocomplementaria_metafisica'] : ''; |
---|
156 | $form['comentario_metafisica'] = array( |
---|
157 | '#title' => t('Información Complementaria (Meta FÃsica)'), |
---|
158 | '#type' => 'textarea', |
---|
159 | '#default_value' => $infocomplementaria_fisica, |
---|
160 | ); |
---|
161 | } |
---|
162 | if ($field == 'comentario_informacionfinanciera' || $field == 'full') { |
---|
163 | $infocomplementaria_financiera = isset($consultaseguimientoactual['segmes']['infocomplementaria_metafinanciera']) ? $consultaseguimientoactual['segmes']['infocomplementaria_metafinanciera'] : ''; |
---|
164 | $form['comentario_informacionfinanciera'] = array( |
---|
165 | '#title' => t('Información Complementaria (Financiera)'), |
---|
166 | '#type' => 'textarea', |
---|
167 | '#default_value' => $infocomplementaria_financiera, |
---|
168 | ); |
---|
169 | } |
---|
170 | |
---|
171 | if (variable_get('proyectos_operativos_muestra_beneficiario', TRUE) && $field == 'comentario_metafisica' || $field == 'full') { |
---|
172 | $header3 = array(); |
---|
173 | $header3[] = array('data' => t('Beneficiario')); |
---|
174 | $header3[] = array('data' => t('Cantidad de Beneficiarios')); |
---|
175 | $cantbeneficiario_mes = 0; |
---|
176 | foreach($node->field_proyecto_beneficiario as $id => $beneficiarios) { |
---|
177 | foreach($consultaseguimientoactual['seguimientos_beneficiarios'] as $seg_benef){ |
---|
178 | if($id == $seg_benef['posicion_beneficiario']){ |
---|
179 | $cantbeneficiario_mes = isset($seg_benef['cant_beneficiarios_mes'])? $seg_benef['cant_beneficiarios_mes']:0; |
---|
180 | break; |
---|
181 | } |
---|
182 | } |
---|
183 | $form['tipobeneficiario_'.$id] = array( |
---|
184 | '#type' => 'textfield', |
---|
185 | '#default_value' => $cantbeneficiario_mes, |
---|
186 | '#size' => 15, |
---|
187 | '#disabled' => FALSE, |
---|
188 | '#attributes' => array('class' => 'number', 'onchange' => "valpositivo('tipobeneficiario-". $id . "');valenterometafisica('tipobeneficiario-". $id . "')"), |
---|
189 | ); |
---|
190 | } |
---|
191 | } |
---|
192 | |
---|
193 | |
---|
194 | $form['buttons'] = array( |
---|
195 | '#prefix' => '<div class="container-inline">', |
---|
196 | '#suffix' => '</div>', |
---|
197 | ); |
---|
198 | |
---|
199 | $form['buttons']['submit'] = array( |
---|
200 | '#type' => 'submit', |
---|
201 | '#value' => t('Guardar'), |
---|
202 | ); |
---|
203 | $form['buttons']['cancel'] = array('#value' => l('Cancelar', 'node/' . $form['#node']->nid . '/seguimiento_proyecto')); |
---|
204 | return $form; |
---|
205 | } |
---|
206 | |
---|
207 | |
---|
208 | /** |
---|
209 | * Implementation of hook_theme(). |
---|
210 | */ |
---|
211 | function proyecto_operativo_seguimiento_theme() { |
---|
212 | return array( |
---|
213 | 'seguimiento_proyecto_datospormes_modificar_form' => array( |
---|
214 | 'arguments' => array('form' => NULL), |
---|
215 | ), |
---|
216 | ); |
---|
217 | } |
---|
218 | /** |
---|
219 | * Formato para el formulario (campos en tablas y carga de algunos datos) |
---|
220 | */ |
---|
221 | function theme_seguimiento_proyecto_datospormes_modificar_form($form) { |
---|
222 | $meses = json_decode(MESES); |
---|
223 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
224 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
225 | $modulo_seguimiento_proyecto_y_aes_path = drupal_get_path('module', 'accion_especifica_de_proyecto_seguimiento'); |
---|
226 | drupal_add_js($modulo_seguimiento_proyecto_y_aes_path . '/js/seg_proyecto_validaciones_original.js'); |
---|
227 | drupal_add_js($form['#format_number'], 'setting'); |
---|
228 | $header = array(); |
---|
229 | $header[] = array('data' => t('AE')); |
---|
230 | $header[] = array('data' => t('Asignado')); |
---|
231 | $header[] = array('data' => t('Comprometido')); |
---|
232 | $header[] = array('data' => t('Causado')); |
---|
233 | $header[] = array('data' => t('Pagado')); |
---|
234 | $header[] = array('data' => t('% de Inversión')); |
---|
235 | $header[] = array('data' => t('Estatus de la Inversión')); |
---|
236 | |
---|
237 | $rows = array(); |
---|
238 | $consultaseguimientoactual = _seguimiento_mesactual_proyecto_load($form['#node'], $form['#mes']); |
---|
239 | $transiciones_dispo = _obtener_transiciones_disponibles($form['#node'], $form['#mes']); |
---|
240 | |
---|
241 | $status_actual = t('Por ingresar'); |
---|
242 | if (isset($transiciones_dispo['nombre_estado_actual'])) { |
---|
243 | $status_actual = $transiciones_dispo['nombre_estado_actual']; |
---|
244 | } |
---|
245 | $seguimiento_financiero_proyecto = _cargar_totales_seguimiento_aes_delproyecto($form['#node'], $form['#mes']); |
---|
246 | |
---|
247 | foreach ($seguimiento_financiero_proyecto['seg_financiero_aes'] as $acciones_especif) { |
---|
248 | $asignadov = $acciones_especif['totalAsignadoAEs']; |
---|
249 | $causadov = $acciones_especif['totalCausadoAEs']; |
---|
250 | $estatus_ejecucion = _calcularzonacritica($asignadov, $causadov); |
---|
251 | $porczonacritica = $estatus_ejecucion['porczonacritica']; |
---|
252 | $textozona = $estatus_ejecucion['textozona']; |
---|
253 | $colorzona = $estatus_ejecucion['colorzona']; |
---|
254 | $colorfontzona = $estatus_ejecucion['colorfontzona']; |
---|
255 | |
---|
256 | $nodo_ae = node_load($acciones_especif['idnodosAEs']); |
---|
257 | |
---|
258 | $row = array(); |
---|
259 | $row[] = array('data' => $acciones_especif['nombreAEs'],); |
---|
260 | if(_mes_dentro_de_duracion_ae_proyecto($nodo_ae, $form['#mes'])){ |
---|
261 | |
---|
262 | $row[] = array('data' => number_format($acciones_especif['totalAsignadoAEs'], $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']),); |
---|
263 | $row[] = array('data' => number_format($acciones_especif['totalComprometidoAEs'], $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']),); |
---|
264 | $row[] = array('data' => number_format($acciones_especif['totalCausadoAEs'], $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']),); |
---|
265 | $row[] = array('data' => number_format($acciones_especif['totalPagadoAEs'], $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']),); |
---|
266 | $row[] = array('data' => $porczonacritica,); |
---|
267 | $row[] = array('data' => $textozona, 'style' => 'font-weight: bold;background:' . $colorzona . '; color:' . $colorfontzona, 'id' => $partida['tid'] . '-inversion-form',); |
---|
268 | }else{ |
---|
269 | $row[] = array('data' => '-',); |
---|
270 | $row[] = array('data' => '-',); |
---|
271 | $row[] = array('data' => '-',); |
---|
272 | $row[] = array('data' => '-',); |
---|
273 | $row[] = array('data' => '-',); |
---|
274 | $row[] = array('data' => '-',); |
---|
275 | } |
---|
276 | $rows[] = $row; |
---|
277 | } |
---|
278 | $row = array(); |
---|
279 | $row[] = array('data' => 'Acumulado',); |
---|
280 | $row[] = array('data' => number_format($seguimiento_financiero_proyecto['seg_financiero_proyecto']['TotalAsignadoProyecto'], $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']),); |
---|
281 | $row[] = array('data' => number_format($seguimiento_financiero_proyecto['seg_financiero_proyecto']['TotalComprometidoProyecto'], $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']),); |
---|
282 | $row[] = array('data' => number_format($seguimiento_financiero_proyecto['seg_financiero_proyecto']['TotalCausadoProyecto'], $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']),); |
---|
283 | $row[] = array('data' => number_format($seguimiento_financiero_proyecto['seg_financiero_proyecto']['TotalPagadoProyecto'], $form['#format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']),); |
---|
284 | $row[] = array('data' => '', 'colspan' => 2); |
---|
285 | $rows[] = $row; |
---|
286 | |
---|
287 | $node= $form['#node']; |
---|
288 | |
---|
289 | $header2 = array(); |
---|
290 | $header2[] = array('data' => t('Planificado')); |
---|
291 | $header2[] = array('data' => t('Ejecutado')); |
---|
292 | $header2[] = array('data' => t('% de Logro')); |
---|
293 | $header2[] = array('data' => t('Estatus de la Inversión')); |
---|
294 | $rows2 = array(); |
---|
295 | |
---|
296 | $planificadov = $form['cantidad_metafisica_planificado']['#value']; |
---|
297 | $ejecutadov = $form['cantidad_metafisica_ejecutado']['#value']; |
---|
298 | $estatus_ejecucion = _calcularzonacritica($planificadov, $ejecutadov); |
---|
299 | $porczonacritica = $estatus_ejecucion['porczonacritica']; |
---|
300 | $textozona = $estatus_ejecucion['textozona']; |
---|
301 | $colorzona = $estatus_ejecucion['colorzona']; |
---|
302 | $colorfontzona = $estatus_ejecucion['colorfontzona']; |
---|
303 | |
---|
304 | $row2 = array(); |
---|
305 | $row2[] = array('data' => drupal_render($form['cantidad_metafisica_planificado']),); |
---|
306 | $row2[] = array('data' => drupal_render($form['cantidad_metafisica_ejecutado']),); |
---|
307 | $row2[] = array('data' => drupal_render($form['cantidad_metafisica_porcen']),); |
---|
308 | $row2[] = array('data' => $textozona, 'style' => 'font-weight: bold;background:' . $colorzona . '; color:' . $colorfontzona, 'id' => 'metafisica-inversion-form',); |
---|
309 | $rows2[] = $row2; |
---|
310 | |
---|
311 | |
---|
312 | $output = ''; |
---|
313 | |
---|
314 | $output .= '<br>'; |
---|
315 | |
---|
316 | $seguimiento_proyecto = _seguimiento_mesactual_proyecto_load($node, $i); |
---|
317 | $state_name = t("Por ingresar"); |
---|
318 | if (workflow_get_state_name($seguimiento_proyecto['segmes']['estado'])) { |
---|
319 | $state_name = workflow_get_state_name($seguimiento_proyecto['segmes']['estado']); |
---|
320 | } |
---|
321 | |
---|
322 | $grupo = explode('-', $form['#grupo']['label']); |
---|
323 | $output .= '<fieldset><legend>Datos del Proyecto Operativo</legend>'; |
---|
324 | $output .= '<b>Código del Proyecto:</b> '. $node->field_proyecto_codigo[0]['value'].'<br>'; |
---|
325 | $output .= '<b>Nombre del Proyecto:</b> '. $node->titulo_asignado.'<br>'; |
---|
326 | |
---|
327 | $output .= '<b>' . t('Estado del Seguimiento: ') . '</b>' . $state_name . '<br>'; |
---|
328 | $output .= '</fieldset>'; |
---|
329 | |
---|
330 | $fecha = explode('-', $node->field_proyecto_fecha_i[0]['value']); |
---|
331 | $mes_inicio = (int) $fecha[1]; |
---|
332 | |
---|
333 | if ($form['#op_fields'] == 'comentario_metafisica' || $form['#op_fields'] == 'full') { |
---|
334 | $output .= '<fieldset><legend>' . t('Indicadores de Meta FÃsica del Proyecto') . '</legend>'; |
---|
335 | |
---|
336 | if ($node->field_proyecto_unidadm) { |
---|
337 | $output .= '<b>' . t("Unidad de Medida del Proyecto: ") . '</b>'; |
---|
338 | $count = 0; |
---|
339 | $output .= '<ul>'; |
---|
340 | foreach ($node->field_proyecto_unidadm as $key => $value) { |
---|
341 | $count++; |
---|
342 | $tid = $value['value']; |
---|
343 | $term = taxonomy_get_term($tid); |
---|
344 | $output .= '<li>' . $count . '-) ' . $term->name . '</li>'; |
---|
345 | } |
---|
346 | $output .= '</ul>'; |
---|
347 | } |
---|
348 | if (in_array($mes_inicio, variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 1))) { |
---|
349 | $title[] = '<b>' . t('La unidad de medida se considera acumulativa:') . '</b>'; |
---|
350 | $column[] = array('data' => drupal_render($form['es_acumulativo'])); |
---|
351 | $columns[] = $column; |
---|
352 | $output .= theme('table', $title, $columns) . '<br>'; |
---|
353 | } |
---|
354 | $output .= '<div class="field-label"><b>' . t('Mes de Seguimiento Actual:') . '</b> ' . $meses[$form['#mes'] -1] . '</div>' . theme('table', $header2, $rows2) ; |
---|
355 | if($form['#metafisica_con_planificado_cero'] == 1){ |
---|
356 | $output .= '<br><b>Nota</b>: Si desea ingresar una cantidad de ejecutado de meta fÃsica mayor que cero, <i>primero</i> debe realizar una reformulación a la meta fÃsica de este mes.<br>'; |
---|
357 | } |
---|
358 | $output .= drupal_render($form['comentario_metafisica']); |
---|
359 | $output .= '</fieldset>'; |
---|
360 | } |
---|
361 | |
---|
362 | if ($form['#op_fields'] == 'comentario_informacionfinanciera') { |
---|
363 | for ($i=1; $i<=count($meses); $i++) { |
---|
364 | if (in_array($mes_inicio, variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 1))) { |
---|
365 | $title[] = '<b>' . t('La unidad de medida se considera acumulativa:') . '</b>'; |
---|
366 | $column[] = array('data' => drupal_render($form['es_acumulativo'])); |
---|
367 | $columns[] = $column; |
---|
368 | $output .= theme('table', $title, $columns) . '<br>'; |
---|
369 | } |
---|
370 | } |
---|
371 | $output .= '<fieldset><legend>' . t('Indicadores Financieros (por Acciones EspecÃficas) del Proyecto') . '</legend>' . '<div class="field-label"><b>' . t('Mes de Seguimiento Actual:') . '</b> ' . $meses[$form['#mes'] -1] . '</div>' . theme('table', $header, $rows) ; |
---|
372 | $output .= '<br><b>Nota</b>: Para modificar los valores de <b>\'Comprometido\'</b>, <b>\'Causado\'</b> y <b>\'Pagado\'</b> debe ingresar por el Seguimiento de cada Acción EspecÃfica.<br>'; |
---|
373 | $output .= drupal_render($form['comentario_informacionfinanciera']); |
---|
374 | $output .= '</fieldset>'; |
---|
375 | } |
---|
376 | |
---|
377 | //beneficiarios |
---|
378 | $muestra_beneficiarios = variable_get('proyectos_operativos_muestra_beneficiario', TRUE); |
---|
379 | $muestra = false; |
---|
380 | if ($muestra_beneficiarios && isset($form['comentario_metafisica'])) { |
---|
381 | $header3 = array(); |
---|
382 | $header3[] = array('data' => t('Beneficiario')); |
---|
383 | $rows3 = array(); |
---|
384 | foreach($node->field_proyecto_beneficiario as $id => $beneficiarios) { |
---|
385 | if (isset($form['tipobeneficiario_'.$id])) { |
---|
386 | $row3 = array(); |
---|
387 | $row3[] = array('data' => $beneficiarios['value'],); |
---|
388 | $row3[] = array('data' => drupal_render($form['tipobeneficiario_'.$id]),); |
---|
389 | $rows3[] = $row3; |
---|
390 | $muestra = true; |
---|
391 | } |
---|
392 | } |
---|
393 | } |
---|
394 | |
---|
395 | if ($muestra_beneficiarios && $muestra || $form['#op_fields'] == 'full') { |
---|
396 | $header3[] = array('data' => t('Cantidad de Beneficiarios durante el mes de ') . $meses[$form['#mes'] -1]); |
---|
397 | $output .= '<fieldset><legend>' . t('Beneficiarios del Proyecto (Durante la Ejecución)') . '</legend>' . '<div class="field-label"></div>' . theme('table', $header3, $rows3) ; |
---|
398 | $output .= '</fieldset>'; |
---|
399 | } |
---|
400 | |
---|
401 | $output .= _mostrarleyendazonacritica(); |
---|
402 | $output .= '<br>'; |
---|
403 | |
---|
404 | $output .= drupal_render($form); |
---|
405 | return $output; |
---|
406 | } |
---|
407 | |
---|
408 | /* |
---|
409 | * validacion del formulario |
---|
410 | * Implementation of seguimiento_proyecto_datospormes_modificar_form_validate() |
---|
411 | */ |
---|
412 | function seguimiento_proyecto_datospormes_modificar_form_validate($form, &$form_state) { |
---|
413 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
414 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
415 | $modulo_seguimiento_proyecto_y_aes_path = drupal_get_path('module', 'accion_especifica_de_proyecto_seguimiento'); |
---|
416 | drupal_add_js($modulo_seguimiento_proyecto_y_aes_path . '/js/seg_proyecto_validaciones_original.js'); |
---|
417 | drupal_add_js($form['#format_number'], 'setting'); |
---|
418 | //valores positivos meta fÃsica |
---|
419 | if (isset($form_state['values']['cantidad_metafisica_ejecutado'])) { |
---|
420 | if ($form_state['values']['cantidad_metafisica_ejecutado'] < 0) { |
---|
421 | form_set_error('cantidad_metafisica_ejecutado', t('El valor \'Ejecutado\' en la meta fÃsica debe ser mayor o igual a cero.')); |
---|
422 | } |
---|
423 | } |
---|
424 | |
---|
425 | //valores positivos cantidad de beneficiarios durante el mes |
---|
426 | if (variable_get('proyectos_operativos_muestra_beneficiario', TRUE) && isset($form['comentario_metafisica'])) { |
---|
427 | if (isset($form['#node']->field_proyecto_beneficiario)) { |
---|
428 | foreach($form['#node']->field_proyecto_beneficiario as $id => $beneficiarios) { |
---|
429 | if ($form_state['values']['tipobeneficiario_'.$id] < 0) { |
---|
430 | form_set_error('tipobeneficiario_'.$id, t('La cantidad de beneficiarios debe ser mayor o igual a cero.')); |
---|
431 | } |
---|
432 | } |
---|
433 | } |
---|
434 | } |
---|
435 | } |
---|
436 | |
---|
437 | /* |
---|
438 | * procesamiento del formulario |
---|
439 | * Implementation of seguimiento_proyecto_datospormes_modificar_form_submit() |
---|
440 | */ |
---|
441 | function seguimiento_proyecto_datospormes_modificar_form_submit($form, &$form_state) { |
---|
442 | global $user; |
---|
443 | $consultaseguimientoactual = _seguimiento_mesactual_proyecto_load($form['#node'], $form['#mes']); |
---|
444 | $es_acumulativo = isset($form_state['values']['es_acumulativo']) ? $form_state['values']['es_acumulativo'] : $form['#node']->es_acumulativo; |
---|
445 | if (isset($consultaseguimientoactual['segmes']['id_seg'])) { |
---|
446 | //actualizar |
---|
447 | if ($form['#op_fields'] == 'comentario_metafisica' || $form['#op_fields'] == 'full' && isset($form_state['values']['cantidad_metafisica_ejecutado'])) { |
---|
448 | $ss1=check_plain($form_state['values']['comentario_metafisica']); |
---|
449 | $exe_query = db_query("UPDATE {seguimiento_proyecto} SET ejecutadometafisica = %d, infocomplementaria_metafisica = '%s' WHERE id_seg = %d", $form_state['values']['cantidad_metafisica_ejecutado'], $ss1, $consultaseguimientoactual['segmes']['id_seg']); |
---|
450 | } |
---|
451 | if($form['#op_fields'] == 'comentario_informacionfinanciera' || $form['#op_fields'] == 'full' && isset($form_state['values']['comentario_informacionfinanciera'])) { |
---|
452 | $sss=check_plain($form_state['values']['comentario_informacionfinanciera']); |
---|
453 | $exe_query = db_query("UPDATE {seguimiento_proyecto} SET infocomplementaria_metafinanciera = '%s' WHERE id_seg = %d", $sss, $consultaseguimientoactual['segmes']['id_seg']); |
---|
454 | } |
---|
455 | $id_seg = $consultaseguimientoactual['segmes']['id_seg']; |
---|
456 | $exe_query = db_query("UPDATE {seguimiento_proyecto} SET acumulativo = %d WHERE nid = %d", $es_acumulativo, $form['#node']->nid); |
---|
457 | } |
---|
458 | else{ |
---|
459 | //insertar |
---|
460 | if (isset($form_state['values']['cantidad_metafisica_ejecutado'])) { |
---|
461 | $exe_query = db_query("INSERT INTO {seguimiento_proyecto} (nid, mes, ejecutadometafisica, infocomplementaria_metafisica, fecha, estado, uid, acumulativo) VALUES (%d, %d, %d, '%s', %d, %d, %d, %d)", $form['#node']->nid, $form['#mes'], $form_state['values']['cantidad_metafisica_ejecutado'], check_plain($form_state['values']['comentario_metafisica']), time(), $form['#state_creation'], $user->uid, $es_acumulativo); |
---|
462 | } |
---|
463 | else { |
---|
464 | $exe_query = db_query("INSERT INTO {seguimiento_proyecto} (nid, mes, infocomplementaria_metafinanciera, fecha, estado, uid, acumulativo) VALUES (%d, %d, '%s', '%s', '%s', %d, %d)", $form['#node']->nid, $form['#mes'], check_plain($form_state['values']['comentario_informacionfinanciera']), time(), $form['#state_creation'], $user->uid, $es_acumulativo); |
---|
465 | } |
---|
466 | $id_seg = db_last_insert_id('seguimiento_proyecto', 'id_seg'); |
---|
467 | //construir transicion (creacion) -> ingresado |
---|
468 | if (module_exists('workflow')) { |
---|
469 | $wid = workflow_get_workflow_for_type('proyectos_operativos'); |
---|
470 | if ($wid) { |
---|
471 | $estadoInicialFlujo = _workflow_creation_state($wid); |
---|
472 | if($estadoInicialFlujo==$form['#state_creation']){ |
---|
473 | |
---|
474 | //Siguiente estado |
---|
475 | $transitions = workflow_allowable_transitions($estadoInicialFlujo); |
---|
476 | unset($transitions[$estadoInicialFlujo]); |
---|
477 | |
---|
478 | db_query("INSERT INTO {seguimiento_proyecto_transiciones_estados} (estado, estado_ant, comentario, date, id_seg, uid) VALUES (%d, %d, '%s', %d, %d, %d)", key($transitions), $estadoInicialFlujo, 'Creación del Seguimiento', time(), $id_seg, $user->uid); |
---|
479 | |
---|
480 | $ultima_id_transicion_seg = db_query("SELECT max(a.id_seg_transicion_estado) AS id FROM {seguimiento_proyecto_transiciones_estados} AS a WHERE a.id_seg = %d", $id_seg); |
---|
481 | $seg_transicion_estado = db_fetch_object($ultima_id_transicion_seg); |
---|
482 | |
---|
483 | db_query('UPDATE {seguimiento_proyecto} SET estado = %d, id_seg_transicion_estado = %d WHERE id_seg = %d', key($transitions), $seg_transicion_estado->id, $id_seg); |
---|
484 | } |
---|
485 | } |
---|
486 | } |
---|
487 | } |
---|
488 | if (variable_get('proyectos_operativos_muestra_beneficiario', TRUE) && isset($form['comentario_metafisica'])) { |
---|
489 | if (isset($form['#node']->field_proyecto_beneficiario)) { |
---|
490 | foreach($form['#node']->field_proyecto_beneficiario as $id => $beneficiarios) { |
---|
491 | $actualizada=0; |
---|
492 | foreach($consultaseguimientoactual['seguimientos_beneficiarios'] as $seg_benef){ |
---|
493 | if($id == $seg_benef['posicion_beneficiario']){ |
---|
494 | //actualizar |
---|
495 | $exe_query = db_query("UPDATE {seguimiento_proyecto_beneficiarios} SET cant_beneficiarios_mes = %d WHERE id_seg_beneficiario = %d", $form_state['values']['tipobeneficiario_'.$id], $seg_benef['id_seg_beneficiario']); |
---|
496 | $actualizada=1; |
---|
497 | } |
---|
498 | } |
---|
499 | if($actualizada==0){//revisar |
---|
500 | //insertar |
---|
501 | $exe_query = db_query("INSERT INTO {seguimiento_proyecto_beneficiarios} (id_seg, posicion_beneficiario, cant_beneficiarios_mes) VALUES (%d, %d, %d)", $id_seg, $id, $form_state['values']['tipobeneficiario_'.$id]); |
---|
502 | } |
---|
503 | } |
---|
504 | } |
---|
505 | } |
---|
506 | |
---|
507 | if ($exe_query == true) { |
---|
508 | |
---|
509 | $meses = json_decode(MESES); |
---|
510 | |
---|
511 | $mes =$form['#mes']; |
---|
512 | drupal_set_message(t('Se ha guardado el seguimiento del mes de ').strval($meses[$mes]).' para el proyecto operativo.'); |
---|
513 | } |
---|
514 | if (!$_REQUEST['destination']) { |
---|
515 | $form_state['redirect'] = 'proyectosop/' . $form['#node']->nid . '/seguimiento/proyecto'; |
---|
516 | } |
---|
517 | } |
---|