1 | <?php |
---|
2 | /** |
---|
3 | * Modulo para la gestión de los detalles de comentarios en workflow |
---|
4 | * Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana |
---|
5 | * @file entes_detail_workflow.module |
---|
6 | * Drupal part Module to code ente planificador module |
---|
7 | * Copyright 2011 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 - Msc. Juan Vizcarrondo |
---|
24 | * @date 2015-05-21 // (año-mes-dia) |
---|
25 | * @version 0.2 // (0.1) |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | /* |
---|
30 | * Implementation of hook_perm |
---|
31 | */ |
---|
32 | function entes_detail_proyectos_perm() { |
---|
33 | return array( |
---|
34 | 'remove observaciones', |
---|
35 | ); |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | function _entes_detail_proyectos_operativos_get_campos_proyectos(){ |
---|
40 | $title_combos = array(); |
---|
41 | $arreglo = array(); |
---|
42 | $title_combos['db']['title'] = t('Datos Básicos'); |
---|
43 | $title_combos['db']['type'] = 'node'; |
---|
44 | $arreglo['db']['identificacion'] = array(); |
---|
45 | $arreglo['db']['identificacion'] = array( |
---|
46 | 'title' => t('Nombre del Proyecto'), |
---|
47 | 'field_proyecto_codigo' => 'field_proyecto_codigo', |
---|
48 | 'field_proyecto_fecha_i' => 'field_proyecto_fecha_i', |
---|
49 | 'field_proyecto_fecha_f' => 'field_proyecto_fecha_f', |
---|
50 | 'field_proyecto_status' => 'field_proyecto_status', |
---|
51 | 'field_proyecto_situacion_p' => 'field_proyecto_situacion_p', |
---|
52 | 'field_proyecto_plurianual' => 'field_proyecto_plurianual', |
---|
53 | 'field_proyecto_monto_anual' => 'field_proyecto_monto_anual', |
---|
54 | 'field_proyecto_total' => 'field_proyecto_total', |
---|
55 | 'field_proyecto_poan' => 'field_proyecto_poan', |
---|
56 | ); |
---|
57 | $title_combos['db']['identificacion']['title'] = t('Datos Básicos de Identificación del Proyecto'); |
---|
58 | $title_combos['db']['identificacion']['type'] = 'node'; |
---|
59 | //Gerente del Proyecto |
---|
60 | $arreglo['db']['gerentep'] = array(); |
---|
61 | $arreglo['db']['gerentep'] = array( |
---|
62 | 'field_proyecto_ente' => 'field_proyecto_ente', |
---|
63 | 'field_proyecto_autoridad' => 'field_proyecto_autoridad', |
---|
64 | 'field_proyecto_lider' => 'field_proyecto_lider', |
---|
65 | 'field_proyecto_unidad_a' => 'field_proyecto_unidad_a', |
---|
66 | 'field_proyecto_cargo' => 'field_proyecto_cargo', |
---|
67 | 'field_proyecto_telefono' => 'field_proyecto_telefono', |
---|
68 | 'field_proyecto_correo' => 'field_proyecto_correo', |
---|
69 | ); |
---|
70 | $title_combos['db']['gerentep']['title'] = t('Gerente del Proyecto'); |
---|
71 | $title_combos['db']['gerentep']['type'] = 'node'; |
---|
72 | //Ãrea Estrategica |
---|
73 | $pndes = variable_get('proyectos_operativos_muestra_pndes', TRUE); |
---|
74 | $mcti = variable_get('proyectos_operativos_muestra_mcti', TRUE); |
---|
75 | if ($pndes || $mcti) { |
---|
76 | $arreglo['db']['areae'] = array(); |
---|
77 | if ($pndes) { |
---|
78 | $arreglo['db']['areae']['field_proyecto_pndes'] = 'field_proyecto_pndes'; |
---|
79 | } |
---|
80 | if ($mcti) { |
---|
81 | $arreglo['db']['areae']['field_proyecto_mcti'] = 'field_proyecto_mcti'; |
---|
82 | } |
---|
83 | $title_combos['db']['areae']['title'] = t('Ãrea Estratégica'); |
---|
84 | $title_combos['db']['areae']['type'] = 'node'; |
---|
85 | } |
---|
86 | //DATOS GENERALES |
---|
87 | $title_combos['dg']['title'] = t('Datos Generales'); |
---|
88 | $title_combos['dg']['type'] = 'node'; |
---|
89 | //Clasificación Sectorial |
---|
90 | $arreglo['dg']['sector'] = array(); |
---|
91 | $arreglo['dg']['sector'] = array( |
---|
92 | 'field_proyecto_sector' => 'field_proyecto_sector', |
---|
93 | ); |
---|
94 | $title_combos['dg']['sector']['title'] = t('Clasificación Sectorial'); |
---|
95 | $title_combos['dg']['sector']['type'] = 'node'; |
---|
96 | //Talento Humano |
---|
97 | if (variable_get('proyectos_operativos_muestra_talento', TRUE)) { |
---|
98 | $arreglo['dg']['talentoh'] = array(); |
---|
99 | $arreglo['dg']['talentoh'] = array( |
---|
100 | 'field_proyecto_institucionth' => 'field_proyecto_institucionth', |
---|
101 | 'field_proyecto_nombres_a' => 'field_proyecto_nombres_a', |
---|
102 | 'field_proyecto_cargo_th' => 'field_proyecto_cargo_th', |
---|
103 | 'field_proyecto_rol_th' => 'field_proyecto_rol_th', |
---|
104 | 'field_proyecto_esfuerzo' => 'field_proyecto_esfuerzo', |
---|
105 | 'field_proyecto_formacion' => 'field_proyecto_formacion', |
---|
106 | ); |
---|
107 | $title_combos['dg']['talentoh']['title'] = t('Talento Humano'); |
---|
108 | $title_combos['dg']['talentoh']['type'] = 'node'; |
---|
109 | } |
---|
110 | //Capacidades |
---|
111 | $arreglo['dg']['capacidades'] = array(); |
---|
112 | if (variable_get('proyectos_operativos_muestra_capacidades', TRUE)) { |
---|
113 | $arreglo['dg']['capacidades'] = array( |
---|
114 | 'field_proyecto_institucion_alc' => 'field_proyecto_institucion_alc', |
---|
115 | 'field_proyecto_infraestructura' => 'field_proyecto_infraestructura', |
---|
116 | 'field_proyecto_equipos' => 'field_proyecto_equipos', |
---|
117 | 'field_proyecto_insumos' => 'field_proyecto_insumos', |
---|
118 | 'field_proyectos_servicios' => 'field_proyectos_servicios', |
---|
119 | ); |
---|
120 | } |
---|
121 | $title_combos['dg']['capacidades']['title'] = t('Capacidades'); |
---|
122 | $title_combos['dg']['capacidades']['type'] = 'node'; |
---|
123 | //Instituciones |
---|
124 | $arreglo['dg']['relacion'] = array(); |
---|
125 | $arreglo['dg']['relacion'] = array( |
---|
126 | 'field_proyecto_relacion' => 'field_proyecto_relacion', |
---|
127 | ); |
---|
128 | $title_combos['dg']['relacion']['title'] = t('Instituciones'); |
---|
129 | $title_combos['dg']['relacion']['type'] = 'node'; |
---|
130 | //Empleos Generados |
---|
131 | |
---|
132 | if (variable_get('proyectos_operativos_muestra_beneficiario', TRUE)) { |
---|
133 | $arreglo['dg']['empleosg'] = array( |
---|
134 | 'field_proyecto_emdirecto' => 'field_proyecto_emdirecto', |
---|
135 | 'field_proyecto_efdirecto' => 'field_proyecto_efdirecto', |
---|
136 | ); |
---|
137 | if (variable_get('proyectos_operativos_muestra_beneficiarios_indirectos', TRUE)) { |
---|
138 | $arreglo['dg']['empleosg']['field_proyecto_emindirecto'] = 'field_proyecto_emindirecto'; |
---|
139 | $arreglo['dg']['empleosg']['field_proyecto_efindirecto'] = 'field_proyecto_efindirecto'; |
---|
140 | } |
---|
141 | $arreglo['dg']['empleosg'] = array(); |
---|
142 | $title_combos['dg']['empleosg']['title'] = t('Empleos Generados'); |
---|
143 | $title_combos['dg']['empleosg']['type'] = 'node'; |
---|
144 | } |
---|
145 | //Objetivos del Proyecto |
---|
146 | $arreglo['dg']['objetivosp'] = array(); |
---|
147 | $arreglo['dg']['objetivosp'] = array( |
---|
148 | 'field_proyecto_og' => 'field_proyecto_og', |
---|
149 | 'field_proyecto_oe' => 'field_proyecto_oe', |
---|
150 | ); |
---|
151 | $title_combos['dg']['objetivosp']['title'] = t('Objetivos'); |
---|
152 | $title_combos['dg']['objetivosp']['type'] = 'node'; |
---|
153 | //INDICADORES DEL PROYECTO |
---|
154 | //Enunciado del Problema |
---|
155 | $title_combos['ip']['title'] = t('Indicadores del Proyecto'); |
---|
156 | $title_combos['ip']['type'] = 'node'; |
---|
157 | $arreglo['ip']['enunciadop'] = array(); |
---|
158 | if (variable_get('proyectos_operativos_muestra_enunciado_problema', TRUE)) { |
---|
159 | $arreglo['ip']['enunciadop'] = array( |
---|
160 | 'field_proyecto_causas' => 'field_proyecto_causas', |
---|
161 | 'field_proyecto_problemas' => 'field_proyecto_problemas', |
---|
162 | 'field_proyecto_consecuencias' => 'field_proyecto_consecuencias', |
---|
163 | ); |
---|
164 | } |
---|
165 | $title_combos['ip']['enunciadop']['title'] = t('Enunciado del Problema'); |
---|
166 | $title_combos['ip']['enunciadop']['type'] = 'node'; |
---|
167 | //Justificación del Proyecto |
---|
168 | $arreglo['ip']['justificacion'] = array(); |
---|
169 | if (variable_get('proyectos_operativos_muestra_justicacion', TRUE)) { |
---|
170 | $arreglo['ip']['justificacion'] = array( |
---|
171 | 'field_proyecto_justificacion' => 'field_proyecto_justificacion', |
---|
172 | ); |
---|
173 | } |
---|
174 | $title_combos['ip']['justificacion']['title'] = t('Justificación del Proyecto'); |
---|
175 | $title_combos['ip']['justificacion']['type'] = 'node'; |
---|
176 | //Alcance del Proyecto |
---|
177 | $arreglo['ip']['alcance'] = array(); |
---|
178 | if (variable_get('proyectos_operativos_muestra_alcance', TRUE)) { |
---|
179 | $arreglo['ip']['alcance'] = array( |
---|
180 | 'field_proyecto_alcance' => 'field_proyecto_alcance', |
---|
181 | ); |
---|
182 | } |
---|
183 | $title_combos['ip']['alcance']['title'] = t('Alcance del Proyecto'); |
---|
184 | $title_combos['ip']['alcance']['type'] = 'node'; |
---|
185 | //Situación Actual del Proyecto |
---|
186 | $arreglo['ip']['situaciona'] = array(); |
---|
187 | if (variable_get('proyectos_operativos_muestra_sa', TRUE)) { |
---|
188 | $arreglo['ip']['situaciona'] = array( |
---|
189 | 'field_proyecto_sa_descripcion' => 'field_proyecto_sa_descripcion', |
---|
190 | ); |
---|
191 | if (variable_get('proyectos_operativos_muestra_sa_cuantificacion', TRUE)) { |
---|
192 | $arreglo['ip']['situaciona']['field_proyecto_sa_cuantificacion'] = 'field_proyecto_sa_cuantificacion'; |
---|
193 | } |
---|
194 | $arreglo['ip']['situaciona']['field_proyecto_sa_formulai'] = 'field_proyecto_sa_formulai'; |
---|
195 | $arreglo['ip']['situaciona']['field_proyecto_sa_fuentei'] = 'field_proyecto_sa_fuentei'; |
---|
196 | $arreglo['ip']['situaciona']['field_proyecto_sa_fecha'] = 'field_proyecto_sa_fecha'; |
---|
197 | } |
---|
198 | $title_combos['ip']['situaciona']['title'] = t('Situación Actual'); |
---|
199 | $title_combos['ip']['situaciona']['type'] = 'node'; |
---|
200 | //Situación Objetivo |
---|
201 | $arreglo['ip']['situaciono'] = array(); |
---|
202 | if (variable_get('proyectos_operativos_muestra_so', TRUE)) { |
---|
203 | $arreglo['ip']['situaciono'] = array( |
---|
204 | 'field_proyecto_so_descripcion' => 'field_proyecto_so_descripcion', |
---|
205 | 'field_proyecto_so_cuantificacion' => 'field_proyecto_so_cuantificacion', |
---|
206 | 'field_proyecto_tiempoi' => 'field_proyecto_tiempoi', |
---|
207 | ); |
---|
208 | } |
---|
209 | $title_combos['ip']['situaciono']['title'] = t('Situación Objetivo'); |
---|
210 | $title_combos['ip']['situaciono']['type'] = 'node'; |
---|
211 | |
---|
212 | //Indicador del resultado del Proyecto |
---|
213 | $arreglo['ip']['resultadop'] = array(); |
---|
214 | $arreglo['ip']['resultadop'] = array( |
---|
215 | 'field_proyecto_descripcion_bien' => 'field_proyecto_descripcion_bien', |
---|
216 | 'field_proyecto_unidadm' => 'field_proyecto_unidadm', |
---|
217 | // 'field_proyecto_meta_m' => 'field_proyecto_meta_m', |
---|
218 | // 'field_proyecto_meta_f' => 'field_proyecto_meta_f', |
---|
219 | 'field_proyecto_meta_fisica' => 'field_proyecto_meta_fisica', |
---|
220 | ); |
---|
221 | $title_combos['ip']['resultadop']['title'] = t('Indicador del resultado del Proyecto'); |
---|
222 | $title_combos['ip']['resultadop']['type'] = 'node'; |
---|
223 | $title_combos['otros']['title'] = t('Otros'); |
---|
224 | $title_combos['otros']['type'] = 'flow'; |
---|
225 | $title_combos['otros']['fl']['title'] = t('Flujo de Trabajo'); |
---|
226 | $arreglo['otros']['fl'] = array( |
---|
227 | 'proyectos_operativos_flujo' => 'Flujo Actual', |
---|
228 | ); |
---|
229 | drupal_alter('proyecto_obtiene_fields_categorias', $title_combos); |
---|
230 | drupal_alter('proyecto_obtiene_fields_campos', $arreglo); |
---|
231 | return array( |
---|
232 | 'categorias' => $title_combos, |
---|
233 | 'campos' => $arreglo, |
---|
234 | ); |
---|
235 | } |
---|
236 | |
---|
237 | |
---|
238 | /* |
---|
239 | * Implementation of hook_menu() |
---|
240 | */ |
---|
241 | function entes_detail_workflow_menu() { |
---|
242 | $items = array(); |
---|
243 | |
---|
244 | $items['entes_detail_workflow_js_util'] = array( |
---|
245 | 'title' => 'JS utilities', |
---|
246 | 'page callback' => 'entes_detail_workflow_js_util', |
---|
247 | 'access arguments' => array('ver planificador'), |
---|
248 | 'type' => MENU_CALLBACK, |
---|
249 | ); |
---|
250 | return $items; |
---|
251 | } |
---|
252 | |
---|
253 | function entes_detail_workflow_js_util() { |
---|
254 | $options_select = isset($_POST['workflow_details']) && is_array($_POST['workflow_details'])? $_POST['workflow_details']: array(); |
---|
255 | //$options_select = array_reverse($options_select); |
---|
256 | $form_state = array('submitted' => FALSE); |
---|
257 | $form_build_id = $_POST['form_build_id']; |
---|
258 | // Add the new element to the stored form. Without adding the element to the |
---|
259 | // form, Drupal is not aware of this new elements existence and will not |
---|
260 | // process it. We retreive the cached form, add the element, and resave. |
---|
261 | $form = form_get_cache($form_build_id, $form_state); |
---|
262 | $new_form = array(); |
---|
263 | $new_form['campos_modificar'] = array( |
---|
264 | '#type' => 'fieldset', |
---|
265 | '#weight' => 11, |
---|
266 | '#title' => 'Observaciones por campos', |
---|
267 | ); |
---|
268 | |
---|
269 | |
---|
270 | foreach($options_select as $select){ |
---|
271 | $nidae = explode('_', $select); |
---|
272 | if (is_numeric($nidae[0])){ |
---|
273 | $fieldae = str_replace($nidae[0] . '_', '', $select); |
---|
274 | $output = $form['#nodeae_workflow_display'][$nidae[0]][$fieldae]; |
---|
275 | } |
---|
276 | else { |
---|
277 | $output = $form['#node_workflow_display'][$select] . 'a'; |
---|
278 | } |
---|
279 | $new_form['campos_modificar'][$select] = array( |
---|
280 | '#type' => 'fieldset', |
---|
281 | '#title' => $form['#node_workflow_titles'][$select], |
---|
282 | '#weight' => 1, |
---|
283 | ); |
---|
284 | $new_form['campos_modificar'][$select]['comentario_' . $select] = array( |
---|
285 | '#title' => t('Comentario'), |
---|
286 | '#prefix' => '<div class="comentario-workflow">' . $output . '</div>', |
---|
287 | '#type' => 'textarea', |
---|
288 | '#default_value' => '', |
---|
289 | ); |
---|
290 | } |
---|
291 | $form['campos_modificar'] = $new_form['campos_modificar']; |
---|
292 | form_set_cache($form_build_id, $form, $form_state); |
---|
293 | $form += array( |
---|
294 | '#post' => $_POST, |
---|
295 | '#programmed' => FALSE, |
---|
296 | ); |
---|
297 | // Rebuild the form. |
---|
298 | $form = form_builder($_POST['form_id'], $form, $form_state); |
---|
299 | $output = drupal_render($form['campos_modificar']); |
---|
300 | print drupal_to_js(array('data' => $output, 'status' => true)); |
---|
301 | exit(); |
---|
302 | } |
---|
303 | |
---|
304 | function _entes_detail_workflow_get_lastworkflow(){ |
---|
305 | |
---|
306 | |
---|
307 | } |
---|
308 | |
---|
309 | /* |
---|
310 | * hook_form_alter() |
---|
311 | */ |
---|
312 | function entes_detail_workflow_form_alter(&$form, $form_state, $form_id) { |
---|
313 | if (($form_id == 'proyectos_operativos_proyecto_basico_form' || $form_id == 'proyectos_operativos_proyecto_generales_form' || $form_id == 'proyectos_operativos_proyecto_indicadores_form') && $form['#node']->nid){ |
---|
314 | $node_load = $form['#node']; |
---|
315 | $field_form = $form['#proyectos_operativos_fields']; |
---|
316 | $new_field_form = array(); |
---|
317 | if (is_array($field_form) && count($field_form)){ |
---|
318 | foreach($field_form as $field_id) |
---|
319 | $new_field_form[$field_id] = $field_id; |
---|
320 | } |
---|
321 | $result = db_query("SELECT * FROM {entes_detail_workflow} WHERE id = %d AND tipo = 'proyectos_operativos' AND active = 1 ORDER BY field_name, time DESC", $node_load->nid); |
---|
322 | $comentarios_details = array(); |
---|
323 | $pre_render = FALSE; |
---|
324 | $form['#proyecto_fields']; |
---|
325 | $nuevos = array(); |
---|
326 | $nuevos1 = array(); |
---|
327 | while($comentario = db_fetch_object($result)) { |
---|
328 | $nidae = explode('_', $comentario->field_name); |
---|
329 | if (array_key_exists($comentario->field_name, $new_field_form) && trim($comentario->comentario) != ''){ |
---|
330 | if (!array_key_exists($comentario->field_name, $nuevos)){ |
---|
331 | $nuevos[$comentario->field_name] = $comentario->field_name; |
---|
332 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;background:#fffcc5;"><b>' . $form['#proyecto_fields'][$comentario->field_name]['widget']['label'] . '</b><br>' . $comentario->comentario . '</div>'; |
---|
333 | } |
---|
334 | else { |
---|
335 | if (!array_key_exists($field, $nuevos1)){ |
---|
336 | $nuevos1[$field] = $field; |
---|
337 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;"><b>Comentarios Anteriores:</b><br>' . $comentario->comentario . '</div>'; |
---|
338 | } |
---|
339 | else { |
---|
340 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;">' . $comentario->comentario . '</div>'; |
---|
341 | } |
---|
342 | } |
---|
343 | } |
---|
344 | } |
---|
345 | if(count($comentarios_details)){ |
---|
346 | $form['entes_detail_workflow']['#value'] = '<div id="bloque_apps" style="position: fixed;vertical-align: bottom;width:160px;z-index: 10000;margin: 0;bottom:0;right:10px;background:#DDDDDD; border: 1px solid #BBBBBB;"><div style="padding:5px;"><b>Observaciones:</b></div><div id="contenido-observaciones" style="overflow-y:scroll;max-height:300px;">' . implode('', $comentarios_details) . '</div></div>'; |
---|
347 | } |
---|
348 | } |
---|
349 | if ($form_id == 'proyectos_operativos_accion_especifica_crear_form'){ |
---|
350 | $node_load = $form['#proyecto']; |
---|
351 | $field_form = $form['#proyectos_operativos_fields']; |
---|
352 | $new_field_form = array(); |
---|
353 | if (is_array($field_form) && count($field_form)){ |
---|
354 | foreach($field_form as $field_id) { |
---|
355 | $new_field_form[$field_id] = $field_id; |
---|
356 | } |
---|
357 | } |
---|
358 | $ae = array(); |
---|
359 | $i = 1; |
---|
360 | foreach($form['#acciones_especificas'] as $accion) { |
---|
361 | if (isset($accion->nid)) { |
---|
362 | $ae[$accion->nid] = $i; |
---|
363 | $i++; |
---|
364 | } |
---|
365 | } |
---|
366 | |
---|
367 | $result = db_query("SELECT * FROM {entes_detail_workflow} WHERE id = %d AND tipo = 'proyectos_operativos' AND active = 1 ORDER BY field_name, time DESC", $node_load->nid); |
---|
368 | $comentarios_details = array(); |
---|
369 | $nuevos = array(); |
---|
370 | $nuevos1 = array(); |
---|
371 | while($comentario = db_fetch_object($result)) { |
---|
372 | $nidae = explode('_', $comentario->field_name); |
---|
373 | if (is_numeric($nidae[0])){ |
---|
374 | $nid = $nidae[0]; |
---|
375 | unset($nidae[0]); |
---|
376 | $field = implode('_', $nidae); |
---|
377 | //se estan viendo todas las acciones especificas |
---|
378 | if ($form['#node']->nid == $nid){ |
---|
379 | if (array_key_exists($field, $new_field_form) && trim($comentario->comentario) != ''){ |
---|
380 | if (!array_key_exists($field, $nuevos)){ |
---|
381 | $nuevos[$field] = $field; |
---|
382 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;background:#fffcc5;"><b>' . $form['#aeproyecto_fields'][$field]['widget']['label'] . '</b><br>' . $comentario->comentario . '</div>'; |
---|
383 | } |
---|
384 | else { |
---|
385 | if (!array_key_exists($field, $nuevos1)){ |
---|
386 | $nuevos1[$field] = $field; |
---|
387 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;"><b>Comentarios Anteriores:</b><br>' . $comentario->comentario . '</div>'; |
---|
388 | } |
---|
389 | else { |
---|
390 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;">' . $comentario->comentario . '</div>'; |
---|
391 | } |
---|
392 | } |
---|
393 | } |
---|
394 | |
---|
395 | } |
---|
396 | elseif(!$form['#node']->nid){ |
---|
397 | |
---|
398 | if (!array_key_exists($field, $nuevos)){ |
---|
399 | $nuevos[$field] = $field; |
---|
400 | $comentarios_details[] = '<div class="comentario-workflow" style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;background:#fffcc5;"><b>AE_' .$ae[$nid] . ' ' . $form['#aeproyecto_fields'][$field]['widget']['label'] . '</b><br>' . $comentario->comentario . '</div>'; |
---|
401 | } |
---|
402 | else { |
---|
403 | if (!array_key_exists($field, $nuevos1)){ |
---|
404 | $nuevos1[$field] = $field; |
---|
405 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;"><b>Comentarios Anteriores:</b><br>' . $comentario->comentario . '</div>'; |
---|
406 | } |
---|
407 | else { |
---|
408 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;">' . $comentario->comentario . '</div>'; |
---|
409 | } |
---|
410 | } |
---|
411 | } |
---|
412 | } |
---|
413 | } |
---|
414 | if(count($comentarios_details)){ |
---|
415 | $form['entes_detail_workflow']['#value'] = '<div id="bloque_apps" style="position: fixed;vertical-align: bottom;width:160px;z-index: 10000;margin: 0;bottom:0;right:10px;background:#DDDDDD; border: 1px solid #BBBBBB;"><div style="padding:5px;"><b>Observaciones:</b></div><div id="contenido-observaciones" style="overflow-y:scroll;max-height:300px;">' . implode('', $comentarios_details) . '</div></div>'; |
---|
416 | } |
---|
417 | } |
---|
418 | |
---|
419 | |
---|
420 | if ($form_id == 'workflow_tab_form') { |
---|
421 | if ($form['node']['#value']->type == 'proyectos_operativos'){ |
---|
422 | $node = $form['node']['#value']; |
---|
423 | $campos_leidos = _entes_detail_proyectos_operativos_get_campos_proyectos(); |
---|
424 | $options_campos = array(); |
---|
425 | $node_type = content_types('proyectos_operativos'); |
---|
426 | $fields = $node_type['fields']; |
---|
427 | $node_type1 = content_types('accion_especifica'); |
---|
428 | $fields1 = $node_type1['fields']; |
---|
429 | $node_workflow_display = node_build_content($node); |
---|
430 | $contenido = array(); |
---|
431 | $array_titles = array(); |
---|
432 | $todas_opciones = array(); |
---|
433 | foreach($campos_leidos['campos'] as $idcat => $array){ |
---|
434 | foreach($array as $idcamp => $arrat1){ |
---|
435 | $array_soptions = array(); |
---|
436 | foreach($arrat1 as $ind2 => $array2){ |
---|
437 | $contenido[$ind2] = drupal_render($node_workflow_display->content[$ind2]); |
---|
438 | if ($ind2 == 'title'){ |
---|
439 | $array_soptions[$ind2] = t('Nombre del Proyecto'); |
---|
440 | } |
---|
441 | else { |
---|
442 | $array_soptions[$ind2] = $fields[$ind2]['widget']['label']; |
---|
443 | } |
---|
444 | $array_titles[$ind2] = $array_soptions[$ind2]; |
---|
445 | $todas_opciones[$ind2] = $ind2; |
---|
446 | } |
---|
447 | if ($campos_leidos['categorias'][$idcat][$idcamp]['type'] == 'node'){ |
---|
448 | $options_campos[$campos_leidos['categorias'][$idcat][$idcamp]['title']] = $array_soptions; |
---|
449 | } |
---|
450 | } |
---|
451 | |
---|
452 | } |
---|
453 | //add weight to submit button |
---|
454 | $form['submit']['#weight'] = 100; |
---|
455 | |
---|
456 | |
---|
457 | $form['#node_workflow_display'] = $contenido; |
---|
458 | //Se obtienen las acciones especificas del proyecto |
---|
459 | |
---|
460 | $i = 1; |
---|
461 | $contenidoae = array(); |
---|
462 | $acciones_especificas = array(); |
---|
463 | if (isset($node->field_proyecto_accion_esp)){ |
---|
464 | foreach($node->field_proyecto_accion_esp as $accion) { |
---|
465 | if ($accion['nid']) { |
---|
466 | $accionep = node_load($accion['nid']); |
---|
467 | $opcionAE = array(); |
---|
468 | $contenidoae[$accionep->nid] = array(); |
---|
469 | $nodeae_workflow_display = node_build_content($accionep); |
---|
470 | foreach($fields1 as $idcat => $array){ |
---|
471 | $contenidoae[$accionep->nid][$idcat] = drupal_render($nodeae_workflow_display->content[$idcat]); |
---|
472 | $opcionAE[$accionep->nid . '_' . $idcat] = $fields1[$idcat]['widget']['label']; |
---|
473 | $array_titles[$accionep->nid . '_' . $idcat] = 'AE_' .$i . ': ' . $opcionAE[$accionep->nid . '_' . $idcat]; |
---|
474 | $todas_opciones[$accionep->nid . '_' . $idcat] = $accionep->nid . '_' . $idcat; |
---|
475 | } |
---|
476 | $options_campos['AE_' .$i] = $opcionAE; |
---|
477 | $i++; |
---|
478 | } |
---|
479 | } |
---|
480 | } |
---|
481 | $form['#nodeae_workflow_display'] = $contenidoae; |
---|
482 | $form['#node_workflow_titles'] = $array_titles; |
---|
483 | $form['#node_workflow_todas_opciones'] = $todas_opciones; |
---|
484 | $form['proyectos_operativos_remove'] = array( |
---|
485 | '#type' => 'checkbox', |
---|
486 | '#title' => t('Borrar los comentarios de campos Previos.'), |
---|
487 | '#default_value' => FALSE, |
---|
488 | '#access' => user_access('remove observaciones'), |
---|
489 | ); |
---|
490 | $form['workflow_details'] = array( |
---|
491 | '#title' => t('Comentarios por Campos'), |
---|
492 | '#type' => 'select', |
---|
493 | '#default_value' => array(), |
---|
494 | '#options' => $options_campos, |
---|
495 | '#multiple' => TRUE, |
---|
496 | '#weight' => 10, |
---|
497 | '#ahah' => array( |
---|
498 | 'path' => 'entes_detail_workflow_js_util', |
---|
499 | 'wrapper' => 'fields_problems', |
---|
500 | 'method' => 'replace', |
---|
501 | 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), |
---|
502 | ), |
---|
503 | ); |
---|
504 | $form['campos_modificar'] = array( |
---|
505 | '#type' => 'fieldset', |
---|
506 | '#prefix' => '<div id="fields_problems">', |
---|
507 | '#suffix' => '</div>', |
---|
508 | '#weight' => 11, |
---|
509 | '#title' => 'Observaciones por campos', |
---|
510 | ); |
---|
511 | $form['campos_modificar']['no_comentarios'] = array( |
---|
512 | '#value' => 'No exiten comentarios de los campos del proyecto', |
---|
513 | ); |
---|
514 | |
---|
515 | |
---|
516 | /* |
---|
517 | $res = db_query('SELECT * FROM {workflow_node} WHERE nid = %d', $form['node']['#value']->nid); |
---|
518 | $row = db_fetch_object($res); |
---|
519 | |
---|
520 | if ($row && $row->sid){ |
---|
521 | $sid = $row->sid; |
---|
522 | //SE OBTIENEN TODOS LOS COMENTARIOS QUE EXISTEN |
---|
523 | $result = db_query("SELECT * FROM {entes_detail_workflow} WHERE id = %d AND sid = %d AND tipo = 'proyectos_operativos'", $form['node']['#value']->nid, $sid); |
---|
524 | $defaults = array(); |
---|
525 | while($comentario = db_fetch_object($result)) { |
---|
526 | $output = $form['#node_workflow_display'][$comentario->field_name]; |
---|
527 | $defaults[$comentario->field_name] = $comentario->field_name; |
---|
528 | $form['campos_modificar'][$comentario->field_name] = array( |
---|
529 | '#type' => 'fieldset', |
---|
530 | '#title' => $form['#node_workflow_titles'][$comentario->field_name], |
---|
531 | '#weight' => 1, |
---|
532 | ); |
---|
533 | $form['campos_modificar'][$comentario->field_name]['comentario_' . $comentario->field_name] = array( |
---|
534 | '#title' => t('Comentario'), |
---|
535 | '#prefix' => '<div class="comentario-workflow">' . $output . '</div>', |
---|
536 | '#type' => 'textarea', |
---|
537 | '#default_value' => $comentario->comentario, |
---|
538 | ); |
---|
539 | |
---|
540 | } |
---|
541 | |
---|
542 | //$form['workflow_details']['#default_value'] = $defaults; |
---|
543 | } |
---|
544 | */ |
---|
545 | //remove previous submit |
---|
546 | $new_submit = array(); |
---|
547 | foreach($form['#submit'] as $submit) { |
---|
548 | if ($submit == 'workflow_tab_form_submit'){ |
---|
549 | $new_submit[] = 'entes_detail_workflow_form_submit'; |
---|
550 | } |
---|
551 | } |
---|
552 | $form['#submit'] = $new_submit; |
---|
553 | } |
---|
554 | |
---|
555 | } |
---|
556 | |
---|
557 | } |
---|
558 | |
---|
559 | /* |
---|
560 | * Implementation of proyectos_reformulacion_reformula_tab_page_ae_form_validate() |
---|
561 | */ |
---|
562 | function entes_detail_workflow_form_submit($form, &$form_state) { |
---|
563 | |
---|
564 | global $user; |
---|
565 | // The entire node object was stashed in the form. |
---|
566 | $node = $form_state['values']['node']; |
---|
567 | $node->workflow = $form_state['values']['workflow']; |
---|
568 | $node->workflow_comment = $form_state['values']['workflow_comment']; |
---|
569 | $node->workflow_scheduled = $form_state['values']['workflow_scheduled']; |
---|
570 | $node->workflow_scheduled_date = $form_state['values']['workflow_scheduled_date']; |
---|
571 | $node->workflow_scheduled_hour = $form_state['values']['workflow_scheduled_hour']; |
---|
572 | //crear una nueva revision |
---|
573 | $node->revision = 1; |
---|
574 | // Call node_save() to make sure any handlers that use the |
---|
575 | // new workflow values will see them. |
---|
576 | node_save($node); |
---|
577 | //add node save values |
---|
578 | $form_state['values']['node'] = $node; |
---|
579 | $form_state['redirect'] = 'node/' . $node->nid; |
---|
580 | $sid = $node->workflow; |
---|
581 | if (array_key_exists('proyectos_operativos_remove', $form_state['values']) && $form_state['values']['proyectos_operativos_remove']){ |
---|
582 | db_query("UPDATE {entes_detail_workflow} set active = 0 WHERE id = %d AND tipo = 'proyectos_operativos'", $node->nid); |
---|
583 | } |
---|
584 | |
---|
585 | $fecha = time(); |
---|
586 | //SE OBTIENE el hid del historico del workflow |
---|
587 | $res = db_query("select max(hid) as hid from workflow_node_history WHERE nid = %d AND sid = %d", $node->nid, $sid); |
---|
588 | $hid = db_fetch_object($res); |
---|
589 | $chid = ($hid && $hid->hid) ? $hid->hid : 0; |
---|
590 | |
---|
591 | $time = time(); |
---|
592 | foreach($form['#node_workflow_todas_opciones'] as $id => $title){ |
---|
593 | if (array_key_exists('comentario_' . $id, $form_state['values'])){ |
---|
594 | db_query("INSERT INTO {entes_detail_workflow} (id, sid, tipo, field_name, comentario, hid, vid, active, time) VALUES (%d, %d, 'proyectos_operativos', '%s', '%s', %d, %d, 1, %d)", $node->nid, $sid, $id, check_plain(trim($form_state['values']['comentario_' . $id])), $chid, $node->vid, $time); |
---|
595 | } |
---|
596 | } |
---|
597 | |
---|
598 | } |
---|