<%-- Document : desp_historico_equipo_computo Created on : 18/11/2011, 11:33:35 AM Author : psoto --%> <%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@page import = "conexion.*" import = "java.sql.*" import = "extras.NombresFormalesEC" import = "general.Config" import = "general.Permisos" import = "own.codec.*" import = "java.util.Date" import = "java.text.SimpleDateFormat" import = "java.text.NumberFormat" import = "java.util.Hashtable" import = "java.util.ArrayList" import = "extras.formatFecha" %> Bitácora del Equipo <% /****** Despliega la lista de cines del sistema filtrados por el texto de búsqueda de buscar_cines.jsp (no obligatorio)***********/ /********************************************creado por: L.I. Salvador Díaz Parra*******************************************************/ out.println(""); String nompag[] = request.getRequestURI().split("/"); /********************** tomo la fecha del sistema *************************/ SimpleDateFormat formato = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat formato2 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); //SimpleDateFormat formato = new SimpleDateFormat("DD-MM-yyyy"); %> <% /**************** variables locales *************************/ Hashtable cambios_encontrados = new Hashtable(); NombresFormalesEC nombre_campo = new NombresFormalesEC(); ArrayList todos_cambios = new ArrayList(); String relation_FieldNames[] = null; String FieldValues[] = null; ConexionEquipos c = null; Connection lcnt_con = null; ResultSet lrs_res = null; Statement lst_stm = null; String ls_query = new String(""); String emergent_error = new String(""); boolean lb_connection = false; String debug = new String("si"); int id_equipo_computo = 0; // Conexión a la base de datos try { if (!Config.getParametro("debug").equals("si")) { debug = "no"; } c = new ConexionEquipos(); lcnt_con = c.getConnection(); lst_stm = lcnt_con.createStatement(); lb_connection = true; } catch (Exception e) { emergent_error = "Error al conectarse a la base de datos "; if (debug.equals("si")) { emergent_error += e; } lb_connection = false; } //********* Validación fundamental para evitar ejecución de código sin privilegios suficientes **********// try { if (!Permisos.PermisoModulo(nompag[nompag.length - 1].toString(), Integer.parseInt(session.getAttribute("id_user").toString()))) { if (lb_connection) { lst_stm.close(); lcnt_con.close(); } emergent_error += " Privilegios insuficientes. "; lb_connection = false; } } catch (Exception e) { emergent_error += " Privilegios insuficientes. "; if (debug.equals("si")) { emergent_error += "Trace: " + e.toString(); } lb_connection = false; } //*******************************************************************************************************// if (lb_connection) { try { todos_cambios.clear(); id_equipo_computo = request.getParameter("id_equipo_computo") == null ? 0 : Integer.parseInt(request.getParameter("id_equipo_computo")); if (id_equipo_computo > 0) { %>
Bitácora del Equipo '<%=new codec().codec(request.getParameter("CI"), 0)%>'
pdf
Actualizaciónes en Datos del Equipos
<% lrs_res = lst_stm.executeQuery("DESC equipo_computo;"); if (lrs_res.next()) { lrs_res.last(); relation_FieldNames = new String[lrs_res.getRow()]; lrs_res.first(); int i = 0; do { relation_FieldNames[i++] = lrs_res.getString("Field"); } while (lrs_res.next()); } ls_query = "SELECT " + " id_equipo_computo_histocico , " + " fecha_snapshot , " + " IFNULL(id_equipo_computo,0) as id_equipo_computo , " + " IFNULL(id_usuarios_cargos,0) as id_usuarios_cargos , " + " IFNULL(id_monitor,0) as id_monitor , " + " IFNULL(id_situacion,0) as id_situacion , " + " IFNULL(CI,'') as CI , " + " IFNULL(no_serie,'') as no_serie , " + " IFNULL(mac,'') as mac , " + " IFNULL(ip,'') as ip , " + " IFNULL(id_cat_sistemas_operativos,'') as id_cat_sistemas_operativos , " + " IFNULL(fecha_adquisicion,'') as fecha_adquisicion , " + " IFNULL(fecha_garantia,'') as fecha_garantia , " + " IFNULL(fecha_baja,'') as fecha_baja, " + " IFNULL(teclado,'') as teclado , " + " IFNULL(mouse,'') as mouse , " + " IFNULL(descripcion,'') as descripcion , " + " IFNULL(id_cat_procesadores,'') as id_cat_procesadores , " + " IFNULL(ram,'') as ram , " + " IFNULL(hd,'') as hd , " + " IFNULL(marca,'') as marca , " + " IFNULL(modelo,'') as modelo , " + " IFNULL(id_cat_tipo_equipo,'') as id_cat_tipo_equipo , " + " IFNULL(id_cat_subtipo_equipo,'') as id_cat_subtipo_equipo , " + " IFNULL(pto_panel,0) as pto_panel , " + " IFNULL(pto_switch,0) as pto_switch , " + " IFNULL(tipo_telefono,'') as tipo_telefono , " + " IFNULL(did,'') as did , " + " IFNULL(extension,'') as extension , " + " IFNULL(tipo_propietario,'') as tipo_propietario , " + " IFNULL(ubicacion_fisica,'') as ubicacion_fisica , " + " IFNULL(status,0) as status " + "FROM equipo_computo_histocico " + "WHERE id_equipo_computo= " + id_equipo_computo + " "; lrs_res = lst_stm.executeQuery(ls_query); int total_campos_consulta = lrs_res.getMetaData().getColumnCount(); int total_registro_consulta = 0; FieldValues = new String[total_campos_consulta]; while (lrs_res.next()) { total_registro_consulta++; } if (total_registro_consulta > 1) { lrs_res.first(); if (lrs_res.next()) { for (int i = 0; i < total_campos_consulta; i++) { FieldValues[i] = lrs_res.getString(lrs_res.getMetaData().getColumnLabel(i + 1)); } lrs_res.first(); do { String nombre_formal = new String(""); String valor_formal_antes = new String(""); String valor_formal_nuevo = new String(""); for (int y = 1; y <= total_campos_consulta; y++) { for (int z = 0; z < relation_FieldNames.length; z++) { cambios_encontrados = new Hashtable(); if (lrs_res.getMetaData().getColumnLabel(y).equals(relation_FieldNames[z])) { if (!FieldValues[y - 1].toString().equals(lrs_res.getString(lrs_res.getMetaData().getColumnLabel(y)))) { //nombre_formal = (nombre_campo.getNombreFormal(lrs_res.getMetaData().getColumnLabel(y))); nombre_formal = (nombre_campo.getNombreFormal(lrs_res.getMetaData().getColumnLabel(y)).equals("") ? lrs_res.getMetaData().getColumnLabel(y) : nombre_campo.getNombreFormal(lrs_res.getMetaData().getColumnLabel(y))); valor_formal_antes = nombre_campo.getNombreFormalValor(lrs_res.getMetaData().getColumnLabel(y), FieldValues[y - 1].toString()); valor_formal_nuevo = nombre_campo.getNombreFormalValor(lrs_res.getMetaData().getColumnLabel(y), lrs_res.getString(lrs_res.getMetaData().getColumnLabel(y))); cambios_encontrados.put("dato", nombre_formal); cambios_encontrados.put("antes", (valor_formal_antes.equals("-1") ? FieldValues[y - 1].toString() : valor_formal_antes)); cambios_encontrados.put("cambio", (valor_formal_nuevo.equals("-1") ? lrs_res.getString(lrs_res.getMetaData().getColumnLabel(y)) : valor_formal_nuevo)); cambios_encontrados.put("fecha", lrs_res.getString("fecha_snapshot").substring(0, 19)); todos_cambios.add(cambios_encontrados); } } } FieldValues[y - 1] = lrs_res.getString(lrs_res.getMetaData().getColumnLabel(y)) == null ? "" : lrs_res.getString(lrs_res.getMetaData().getColumnLabel(y)); } } while (lrs_res.next()); if (todos_cambios.size() > 0) { %> <% for (int x = 0; x < todos_cambios.size(); x++) { %> <% } } %>
Dato Valor Anterior: Valor Nuevo: Fecha del Cambio
<%=((Hashtable) todos_cambios.get(x)).get("dato").toString()%> <%=((Hashtable) todos_cambios.get(x)).get("antes").toString()%> <%=((Hashtable) todos_cambios.get(x)).get("cambio").toString()%> <%=((Hashtable) todos_cambios.get(x)).get("fecha").toString()%>
<% } } else { %>
-- No hay cambios en el Equipo --

<% } %>
Tickets Relacionados al Equipo
<% ls_query = "SELECT " + " clave_ticket, " + " fecha_creacion, " + " nombre_categoria, " + " pr.nombre as propietario, " + " fecha_cierre, " + " cerrado, " + " IF(tipo_cerrado='ce','Cerrado con exito',IF(tipo_cerrado = 'se','Cerrado Sin exito','')) as tipo_cerrado, " + " tk.descripcion " + "FROM tickets tk " + "LEFT JOIN cat_categorias cc USING(id_cat_categorias) " + "LEFT JOIN cat_perfiles pr USING(id_cat_perfiles) " + "WHERE tk.status=true " + " AND id_equipo_computo=" + id_equipo_computo; lrs_res = lst_stm.executeQuery(ls_query); if (lrs_res.next()) { %> <% do { %> <% } while (lrs_res.next()); %>
Ticket Creación Tipo Ticket Propietario Cerrado Fecha Cierre Tipo Cierre Descripción
<%=lrs_res.getString("clave_ticket")%> <%=lrs_res.getString("fecha_creacion").substring(0, 19)%> <%=lrs_res.getString("nombre_categoria")%> <%=lrs_res.getString("propietario")%> <%=lrs_res.getBoolean("cerrado") ? "Si" : "No"%> <%=lrs_res.getBoolean("cerrado") ? lrs_res.getString("fecha_cierre").substring(0, 19) : ""%> <%=lrs_res.getString("tipo_cerrado")%> <%=formatFecha.quitarHTML(lrs_res.getString("descripcion"))%>
<% } else { emergent_error = "Al Equipo no se le ha levantado ningun Ticket. "; %>
<%=emergent_error%>
<% } %> <%%>
<%} else { emergent_error = "Error al recuperar datos del equipo , debido aque no Existe "; %>
<%=emergent_error%>
<% } } catch (Exception e) { emergent_error = "Error al recuperar lista de equipo del sistema "; if (debug.equals("si")) { emergent_error += e + " Query actual: " + ls_query; } %>
<%=emergent_error%>
<% } finally { lst_stm.close(); lcnt_con.close(); } %>
);">  
<% } else { %>
<%=emergent_error%>
<% } //Registrar en la bitácora try { String mensaje_log = new String(""); mensaje_log = "Usuario -" + session.getAttribute("username").toString() + "- desplegó el historico del Equipo -" + request.getParameter("id_equipo_computo") + "-;"; Config.GuardarLog(Integer.parseInt(session.getAttribute("id_user").toString()), mensaje_log, 3); } catch (Exception e) { } %>