<%-- Document : frm_modificar_declarantes Created on : 28/09/2012, 03:53:36 PM Author : Martha --%> <%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@page import = "conexion.*" import = "java.sql.*" import = "general.Config" import = "general.Permisos" import = "java.util.Date" import = "java.text.SimpleDateFormat" %> Actualizando el sistema... <% /*********************************** Permite modificar los datos de un usuario existente ***********************************************/ /********************************************creado por: Ing Martha Garcia*******************************************************/ out.println(""); String nompag[] = request.getRequestURI().split("/"); Date hoy = new Date(); SimpleDateFormat formato = new SimpleDateFormat("yyyy-MM-dd"); //String fecha_hoy = formato.format(hoy); java.sql.Date fecha_hoy = new java.sql.Date(hoy.getTime()); String fecha = formato.format(fecha_hoy); String fecha_baja = ""; %> <% //Connection lcnt_con = null; ResultSet lrs_res = null; Statement lst_stm = null; ResultSet lrs_res2 = null; Statement lst_stm2 = null; ResultSet lrs_res3 = null; Statement lst_stm3 = null; ResultSet lrs_res4 = null; Statement lst_stm4 = null; /*Segunda Conexión*/ ConexionDeclaranet cd = null; Connection lcd_connection = null; //Statement lstg_conecta=null; /*FIN. SEGUNDA CONEXIÓN*/ String ls_query = new String(""); String emergent_error = new String(""); boolean lb_connection = false; String debug = new String("si"); String lower_limit = new String("0"); String upper_limit = new String("1"); String total_funcionarios = new String("0"); //Integer x=1, y=1; /********* INICIO. Conexión a la base de datos ********/ try { if (!Config.getParametro("debug").equals("si")) { debug = "no"; } cd = new ConexionDeclaranet(); lcd_connection = cd.getConnection(); lst_stm = lcd_connection.createStatement(); lst_stm2 = lcd_connection.createStatement(); lst_stm3 = lcd_connection.createStatement(); lst_stm4= lcd_connection.createStatement(); session.setAttribute("id_funcionario", request.getParameter("id_funcionario")); 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; } /********* FIN. Conexión a la base de datos ********/ //********* 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_stm2.close(); lst_stm.close(); lst_stm3.close(); lst_stm4.close(); lcd_connection.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 { ls_query = "SELECT " + " COUNT(DISTINCT h.id_historial) as total_funcionarios " + "FROM historial h " + "LEFT JOIN altabaja a USING(id_historial) " + "WHERE a.clave<>'C' and h.id_funcionario=" + request.getParameter("id_funcionario")+" " + " "; lrs_res = lst_stm.executeQuery(ls_query); if (lrs_res.next()) { total_funcionarios = lrs_res.getString("total_funcionarios"); //out.println("Total "+total_funcionarios); } else { total_funcionarios = "0"; } // para la paginacion try { lower_limit = request.getParameter("lower").toString(); upper_limit = String.valueOf(Integer.valueOf(request.getParameter("lower").toString()) + 1); upper_limit = "1"; } catch (Exception e) { lower_limit = "0"; upper_limit = "1"; } if(Integer.parseInt(total_funcionarios)>0){ %>
Paginación
<% } ls_query = "SELECT " + " CONCAT(f.ap_paterno, ' ', f.ap_materno, ' ', f.nombre) as nombre, " + " a.id_altabaja, " + " a.fecha_alta, " + " IFNULL(IF(a.fecha_baja='0000-00-00 00:00:00', NULL, a.fecha_baja), NOW()) as fecha_baja, " + " a.clave, " + " IFNULL (a.status, 0) as status, " + " h.dependencia, " + " h.puesto, " + " h.archivofisico " + "FROM historial h " + "LEFT JOIN altabaja a USING(id_historial) " + "LEFT JOIN funcionarios f ON f.id_funcionario=a.id_funcionario " + "WHERE h.id_funcionario=" + request.getParameter("id_funcionario")+" and a.clave<>'C' "; if (Integer.parseInt(lower_limit) >= 0) { ls_query += " LIMIT " + lower_limit + ", " + upper_limit + " ; "; } lrs_res2 = lst_stm2.executeQuery(ls_query); // out.println(ls_query); %> <% if (lrs_res2.next()) { do{ if(lrs_res2.getString("status").equals("1") && (formato.format(lrs_res2.getDate("fecha_baja")).equals(fecha))) { fecha_baja= ""; }else{ fecha_baja= formato.format(lrs_res2.getDate("fecha_baja")); } %> <% ls_query = "SELECT" + " de.id_altabaja, " + " IFNULL (de.id_tipodeclaracion, 1) as id_tipodeclaracion, " + " de.fecha_declaracion, " + " de.id_declaracion " + "FROM declaration de " + "WHERE de.id_altabaja=" + lrs_res2.getString("id_altabaja") + " order by de.fecha_declaracion DESC"+";"; lrs_res3 = lst_stm3.executeQuery(ls_query); %>
Datos Generales del Puesto del Funcionario <%=lrs_res2.getString("nombre") %>
CLAVE: <%=lrs_res2.getString("clave")%>
 Dependencia: <%=lrs_res2.getString("dependencia")%>
 Puesto del Funcionario: <%=lrs_res2.getString("puesto")%>
 Archivo Físico: <%=lrs_res2.getString("archivofisico")%>
 Fecha de Alta: <%=lrs_res2.getString("fecha_alta")%>
 Fecha de Baja: <%=fecha_baja%>
  Status: <%if (lrs_res2.getString("status").equals("0")) {%> Baja <% } else {%>Alta<% }%>
<% while (lrs_res3.next()) { %> <% } %>
 Tipo de Declaración: <% ls_query = "SELECT id_tipodeclaracion, descripcion FROM tipodeclaracion where id_tipodeclaracion="+lrs_res3.getString("id_tipodeclaracion"); lrs_res4 = lst_stm4.executeQuery(ls_query); if (lrs_res4.next()) { do { %> <%=lrs_res4.getString("descripcion")%> <% } while (lrs_res4.next()); } else { %> -- No hay tipo de Declaraciones Disponibles -- <% } %>  Fecha de Declaración: <%=lrs_res3.getString("fecha_declaracion")%>
<% }while(lrs_res2.next()); } else{ ls_query = "SELECT " + " CONCAT(f.ap_paterno, ' ', f.ap_materno, ' ', f.nombre) as nombre " + "FROM funcionarios f " + "WHERE f.id_funcionario=" + request.getParameter("id_funcionario")+" "; lrs_res2 = lst_stm2.executeQuery(ls_query); if(lrs_res2.next()){ %>
El funcionario no tiene Historial <%=lrs_res2.getString("nombre") %>
<% } }%>
    
<% } catch (Exception e) { emergent_error = "Error al recuperar datos del historico "; if (debug.equals("si")) { emergent_error += e + " Query actual: " + ls_query; } %>
<%=emergent_error%>
<% } finally { lst_stm4.close(); lst_stm3.close(); lst_stm2.close(); lst_stm.close(); lcd_connection.close(); } } else { %>
<%=emergent_error%>
<% } //Registrar en la bitácora try { String mensaje_log = new String(""); mensaje_log = "Usuario -" + session.getAttribute("username").toString() + "- desplegó lista de declaraciones del funcionario -" + request.getParameter("id_funcionario") + "-;"; Config.GuardarLog(Integer.parseInt(session.getAttribute("id_user").toString()), mensaje_log, 3); } catch (Exception e) { } %>