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