1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana |
---|
5 | * @file accion_especifica_de_proyecto_seguimiento.module |
---|
6 | * Drupal part Module to code proyectos operativos module |
---|
7 | * Copyright 2012 Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana (CENDITEL) |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or modify |
---|
10 | * it under the terms of the GNU General Public License as published by |
---|
11 | * the Free Software Foundation; either version 2 of the License, or |
---|
12 | * (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
22 | * |
---|
23 | * @author CENDITEL Merida - Ing. Diego Uzcategui |
---|
24 | * @date 2013-02-07 // (anno-mes-dia) |
---|
25 | * Modificado |
---|
26 | * @author CENDITEL Merida - Msc. Juan Vizcarrondo |
---|
27 | * @date 2013-11-19 // (anno-mes-dia) |
---|
28 | * Correccion de meses y formato numerico |
---|
29 | * @version 0.1 |
---|
30 | * |
---|
31 | */ |
---|
32 | |
---|
33 | /** |
---|
34 | * Definicion del Formulario |
---|
35 | */ |
---|
36 | function seguimiento_accion_especifica_deproyecto_partidaspormes_modificar_form($form_state, $proyecto, $ae, $mes = 0, $field = 'full') { |
---|
37 | if (!$mes) { |
---|
38 | $mes = variable_get('accion_especifica_de_proyecto_seguimiento_mes_seguimiento', 0) ; |
---|
39 | } |
---|
40 | $form['#field_type'] = $field; |
---|
41 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
42 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
43 | $modulo_seguimiento_proyecto_y_aes_path = drupal_get_path('module', 'accion_especifica_de_proyecto_seguimiento'); |
---|
44 | drupal_add_js($modulo_seguimiento_proyecto_y_aes_path . '/js/seg_proyecto_validaciones_original.js'); |
---|
45 | $settings['accion_especifica_de_proyecto_seguimiento'] = _cargarconfiguracioncolorimetria(); |
---|
46 | drupal_add_js($settings, 'setting'); |
---|
47 | $format_number = array( |
---|
48 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
49 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
50 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
51 | ); |
---|
52 | $form['#format_number'] = array('format_number' => $format_number); |
---|
53 | |
---|
54 | drupal_add_js($form['#format_number'], 'setting'); |
---|
55 | |
---|
56 | //reformulaciones aprobadas |
---|
57 | $ref_aprob = _seguimiento_mesactual_partida_ae_deproyecto_reformulaciones_load($ae, $mes); |
---|
58 | $meses = json_decode(MESES); |
---|
59 | drupal_set_title(t('Seguimiento y Control de Acción EspecÃfica de Proyecto Operativo (Mes de '.$meses[$mes -1].')')); |
---|
60 | $form = array(); |
---|
61 | $campo = ''; |
---|
62 | $form['#accion_especifica_de_proyecto_seguimiento'] = $settings['accion_especifica_de_proyecto_seguimiento']; |
---|
63 | $form['#node'] = $ae; |
---|
64 | $form['#proyecto'] = $proyecto; |
---|
65 | $form['#mes'] = $mes; |
---|
66 | |
---|
67 | $form['#ftypes'] = array( |
---|
68 | 'value' => t('January'), |
---|
69 | 'value_1' => t('February'), |
---|
70 | 'value_2' => t('March'), |
---|
71 | 'value_3' => t('April'), |
---|
72 | 'value_4' => t('May'), |
---|
73 | 'value_5' => t('June'), |
---|
74 | 'value_6' => t('July'), |
---|
75 | 'value_7' => t('August'), |
---|
76 | 'value_8' => t('September'), |
---|
77 | 'value_9' => t('Octuber'), |
---|
78 | 'value_10' => t('November'), |
---|
79 | 'value_11' => t('December'), |
---|
80 | ); |
---|
81 | $output = ''; |
---|
82 | |
---|
83 | $consultaseguimientoactual = _seguimiento_mesactual_partida_ae_deproyecto_load($ae, $mes); |
---|
84 | |
---|
85 | //estado |
---|
86 | $estado = (isset($consultaseguimientoactual['segmes']['estado'])) ? $consultaseguimientoactual['segmes']['estado'] : -1; |
---|
87 | $form['#state_creation'] = $estado; |
---|
88 | //get first state |
---|
89 | $form['#estado_inicial'] = 0; |
---|
90 | |
---|
91 | |
---|
92 | if ($estado == -1 && module_exists('workflow')) { |
---|
93 | $estados = _proyectos_operativos_reformulacion_obtiene_estados(); |
---|
94 | $estado_inicial = variable_get('proyectos_operativos_state_seguimiento', 0); |
---|
95 | $form['#estado_inicial'] = _workflow_creation_state($estados['wid']); |
---|
96 | if ($estados['wid']) { |
---|
97 | if ($estado_inicial && $estados['states'][$estado_inicial]) { |
---|
98 | $form['#state_creation'] = $estado_inicial; |
---|
99 | } |
---|
100 | else { |
---|
101 | $form['#state_creation'] = $form['#estado_inicial']; |
---|
102 | } |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | $header = array(); |
---|
107 | $header[] = array('data' => t('Partida')); |
---|
108 | $header[] = array('data' => t('Asignado')); |
---|
109 | $header[] = array('data' => t('Comprometido')); |
---|
110 | $header[] = array('data' => t('Causado')); |
---|
111 | $header[] = array('data' => t('Pagado')); |
---|
112 | $header[] = array('data' => t('% de Inversión')); |
---|
113 | $header[] = array('data' => t('Estatus de la Inversión')); |
---|
114 | $header[] = array('data' => t('Información Complementaria')); |
---|
115 | $grupos_form = array(); |
---|
116 | |
---|
117 | $alguna_partida_con_asignado_cero = 0;//bandera para verificar que si se muestra el mensajes sobre reformulaciones |
---|
118 | $partidas_accion_especifica = $ae->field_accion_esp_programacion; |
---|
119 | $mesi = $mes - 1; |
---|
120 | foreach ($partidas_accion_especifica as $partida) { |
---|
121 | if ($partida['tid']) { |
---|
122 | |
---|
123 | //calcular la variacion si existe |
---|
124 | $variacion_por_ref = 0; |
---|
125 | foreach ($ref_aprob as $id => $ref_aprob_i) { |
---|
126 | if(($ref_aprob_i['partida']==$partida['tid'])&&($ref_aprob_i['tomado_en_cuenta']==0)){ |
---|
127 | $variacion_por_ref += $ref_aprob_i['asignado_mes']; |
---|
128 | $ref_aprob[$id]['tomado_en_cuenta']=1; |
---|
129 | } |
---|
130 | } |
---|
131 | |
---|
132 | $term = taxonomy_get_term($partida['tid']); |
---|
133 | // If this term's vocabulary supports localization. |
---|
134 | if (module_exists('i18ntaxonomy') && i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_LOCALIZE) { |
---|
135 | $term->name = tt("taxonomy:term:$term->tid:name", $term->name); |
---|
136 | } |
---|
137 | |
---|
138 | $valor1 = $mesi > 0 ? 'value_' . $mesi : 'value'; |
---|
139 | |
---|
140 | $comprometidov = 0; |
---|
141 | $causadov = 0; |
---|
142 | $pagadov = 0; |
---|
143 | |
---|
144 | $asignadov = $partida[$valor1] + $variacion_por_ref; |
---|
145 | // if($asignadov){ |
---|
146 | foreach ($consultaseguimientoactual['segmespartidas'] as $consultapartida) {//colocando valor por omision (consultado de base de datos si esta) |
---|
147 | if($partida['tid']==$consultapartida['partida']){ |
---|
148 | $comprometidov = isset($consultapartida['comprometido']) && $consultapartida['comprometido'] > 0? $consultapartida['comprometido'] : 0; |
---|
149 | $causadov = isset($consultapartida['causado']) && $consultapartida['causado'] > 0 ? $consultapartida['causado'] : 0; |
---|
150 | $pagadov = isset($consultapartida['pagado']) && $consultapartida['pagado'] > 0 ? $consultapartida['pagado'] : 0; |
---|
151 | } |
---|
152 | } |
---|
153 | /* }else{ |
---|
154 | $alguna_partida_con_asignado_cero = 1; |
---|
155 | } |
---|
156 | */ |
---|
157 | $desabilitarasignado = $asignadov == 0 ? TRUE : FALSE; |
---|
158 | $zonacritica = $asignadov ? ($causadov/$asignadov)*100 : -1; |
---|
159 | |
---|
160 | $porczonacritica = $zonacritica >= 0 ? ($zonacritica * 100) . '%' : 'N/A'; |
---|
161 | $porczonacritica = round($porczonacritica, 2); |
---|
162 | //$porczonacritica = $zonacritica >= 0 ? ($zonacritica) . '%' : $causadov ? 'N/D' : 'N/A'; //no definido|no agregado |
---|
163 | $form[$partida['tid'] . '_asignado'] = array( |
---|
164 | '#type' => 'textfield', |
---|
165 | '#default_value' => $asignadov, |
---|
166 | '#size' => 15, |
---|
167 | '#disabled' => $desabilitarasignado, |
---|
168 | '#attributes' => array('class' => 'number campo-asignado'), |
---|
169 | ); |
---|
170 | $disabled = $asignadov == 0 ? TRUE : FALSE; |
---|
171 | $form[$partida['tid'] . '_comprometido'] = array( |
---|
172 | '#type' => 'textfield', |
---|
173 | '#default_value' => $comprometidov, |
---|
174 | '#size' => 15, |
---|
175 | // '#disabled' => $disabled, |
---|
176 | '#attributes' => array('class' => 'number', 'onchange' => "valpositivo('" . $partida['tid'] . '-comprometido' . "'); valentero('" . $partida['tid'] . '-comprometido' . "');"), |
---|
177 | ); |
---|
178 | $form[$partida['tid'] . '_causado'] = array( |
---|
179 | '#type' => 'textfield', |
---|
180 | '#default_value' => $causadov, |
---|
181 | '#size' => 15, |
---|
182 | // '#disabled' => $disabled, |
---|
183 | '#attributes' => array('class' => 'number indicadores-financieros-por-partidas', 'onchange' => "valpositivo('" . $partida['tid'] . '-causado' . "');calculaporc('" . $partida['tid'] . "');valentero('" . $partida['tid'] . '-causado' . "');"), |
---|
184 | ); |
---|
185 | $form[$partida['tid'] . '_pagado'] = array( |
---|
186 | '#type' => 'textfield', |
---|
187 | '#default_value' => $pagadov, |
---|
188 | '#size' => 15, |
---|
189 | // '#disabled' => $disabled, |
---|
190 | '#attributes' => array('class' => 'number', 'onchange' => "valpositivo('" . $partida['tid'] . '-pagado' . "');valentero('" . $partida['tid'] . '-pagado' . "');"), |
---|
191 | ); |
---|
192 | $form[$partida['tid'] . '_porcen'] = array( |
---|
193 | '#type' => 'textfield', |
---|
194 | '#default_value' => $porczonacritica, |
---|
195 | '#size' => 5, |
---|
196 | '#disabled' => TRUE, |
---|
197 | ); |
---|
198 | } |
---|
199 | } |
---|
200 | |
---|
201 | $form['#alguna_partida_con_asignado_cero']= $alguna_partida_con_asignado_cero; |
---|
202 | |
---|
203 | $partidas_nuevas_por_ref = array(); |
---|
204 | |
---|
205 | //colocar partidas nuevas por reformulacion ********************************************************************************** |
---|
206 | foreach ($ref_aprob as $id_0 => $ref_aprob_i_0) { |
---|
207 | if($ref_aprob_i_0['tomado_en_cuenta']==0){ |
---|
208 | $ref_aprob[$id_0]['tomado_en_cuenta']=1; |
---|
209 | $partida_actual = $ref_aprob_i_0['partida']; |
---|
210 | $partidas_nuevas_por_ref[] = $partida_actual; |
---|
211 | |
---|
212 | //buscar todas las reformulaciones sobre esa partida en el mes actual |
---|
213 | $variacion_por_ref = $ref_aprob_i_0['asignado_mes']; |
---|
214 | foreach ($ref_aprob as $id => $ref_aprob_i){ |
---|
215 | if(($ref_aprob_i['partida']==$partida_actual)&&($ref_aprob_i['tomado_en_cuenta']==0)){ |
---|
216 | $variacion_por_ref += $ref_aprob_i['asignado_mes']; |
---|
217 | $ref_aprob[$id]['tomado_en_cuenta']=1; |
---|
218 | } |
---|
219 | } |
---|
220 | |
---|
221 | $term = taxonomy_get_term($partida_actual); |
---|
222 | // If this term's vocabulary supports localization. |
---|
223 | if (module_exists('i18ntaxonomy') && i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_LOCALIZE) { |
---|
224 | $term->name = tt("taxonomy:term:$term->tid:name", $term->name); |
---|
225 | } |
---|
226 | |
---|
227 | $asignadov = $variacion_por_ref; |
---|
228 | |
---|
229 | $comprometidov = 0; |
---|
230 | $causadov = 0; |
---|
231 | $pagadov = 0; |
---|
232 | |
---|
233 | foreach ($consultaseguimientoactual['segmespartidas'] as $consultapartida) {//colocando valor por omision (consultado de base de datos si esta) |
---|
234 | if($partida_actual==$consultapartida['partida']){ |
---|
235 | $comprometidov = isset($consultapartida['comprometido']) && $consultapartida['comprometido'] > 0? $consultapartida['comprometido'] : 0; |
---|
236 | $causadov = isset($consultapartida['causado']) && $consultapartida['causado'] > 0 ? $consultapartida['causado'] : 0; |
---|
237 | $pagadov = isset($consultapartida['pagado']) && $consultapartida['pagado'] > 0 ? $consultapartida['pagado'] : 0; |
---|
238 | } |
---|
239 | } |
---|
240 | |
---|
241 | $desabilitarasignado = $asignadov == 0 ? TRUE : FALSE; |
---|
242 | $zonacritica = $asignadov ? $causadov/$asignadov : -1; |
---|
243 | $porczonacritica = $zonacritica >= 0 ? ($zonacritica * 100) . '%' : 'N/A'; |
---|
244 | $porczonacritica = round($porczonacritica, 2); |
---|
245 | //$porczonacritica = $zonacritica >= 0 ? ($zonacritica * 100) . '%' : $causadov ? 'N/D' : 'N/A'; |
---|
246 | $form[$partida_actual . '_asignado'] = array( |
---|
247 | '#type' => 'textfield', |
---|
248 | '#default_value' => $asignadov, |
---|
249 | '#size' => 15, |
---|
250 | '#disabled' => $desabilitarasignado, |
---|
251 | '#attributes' => array('class' => 'number campo-asignado'), |
---|
252 | ); |
---|
253 | $disabled = $asignadov == 0 ? TRUE : FALSE; |
---|
254 | $form[$partida_actual . '_comprometido'] = array( |
---|
255 | '#type' => 'textfield', |
---|
256 | '#default_value' => $comprometidov, |
---|
257 | '#size' => 15, |
---|
258 | // '#disabled' => $disabled, |
---|
259 | '#attributes' => array('class' =>'number', 'onchange' => "valpositivo('" . $partida_actual . '-comprometido' . "'); valentero('" . $partida_actual . '-comprometido' . "');"), |
---|
260 | ); |
---|
261 | $form[$partida_actual . '_causado'] = array( |
---|
262 | '#type' => 'textfield', |
---|
263 | '#default_value' => $causadov, |
---|
264 | '#size' => 15, |
---|
265 | '#disabled' => $disabled, |
---|
266 | '#attributes' => array('class' =>'number indicadores-financieros-por-partidas','onchange' => "valpositivo('" . $partida_actual . '-causado' . "');calculaporc('" . $partida_actual . "');valentero('" . $partida_actual . '-causado' . "');"), |
---|
267 | ); |
---|
268 | $form[$partida_actual . '_pagado'] = array( |
---|
269 | '#type' => 'textfield', |
---|
270 | '#default_value' => $pagadov, |
---|
271 | '#size' => 15, |
---|
272 | // '#disabled' => $disabled, |
---|
273 | '#attributes' => array('class' =>'number','onchange' => "valpositivo('" . $partida_actual . '-pagado' . "');valentero('" . $partida_actual . '-pagado' . "');"), |
---|
274 | ); |
---|
275 | $form[$partida_actual . '_porcen'] = array( |
---|
276 | '#type' => 'textfield', |
---|
277 | '#default_value' => $porczonacritica, |
---|
278 | '#size' => 15, |
---|
279 | '#disabled' => TRUE, |
---|
280 | ); |
---|
281 | } |
---|
282 | } |
---|
283 | |
---|
284 | $form['#partidas_nuevas_por_ref'] = $partidas_nuevas_por_ref; |
---|
285 | |
---|
286 | //*************************************************************************************************************************** |
---|
287 | |
---|
288 | //calcular variacion en el planificado de la meta fisica |
---|
289 | |
---|
290 | $variacion_planificado_mes = _seguimiento_mesactual_metafisica_ae_deproyecto_reformulaciones_load($ae, $mes); |
---|
291 | $valor_texto = $mesi > 0 ? 'value_' . $mesi : 'value'; |
---|
292 | $cant_metafisica_planif = $ae->field_accion_esp_metaf[0][$valor_texto] + $variacion_planificado_mes; |
---|
293 | $disabled = $cant_metafisica_planif == 0 ? TRUE : FALSE; |
---|
294 | $form['#metafisica_con_planificado_cero'] = $cant_metafisica_planif == 0 ? 1 : 0; |
---|
295 | |
---|
296 | $form['cantidad_metafisica_planificado'] = array( |
---|
297 | //'#title' => t('Ejecutado Meta Fisica'), |
---|
298 | '#type' => 'textfield', |
---|
299 | '#size' => 15, |
---|
300 | '#default_value' => $cant_metafisica_planif, |
---|
301 | '#attributes' => array('class' => 'number campo-asignado'), |
---|
302 | ); |
---|
303 | |
---|
304 | $fecha = explode('-', $proyecto->field_proyecto_fecha_i[0]['value']); |
---|
305 | $mes_inicio = (int) $fecha[1]; |
---|
306 | if (in_array($mes, variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 1))) { |
---|
307 | $form['acumulativo_metafisica_planificado'] = array( |
---|
308 | //'#title' => t('Es acumulativo'), |
---|
309 | '#type' => 'select', |
---|
310 | '#options' => array(t('NO'), t('SI')), |
---|
311 | '#default_value' => ($ae->es_acumulativo) ? 1 : 0, |
---|
312 | '#required' => TRUE, |
---|
313 | ); |
---|
314 | } |
---|
315 | |
---|
316 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
317 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
318 | $seg_proyecto_path = drupal_get_path('module', 'accion_especifica_de_proyecto_seguimiento'); |
---|
319 | drupal_add_js($seg_proyecto_path . '/js/seguimiento_proyecto.js'); |
---|
320 | |
---|
321 | $consultaseguimientoactual = _seguimiento_mesactual_partida_ae_deproyecto_load($ae, $mes); |
---|
322 | $cant_metafisica_ej = isset($consultaseguimientoactual['segmes']['ejecutadometafisica']) ? $consultaseguimientoactual['segmes']['ejecutadometafisica'] : 0; |
---|
323 | |
---|
324 | $form['cantidad_metafisica_ejecutado'] = array( |
---|
325 | //'#title' => t('Ejecutado Meta Fisica'), |
---|
326 | '#type' => 'textfield', |
---|
327 | '#size' => 15, |
---|
328 | '#default_value' => $cant_metafisica_ej, |
---|
329 | // '#disabled' => $disabled, |
---|
330 | '#attributes' => array('class' => 'number cantidad_metafisica_ejecutado', 'onchange' => "valpositivo('" . 'cantidad-metafisica-ejecutado' . "');calculaporc_metafisica('" . "');valenterometafisica('cantidad-metafisica-ejecutado')"), |
---|
331 | ); |
---|
332 | |
---|
333 | $zonacritica1 = $cant_metafisica_planif ? $cant_metafisica_ej/$cant_metafisica_planif : -1; |
---|
334 | $porczonacritica1 = $zonacritica1 >= 0 ? ($zonacritica1 * 100) . '%' : 'N/A'; |
---|
335 | $porczonacritica1 = round($porczonacritica1, 2); |
---|
336 | //$porczonacritica1 = $zonacritica1 >= 0 ? ($zonacritica1 * 100) . '%' : $cant_metafisica_ej ? 'N/D' : 'N/A'; |
---|
337 | $form['cantidad_metafisica_porcen'] = array( |
---|
338 | '#type' => 'textfield', |
---|
339 | '#default_value' => $porczonacritica1, |
---|
340 | '#size' => 15, |
---|
341 | '#disabled' => TRUE, |
---|
342 | ); |
---|
343 | |
---|
344 | if ($field == 'comentario_metafisica' || $field == 'full') { |
---|
345 | $infocomplementaria_fisica = isset($consultaseguimientoactual['segmes']['infocomplementaria_metafisica']) ? $consultaseguimientoactual['segmes']['infocomplementaria_metafisica'] : ''; |
---|
346 | $form['comentario_metafisica'] = array( |
---|
347 | '#title' => t('Información Complementaria (Meta FÃsica)'), |
---|
348 | '#type' => 'textarea', |
---|
349 | '#default_value' => $infocomplementaria_fisica, |
---|
350 | ); |
---|
351 | } |
---|
352 | $infocomplementaria_financiera = isset($consultaseguimientoactual['segmes']['infocomplementaria_metafinanciera']) ? $consultaseguimientoactual['segmes']['infocomplementaria_metafinanciera'] : ''; |
---|
353 | |
---|
354 | if ($field == 'comentario_informacionfinanciera' || $field == 'full') { |
---|
355 | $form['comentario_informacionfinanciera'] = array( |
---|
356 | '#title' => t('Información Complementaria (Financiera)'), |
---|
357 | '#type' => 'textarea', |
---|
358 | '#default_value' => $infocomplementaria_financiera, |
---|
359 | ); |
---|
360 | } |
---|
361 | $form['buttons'] = array( |
---|
362 | '#prefix' => '<div class="container-inline">', |
---|
363 | '#suffix' => '</div>', |
---|
364 | ); |
---|
365 | |
---|
366 | $form['buttons']['submit'] = array( |
---|
367 | '#type' => 'submit', |
---|
368 | '#value' => t('Guardar'), |
---|
369 | ); |
---|
370 | $form['buttons']['cancel'] = array('#value' => l('Cancelar', 'proyectosop/' . $form['#proyecto']->nid . '/seguimiento/ae' . $form['#node']->nid . '/partidas/' . $form['#mes'])); |
---|
371 | return $form; |
---|
372 | } |
---|
373 | |
---|
374 | |
---|
375 | /** |
---|
376 | * Implementation of hook_theme(). |
---|
377 | */ |
---|
378 | function accion_especifica_de_proyecto_seguimiento_theme() { |
---|
379 | return array( |
---|
380 | 'seguimiento_accion_especifica_deproyecto_partidaspormes_modificar_form' => array( |
---|
381 | 'arguments' => array('form' => NULL), |
---|
382 | ), |
---|
383 | ); |
---|
384 | } |
---|
385 | /** |
---|
386 | * Formato para el formulario (campos en tablas y carga de algunos datos) |
---|
387 | */ |
---|
388 | function theme_seguimiento_accion_especifica_deproyecto_partidaspormes_modificar_form($form) { |
---|
389 | |
---|
390 | $node= $form['#node']; |
---|
391 | |
---|
392 | $meses = json_decode(MESES); |
---|
393 | |
---|
394 | $header = array(); |
---|
395 | $header[] = array('data' => t('Partida')); |
---|
396 | $header[] = array('data' => t('Asignado')); |
---|
397 | $header[] = array('data' => t('Comprometido')); |
---|
398 | $header[] = array('data' => t('Causado')); |
---|
399 | $header[] = array('data' => t('Pagado')); |
---|
400 | $header[] = array('data' => t('% de Inversión')); |
---|
401 | $header[] = array('data' => t('Estatus de la Inversión')); |
---|
402 | |
---|
403 | $rows = array(); |
---|
404 | |
---|
405 | $partidas_accion_especifica = $node->field_accion_esp_programacion; |
---|
406 | foreach ($partidas_accion_especifica as $partida) { |
---|
407 | if ($partida['tid']) { |
---|
408 | $term = taxonomy_get_term($partida['tid']); |
---|
409 | // If this term's vocabulary supports localization. |
---|
410 | if (module_exists('i18ntaxonomy') && i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_LOCALIZE) { |
---|
411 | $term->name = tt("taxonomy:term:$term->tid:name", $term->name); |
---|
412 | } |
---|
413 | $asignadov = $form[$partida['tid'] . '_asignado']['#value']; |
---|
414 | $causadov = $form[$partida['tid'] . '_causado']['#value']; |
---|
415 | $estatus_ejecucion = _calcularzonacritica($asignadov, $causadov); |
---|
416 | $porczonacritica = $estatus_ejecucion['porczonacritica']; |
---|
417 | $textozona = $estatus_ejecucion['textozona']; |
---|
418 | $colorzona = $estatus_ejecucion['colorzona']; |
---|
419 | $colorfontzona = $estatus_ejecucion['colorfontzona']; |
---|
420 | |
---|
421 | $row = array(); |
---|
422 | $row[] = array('data' => $term->name,); |
---|
423 | $row[] = array('data' => drupal_render($form[$partida['tid'] . '_asignado']),); |
---|
424 | $row[] = array('data' => drupal_render($form[$partida['tid'] . '_comprometido']),); |
---|
425 | $row[] = array('data' => drupal_render($form[$partida['tid'] . '_causado']),); |
---|
426 | $row[] = array('data' => drupal_render($form[$partida['tid'] . '_pagado']),); |
---|
427 | $row[] = array('data' => drupal_render($form[$partida['tid'] . '_porcen']),); |
---|
428 | $row[] = array('data' => $textozona, 'style' => 'font-weight: bold;background:' . $colorzona . '; color:' . $colorfontzona, 'id' => $partida['tid'] . '-inversion-form',); |
---|
429 | $rows[] = $row; |
---|
430 | } |
---|
431 | } |
---|
432 | |
---|
433 | $partidas_nuevas_por_ref = $form['#partidas_nuevas_por_ref']; |
---|
434 | |
---|
435 | //colocar partidas nuevas por reformulacion ********************************************************************************** |
---|
436 | foreach ($partidas_nuevas_por_ref as $id_0 => $ref_aprob_i_0){ |
---|
437 | |
---|
438 | //buscar todas las reformulaciones sobre esa partida |
---|
439 | $partida_actual = $ref_aprob_i_0; |
---|
440 | |
---|
441 | $term = taxonomy_get_term($partida_actual); |
---|
442 | // If this term's vocabulary supports localization. |
---|
443 | if (module_exists('i18ntaxonomy') && i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_LOCALIZE) { |
---|
444 | $term->name = tt("taxonomy:term:$term->tid:name", $term->name); |
---|
445 | } |
---|
446 | $asignadov = $form[$partida_actual . '_asignado']['#value']; |
---|
447 | $causadov = $form[$partida_actual . '_causado']['#value']; |
---|
448 | $estatus_ejecucion = _calcularzonacritica($asignadov, $causadov); |
---|
449 | $porczonacritica = $estatus_ejecucion['porczonacritica']; |
---|
450 | $textozona = $estatus_ejecucion['textozona']; |
---|
451 | $colorzona = $estatus_ejecucion['colorzona']; |
---|
452 | $colorfontzona = $estatus_ejecucion['colorfontzona']; |
---|
453 | |
---|
454 | $row = array(); |
---|
455 | $row[] = array('data' => $term->name,); |
---|
456 | $row[] = array('data' => drupal_render($form[$partida_actual . '_asignado']),); |
---|
457 | $row[] = array('data' => drupal_render($form[$partida_actual . '_comprometido']),); |
---|
458 | $row[] = array('data' => drupal_render($form[$partida_actual . '_causado']),); |
---|
459 | $row[] = array('data' => drupal_render($form[$partida_actual . '_pagado']),); |
---|
460 | $row[] = array('data' => drupal_render($form[$partida_actual . '_porcen']),); |
---|
461 | $row[] = array('data' => $textozona, 'style' => 'font-weight: bold;background:' . $colorzona . '; color:' . $colorfontzona, 'id' => $partida_actual . '-inversion-form',); |
---|
462 | $rows[] = $row; |
---|
463 | } |
---|
464 | |
---|
465 | |
---|
466 | $header2 = array(); |
---|
467 | $header2[] = array('data' => t('Planificado')); |
---|
468 | |
---|
469 | $fecha = explode('-', $proyecto->field_proyecto_fecha_i[0]['value']); |
---|
470 | $mes_inicio = (int) $fecha[1]; |
---|
471 | $mes_final = variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 0); |
---|
472 | |
---|
473 | |
---|
474 | $header2[] = array('data' => t('Ejecutado')); |
---|
475 | $header2[] = array('data' => t('% de Logro')); |
---|
476 | $header2[] = array('data' => t('Estatus de la Inversión')); |
---|
477 | $rows2 = array(); |
---|
478 | |
---|
479 | $planificadov = $form['cantidad_metafisica_planificado']['#value']; |
---|
480 | $ejecutadov = $form['cantidad_metafisica_ejecutado']['#value']; |
---|
481 | $estatus_ejecucion = _calcularzonacritica($planificadov, $ejecutadov); |
---|
482 | $porczonacritica = $estatus_ejecucion['porczonacritica']; |
---|
483 | $textozona = $estatus_ejecucion['textozona']; |
---|
484 | $colorzona = $estatus_ejecucion['colorzona']; |
---|
485 | $colorfontzona = $estatus_ejecucion['colorfontzona']; |
---|
486 | |
---|
487 | $row2 = array(); |
---|
488 | $row2[] = array('data' => drupal_render($form['cantidad_metafisica_planificado']),); |
---|
489 | |
---|
490 | $fecha = explode('-', $proyecto->field_proyecto_fecha_i[0]['value']); |
---|
491 | $mes_inicio = (int) $fecha[1]; |
---|
492 | |
---|
493 | $row2[] = array('data' => drupal_render($form['cantidad_metafisica_ejecutado']),); |
---|
494 | $row2[] = array('data' => drupal_render($form['cantidad_metafisica_porcen']),); |
---|
495 | $row2[] = array('data' => $textozona, 'style' => 'font-weight: bold;background:' . $colorzona . '; color:' . $colorfontzona, 'id' => 'metafisica-inversion-form',); |
---|
496 | $rows2[] = $row2; |
---|
497 | |
---|
498 | $output = ''; |
---|
499 | |
---|
500 | $output .= '<br>'; |
---|
501 | |
---|
502 | $grupo = explode('-', $form['#grupo']['label']); |
---|
503 | |
---|
504 | //cargar el nodo del proyecto al que pertenece |
---|
505 | $nodoproyecto = $form['#proyecto']; |
---|
506 | |
---|
507 | $output .= '<fieldset><legend>' . t('Datos del Proyecto al que pertenece la Acción EspecÃfica') . ' </legend>'; |
---|
508 | $output .= '<b>' . t('Código del Proyecto') . ':</b> '.$nodoproyecto->field_proyecto_codigo[0]['value'].'<br>'; |
---|
509 | $output .= '<b>' . t('Nombre del Proyecto') . ':</b> '.$nodoproyecto->titulo_asignado.'<br>'; |
---|
510 | $output .= '</fieldset>'; |
---|
511 | |
---|
512 | $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> ' . $node->titulo_asignado . '</div>'. '</fieldset>'; |
---|
513 | $add = false; |
---|
514 | if (isset($form['comentario_metafisica'])) { |
---|
515 | |
---|
516 | $output .= '<fieldset><legend>' . t('Indicadores de Meta FÃsica de la Acción EspecÃfica') . '</legend>' ; |
---|
517 | |
---|
518 | if ($node->field_accion_esp_unidadm) { |
---|
519 | $output .= '<b>' . t("Unidad de Medida de la acción Especifica: ") . '</b>'; |
---|
520 | $count = 0; |
---|
521 | $output .= '<ul>'; |
---|
522 | foreach ($node->field_accion_esp_unidadm as $key => $value) { |
---|
523 | $count++; |
---|
524 | $tid = $value['value']; |
---|
525 | $term = taxonomy_get_term($tid); |
---|
526 | $output .= '<li>' . $count . '-) ' . $term->name . '</li>'; |
---|
527 | } |
---|
528 | $output .= '</ul>'; |
---|
529 | } |
---|
530 | |
---|
531 | if (in_array($mes_inicio, variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 1))) { |
---|
532 | $add = true; |
---|
533 | $title[] = '<b>' . t('La unidad de medida se considera acumulativa:') . '</b>'; |
---|
534 | $column[] = array('data' => drupal_render($form['acumulativo_metafisica_planificado'])); |
---|
535 | |
---|
536 | $columns[] = $column; |
---|
537 | $output .= theme('table', $title, $columns) . '<br>'; |
---|
538 | } |
---|
539 | |
---|
540 | $output .= '<div class="field-label"><b>' . t('Mes de Seguimiento Actual:') . '</b> ' . $meses[$form['#mes'] -1] . '</div>' . theme('table', $header2, $rows2) ; |
---|
541 | if ($form['#metafisica_con_planificado_cero'] == 1){ |
---|
542 | $output .= '<br><b>' . t('Nota') . ':</b> ' . t('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>'; |
---|
543 | } |
---|
544 | $output .= drupal_render($form['comentario_metafisica']); |
---|
545 | $output .= '</fieldset>'; |
---|
546 | } |
---|
547 | if (isset($form['comentario_informacionfinanciera'])) { |
---|
548 | |
---|
549 | if (in_array($mes_inicio, variable_get('seguimiento_proyectos_cantidad_meses_seguimiento', 1)) && empty($add)) { |
---|
550 | $title[] = '<b>' . t('La unidad de medida se considera acumulativa:') . '</b>'; |
---|
551 | $column[] = array('data' => drupal_render($form['acumulativo_metafisica_planificado'])); |
---|
552 | |
---|
553 | $columns[] = $column; |
---|
554 | $output .= theme('table', $title, $columns) . '<br>'; |
---|
555 | } |
---|
556 | |
---|
557 | $output .= '<fieldset><legend>' . t('Indicadores Financieros (por Partidas) de la Acción EspecÃfica') . '</legend>' . '<div class="field-label"><b>' . t('Mes de Seguimiento Actual:') . '</b> ' . $meses[$form['#mes'] -1] . '</div>' . theme('table', $header, $rows) ; |
---|
558 | $output .= '<br><b>' . t('Nota') . ':</b> .' . "La relación entre las cantidades debe ser: <b>'Comprometido' >= 'Causado' >= 'Pagado'</b>" . '.<br>'; |
---|
559 | if($form['#alguna_partida_con_asignado_cero'] == 1){ |
---|
560 | $output .= '<b>' . t('Nota 2') . ':</b> '. t('Si desea ingresar los valores de comprometido, causado y pagado de una partida con valor de asignado cero (0), <i>primero</i> debe realizar una reformulación a dicha partida.') . '<br>'; |
---|
561 | } |
---|
562 | $output .= drupal_render($form['comentario_informacionfinanciera']); |
---|
563 | $output .= '</fieldset>'; |
---|
564 | } |
---|
565 | $output .= _mostrarleyendazonacritica(); |
---|
566 | $output .= '<br>'; |
---|
567 | |
---|
568 | $output .= drupal_render($form); |
---|
569 | return $output; |
---|
570 | } |
---|
571 | |
---|
572 | /* |
---|
573 | * validacion del formulario |
---|
574 | * Implementation of seguimiento_accion_especifica_deproyecto_partidaspormes_modificar_form_validate() |
---|
575 | */ |
---|
576 | function seguimiento_accion_especifica_deproyecto_partidaspormes_modificar_form_validate($form, &$form_state) { |
---|
577 | |
---|
578 | //valores positivos meta fisica |
---|
579 | if ($form_state['values']['cantidad_metafisica_ejecutado'] < 0) { |
---|
580 | form_set_error('cantidad_metafisica_ejecutado', t('El valor \'Ejecutado\' en la meta fÃsica debe ser mayor o igual a cero')); |
---|
581 | } |
---|
582 | $proyectos_reformulacion_path = drupal_get_path('module', 'proyectos_reformulacion'); |
---|
583 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
584 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
585 | drupal_add_js($proyectos_reformulacion_path . '/js/proyectos_reformulacion.js'); |
---|
586 | drupal_add_js($form['#format_number'], 'setting'); |
---|
587 | $modulo_seguimiento_proyecto_y_aes_path = drupal_get_path('module', 'accion_especifica_de_proyecto_seguimiento'); |
---|
588 | drupal_add_js($modulo_seguimiento_proyecto_y_aes_path . '/js/seg_proyecto_validaciones_original.js'); |
---|
589 | /* |
---|
590 | print '<pre>'; |
---|
591 | print_r($form); |
---|
592 | print '</pre>'; |
---|
593 | asas(); |
---|
594 | */ |
---|
595 | |
---|
596 | $node= $form['#node']; |
---|
597 | $partidas_accion_especifica = $node->field_accion_esp_programacion; |
---|
598 | foreach ($partidas_accion_especifica as $partida) { |
---|
599 | if ($partida['tid']) { |
---|
600 | //comprometido < causado |
---|
601 | /* if ($form_state['values'][$partida['tid'] . '_comprometido'] < $form_state['values'][$partida['tid'] . '_causado']) { |
---|
602 | //$output .= '<br><b>Nota</b>: La relacion entre las cantidades debe ser: <b>\'Comprometido\' >= \'Causado\' >= \'Pagado\'</b>'; |
---|
603 | form_set_error($partida['tid'] . '_comprometido', t("El valor 'Comprometido @comprometido' debe ser mayor o igual que el valor de 'Causado @causado'.", array("@comprometido" => $form_state['values'][$partida['tid'] . '_comprometido'], "@causado" => $form_state['values'][$partida['tid'] . '_causado']))); |
---|
604 | } |
---|
605 | */ |
---|
606 | //causado < pagado |
---|
607 | /* if ($form_state['values'][$partida['tid'] . '_causado'] < $form_state['values'][$partida['tid'] . '_pagado']) { |
---|
608 | //$output .= '<br><b>Nota</b>: La relacion entre las cantidades debe ser: <b>\'Comprometido\' >= \'Causado\' >= \'Pagado\'</b>'; |
---|
609 | form_set_error($partida['tid'] . '_causado', t("El valor 'Causado @causado' debe ser mayor o igual que el valor de 'Pagado @pagado'.", array("@causado" => $form_state['values'][$partida['tid'] . '_causado'], "@pagado" => $form_state['values'][$partida['tid'] . '_pagado']))); |
---|
610 | } |
---|
611 | */ |
---|
612 | /* |
---|
613 | //asignado < comprometido |
---|
614 | if ($form_state['values'][$partida['tid'] . '_asignado'] || $form_state['values'][$partida['tid'] . '_comprometido']) { |
---|
615 | if ($form_state['values'][$partida['tid'] . '_asignado'] < $form_state['values'][$partida['tid'] . '_comprometido']) { |
---|
616 | form_set_error($partida['tid'] . '_comprometido', t("El valor 'Comprometido @comprometido' debe ser menor o igual al valor de 'Asignado @asignado.", array("@comprometido" => $form_state['values'][$partida['tid'] . '_asignado'], "@asignado" => $form_state['values'][$partida['tid'] . '_comprometido']))); |
---|
617 | } |
---|
618 | } |
---|
619 | //asignado < causado |
---|
620 | if ($form_state['values'][$partida['tid'] . '_asignado'] || $form_state['values'][$partida['tid'] . '_causado']) { |
---|
621 | if ($form_state['values'][$partida['tid'] . '_asignado'] < $form_state['values'][$partida['tid'] . '_causado']) { |
---|
622 | form_set_error($partida['tid'] . '_causado', t("El valor 'Causado @causado' debe ser menor o igual al valor de 'Asignado @asignado'.", array("@causado" => $form_state['values'][$partida['tid'] . '_asignado'], "@asignado" => $form_state['values'][$partida['tid'] . '_causado']))); |
---|
623 | } |
---|
624 | } |
---|
625 | //asignado < pagado |
---|
626 | if ($form_state['values'][$partida['tid'] . '_asignado'] || $form_state['values'][$partida['tid'] . '_pagado']) { |
---|
627 | if ($form_state['values'][$partida['tid'] . '_asignado'] < $form_state['values'][$partida['tid'] . '_pagado']) { |
---|
628 | form_set_error($partida['tid'] . '_pagado', t("El valor 'Pagado @pagado' debe ser menor o igual al valor de 'Asignado @asignado'.", array("@pagado" => $form_state['values'][$partida['tid'] . '_pagado'], "@asignado" => $form_state['values'][$partida['tid'] . '_asignado']))); |
---|
629 | } |
---|
630 | }*/ |
---|
631 | //valores positivos |
---|
632 | if ($form_state['values'][$partida['tid'] . '_comprometido'] < 0) { |
---|
633 | form_set_error($partida['tid'] . '_comprometido', t("El valor 'Comprometido @comprometido' debe ser mayor o igual a cero", array("@comprometido" => $form_state['values'][$partida['tid'] . '_comprometido']))); |
---|
634 | } |
---|
635 | if ($form_state['values'][$partida['tid'] . '_causado'] < 0) { |
---|
636 | form_set_error($partida['tid'] . '_causado', t("El valor 'Causado @causado' debe ser mayor o igual a cero", array("@causado" => $form_state['values'][$partida['tid'] . '_causado']))); |
---|
637 | } |
---|
638 | if ($form_state['values'][$partida['tid'] . '_pagado'] < 0) { |
---|
639 | form_set_error($partida['tid'] . '_pagado', t("El valor 'Pagado @pagado' debe ser mayor o igual a cero", array("@pagado" => $form_state['values'][$partida['tid'] . '_pagado']))); |
---|
640 | } |
---|
641 | |
---|
642 | } |
---|
643 | } |
---|
644 | |
---|
645 | |
---|
646 | /* |
---|
647 | //partidas nuevas |
---|
648 | $partidas_nuevas_por_ref = $form['#partidas_nuevas_por_ref']; |
---|
649 | foreach ($partidas_nuevas_por_ref as $id_0 => $ref_aprob_i_0) { |
---|
650 | //comprometido < causado |
---|
651 | if ($form_state['values'][$ref_aprob_i_0 . '_comprometido'] < $form_state['values'][$ref_aprob_i_0 . '_causado']) { |
---|
652 | //$output .= '<br><b>Nota</b>: La relacion entre las cantidades debe ser: <b>\'Comprometido\' >= \'Causado\' >= \'Pagado\'</b>'; |
---|
653 | form_set_error($ref_aprob_i_0 . '_comprometido', t('El valor \'Comprometido\' debe ser mayor o igual que el valor de \'Causado\'. ')); |
---|
654 | } |
---|
655 | //causado < pagado |
---|
656 | if ($form_state['values'][$ref_aprob_i_0 . '_causado'] < $form_state['values'][$ref_aprob_i_0 . '_pagado']) { |
---|
657 | //$output .= '<br><b>Nota</b>: La relacion entre las cantidades debe ser: <b>\'Comprometido\' >= \'Causado\' >= \'Pagado\'</b>'; |
---|
658 | form_set_error($ref_aprob_i_0 . '_causado', t('El valor \'Causado\' debe ser mayor o igual que el valor de \'Pagado\'. ')); |
---|
659 | } |
---|
660 | |
---|
661 | //asignado < comprometido |
---|
662 | if ($form_state['values'][$ref_aprob_i_0 . '_asignado'] < $form_state['values'][$ref_aprob_i_0 . '_comprometido']) { |
---|
663 | form_set_error($ref_aprob_i_0 . '_comprometido', t('El valor \'Comprometido\' debe ser menor o igual al valor de \'Asignado\'.')); |
---|
664 | } |
---|
665 | //asignado < causado |
---|
666 | if ($form_state['values'][$ref_aprob_i_0 . '_asignado'] < $form_state['values'][$ref_aprob_i_0 . '_causado']) { |
---|
667 | form_set_error($ref_aprob_i_0 . '_causado', t('El valor \'Causado\' debe ser menor o igual al valor de \'Asignado\'. ')); |
---|
668 | } |
---|
669 | //asignado < pagado |
---|
670 | if ($form_state['values'][$ref_aprob_i_0 . '_asignado'] < $form_state['values'][$ref_aprob_i_0 . '_pagado']) { |
---|
671 | form_set_error($ref_aprob_i_0 . '_pagado', t('El valor \'Pagado\'debe ser menor o igual al valor de \'Asignado\'. ')); |
---|
672 | } |
---|
673 | |
---|
674 | //valores positivos |
---|
675 | if ($form_state['values'][$ref_aprob_i_0 . '_comprometido'] < 0) { |
---|
676 | form_set_error($ref_aprob_i_0 . '_comprometido', t('El valor \'Comprometido\' debe ser mayor o igual a cero')); |
---|
677 | } |
---|
678 | if ($form_state['values'][$ref_aprob_i_0 . '_causado'] < 0) { |
---|
679 | form_set_error($partida['tid'] . '_causado', t('El valor \'Causado\' debe ser mayor o igual a cero')); |
---|
680 | } |
---|
681 | if ($form_state['values'][$ref_aprob_i_0 . '_pagado'] < 0) { |
---|
682 | form_set_error($partida['tid'] . '_pagado', t('El valor \'Pagado\' debe ser mayor o igual a cero')); |
---|
683 | } |
---|
684 | } |
---|
685 | */ |
---|
686 | |
---|
687 | } |
---|
688 | |
---|
689 | /* |
---|
690 | * procesamiento del formulario |
---|
691 | * Implementation of seguimiento_accion_especifica_deproyecto_partidaspormes_modificar_form_submit() |
---|
692 | */ |
---|
693 | function seguimiento_accion_especifica_deproyecto_partidaspormes_modificar_form_submit($form, &$form_state) { |
---|
694 | |
---|
695 | $consultaseguimientoactual = _seguimiento_mesactual_partida_ae_deproyecto_load($form['#node'], $form['#mes']); |
---|
696 | global $user; |
---|
697 | if(isset($consultaseguimientoactual['segmes']['id_seg'])) { |
---|
698 | //actualizar |
---|
699 | $es_acumulativo = isset($form_state['values']['acumulativo_metafisica_planificado']) ? $form_state['values']['acumulativo_metafisica_planificado'] : $form['#node']->es_acumulativo; |
---|
700 | |
---|
701 | if (isset($form_state['values']['comentario_metafisica'])) { |
---|
702 | $ss1=check_plain($form_state['values']['comentario_metafisica']); |
---|
703 | $exe_query = db_query("UPDATE {seguimiento_aeproyecto} SET ejecutadometafisica = %d, infocomplementaria_metafisica = '%s', acumulativa = %d WHERE id_seg = %d", $form_state['values']['cantidad_metafisica_ejecutado'], $ss1, $es_acumulativo, $consultaseguimientoactual['segmes']['id_seg']); |
---|
704 | } |
---|
705 | if (isset($form_state['values']['comentario_informacionfinanciera'])) { |
---|
706 | $sss=check_plain($form_state['values']['comentario_informacionfinanciera']); |
---|
707 | $exe_query = db_query("UPDATE {seguimiento_aeproyecto} SET ejecutadometafisica = %d, infocomplementaria_metafinanciera = '%s', acumulativa = %d WHERE id_seg = %d", $form_state['values']['cantidad_metafisica_ejecutado'], $sss, $es_acumulativo, $consultaseguimientoactual['segmes']['id_seg']); |
---|
708 | } |
---|
709 | $id_seg = $consultaseguimientoactual['segmes']['id_seg']; |
---|
710 | $exe_query = db_query("UPDATE {seguimiento_aeproyecto} SET acumulativa = %d WHERE nid = %d", $es_acumulativo, $form['#node']->nid); |
---|
711 | //$exe_query = db_query("UPDATE {seguimiento_aeproyecto} SET mes = %d WHERE id_seg = %d", $form['#mes'], $consultaseguimientoactual['segmes']['id_seg']); |
---|
712 | }else{ |
---|
713 | $es_acumulativo = isset($form_state['values']['acumulativo_metafisica_planificado']) ? $form_state['values']['acumulativo_metafisica_planificado'] : $form['#node']->es_acumulativo; |
---|
714 | //insertar |
---|
715 | $exe_query = db_query("INSERT INTO {seguimiento_aeproyecto} (nid, mes, ejecutadometafisica, infocomplementaria_metafisica, infocomplementaria_metafinanciera, fecha, estado, uid, acumulativa) VALUES (%d, %d, %d, '%s', '%s', %d, %d, %d, %d)", $form['#node']->nid, $form['#mes'], $form_state['values']['cantidad_metafisica_ejecutado'], check_plain($form_state['values']['comentario_metafisica']), check_plain($form_state['values']['comentario_informacionfinanciera']), time(), $form['#state_creation'], $user->uid, $es_acumulativo); |
---|
716 | $id_seg = db_last_insert_id('seguimiento_aeproyecto', 'id_seg'); |
---|
717 | //construir transicion (creacion) -> ingresado |
---|
718 | if (module_exists('workflow') && $form['#estado_inicial']) { |
---|
719 | $wid = workflow_get_workflow_for_type('proyectos_operativos'); |
---|
720 | $estadoInicialFlujo = _workflow_creation_state($wid); |
---|
721 | //Siguiente estado |
---|
722 | $transitions = workflow_allowable_transitions($estadoInicialFlujo); |
---|
723 | unset($transitions[$estadoInicialFlujo]); |
---|
724 | |
---|
725 | db_query("INSERT INTO {seguimiento_aeproyecto_transiciones_estados} (estado, estado_ant, comentario, date, id_seg, uid) VALUES (%d, %d, '%s', %d, %d, %d)", key($transitions), $form['#estado_inicial'], t('Creación del Seguimiento del mes @mes de la AE: @nodo ', array('@mes' => $form['#mes'], '@nodo' => check_plain($form['#node']->titulo_asignado))), time(), $id_seg, $user->uid); |
---|
726 | $ultima_id_transicion_seg = db_query("SELECT max(a.id_seg_transicion_estado) AS id FROM {seguimiento_aeproyecto_transiciones_estados} AS a WHERE a.id_seg = %d", $id_seg); |
---|
727 | $seg_transicion_estado = db_fetch_object ( $ultima_id_transicion_seg ) ; |
---|
728 | db_query('UPDATE {seguimiento_aeproyecto} SET estado = %d, id_seg_transicion_estado = %d WHERE id_seg = %d', key($transitions), $seg_transicion_estado->id, $id_seg); |
---|
729 | |
---|
730 | } |
---|
731 | |
---|
732 | } |
---|
733 | //echo $id_seg.'<br>'; |
---|
734 | |
---|
735 | $node= $form['#node']; |
---|
736 | |
---|
737 | $partidas_accion_especifica = $node->field_accion_esp_programacion; |
---|
738 | foreach ($partidas_accion_especifica as $partida) { |
---|
739 | |
---|
740 | $suma = $form_state['values'][$partida['tid'] . '_comprometido'] + $form_state['values'][$partida['tid'] . '_causado'] +$form_state['values'][$partida['tid'] . '_pagado']; |
---|
741 | $actualizada=0; |
---|
742 | foreach ($consultaseguimientoactual['segmespartidas'] as $consultapartida) {//colocando valor por omision (consultado de base de datos si esta) |
---|
743 | if($partida['tid']==$consultapartida['partida']){ |
---|
744 | //actualizar |
---|
745 | $exe_query = db_query("UPDATE {seguimiento_aeproyecto_partida} SET comprometido = %d, causado = %d, pagado = %d WHERE id_seg_partida = %d", $form_state['values'][$partida['tid'] . '_comprometido'], $form_state['values'][$partida['tid'] . '_causado'], $form_state['values'][$partida['tid'] . '_pagado'], $consultapartida['id_seg_partida']); |
---|
746 | $actualizada=1; |
---|
747 | } |
---|
748 | } |
---|
749 | |
---|
750 | if($actualizada==0){//revisar |
---|
751 | //insertar |
---|
752 | if ($partida['tid'] && $suma) { |
---|
753 | $exe_query = db_query("INSERT INTO {seguimiento_aeproyecto_partida} (id_seg, partida, comprometido, causado, pagado) VALUES (%d, %d, %d, %d, %d)", $id_seg, $partida['tid'], $form_state['values'][$partida['tid'] . '_comprometido'], $form_state['values'][$partida['tid'] . '_causado'], $form_state['values'][$partida['tid'] . '_pagado']); |
---|
754 | } |
---|
755 | } |
---|
756 | } |
---|
757 | |
---|
758 | //partidas nuevas |
---|
759 | $partidas_nuevas_por_ref = $form['#partidas_nuevas_por_ref']; |
---|
760 | foreach ($partidas_nuevas_por_ref as $id_0 => $ref_aprob_i_0) { |
---|
761 | $suma = $form_state['values'][$ref_aprob_i_0 . '_comprometido'] + $form_state['values'][$ref_aprob_i_0 . '_causado'] +$form_state['values'][$ref_aprob_i_0 . '_pagado']; |
---|
762 | $actualizada=0; |
---|
763 | foreach ($consultaseguimientoactual['segmespartidas'] as $consultapartida) {//colocando valor por omision (consultado de base de datos si esta) |
---|
764 | if($ref_aprob_i_0==$consultapartida['partida']){ |
---|
765 | //actualizar |
---|
766 | $exe_query = db_query("UPDATE {seguimiento_aeproyecto_partida} SET comprometido = %d, causado = %d, pagado = %d WHERE id_seg_partida = %d", $form_state['values'][$ref_aprob_i_0 . '_comprometido'], $form_state['values'][$ref_aprob_i_0 . '_causado'], $form_state['values'][$ref_aprob_i_0 . '_pagado'], $consultapartida['id_seg_partida']); |
---|
767 | $actualizada=1; |
---|
768 | } |
---|
769 | } |
---|
770 | |
---|
771 | if($actualizada==0){//revisar |
---|
772 | //insertar |
---|
773 | if ($ref_aprob_i_0 && $suma) { |
---|
774 | $exe_query = db_query("INSERT INTO {seguimiento_aeproyecto_partida} (id_seg, partida, comprometido, causado, pagado) VALUES (%d, %d, %d, %d, %d)", $id_seg, $ref_aprob_i_0, $form_state['values'][$ref_aprob_i_0 . '_comprometido'], $form_state['values'][$ref_aprob_i_0 . '_causado'], $form_state['values'][$ref_aprob_i_0 . '_pagado']); |
---|
775 | } |
---|
776 | } |
---|
777 | } |
---|
778 | |
---|
779 | if ($exe_query == true) { |
---|
780 | $meses = json_decode(MESES); |
---|
781 | |
---|
782 | $mes =$form['#mes']; |
---|
783 | drupal_set_message(t('Se ha guardado el seguimiento del mes de @mes para la AE: @title', array('@mes' => $meses[$mes], '@title' => check_plain($form['#node']->titulo_asignado)))); |
---|
784 | } |
---|
785 | if (!$_REQUEST['destination']) { |
---|
786 | $form_state['redirect'] = 'proyectosop/' . $form['#proyecto']->nid . '/seguimiento'; |
---|
787 | } |
---|
788 | } |
---|