[a0b4327] | 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_nodeapi() |
---|
| 31 | */ |
---|
| 32 | function entes_detail_workflow_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
---|
| 33 | switch ($op) { |
---|
| 34 | case 'view': |
---|
| 35 | if ($node->type == 'proyectos_operativos') { |
---|
| 36 | //Se obtienen las AE |
---|
| 37 | $aes = array(); |
---|
| 38 | foreach($node->field_proyecto_accion_esp as $ae){ |
---|
| 39 | if (isset($ae['nid'])){ |
---|
| 40 | $aes[$ae['nid']] = $ae['safe']['title']; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | } |
---|
| 44 | $node_type = content_types('proyectos_operativos'); |
---|
| 45 | $fields = $node_type['fields']; |
---|
| 46 | $node_type1 = content_types('accion_especifica'); |
---|
| 47 | $fields1 = $node_type1['fields']; |
---|
| 48 | $result = db_query("SELECT sid, state FROM {workflow_states} WHERE status = 1 ORDER BY sid"); |
---|
| 49 | while ($data = db_fetch_object($result)) { |
---|
| 50 | $states[$data->sid] = check_plain(t($data->state)); |
---|
| 51 | } |
---|
| 52 | //leer los comentarios |
---|
| 53 | $result = db_query("SELECT e.*, u.name, u.uid, w.old_sid, w.comment FROM {entes_detail_workflow} AS e INNER JOIN {workflow_node_history} AS w ON w.hid = e.hid INNER JOIN {users} AS u ON w.uid =u.uid WHERE id = %d AND tipo = 'proyectos_operativos' AND active = 1 ORDER BY time DESC", $node->nid); |
---|
| 54 | $tablas_row = array(); |
---|
| 55 | $headers_tabla = array(); |
---|
| 56 | $headers_tabla[] = array('data' => t('Fecha')); |
---|
| 57 | $headers_tabla[] = array('data' => t('Estado Pasado')); |
---|
| 58 | $headers_tabla[] = array('data' => t('Estado Nuevo')); |
---|
| 59 | $headers_tabla[] = array('data' => t('Usuario')); |
---|
| 60 | $headers_tabla[] = array('data' => t('Comentario General')); |
---|
| 61 | $headers_tabla[] = array('data' => t('Campo')); |
---|
| 62 | $headers_tabla[] = array('data' => t('Comentario')); |
---|
| 63 | $rows = array(); |
---|
| 64 | while($comentario = db_fetch_object($result)) { |
---|
| 65 | $row = array(); |
---|
| 66 | $row[] = array('data' => format_date($comentario->time),); |
---|
| 67 | $estado = isset($states[$comentario->old_sid])? $states[$comentario->old_sid] : 'N/A'; |
---|
| 68 | $row[] = array('data' => $estado,); |
---|
| 69 | $estado = isset($states[$comentario->sid])? $states[$comentario->sid] : 'N/A'; |
---|
| 70 | $row[] = array('data' => $estado,); |
---|
| 71 | $row[] = array('data' => theme('username', $comentario),); |
---|
| 72 | $row[] = array('data' => filter_xss($comentario->comment, array('a', 'em', 'strong')),); |
---|
| 73 | $titulo = $comentario->field_name; |
---|
| 74 | if ($comentario->field_name == 'title') { |
---|
| 75 | $titulo = t('Nombre del Proyecto'); |
---|
| 76 | } |
---|
| 77 | elseif(isset($fields[$comentario->field_name])){ |
---|
| 78 | $titulo = $fields[$comentario->field_name]['widget']['label']; |
---|
| 79 | } |
---|
| 80 | else { |
---|
| 81 | $nidae = explode('_', $comentario->field_name); |
---|
| 82 | if (is_numeric($nidae[0])){ |
---|
| 83 | $nid = $nidae[0]; |
---|
| 84 | unset($nidae[0]); |
---|
| 85 | $field = implode('_', $nidae); |
---|
| 86 | if (isset($fields1[$field])) { |
---|
| 87 | $ae_title = isset($aes[$nid])? ' (' . l($aes[$nid], 'proyectosopedit/' . $node->nid . '/ae/' . $nid . '/edit') . ')' : ''; |
---|
| 88 | $titulo = 'AE' . $ae_title . ': ' . $fields1[$field]['widget']['label']; |
---|
| 89 | } |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | $row[] = array('data' => $titulo,); |
---|
| 93 | $row[] = array('data' => filter_xss($comentario->comentario, array('a', 'em', 'strong')),); |
---|
| 94 | $rows[] = $row; |
---|
| 95 | |
---|
| 96 | } |
---|
| 97 | $output = theme('table', $headers_tabla, $rows); |
---|
| 98 | $node->content['flujo_comentarios'] = array( |
---|
| 99 | '#value' => '<fieldset><legend>' . t('Flujo con Comentarios') . '</legend>' . $output . '</fieldset>', |
---|
| 100 | '#weight' => 100, |
---|
| 101 | ); |
---|
| 102 | } |
---|
| 103 | break; |
---|
| 104 | } |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | /* |
---|
| 108 | * Implementation of reformula_ver_campos() |
---|
| 109 | * Retorna los campos de reformulacion |
---|
| 110 | */ |
---|
| 111 | function reformula_ver_campos($node, $reformulacion_load) { |
---|
| 112 | $id_ref = $reformulacion_load ? $reformulacion_load->id_ref : 0; |
---|
| 113 | $reformula = _proyectos_reformulacion_load($node, $id_ref); |
---|
| 114 | $format_number = array( |
---|
| 115 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
| 116 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
| 117 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
| 118 | ); |
---|
| 119 | $ftypes = array( |
---|
| 120 | 'value' => t('January'), |
---|
| 121 | 'value_1' => t('February'), |
---|
| 122 | 'value_2' => t('March'), |
---|
| 123 | 'value_3' => t('April'), |
---|
| 124 | 'value_4' => t('May'), |
---|
| 125 | 'value_5' => t('June'), |
---|
| 126 | 'value_6' => t('July'), |
---|
| 127 | 'value_7' => t('August'), |
---|
| 128 | 'value_8' => t('September'), |
---|
| 129 | 'value_9' => t('Octuber'), |
---|
| 130 | 'value_10' => t('November'), |
---|
| 131 | 'value_11' => t('December'), |
---|
| 132 | ); |
---|
| 133 | $tipos = array( |
---|
| 134 | 1 => t('Traspaso'), |
---|
| 135 | 2 => t('Incremento'), |
---|
| 136 | 3 => t('Disminución'), |
---|
| 137 | ); |
---|
| 138 | //se obtiene la unidad de medida |
---|
| 139 | $field = content_fields('field_proyecto_unidadm', 'proyectos_operativos'); |
---|
| 140 | $tree = taxonomy_get_tree($field['vid']); |
---|
| 141 | $options = array(); |
---|
| 142 | if ($tree) { |
---|
| 143 | foreach ($tree as $term) { |
---|
| 144 | if ($term->tid == $unidad_ant) { |
---|
| 145 | $text_unidad = $term->name; |
---|
| 146 | } |
---|
| 147 | $choice = new stdClass(); |
---|
| 148 | $choice->option = array($term->tid => str_repeat('-', $term->depth) . $term->name); |
---|
| 149 | $options[$term->tid] = $term->name; |
---|
| 150 | } |
---|
| 151 | } |
---|
| 152 | $grupos = array(); |
---|
| 153 | if ($node->field_proyecto_accion_esp[0]['nid']) { |
---|
| 154 | foreach($node->field_proyecto_accion_esp as $ae) { |
---|
| 155 | $grupos[$ae['nid']] = node_load($ae['nid']); |
---|
| 156 | } |
---|
| 157 | } |
---|
| 158 | $field = content_fields('field_accion_esp_unidadm', 'accion_especifica'); |
---|
| 159 | $unidadesm = array(); |
---|
| 160 | $tree = taxonomy_get_tree($field['vid']); |
---|
| 161 | if ($tree) { |
---|
| 162 | foreach ($tree as $term) { |
---|
| 163 | $unidadesm[$term->tid] = $term->name; |
---|
| 164 | } |
---|
| 165 | } |
---|
| 166 | $field = content_fields('field_accion_esp_programacion', 'accion_especifica'); |
---|
| 167 | $tree = taxonomy_get_tree($field['vid']); |
---|
| 168 | $vtid = $field['vtid']; |
---|
| 169 | $partidas = array(); |
---|
| 170 | if ($tree) { |
---|
| 171 | foreach ($tree as $term) { |
---|
| 172 | if (isset($vtid[$term->tid])) { |
---|
| 173 | $partidas[$term->tid] = $term->name; |
---|
| 174 | } |
---|
| 175 | } |
---|
| 176 | } |
---|
| 177 | $financia = array(); |
---|
| 178 | $accion_especifica_number_fields = variable_get('accion_especifica_number_fields', 4); |
---|
| 179 | $financia = array(); |
---|
| 180 | for($i = 0; $i < $accion_especifica_number_fields; $i++) { |
---|
| 181 | $financarray = variable_get('accion_especifica_financiamiento_options_' . $i, array()); |
---|
| 182 | if (count($financarray)) { |
---|
| 183 | foreach($financarray as $id1 => $camp1){ |
---|
| 184 | if ($camp1){ |
---|
| 185 | $financia[$id1] = $fields1[$id1]['widget']['label']; |
---|
| 186 | } |
---|
| 187 | } |
---|
| 188 | } |
---|
| 189 | } |
---|
| 190 | $display = array(); |
---|
| 191 | $display['fecha_onapre'] = date( 'd/m/Y', $reformula['fecha_onapre']); |
---|
| 192 | $display['justificacion'] = $reformula['justificacion']; |
---|
| 193 | $display['traspaso'] = array_key_exists($reformula['tipo'], $tipos) ? $tipos[$reformula['tipo']] : 'N/A'; |
---|
| 194 | $signo = ''; |
---|
| 195 | if ($reformulacion_load->variacion > 0) { |
---|
| 196 | $signo = '+'; |
---|
| 197 | } |
---|
| 198 | $display['variacion'] = $signo . number_format($reformulacion_load->variacion, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']); |
---|
| 199 | $display['field_proyecto_unidadm'] = $options[$reformulacion_load->unidad]; |
---|
| 200 | //meta fisica del proyecto |
---|
| 201 | foreach($ftypes as $id_field => $texto) { |
---|
| 202 | $valor = isset($reformula['field_proyecto_meta_fisica'][0][$id_field])? $reformula['field_proyecto_meta_fisica'][0][$id_field] : 0; |
---|
| 203 | $signo = ''; |
---|
| 204 | if ($valor > 0) { |
---|
| 205 | $signo = '+'; |
---|
| 206 | } |
---|
| 207 | $display['field_proyecto_meta_fisica_' . $id_field] = $signo . number_format($valor, 0, $format_number['dec_point'], $format_number['thousands_sep']); |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | foreach($grupos as $nid => $grupo) { |
---|
| 211 | $display[$nid]['field_accion_esp_metaf_unidadm'] = $unidadesm[$reformula['field_accion_esp_metaf_' . $nid][0]['unidad']]; |
---|
| 212 | foreach($ftypes as $id_field => $texto) { |
---|
| 213 | $valor = isset($reformula['field_accion_esp_metaf_' . $nid][0][$id_field])? $reformula['field_accion_esp_metaf_' . $nid][0][$id_field] : 0; |
---|
| 214 | $signo = ''; |
---|
| 215 | if ($valor > 0) { |
---|
| 216 | $signo = '+'; |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | $display[$nid]['field_accion_esp_metaf_' . $id_field] = $signo . number_format($valor, 0, $format_number['dec_point'], $format_number['thousands_sep']); |
---|
| 220 | foreach($partidas as $tid => $term) { |
---|
| 221 | $valor = isset($reformula['field_accion_esp_programacion_' . $nid][$tid][$id_field])? $reformula['field_accion_esp_programacion_' . $nid][$tid][$id_field] : 0; |
---|
| 222 | $signo = ''; |
---|
| 223 | if ($valor > 0) { |
---|
| 224 | $signo = '+'; |
---|
| 225 | } |
---|
| 226 | $idformu = 'field_accion_esp_programacion_' . $tid . '_' . $id_field; |
---|
| 227 | $display[$nid][$idformu] = $signo . number_format($valor, 0, $format_number['dec_point'], $format_number['thousands_sep']); |
---|
| 228 | } |
---|
| 229 | } |
---|
| 230 | foreach($financia as $id_field => $texto) { |
---|
| 231 | $valor = isset($reformula[$id_field . '_' . $nid][0]['value'])? $reformula[$id_field . '_' . $nid][0]['value'] : 0; |
---|
| 232 | $signo = ''; |
---|
| 233 | if ($valor > 0) { |
---|
| 234 | $signo = '+'; |
---|
| 235 | } |
---|
| 236 | $display[$nid][$id_field] = $signo . number_format($valor, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']); |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | } |
---|
| 240 | return $display; |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | /* |
---|
| 244 | * Implementation of hook_perm() |
---|
| 245 | */ |
---|
| 246 | function entes_detail_proyectos_perm() { |
---|
| 247 | return array( |
---|
| 248 | 'remove observaciones', |
---|
| 249 | ); |
---|
| 250 | } |
---|
| 251 | |
---|
| 252 | /* |
---|
| 253 | * Implementation of _entes_detail_proyectos_operativos_get_campos_proyectos_reformula() |
---|
| 254 | * Obtiene los capos de reformulacion |
---|
| 255 | */ |
---|
| 256 | function _entes_detail_proyectos_operativos_get_campos_proyectos_reformula($proyecto = 0){ |
---|
| 257 | $title_combos = array(); |
---|
| 258 | $arreglo = array(); |
---|
| 259 | if ($proyecto && $proyecto->nid){ |
---|
| 260 | $title_combos['monto']['title'] = t('Monto Total del Proyecto'); |
---|
| 261 | $arreglo['monto'] = array(); |
---|
| 262 | $arreglo['monto'] = array( |
---|
| 263 | 'fecha_onapre' => t('Fecha de Aprobación'), |
---|
| 264 | 'traspaso' => t('Traspaso'), |
---|
| 265 | 'justificacion' => t('Justificación'), |
---|
| 266 | 'variacion' => t('Variación Presupuestaria'), |
---|
| 267 | ); |
---|
| 268 | $ftypes = array( |
---|
| 269 | 'value' => t('January'), |
---|
| 270 | 'value_1' => t('February'), |
---|
| 271 | 'value_2' => t('March'), |
---|
| 272 | 'value_3' => t('April'), |
---|
| 273 | 'value_4' => t('May'), |
---|
| 274 | 'value_5' => t('June'), |
---|
| 275 | 'value_6' => t('July'), |
---|
| 276 | 'value_7' => t('August'), |
---|
| 277 | 'value_8' => t('September'), |
---|
| 278 | 'value_9' => t('Octuber'), |
---|
| 279 | 'value_10' => t('November'), |
---|
| 280 | 'value_11' => t('December'), |
---|
| 281 | ); |
---|
| 282 | $title_combos['distribucion']['title'] = t('Distribución de la Meta FÃsica'); |
---|
| 283 | $arreglo['distribucion'] = array( |
---|
| 284 | 'field_proyecto_unidadm' => t('Unidad de Medida Nueva'), |
---|
| 285 | ); |
---|
| 286 | foreach($ftypes as $id_field => $texto) { |
---|
| 287 | $arreglo['distribucion']['field_proyecto_meta_fisica_' . $id_field] = t('Variación del Proyecto: @mes', array('@mes' => t($texto))); |
---|
| 288 | } |
---|
| 289 | //Se obtienen todas las fuentes de finaciamiento |
---|
| 290 | //financiamiento |
---|
| 291 | $arreglo_financiamiento = array(); |
---|
| 292 | $arreglo_financiamiento_fields = array(); |
---|
| 293 | $accion_especifica_number_fields = variable_get('accion_especifica_number_fields', 4); |
---|
| 294 | for($i = 0; $i < $accion_especifica_number_fields; $i++) { |
---|
| 295 | $arreglo_financiamiento['financiamiento_' . $i] = variable_get('accion_especifica_financiamiento_label_' . $i, '') ? variable_get('accion_especifica_financiamiento_label_' . $i, '') : ''; |
---|
| 296 | $arreglo_financiamiento_fields['financiamiento_' . $i] = variable_get('accion_especifica_financiamiento_options_' . $i, array()); |
---|
| 297 | } |
---|
| 298 | //se obtienen las partidas presupuestarias |
---|
| 299 | $field = content_fields('field_accion_esp_programacion', 'accion_especifica'); |
---|
| 300 | $tree = taxonomy_get_tree($field['vid']); |
---|
| 301 | $vtid = $field['vtid']; |
---|
| 302 | $partidas = array(); |
---|
| 303 | if ($tree) { |
---|
| 304 | foreach ($tree as $term) { |
---|
| 305 | if (isset($vtid[$term->tid])) { |
---|
| 306 | $partidas[$term->tid] = $term->name; |
---|
| 307 | } |
---|
| 308 | } |
---|
| 309 | } |
---|
| 310 | //financiamiento |
---|
| 311 | $node_type1 = content_types('accion_especifica'); |
---|
| 312 | $fields1 = $node_type1['fields']; |
---|
| 313 | $arreglo_financiamiento = array(); |
---|
| 314 | $financia = array(); |
---|
| 315 | $accion_especifica_number_fields = variable_get('accion_especifica_number_fields', 4); |
---|
| 316 | $financia = array(); |
---|
| 317 | for($i = 0; $i < $accion_especifica_number_fields; $i++) { |
---|
| 318 | $financarray = variable_get('accion_especifica_financiamiento_options_' . $i, array()); |
---|
| 319 | if (count($financarray)) { |
---|
| 320 | foreach($financarray as $id1 => $camp1){ |
---|
| 321 | if ($camp1){ |
---|
| 322 | $financia[$id1] = $fields1[$id1]['widget']['label']; |
---|
| 323 | } |
---|
| 324 | } |
---|
| 325 | } |
---|
| 326 | } |
---|
| 327 | $i = 1; |
---|
| 328 | if ($proyecto->field_proyecto_accion_esp[0]['nid']) { |
---|
| 329 | foreach($proyecto->field_proyecto_accion_esp as $ae) { |
---|
| 330 | if (is_numeric($ae['nid'])) { |
---|
| 331 | $idae = 'AE_' . $i; |
---|
| 332 | $title_combos['AE_' . $i]['title'] = 'AE_' . $i; |
---|
| 333 | $arreglo['distribucion'][$ae['nid'] . '_field_accion_esp_metaf_unidadm'] = '(AE_' . $i . ') ' . t('Unidad de Medida Nueva'); |
---|
| 334 | foreach($ftypes as $id_field => $texto) { |
---|
| 335 | $arreglo['distribucion'][$ae['nid'] . '_field_accion_esp_metaf_' . $id_field] = '(AE_' . $i . ') ' . t('Variación') . ': ' . t($texto); |
---|
| 336 | foreach($partidas as $tid => $term) { |
---|
| 337 | $idformu = $ae['nid'] . '_field_accion_esp_programacion_' . $tid . '_' . $id_field; |
---|
| 338 | $arreglo[$idae][$idformu] = t('Variación partida') . ' ' . $term .': ' . t($texto); |
---|
| 339 | } |
---|
| 340 | } |
---|
| 341 | foreach($financia as $id_field => $texto) { |
---|
| 342 | $arreglo[$idae][$ae['nid'] . '_' . $id_field] = t('Fuente de Finaciamiento') . ': ' . $texto; |
---|
| 343 | } |
---|
| 344 | |
---|
| 345 | $i++; |
---|
| 346 | } |
---|
| 347 | } |
---|
| 348 | } |
---|
| 349 | } |
---|
| 350 | drupal_alter('proyecto_reformula_obtiene_fields_categorias', $title_combos); |
---|
| 351 | drupal_alter('proyecto_reformula_obtiene_fields_campos', $arreglo); |
---|
| 352 | return array( |
---|
| 353 | 'categorias' => $title_combos, |
---|
| 354 | 'campos' => $arreglo, |
---|
| 355 | ); |
---|
| 356 | } |
---|
| 357 | |
---|
| 358 | /* |
---|
| 359 | * Implementation of _entes_detail_proyectos_operativos_get_campos_proyectos() |
---|
| 360 | * Obtiene los capos de proyectos |
---|
| 361 | */ |
---|
| 362 | function _entes_detail_proyectos_operativos_get_campos_proyectos(){ |
---|
| 363 | $title_combos = array(); |
---|
| 364 | $arreglo = array(); |
---|
| 365 | $title_combos['db']['title'] = t('Datos Básicos'); |
---|
| 366 | $title_combos['db']['type'] = 'node'; |
---|
| 367 | $arreglo['db']['identificacion'] = array(); |
---|
| 368 | $arreglo['db']['identificacion'] = array( |
---|
| 369 | 'title' => t('Nombre del Proyecto'), |
---|
| 370 | 'field_proyecto_codigo' => 'field_proyecto_codigo', |
---|
[8467160] | 371 | 'field_proyecto_codigo_n_etap' => 'field_proyecto_codigo_n_etap', |
---|
[a0b4327] | 372 | 'field_proyecto_fecha_i' => 'field_proyecto_fecha_i', |
---|
| 373 | 'field_proyecto_fecha_f' => 'field_proyecto_fecha_f', |
---|
| 374 | 'field_proyecto_status' => 'field_proyecto_status', |
---|
| 375 | 'field_proyecto_situacion_p' => 'field_proyecto_situacion_p', |
---|
| 376 | 'field_proyecto_plurianual' => 'field_proyecto_plurianual', |
---|
| 377 | 'field_proyecto_monto_anual' => 'field_proyecto_monto_anual', |
---|
| 378 | 'field_proyecto_total' => 'field_proyecto_total', |
---|
| 379 | 'field_proyecto_poan' => 'field_proyecto_poan', |
---|
| 380 | ); |
---|
| 381 | $title_combos['db']['identificacion']['title'] = t('Datos Básicos de Identificación del Proyecto'); |
---|
| 382 | $title_combos['db']['identificacion']['type'] = 'node'; |
---|
| 383 | //Gerente del Proyecto |
---|
| 384 | $arreglo['db']['gerentep'] = array(); |
---|
| 385 | $arreglo['db']['gerentep'] = array( |
---|
| 386 | 'field_proyecto_ente' => 'field_proyecto_ente', |
---|
| 387 | 'field_proyecto_autoridad' => 'field_proyecto_autoridad', |
---|
| 388 | 'field_proyecto_lider' => 'field_proyecto_lider', |
---|
| 389 | 'field_proyecto_unidad_a' => 'field_proyecto_unidad_a', |
---|
| 390 | 'field_proyecto_cargo' => 'field_proyecto_cargo', |
---|
| 391 | 'field_proyecto_telefono' => 'field_proyecto_telefono', |
---|
| 392 | 'field_proyecto_correo' => 'field_proyecto_correo', |
---|
| 393 | ); |
---|
| 394 | $title_combos['db']['gerentep']['title'] = t('Gerente del Proyecto'); |
---|
| 395 | $title_combos['db']['gerentep']['type'] = 'node'; |
---|
| 396 | //Ãrea Estrategica |
---|
| 397 | $pndes = variable_get('proyectos_operativos_muestra_pndes', TRUE); |
---|
| 398 | $mcti = variable_get('proyectos_operativos_muestra_mcti', TRUE); |
---|
| 399 | if ($pndes || $mcti) { |
---|
| 400 | $arreglo['db']['areae'] = array(); |
---|
| 401 | if ($pndes) { |
---|
| 402 | $arreglo['db']['areae']['field_proyecto_pndes'] = 'field_proyecto_pndes'; |
---|
| 403 | } |
---|
| 404 | if ($mcti) { |
---|
| 405 | $arreglo['db']['areae']['field_proyecto_mcti'] = 'field_proyecto_mcti'; |
---|
| 406 | } |
---|
| 407 | $title_combos['db']['areae']['title'] = t('Ãrea Estratégica'); |
---|
| 408 | $title_combos['db']['areae']['type'] = 'node'; |
---|
| 409 | } |
---|
| 410 | //DATOS GENERALES |
---|
| 411 | $title_combos['dg']['title'] = t('Datos Generales'); |
---|
| 412 | $title_combos['dg']['type'] = 'node'; |
---|
| 413 | //Clasificación Sectorial |
---|
| 414 | $arreglo['dg']['sector'] = array(); |
---|
| 415 | $arreglo['dg']['sector'] = array( |
---|
| 416 | 'field_proyecto_sector' => 'field_proyecto_sector', |
---|
| 417 | ); |
---|
| 418 | $title_combos['dg']['sector']['title'] = t('Clasificación Sectorial'); |
---|
| 419 | $title_combos['dg']['sector']['type'] = 'node'; |
---|
| 420 | //Talento Humano |
---|
| 421 | if (variable_get('proyectos_operativos_muestra_talento', TRUE)) { |
---|
| 422 | $arreglo['dg']['talentoh'] = array(); |
---|
| 423 | $arreglo['dg']['talentoh'] = array( |
---|
| 424 | 'field_proyecto_institucionth' => 'field_proyecto_institucionth', |
---|
| 425 | 'field_proyecto_nombres_a' => 'field_proyecto_nombres_a', |
---|
| 426 | 'field_proyecto_cargo_th' => 'field_proyecto_cargo_th', |
---|
| 427 | 'field_proyecto_rol_th' => 'field_proyecto_rol_th', |
---|
| 428 | 'field_proyecto_esfuerzo' => 'field_proyecto_esfuerzo', |
---|
| 429 | 'field_proyecto_formacion' => 'field_proyecto_formacion', |
---|
| 430 | ); |
---|
| 431 | $title_combos['dg']['talentoh']['title'] = t('Talento Humano'); |
---|
| 432 | $title_combos['dg']['talentoh']['type'] = 'node'; |
---|
| 433 | } |
---|
| 434 | //Capacidades |
---|
| 435 | $arreglo['dg']['capacidades'] = array(); |
---|
| 436 | if (variable_get('proyectos_operativos_muestra_capacidades', TRUE)) { |
---|
| 437 | $arreglo['dg']['capacidades'] = array( |
---|
| 438 | 'field_proyecto_institucion_alc' => 'field_proyecto_institucion_alc', |
---|
| 439 | 'field_proyecto_infraestructura' => 'field_proyecto_infraestructura', |
---|
| 440 | 'field_proyecto_equipos' => 'field_proyecto_equipos', |
---|
| 441 | 'field_proyecto_insumos' => 'field_proyecto_insumos', |
---|
| 442 | 'field_proyectos_servicios' => 'field_proyectos_servicios', |
---|
| 443 | ); |
---|
| 444 | } |
---|
| 445 | $title_combos['dg']['capacidades']['title'] = t('Capacidades'); |
---|
| 446 | $title_combos['dg']['capacidades']['type'] = 'node'; |
---|
| 447 | //Instituciones |
---|
| 448 | $arreglo['dg']['relacion'] = array(); |
---|
| 449 | $arreglo['dg']['relacion'] = array( |
---|
| 450 | 'field_proyecto_relacion' => 'field_proyecto_relacion', |
---|
| 451 | ); |
---|
| 452 | $title_combos['dg']['relacion']['title'] = t('Instituciones'); |
---|
| 453 | $title_combos['dg']['relacion']['type'] = 'node'; |
---|
| 454 | //Empleos Generados |
---|
| 455 | |
---|
| 456 | if (variable_get('proyectos_operativos_muestra_beneficiario', TRUE)) { |
---|
| 457 | $arreglo['dg']['empleosg'] = array( |
---|
| 458 | 'field_proyecto_emdirecto' => 'field_proyecto_emdirecto', |
---|
| 459 | 'field_proyecto_efdirecto' => 'field_proyecto_efdirecto', |
---|
| 460 | ); |
---|
| 461 | if (variable_get('proyectos_operativos_muestra_beneficiarios_indirectos', TRUE)) { |
---|
| 462 | $arreglo['dg']['empleosg']['field_proyecto_emindirecto'] = 'field_proyecto_emindirecto'; |
---|
| 463 | $arreglo['dg']['empleosg']['field_proyecto_efindirecto'] = 'field_proyecto_efindirecto'; |
---|
| 464 | } |
---|
| 465 | $arreglo['dg']['empleosg'] = array(); |
---|
| 466 | $title_combos['dg']['empleosg']['title'] = t('Empleos Generados'); |
---|
| 467 | $title_combos['dg']['empleosg']['type'] = 'node'; |
---|
| 468 | } |
---|
| 469 | //Objetivos del Proyecto |
---|
| 470 | $arreglo['dg']['objetivosp'] = array(); |
---|
| 471 | $arreglo['dg']['objetivosp'] = array( |
---|
| 472 | 'field_proyecto_og' => 'field_proyecto_og', |
---|
| 473 | 'field_proyecto_oe' => 'field_proyecto_oe', |
---|
| 474 | ); |
---|
| 475 | $title_combos['dg']['objetivosp']['title'] = t('Objetivos'); |
---|
| 476 | $title_combos['dg']['objetivosp']['type'] = 'node'; |
---|
| 477 | //INDICADORES DEL PROYECTO |
---|
| 478 | //Enunciado del Problema |
---|
| 479 | $title_combos['ip']['title'] = t('Indicadores del Proyecto'); |
---|
| 480 | $title_combos['ip']['type'] = 'node'; |
---|
| 481 | $arreglo['ip']['enunciadop'] = array(); |
---|
| 482 | if (variable_get('proyectos_operativos_muestra_enunciado_problema', TRUE)) { |
---|
| 483 | $arreglo['ip']['enunciadop'] = array( |
---|
| 484 | 'field_proyecto_causas' => 'field_proyecto_causas', |
---|
| 485 | 'field_proyecto_problemas' => 'field_proyecto_problemas', |
---|
| 486 | 'field_proyecto_consecuencias' => 'field_proyecto_consecuencias', |
---|
| 487 | ); |
---|
| 488 | } |
---|
| 489 | $title_combos['ip']['enunciadop']['title'] = t('Enunciado del Problema'); |
---|
| 490 | $title_combos['ip']['enunciadop']['type'] = 'node'; |
---|
| 491 | //Justificación del Proyecto |
---|
| 492 | $arreglo['ip']['justificacion'] = array(); |
---|
| 493 | if (variable_get('proyectos_operativos_muestra_justicacion', TRUE)) { |
---|
| 494 | $arreglo['ip']['justificacion'] = array( |
---|
| 495 | 'field_proyecto_justificacion' => 'field_proyecto_justificacion', |
---|
| 496 | ); |
---|
| 497 | } |
---|
| 498 | $title_combos['ip']['justificacion']['title'] = t('Justificación del Proyecto'); |
---|
| 499 | $title_combos['ip']['justificacion']['type'] = 'node'; |
---|
| 500 | //Alcance del Proyecto |
---|
| 501 | $arreglo['ip']['alcance'] = array(); |
---|
| 502 | if (variable_get('proyectos_operativos_muestra_alcance', TRUE)) { |
---|
| 503 | $arreglo['ip']['alcance'] = array( |
---|
| 504 | 'field_proyecto_alcance' => 'field_proyecto_alcance', |
---|
| 505 | ); |
---|
| 506 | } |
---|
| 507 | $title_combos['ip']['alcance']['title'] = t('Alcance del Proyecto'); |
---|
| 508 | $title_combos['ip']['alcance']['type'] = 'node'; |
---|
| 509 | //Situación Actual del Proyecto |
---|
| 510 | $arreglo['ip']['situaciona'] = array(); |
---|
| 511 | if (variable_get('proyectos_operativos_muestra_sa', TRUE)) { |
---|
| 512 | $arreglo['ip']['situaciona'] = array( |
---|
| 513 | 'field_proyecto_sa_descripcion' => 'field_proyecto_sa_descripcion', |
---|
| 514 | ); |
---|
| 515 | if (variable_get('proyectos_operativos_muestra_sa_cuantificacion', TRUE)) { |
---|
| 516 | $arreglo['ip']['situaciona']['field_proyecto_sa_cuantificacion'] = 'field_proyecto_sa_cuantificacion'; |
---|
| 517 | } |
---|
| 518 | $arreglo['ip']['situaciona']['field_proyecto_sa_formulai'] = 'field_proyecto_sa_formulai'; |
---|
| 519 | $arreglo['ip']['situaciona']['field_proyecto_sa_fuentei'] = 'field_proyecto_sa_fuentei'; |
---|
| 520 | $arreglo['ip']['situaciona']['field_proyecto_sa_fecha'] = 'field_proyecto_sa_fecha'; |
---|
| 521 | } |
---|
| 522 | $title_combos['ip']['situaciona']['title'] = t('Situación Actual'); |
---|
| 523 | $title_combos['ip']['situaciona']['type'] = 'node'; |
---|
| 524 | //Situación Objetivo |
---|
| 525 | $arreglo['ip']['situaciono'] = array(); |
---|
| 526 | if (variable_get('proyectos_operativos_muestra_so', TRUE)) { |
---|
| 527 | $arreglo['ip']['situaciono'] = array( |
---|
| 528 | 'field_proyecto_so_descripcion' => 'field_proyecto_so_descripcion', |
---|
| 529 | 'field_proyecto_so_cuantificacion' => 'field_proyecto_so_cuantificacion', |
---|
| 530 | 'field_proyecto_tiempoi' => 'field_proyecto_tiempoi', |
---|
| 531 | ); |
---|
| 532 | } |
---|
| 533 | $title_combos['ip']['situaciono']['title'] = t('Situación Objetivo'); |
---|
| 534 | $title_combos['ip']['situaciono']['type'] = 'node'; |
---|
| 535 | |
---|
| 536 | //Indicador del resultado del Proyecto |
---|
| 537 | $arreglo['ip']['resultadop'] = array(); |
---|
| 538 | $arreglo['ip']['resultadop'] = array( |
---|
| 539 | 'field_proyecto_descripcion_bien' => 'field_proyecto_descripcion_bien', |
---|
| 540 | 'field_proyecto_unidadm' => 'field_proyecto_unidadm', |
---|
| 541 | 'field_proyecto_meta_m' => 'field_proyecto_meta_m', |
---|
| 542 | 'field_proyecto_meta_f' => 'field_proyecto_meta_f', |
---|
| 543 | 'field_proyecto_meta_fisica' => 'field_proyecto_meta_fisica', |
---|
| 544 | ); |
---|
| 545 | $title_combos['ip']['resultadop']['title'] = t('Indicador del resultado del Proyecto'); |
---|
| 546 | $title_combos['ip']['resultadop']['type'] = 'node'; |
---|
| 547 | $title_combos['otros']['title'] = t('Otros'); |
---|
| 548 | $title_combos['otros']['type'] = 'flow'; |
---|
| 549 | $title_combos['otros']['fl']['title'] = t('Flujo de Trabajo'); |
---|
| 550 | $arreglo['otros']['fl'] = array( |
---|
| 551 | 'proyectos_operativos_flujo' => 'Flujo Actual', |
---|
| 552 | ); |
---|
| 553 | drupal_alter('proyecto_obtiene_fields_categorias', $title_combos); |
---|
| 554 | drupal_alter('proyecto_obtiene_fields_campos', $arreglo); |
---|
| 555 | return array( |
---|
| 556 | 'categorias' => $title_combos, |
---|
| 557 | 'campos' => $arreglo, |
---|
| 558 | ); |
---|
| 559 | } |
---|
| 560 | |
---|
| 561 | /* |
---|
| 562 | * Implementation of hook_menu() |
---|
| 563 | */ |
---|
| 564 | function entes_detail_workflow_menu() { |
---|
| 565 | $items = array(); |
---|
[221dd7a] | 566 | $items['entes_detail_workflow_js_util/proyectos'] = array( |
---|
[a0b4327] | 567 | 'title' => 'JS utilities', |
---|
[221dd7a] | 568 | 'page callback' => 'entes_detail_workflow_js_util_proyectos', |
---|
[a0b4327] | 569 | 'access arguments' => array('ver planificador'), |
---|
| 570 | 'type' => MENU_CALLBACK, |
---|
| 571 | ); |
---|
[221dd7a] | 572 | //consulta proyecto operativo (comentarios) |
---|
| 573 | $items['proyectosop/%proyectosop/comentarios'] = array( |
---|
| 574 | 'title' => t('Comentarios'), |
---|
| 575 | 'page callback' => '_list_proyectos_operativos_detail_workflow', |
---|
| 576 | 'page arguments' => array(1), |
---|
| 577 | 'access callback' => '_proyectos_operativos_ver_datos_wk_access', |
---|
| 578 | 'access arguments' => array(1), |
---|
| 579 | 'weight' => -5, |
---|
| 580 | 'type' => MENU_LOCAL_TASK, |
---|
| 581 | ); |
---|
[a0b4327] | 582 | return $items; |
---|
| 583 | } |
---|
| 584 | |
---|
| 585 | /* |
---|
[221dd7a] | 586 | * Implementation of hook_acciones_obtiene_links_alter() |
---|
| 587 | */ |
---|
| 588 | function entes_detail_workflow_proyecto_obtiene_links_alter(&$links, $proyecto, $acceso = FALSE) { |
---|
| 589 | $node_accion = node_load($proyecto->nid); |
---|
| 590 | if (_proyectos_operativos_ver_datos_wk_access($node_accion)) { |
---|
| 591 | $links['proyecto_view_comentarios'] = array( |
---|
| 592 | 'data' => l(t('Consultar Comentarios'), 'proyectosop/' . $proyecto->nid . '/comentarios'), |
---|
| 593 | 'class' => 'proyectos-operativos-comentarios', |
---|
| 594 | ); |
---|
| 595 | } |
---|
| 596 | } |
---|
| 597 | |
---|
| 598 | function _list_proyectos_operativos_detail_workflow($node){ |
---|
| 599 | module_load_include('inc', 'workflow', 'workflow.pages'); |
---|
| 600 | $campos_leidos = _entes_detail_proyectos_operativos_get_campos_proyectos(); |
---|
| 601 | $options_campos = array(); |
---|
| 602 | $node_type = content_types('proyectos_operativos'); |
---|
| 603 | $fields = $node_type['fields']; |
---|
| 604 | $node_type1 = content_types('accion_especifica'); |
---|
| 605 | $fields1 = $node_type1['fields']; |
---|
| 606 | $node_workflow_display = node_build_content($node); |
---|
| 607 | $result = db_query("SELECT e.*, u.name, u.uid, w.old_sid, w.comment FROM {entes_detail_workflow} AS e INNER JOIN {workflow_node_history} AS w ON w.hid = e.hid INNER JOIN {users} AS u ON w.uid =u.uid WHERE id = %d AND tipo = 'proyectos_operativos' AND active = 1 ORDER BY field_name, time DESC", $node->nid); |
---|
| 608 | $comentarios =array(); |
---|
| 609 | while($comentario = db_fetch_object($result)) { |
---|
| 610 | if (!isset($comentarios[$comentario->field_name])) { |
---|
| 611 | $comentarios[$comentario->field_name] = array(); |
---|
| 612 | } |
---|
| 613 | if (trim($comentario->comentario) != '') { |
---|
| 614 | $comentarios[$comentario->field_name][] = '<div class="comentario-ver"><div class="comentario-contenido">' . check_plain($comentario->comentario) . '</div><div class="comentario-usuario-fecha">' . theme('username', $comentario) . ' | ' . format_date($comentario->time) . '</div></div>'; |
---|
| 615 | } |
---|
| 616 | } |
---|
| 617 | $contenido = array(); |
---|
| 618 | $array_titles = array(); |
---|
| 619 | $todas_opciones = array(); |
---|
| 620 | $output = ''; |
---|
| 621 | foreach($campos_leidos['campos'] as $idcat => $array){ |
---|
| 622 | foreach($array as $idcamp => $arrat1){ |
---|
| 623 | $output .= '<fieldset><legend>' . $campos_leidos['categorias'][$idcat][$idcamp]['title'] . '</legend>'; |
---|
| 624 | $array_soptions = array(); |
---|
| 625 | foreach($arrat1 as $ind2 => $array2){ |
---|
| 626 | if ($ind2 == 'title'){ |
---|
| 627 | $contenido[$ind2] = '<div class="field field-type-title field-field-proyecto-title"><div class="field-label">' . t('Nombre del Proyecto') . ': </div><div class="field-items"><div class="field-item odd">' . check_plain($node->title) . '</div></div></div>'; |
---|
| 628 | $array_soptions[$ind2] = t('Nombre del Proyecto'); |
---|
| 629 | } |
---|
| 630 | else { |
---|
| 631 | $contenido[$ind2] = drupal_render($node_workflow_display->content[$ind2]); |
---|
| 632 | $array_soptions[$ind2] = $fields[$ind2]['widget']['label']; |
---|
| 633 | } |
---|
| 634 | $array_titles[$ind2] = $array_soptions[$ind2]; |
---|
| 635 | $todas_opciones[$ind2] = $ind2; |
---|
| 636 | if ($fields[$ind2]['display_settings']['full']['format'] != 'hidden' && trim($contenido[$ind2]) != '') { |
---|
| 637 | $ncomentario = isset($comentarios[$ind2]) && count($comentarios[$ind2])? '<div class="todos-comentarios"><b>' . t('Comentarios') . ':</b>' . implode ('', $comentarios[$ind2]) . '</div>' : ''; |
---|
| 638 | $output .= $contenido[$ind2] . $ncomentario; |
---|
| 639 | } |
---|
| 640 | } |
---|
| 641 | if ($campos_leidos['categorias'][$idcat][$idcamp]['type'] == 'node'){ |
---|
| 642 | $options_campos[$campos_leidos['categorias'][$idcat][$idcamp]['title']] = $array_soptions; |
---|
| 643 | } |
---|
| 644 | $output .= '</fieldset>'; |
---|
| 645 | } |
---|
| 646 | } |
---|
| 647 | $contenidoae = array(); |
---|
| 648 | $acciones_especificas = array(); |
---|
| 649 | if (isset($node->field_proyecto_accion_esp)){ |
---|
| 650 | foreach($node->field_proyecto_accion_esp as $accion) { |
---|
| 651 | if ($accion['nid']) { |
---|
| 652 | $accionep = node_load($accion['nid']); |
---|
| 653 | $output .= '<fieldset><legend>' . 'AE: ' . check_plain($accionep->title) . '</legend>'; |
---|
| 654 | $opcionAE = array(); |
---|
| 655 | $contenidoae[$accionep->nid] = array(); |
---|
| 656 | $nodeae_workflow_display = node_build_content($accionep); |
---|
| 657 | foreach($fields1 as $idcat => $array){ |
---|
| 658 | $idcat1 = $accion['nid'] . '_' . $idcat; |
---|
| 659 | $contenidoae[$accionep->nid][$idcat] = drupal_render($nodeae_workflow_display->content[$idcat]); |
---|
| 660 | $opcionAE[$accionep->nid . '_' . $idcat] = $fields1[$idcat]['widget']['label']; |
---|
| 661 | $array_titles[$accionep->nid . '_' . $idcat] = 'AE_' .$i . ': ' . $opcionAE[$accionep->nid . '_' . $idcat]; |
---|
| 662 | $todas_opciones[$accionep->nid . '_' . $idcat] = $accionep->nid . '_' . $idcat; |
---|
| 663 | if ($fields1[$idcat]['display_settings']['full']['format'] != 'hidden' && trim($contenidoae[$accionep->nid][$idcat]) != '') { |
---|
| 664 | $ncomentario = isset($comentarios[$idcat1]) && count($comentarios[$idcat1])? '<div class="todos-comentarios"><b>' . t('Comentarios') . ':</b>' . implode ('', $comentarios[$idcat1]) . '</div>' : ''; |
---|
| 665 | $output .= $contenidoae[$accionep->nid][$idcat] . $ncomentario; |
---|
| 666 | } |
---|
| 667 | } |
---|
| 668 | $output .= '</fieldset>'; |
---|
| 669 | } |
---|
| 670 | } |
---|
| 671 | } |
---|
| 672 | return $output; |
---|
| 673 | } |
---|
| 674 | |
---|
| 675 | /* |
---|
[a0b4327] | 676 | * Implementation of entes_detail_workflow_js_util() |
---|
| 677 | * Utilidad javascript para realizar ajax en el formulario |
---|
| 678 | */ |
---|
[221dd7a] | 679 | function entes_detail_workflow_js_util_proyectos($categoria = '', $campo = '') { |
---|
| 680 | $options_select = isset($_POST[$campo])? $_POST[$campo]: 0; |
---|
[a0b4327] | 681 | $form_state = array('submitted' => FALSE); |
---|
| 682 | $form_build_id = $_POST['form_build_id']; |
---|
| 683 | // Add the new element to the stored form. Without adding the element to the |
---|
| 684 | // form, Drupal is not aware of this new elements existence and will not |
---|
| 685 | // process it. We retreive the cached form, add the element, and resave. |
---|
| 686 | $form = form_get_cache($form_build_id, $form_state); |
---|
[221dd7a] | 687 | if ($options_select) { |
---|
| 688 | $form[$categoria][$campo]['comentario_' . $campo] = array( |
---|
| 689 | '#title' => t('Comentario'), |
---|
| 690 | '#type' => 'textarea', |
---|
| 691 | '#default_value' => '', |
---|
| 692 | ); |
---|
[a0b4327] | 693 | } |
---|
[221dd7a] | 694 | elseif (isset($form[$categoria][$campo]['comentario_' . $campo])) { |
---|
| 695 | unset($form[$categoria][$campo]['comentario_' . $campo]); |
---|
[a0b4327] | 696 | } |
---|
| 697 | form_set_cache($form_build_id, $form, $form_state); |
---|
| 698 | $form += array( |
---|
| 699 | '#post' => $_POST, |
---|
| 700 | '#programmed' => FALSE, |
---|
| 701 | ); |
---|
| 702 | // Rebuild the form. |
---|
| 703 | $form = form_builder($_POST['form_id'], $form, $form_state); |
---|
[221dd7a] | 704 | $output = drupal_render($form[$categoria][$campo]['comentario_' . $campo]); |
---|
[a0b4327] | 705 | print drupal_to_js(array('data' => $output, 'status' => true)); |
---|
| 706 | exit(); |
---|
| 707 | } |
---|
| 708 | |
---|
| 709 | /* |
---|
| 710 | * hook_form_alter() |
---|
| 711 | */ |
---|
| 712 | function entes_detail_workflow_form_alter(&$form, $form_state, $form_id) { |
---|
| 713 | if ($form_id == 'proyectos_operativos_proyecto_genera_campos_form' && isset($form['otros']['fl'])){ |
---|
| 714 | $form['otros']['fl']['#options']['flujo_comentarios'] = t('Flujo de Trabajo con comentarios'); |
---|
| 715 | } |
---|
| 716 | 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){ |
---|
| 717 | $node_load = $form['#node']; |
---|
| 718 | $field_form = $form['#proyectos_operativos_fields']; |
---|
| 719 | $new_field_form = array(); |
---|
| 720 | if (is_array($field_form) && count($field_form)){ |
---|
| 721 | foreach($field_form as $field_id) |
---|
| 722 | $new_field_form[$field_id] = $field_id; |
---|
| 723 | } |
---|
| 724 | $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); |
---|
| 725 | $comentarios_details = array(); |
---|
| 726 | $pre_render = FALSE; |
---|
| 727 | $form['#proyecto_fields']; |
---|
| 728 | $nuevos = array(); |
---|
| 729 | $nuevos1 = array(); |
---|
| 730 | $campos_comentarios = array(); |
---|
| 731 | while($comentario = db_fetch_object($result)) { |
---|
| 732 | $campo = $comentario->field_name == 'title'? 'field_proyecto_titulo': $comentario->field_name; |
---|
| 733 | $nidae = explode('_', $comentario->field_name); |
---|
| 734 | if (array_key_exists($campo, $new_field_form) && trim($comentario->comentario) != ''){ |
---|
| 735 | if (!array_key_exists($campo, $nuevos)){ |
---|
| 736 | if (!isset($campos_comentarios[$campo])) { |
---|
| 737 | $campos_comentarios[$campo] = check_plain($comentario->comentario); |
---|
| 738 | } |
---|
| 739 | $nuevos[$campo] = $campo; |
---|
| 740 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;background:#fffcc5;"><b>' . $form['#proyecto_fields'][$campo]['widget']['label'] . '</b><br>' . $comentario->comentario . '</div>'; |
---|
| 741 | } |
---|
| 742 | else { |
---|
| 743 | if (!array_key_exists($field, $nuevos1)){ |
---|
| 744 | $nuevos1[$field] = $field; |
---|
| 745 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;"><b>' . t('Comentarios Anteriores') . ':</b><br>' . $comentario->comentario . '</div>'; |
---|
| 746 | } |
---|
| 747 | else { |
---|
| 748 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;">' . $comentario->comentario . '</div>'; |
---|
| 749 | } |
---|
| 750 | } |
---|
| 751 | } |
---|
| 752 | } |
---|
| 753 | if(count($comentarios_details)){ |
---|
| 754 | if (!isset($form['#pre_render'])) { |
---|
| 755 | $form['#pre_render'] = array(); |
---|
| 756 | } |
---|
| 757 | $form['#entes_detail_workflow_comment'] = $campos_comentarios; |
---|
| 758 | $form['#pre_render'][] = 'entes_detail_workflow_commment_field_pre_render'; |
---|
| 759 | $form['entes_detail_workflow']['#value'] = '<div id="bloque_apps" style="position: fixed;vertical-align: top;width:180px;z-index: 10000;margin: 0;top:10px;right:10px;background:#DDDDDD; border: 1px solid #BBBBBB;"><div style="padding:5px;"><b>' . t('Observaciones') . ':</b></div><div id="contenido-observaciones" style="overflow-y:scroll;max-height:100px;">' . implode('', $comentarios_details) . '</div></div>'; |
---|
| 760 | } |
---|
| 761 | } |
---|
| 762 | if ($form_id == 'proyectos_operativos_accion_especifica_crear_form'){ |
---|
| 763 | $node_load = $form['#proyecto']; |
---|
| 764 | $field_form = $form['#proyectos_operativos_fields']; |
---|
| 765 | $new_field_form = array(); |
---|
| 766 | if (is_array($field_form) && count($field_form)){ |
---|
| 767 | foreach($field_form as $field_id) { |
---|
| 768 | $new_field_form[$field_id] = $field_id; |
---|
| 769 | } |
---|
| 770 | } |
---|
| 771 | $ae = array(); |
---|
| 772 | $i = 1; |
---|
| 773 | foreach($form['#acciones_especificas'] as $accion) { |
---|
| 774 | if (isset($accion->nid)) { |
---|
| 775 | $ae[$accion->nid] = $i; |
---|
| 776 | $i++; |
---|
| 777 | } |
---|
| 778 | } |
---|
| 779 | $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); |
---|
| 780 | $comentarios_details = array(); |
---|
| 781 | $nuevos = array(); |
---|
| 782 | $nuevos1 = array(); |
---|
| 783 | $campos_comentarios = array(); |
---|
| 784 | while($comentario = db_fetch_object($result)) { |
---|
| 785 | $nidae = explode('_', $comentario->field_name); |
---|
| 786 | if (is_numeric($nidae[0])){ |
---|
| 787 | $nid = $nidae[0]; |
---|
| 788 | unset($nidae[0]); |
---|
| 789 | $field = implode('_', $nidae); |
---|
| 790 | //se estan viendo todas las acciones especificas |
---|
| 791 | if ($form['#node']->nid == $nid){ |
---|
| 792 | if (array_key_exists($field, $new_field_form) && trim($comentario->comentario) != ''){ |
---|
| 793 | if (!array_key_exists($field, $nuevos)){ |
---|
| 794 | if (!isset($campos_comentarios[$field])) { |
---|
| 795 | $campos_comentarios[$field] = check_plain($comentario->comentario); |
---|
| 796 | } |
---|
| 797 | $nuevos[$field] = $field; |
---|
| 798 | $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>'; |
---|
| 799 | } |
---|
| 800 | else { |
---|
| 801 | if (!array_key_exists($field, $nuevos1)){ |
---|
| 802 | $nuevos1[$field] = $field; |
---|
| 803 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;"><b>' . t('Comentarios Anteriores') . ':</b><br>' . $comentario->comentario . '</div>'; |
---|
| 804 | } |
---|
| 805 | else { |
---|
| 806 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;">' . $comentario->comentario . '</div>'; |
---|
| 807 | } |
---|
| 808 | } |
---|
| 809 | } |
---|
| 810 | } |
---|
| 811 | elseif(!$form['#node']->nid){ |
---|
| 812 | if (!array_key_exists($field, $nuevos)){ |
---|
| 813 | $nuevos[$field] = $field; |
---|
| 814 | $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>'; |
---|
| 815 | } |
---|
| 816 | else { |
---|
| 817 | if (!array_key_exists($field, $nuevos1)){ |
---|
| 818 | $nuevos1[$field] = $field; |
---|
| 819 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;"><b>' . t('Comentarios Anteriores') . ':</b><br>' . $comentario->comentario . '</div>'; |
---|
| 820 | } |
---|
| 821 | else { |
---|
| 822 | $comentarios_details[] = '<div style="border: 1px solid #BBBBBB;font-size:10px;background:#FFFFFF;line-height: 12px;">' . $comentario->comentario . '</div>'; |
---|
| 823 | } |
---|
| 824 | } |
---|
| 825 | } |
---|
| 826 | } |
---|
| 827 | } |
---|
| 828 | if(count($comentarios_details)){ |
---|
| 829 | if (!isset($form['#pre_render'])) { |
---|
| 830 | $form['#pre_render'] = array(); |
---|
| 831 | } |
---|
| 832 | $form['#entes_detail_workflow_comment'] = $campos_comentarios; |
---|
| 833 | $form['#pre_render'][] = 'entes_detail_workflow_commment_field_pre_render'; |
---|
| 834 | $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>' . t('Observaciones') . ':</b></div><div id="contenido-observaciones" style="overflow-y:scroll;max-height:300px;">' . implode('', $comentarios_details) . '</div></div>'; |
---|
| 835 | } |
---|
| 836 | } |
---|
| 837 | if ($form_id == 'workflow_tab_form') { |
---|
| 838 | if ($form['node']['#value']->type == 'proyectos_operativos'){ |
---|
| 839 | $node = $form['node']['#value']; |
---|
| 840 | $campos_leidos = _entes_detail_proyectos_operativos_get_campos_proyectos(); |
---|
| 841 | $options_campos = array(); |
---|
| 842 | $node_type = content_types('proyectos_operativos'); |
---|
| 843 | $fields = $node_type['fields']; |
---|
| 844 | $node_type1 = content_types('accion_especifica'); |
---|
| 845 | $fields1 = $node_type1['fields']; |
---|
| 846 | $node_workflow_display = node_build_content($node); |
---|
[221dd7a] | 847 | $result = db_query("SELECT e.*, u.name, u.uid, w.old_sid, w.comment FROM {entes_detail_workflow} AS e INNER JOIN {workflow_node_history} AS w ON w.hid = e.hid INNER JOIN {users} AS u ON w.uid =u.uid WHERE id = %d AND tipo = 'proyectos_operativos' AND active = 1 ORDER BY field_name, time DESC", $node->nid); |
---|
| 848 | $comentarios =array(); |
---|
| 849 | while($comentario = db_fetch_object($result)) { |
---|
| 850 | if (!isset($comentarios[$comentario->field_name])) { |
---|
| 851 | $comentarios[$comentario->field_name] = array(); |
---|
| 852 | } |
---|
| 853 | if (trim($comentario->comentario) != '') { |
---|
| 854 | $comentarios[$comentario->field_name][] = '<div class="comentario-ver"><div class="comentario-contenido">' . check_plain($comentario->comentario) . '</div><div class="comentario-usuario-fecha">' . theme('username', $comentario) . ' | ' . format_date($comentario->time) . '</div></div>'; |
---|
| 855 | } |
---|
| 856 | } |
---|
[a0b4327] | 857 | $contenido = array(); |
---|
| 858 | $array_titles = array(); |
---|
| 859 | $todas_opciones = array(); |
---|
[221dd7a] | 860 | $form['proyectos_operativos_remove'] = array( |
---|
| 861 | '#type' => 'checkbox', |
---|
| 862 | '#title' => t('Borrar los comentarios de campos Previos.'), |
---|
| 863 | '#default_value' => FALSE, |
---|
| 864 | '#access' => user_access('remove observaciones'), |
---|
| 865 | ); |
---|
[a0b4327] | 866 | foreach($campos_leidos['campos'] as $idcat => $array){ |
---|
| 867 | foreach($array as $idcamp => $arrat1){ |
---|
[221dd7a] | 868 | $form[$idcamp] = array( |
---|
| 869 | '#type' => 'fieldset', |
---|
| 870 | '#title' => $campos_leidos['categorias'][$idcat][$idcamp]['title'], |
---|
| 871 | ); |
---|
[a0b4327] | 872 | $array_soptions = array(); |
---|
| 873 | foreach($arrat1 as $ind2 => $array2){ |
---|
| 874 | if ($ind2 == 'title'){ |
---|
[221dd7a] | 875 | $contenido[$ind2] = '<div class="field field-type-title field-field-proyecto-title"><div class="field-label">' . t('Nombre del Proyecto') . ': </div><div class="field-items"><div class="field-item odd">' . check_plain($node->title) . '</div></div></div>'; |
---|
[a0b4327] | 876 | $array_soptions[$ind2] = t('Nombre del Proyecto'); |
---|
| 877 | } |
---|
| 878 | else { |
---|
[221dd7a] | 879 | $contenido[$ind2] = drupal_render($node_workflow_display->content[$ind2]); |
---|
[a0b4327] | 880 | $array_soptions[$ind2] = $fields[$ind2]['widget']['label']; |
---|
| 881 | } |
---|
| 882 | $array_titles[$ind2] = $array_soptions[$ind2]; |
---|
| 883 | $todas_opciones[$ind2] = $ind2; |
---|
[221dd7a] | 884 | if ($fields[$ind2]['display_settings']['full']['format'] != 'hidden' && trim($contenido[$ind2]) != '') { |
---|
| 885 | $ncomentario = isset($comentarios[$ind2]) && count($comentarios[$ind2])? '<div class="todos-comentarios"><b>' . t('Comentarios Previos') . ':</b>' . implode ('', $comentarios[$ind2]) . '</div>' : ''; |
---|
| 886 | $form[$idcamp][$ind2 . '_display']['#value'] = $contenido[$ind2] . $ncomentario; |
---|
| 887 | $form[$idcamp][$ind2][$ind2] = array( |
---|
| 888 | '#type' => 'checkbox', |
---|
| 889 | '#title' => t('Agregar comentario al campos (@campo9).', array('@campo9' => $array_soptions[$ind2])), |
---|
| 890 | '#default_value' => FALSE, |
---|
| 891 | '#suffix' => '<div id ="' . $ind2 . '_comentario"></div>', |
---|
| 892 | '#ahah' => array( |
---|
| 893 | 'path' => 'entes_detail_workflow_js_util/proyectos/' . $idcamp . '/' . $ind2, |
---|
| 894 | 'wrapper' => $ind2 . '_comentario', |
---|
| 895 | 'method' => 'replace', |
---|
| 896 | 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), |
---|
| 897 | ), |
---|
| 898 | ); |
---|
| 899 | } |
---|
[a0b4327] | 900 | } |
---|
[221dd7a] | 901 | |
---|
[a0b4327] | 902 | if ($campos_leidos['categorias'][$idcat][$idcamp]['type'] == 'node'){ |
---|
| 903 | $options_campos[$campos_leidos['categorias'][$idcat][$idcamp]['title']] = $array_soptions; |
---|
[221dd7a] | 904 | } |
---|
[a0b4327] | 905 | } |
---|
| 906 | } |
---|
| 907 | //add weight to submit button |
---|
| 908 | $form['submit']['#weight'] = 100; |
---|
| 909 | $form['#node_workflow_display'] = $contenido; |
---|
| 910 | //Se obtienen las acciones especificas del proyecto |
---|
| 911 | $i = 1; |
---|
| 912 | $contenidoae = array(); |
---|
| 913 | $acciones_especificas = array(); |
---|
| 914 | if (isset($node->field_proyecto_accion_esp)){ |
---|
| 915 | foreach($node->field_proyecto_accion_esp as $accion) { |
---|
| 916 | if ($accion['nid']) { |
---|
| 917 | $accionep = node_load($accion['nid']); |
---|
[221dd7a] | 918 | $form['AE_' . $accionep->nid] = array( |
---|
| 919 | '#type' => 'fieldset', |
---|
| 920 | '#title' => 'AE: ' . check_plain($accionep->title), |
---|
| 921 | ); |
---|
[a0b4327] | 922 | $opcionAE = array(); |
---|
| 923 | $contenidoae[$accionep->nid] = array(); |
---|
| 924 | $nodeae_workflow_display = node_build_content($accionep); |
---|
| 925 | foreach($fields1 as $idcat => $array){ |
---|
| 926 | $contenidoae[$accionep->nid][$idcat] = drupal_render($nodeae_workflow_display->content[$idcat]); |
---|
| 927 | $opcionAE[$accionep->nid . '_' . $idcat] = $fields1[$idcat]['widget']['label']; |
---|
| 928 | $array_titles[$accionep->nid . '_' . $idcat] = 'AE_' .$i . ': ' . $opcionAE[$accionep->nid . '_' . $idcat]; |
---|
| 929 | $todas_opciones[$accionep->nid . '_' . $idcat] = $accionep->nid . '_' . $idcat; |
---|
[221dd7a] | 930 | if ($fields1[$idcat]['display_settings']['full']['format'] != 'hidden' && trim($contenidoae[$accionep->nid][$idcat]) != '') { |
---|
| 931 | $idcat1 = $accion['nid'] . '_' . $idcat; |
---|
| 932 | $ncomentario = isset($comentarios[$idcat1]) && count($comentarios[$idcat1])? '<div class="todos-comentarios"><b>' . t('Comentarios Previos') . ':</b>' . implode ('', $comentarios[$idcat1]) . '</div>' : ''; |
---|
| 933 | $form['AE_' . $accionep->nid][$accionep->nid . '_' . $idcat . '_display']['#value'] = $contenidoae[$accionep->nid][$idcat] . $ncomentario; |
---|
| 934 | $form['AE_' . $accionep->nid][$accionep->nid . '_' . $idcat][$accionep->nid . '_' . $idcat] = array( |
---|
| 935 | '#type' => 'checkbox', |
---|
| 936 | '#title' => t('Agregar comentario al campo (@campo9).', array('@campo9' => $array_titles[$accionep->nid . '_' . $idcat])), |
---|
| 937 | '#default_value' => FALSE, |
---|
| 938 | '#suffix' => '<div id ="' . $accionep->nid . '_' . $idcat . '_comentario"></div>', |
---|
| 939 | '#ahah' => array( |
---|
| 940 | 'path' => 'entes_detail_workflow_js_util/proyectos/' . 'AE_' . $accionep->nid . '/' . $accionep->nid . '_' . $idcat, |
---|
| 941 | 'wrapper' => $accionep->nid . '_' . $idcat . '_comentario', |
---|
| 942 | 'method' => 'replace', |
---|
| 943 | 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), |
---|
| 944 | ), |
---|
| 945 | ); |
---|
| 946 | } |
---|
[a0b4327] | 947 | } |
---|
| 948 | $options_campos['AE_' .$i] = $opcionAE; |
---|
| 949 | $i++; |
---|
| 950 | } |
---|
| 951 | } |
---|
| 952 | } |
---|
| 953 | $form['#nodeae_workflow_display'] = $contenidoae; |
---|
| 954 | $form['#node_workflow_titles'] = $array_titles; |
---|
| 955 | $form['#node_workflow_todas_opciones'] = $todas_opciones; |
---|
| 956 | //remove previous submit |
---|
| 957 | $new_submit = array(); |
---|
| 958 | foreach($form['#submit'] as $submit) { |
---|
| 959 | if ($submit == 'workflow_tab_form_submit'){ |
---|
| 960 | $new_submit[] = 'entes_detail_workflow_form_submit'; |
---|
| 961 | } |
---|
| 962 | } |
---|
| 963 | $form['#submit'] = $new_submit; |
---|
| 964 | } |
---|
| 965 | } |
---|
| 966 | if ($form_id == 'proyectos_reformulacion_reformula_wk_tab_page_form'){ |
---|
| 967 | $proyecto = $form['#node']; |
---|
| 968 | $options_campos = _entes_detail_proyectos_operativos_get_campos_proyectos_reformula($proyecto); |
---|
| 969 | $display = reformula_ver_campos($form['#node'], $form['#reformulacion']); |
---|
| 970 | $nodeae_workflow_display = array(); |
---|
| 971 | if (count($options_campos['campos'])) { |
---|
| 972 | $todas_opciones = array(); |
---|
| 973 | $array_titles = $options_campos['categorias']; |
---|
| 974 | foreach($options_campos['campos'] as $idcat => $array){ |
---|
| 975 | $array_soptions[$array_titles[$idcat]['title']] = $array ; |
---|
| 976 | foreach($array as $idcamp => $arrat1){ |
---|
| 977 | $array_titles[$idcamp] = $arrat1; |
---|
| 978 | $todas_opciones[$idcamp] = $arrat1; |
---|
| 979 | } |
---|
| 980 | } |
---|
| 981 | foreach($display as $id_d => $disp){ |
---|
| 982 | if (is_numeric($id_d)){ |
---|
| 983 | $nodeae_workflow_display[$id_d] = $display[$id_d]; |
---|
| 984 | } |
---|
| 985 | } |
---|
| 986 | $form['#node_workflow_display'] = $display; |
---|
| 987 | $form['#nodeae_workflow_display'] = $nodeae_workflow_display; |
---|
| 988 | $form['#node_workflow_titles'] = $array_titles; |
---|
| 989 | $form['#node_workflow_todas_opciones'] = $todas_opciones; |
---|
| 990 | $form['proyectos_operativos_remove'] = array( |
---|
| 991 | '#type' => 'checkbox', |
---|
| 992 | '#title' => t('Borrar los comentarios de campos Previos.'), |
---|
| 993 | '#default_value' => FALSE, |
---|
| 994 | '#access' => user_access('remove observaciones'), |
---|
| 995 | ); |
---|
| 996 | $form['workflow_details'] = array( |
---|
| 997 | '#title' => t('Comentarios por Campos'), |
---|
| 998 | '#type' => 'select', |
---|
| 999 | '#default_value' => array(), |
---|
| 1000 | '#options' => $array_soptions, |
---|
| 1001 | '#multiple' => TRUE, |
---|
| 1002 | '#weight' => 10, |
---|
| 1003 | '#ahah' => array( |
---|
| 1004 | 'path' => 'entes_detail_workflow_js_util', |
---|
| 1005 | 'wrapper' => 'fields_problems', |
---|
| 1006 | 'method' => 'replace', |
---|
| 1007 | 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), |
---|
| 1008 | ), |
---|
| 1009 | ); |
---|
| 1010 | $form['campos_modificar'] = array( |
---|
| 1011 | '#type' => 'fieldset', |
---|
| 1012 | '#prefix' => '<div id="fields_problems">', |
---|
| 1013 | '#suffix' => '</div>', |
---|
| 1014 | '#weight' => 11, |
---|
| 1015 | '#title' => t('Observaciones por campos'), |
---|
| 1016 | ); |
---|
| 1017 | $form['campos_modificar']['no_comentarios'] = array( |
---|
| 1018 | '#value' => t('No exiten comentarios de los campos de la modificación'), |
---|
| 1019 | ); |
---|
| 1020 | $form['#submit'][] = 'entes_detail_workflow_reformula_form_submit'; |
---|
| 1021 | $form['actions']['#weight'] = 100; |
---|
| 1022 | |
---|
| 1023 | } |
---|
| 1024 | } |
---|
| 1025 | } |
---|
| 1026 | |
---|
| 1027 | /* |
---|
| 1028 | * Implementation of proyectos_operativos_nodereference2_field_pre_render() |
---|
| 1029 | * Limitar al formulario a los entes que le es posible a los usuarios |
---|
| 1030 | */ |
---|
| 1031 | function entes_detail_workflow_commment_field_pre_render($form) { |
---|
| 1032 | $campos_comentarios = $form['#entes_detail_workflow_comment']; |
---|
| 1033 | foreach($campos_comentarios as $campo => $comentario) { |
---|
| 1034 | if (isset($form[$campo])) { |
---|
| 1035 | if (!isset($form[$campo][0]['value']['#attributes']['class'])) { |
---|
| 1036 | $form[$campo][0]['value']['#attributes']['class'] = ''; |
---|
| 1037 | } |
---|
| 1038 | $form[$campo][0]['value']['#attributes']['class'] .= ' campos_comentarios beautytips'; |
---|
| 1039 | $form[$campo][0]['value']['#attributes']['title'] = $comentario; |
---|
| 1040 | } |
---|
| 1041 | } |
---|
| 1042 | return $form; |
---|
| 1043 | } |
---|
| 1044 | |
---|
| 1045 | /* |
---|
| 1046 | * Implementation of proyectos_reformulacion_reformula_tab_page_ae_form_validate() |
---|
| 1047 | */ |
---|
| 1048 | function entes_detail_workflow_form_submit($form, &$form_state) { |
---|
| 1049 | global $user; |
---|
| 1050 | // The entire node object was stashed in the form. |
---|
| 1051 | $node = $form_state['values']['node']; |
---|
| 1052 | $node->workflow = $form_state['values']['workflow']; |
---|
| 1053 | $node->workflow_comment = $form_state['values']['workflow_comment']; |
---|
| 1054 | $node->workflow_scheduled = $form_state['values']['workflow_scheduled']; |
---|
| 1055 | $node->workflow_scheduled_date = $form_state['values']['workflow_scheduled_date']; |
---|
| 1056 | $node->workflow_scheduled_hour = $form_state['values']['workflow_scheduled_hour']; |
---|
| 1057 | //crear una nueva revision |
---|
| 1058 | $node->revision = 1; |
---|
| 1059 | // Call node_save() to make sure any handlers that use the |
---|
| 1060 | // new workflow values will see them. |
---|
| 1061 | node_save($node); |
---|
| 1062 | //add node save values |
---|
| 1063 | $form_state['values']['node'] = $node; |
---|
| 1064 | $form_state['redirect'] = 'node/' . $node->nid; |
---|
| 1065 | $sid = $node->workflow; |
---|
| 1066 | if (array_key_exists('proyectos_operativos_remove', $form_state['values']) && $form_state['values']['proyectos_operativos_remove']){ |
---|
| 1067 | db_query("UPDATE {entes_detail_workflow} set active = 0 WHERE id = %d AND tipo = 'proyectos_operativos'", $node->nid); |
---|
| 1068 | } |
---|
| 1069 | //SE OBTIENE el hid del historico del workflow |
---|
| 1070 | $res = db_query("select max(hid) as hid from workflow_node_history WHERE nid = %d AND sid = %d", $node->nid, $sid); |
---|
| 1071 | $hid = db_fetch_object($res); |
---|
| 1072 | $chid = ($hid && $hid->hid) ? $hid->hid : 0; |
---|
| 1073 | |
---|
| 1074 | $time = time(); |
---|
| 1075 | foreach($form['#node_workflow_todas_opciones'] as $id => $title){ |
---|
| 1076 | if (array_key_exists('comentario_' . $id, $form_state['values'])){ |
---|
| 1077 | 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); |
---|
| 1078 | } |
---|
| 1079 | } |
---|
| 1080 | } |
---|
| 1081 | |
---|
| 1082 | /* |
---|
| 1083 | * Implementation of proyectos_reformulacion_reformula_tab_page_ae_form_validate() |
---|
| 1084 | */ |
---|
| 1085 | function entes_detail_workflow_reformula_form_submit($form, &$form_state) { |
---|
| 1086 | global $user; |
---|
| 1087 | if (array_key_exists('proyectos_operativos_remove', $form_state['values']) && $form_state['values']['proyectos_operativos_remove']){ |
---|
| 1088 | db_query("UPDATE {entes_detail_workflow} set active = 0 WHERE id = %d AND tipo = 'proyectos_reformula'", $node->nid); |
---|
| 1089 | } |
---|
| 1090 | $time = time(); |
---|
| 1091 | foreach($form['#node_workflow_todas_opciones'] as $id => $title){ |
---|
| 1092 | if (array_key_exists('comentario_' . $id, $form_state['values'])){ |
---|
| 1093 | db_query("INSERT INTO {entes_detail_workflow} (id, sid, tipo, field_name, comentario, hid, vid, active, time) VALUES (%d, %d, 'proyectos_reformula', '%s', '%s', %d, %d, 1, %d)", $form['#reformulacion']->id_ref, $form['#nuevo_estado'], $id, check_plain(trim($form_state['values']['comentario_' . $id])), 0, 0, $time); |
---|
| 1094 | } |
---|
| 1095 | } |
---|
| 1096 | } |
---|