%--
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);
%>
<%
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;
// Conexión a la base de datos
/*try {
if (!Config.getParametro("debug").equals("si")) {
debug = "no";
}
Conexion c = new Conexion();
lcnt_con = c.getConnection();
/*lst_stm = lcnt_con.createStatement();
lst_stm2 = lcnt_con.createStatement();
lst_stm3 = lcnt_con.createStatement();
lst_stm4 = 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;
}*/
/********* 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();
lb_connection = true;
}catch (Exception e) {
emergent_error = "Error al conectarse a la base de datos 2 ";
}
/********* 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();
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 {
ls_query = "SELECT "
+ " COUNT(DISTINCT a.id_funcionario) as total_funcionarios "
+ "FROM altabaja a "
+ "LEFT JOIN historial h USING(id_historial) "
+ "WHERE a.id_funcionario=" + lrs_res.getString("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";
}
%>
<%
ls_query = "SELECT"
+ " a.id_altabaja, "
+ " a.fecha_alta, "
+ " a.fecha_baja, "
+ " a.clave, "
+ " IFNULL (a.status, 0) as status, "
+ " h.dependencia, "
+ " h.puesto, "
+ " h.archivofisico "
+ "FROM altabaja a "
+ "LEFT JOIN historial h on h.id_historial=a.id_historial "
+ "WHERE a.id_funcionario=" + lrs_res.getString("id_funcionario")+";";
if (Integer.parseInt(lower_limit) >= 0) {
ls_query += " LIMIT " + lower_limit + ", " + upper_limit + " ";
}
lrs_res2 = lst_stm2.executeQuery(ls_query);
%>
<%
while (lrs_res2.next()) {
%>
Datos Generales del Puesto del Funcionario <%=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:
<%=lrs_res2.getString("fecha_baja")%>
Status:
<%if (lrs_res2.getString("status").equals("0")) {%> Baja <% } else {%>Alta<% }%>
<%
ls_query = "SELECT"
+ " de.id_altabaja, "
+ " IFNULL (de.id_tipodeclaracion, 1) as id_tipodeclaracion, "
+ " de.fecha_declaracion, "
+ " de.id_declaracion "
+ "FROM declaraciones de "
+ "WHERE de.id_altabaja=" + lrs_res2.getString("id_altabaja")
+ " order by de.fecha_declaracion DESC"+";";
lrs_res3 = lst_stm3.executeQuery(ls_query);
%>
<%
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")%>
<%
}
%>
<% } %>
<%
} 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();
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ó formulario del historico de los funcionarios -" + request.getParameter("id_equipo_computos") + "-;";
Config.GuardarLog(Integer.parseInt(session.getAttribute("id_user").toString()), mensaje_log, 3);
} catch (Exception e) {
}
%>