<%@page import="java.util.*,javax.sql.*,java.sql.*,javax.naming.*,m05bClasses.*"%>
<%@include file="/mantenimientosJSP/includes/m05b.inc"%>

<%
	boolean noEncontrado = false;

	String idAsignacion = request.getParameter("IdAsignacion")==null?"":request.getParameter("IdAsignacion").toUpperCase();
	if (idAsignacion == null) {
		idAsignacion = "";
	}

	String dni = request.getParameter("Dni")==null?"":request.getParameter("Dni").toUpperCase();
	if (dni == null) {
		dni = "";
	}

	String miCodigo, fechaSolicitud, nombre_apellidos, codDepto, descDepto, fechaIni, fechaFin, motivoSolicitud, estadoSolicitudReserva;
%>
<%	// _______________________________XLNETs______________________________________
	// Evaluar variable de session que indica si esta conectado a XLNets
	if (session.getAttribute("objetoSeguridad") == null) {
		// Verificar que no ha transcurrido el tiempo de sesion (web.xml) %>
		<%@ include file="/m05bControlAcceso.inc"%>
<%	}
	String persona = (String) session.getAttribute("persona");
	m05bComun comun = new m05bComun();
%>

	<%@ include file="/m05bIdioma.inc"%>

<HTML>

	<head>
		<title><%=resTit.getString("titDatosPersonales")%></title>
		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
		<link rel="stylesheet" href="<%=m05bConstantesPaginas.PATH_ESTILOS%>/m05bestilos.css" type="text/css">
	  	<script language="javascript1.2" src="<%=m05bConstantesPaginas.PATH_SCRIPTS%>/formateador.js"></script>
		<script language="javascript1.2" src="<%=m05bConstantesPaginas.PATH_SCRIPTS%>/m05Funciones.js"></script>
	</head>

	<BODY onkeydown="cancelaEnter();"
		  style="cursor: wait"
		  onload="document.body.style.cursor='default';"
		  onunload="document.body.style.cursor='wait';">
<%
	String sql="", sCodigo="";
	m05bFileLog miLog = new m05bFileLog();
    java.sql.Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
	ResultSet rs2 = null;
%>

<%
	try {
		sql = "SELECT DNI_NIE, APELLIDOS, "
			  + "NOMBRE, NOMBRE || ' ' || APELLIDOS AS NOMBRE_APELLIDOS, "
			  + "DOMICILIO, CODIGO_POSTAL, "
			  + "MUNICIPIO, PROVINCIA, RESIDENTE_EXTRANJERO, "
			  + "NVL(PAIS, 'ESPAŅA') AS PAIS, ULT_REL_EJGV "
			  + "FROM GIP_DIRECCION_NOMINA "
			  + "WHERE DNI_NIE like '" + dni + "%'";

		miLog.addTraza(persona, "m05bVisorDatosPersonalesGipJsp", "SQL1: " + sql, m05bConstantes.LOG_NIVEL_BAJO);
		m05bConexion miConex = new m05bConexion();
		conn = miConex.getConnection();
		pstmt = conn.prepareStatement(sql);
		rs = pstmt.executeQuery();


		sql = "SELECT TELEF_21 FROM M0521T00 WHERE DNI_21 = '" + dni + "'";

		miLog.addTraza(persona, "m05bVisorDatosPersonalesGipJsp", "SQL2: " + sql, m05bConstantes.LOG_NIVEL_BAJO);
		pstmt = conn.prepareStatement(sql);
		rs2 = pstmt.executeQuery();
%>

<p>
	<TABLE width="100%">
		<tr>
			<td width="70%" valign="top" class="searchTitle"></td>
		</tr>
		<tr align="right">
			<td align="right">
				<input style="margin-left: 20px;" type="button" class="boton" name="<%= res.getString("etBOT_CERRAR")%>" value="<%= res.getString("etBOT_CERRAR")%>" ONCLICK="JavaScript:self.close();" onMouseOver="top.status='<%= res.getString("etBOT_STATUSCERRAR")%>'; return false" onMouseOut="top.status=''; return false" />
      		</td>
		</tr>
	</TABLE>

	<%if (rs.next()) { %>

	<TABLE class="general" style="width: auto" align="left">

		<tr>
			<td colspan="6" width="70%" valign="top" class="searchTitle"><%= res.getString("etDatosPersona")%></td>
		</tr>

		<tr>
			<td width="15%" class="inputFieldTitle"><%= res.getString("etDNI")%></td>
		    <td align="left" colspan="5"><INPUT class="inputFieldOblig" TYPE="TEXT" NAME="DNI" readonly="readonly" VALUE="<%=comun.mostrarTexto(rs.getString("DNI_NIE"))%>" size="10"/></td>
		</tr>
		<tr>
			<td width="15%" class="inputFieldTitle"><%= res.getString("etNombreYApellidos")%></td>
		    <td align="left" colspan="5"><INPUT class="inputFieldOblig" TYPE="TEXT" NAME="NombreYApellidos" readonly="readonly" VALUE="<%=comun.mostrarTexto(rs.getString("NOMBRE_APELLIDOS"))%>" size="60"/></td>
		</tr>
		<tr>
			<td width="15%" class="inputFieldTitle"><%= res.getString("etMunicipio")%></td>
			<td align="left" colspan="5"><INPUT class="inputFieldOblig" TYPE="TEXT" NAME="Municipio" readonly="readonly" VALUE="<%=comun.mostrarTexto(rs.getString("MUNICIPIO"))%>" size="60"/></td>
		</tr>
		<tr>
			<td width="15%" class="inputFieldTitle"><%= res.getString("etProvincia")%></td>
			<td align="left" colspan="5"><INPUT class="inputFieldOblig" TYPE="TEXT" NAME="Provincia" readonly="readonly" VALUE="<%=comun.mostrarTexto(rs.getString("PROVINCIA"))%>" size="60"/></td>
		</tr>
		<tr>
			<td width="15%" class="inputFieldTitle"><%= res.getString("etDomicilio")%></td>
		   	<td align="left">
		   		<textarea rows="3" cols="40" class="inputFieldOblig" NAME="Domicilio" readonly="readonly"><%=comun.mostrarTexto(rs.getString("DOMICILIO"))%></textarea>
			</td>
		</tr>
		<tr>
			<td width="15%" class="inputFieldTitle"><%= res.getString("etCodigoPostal")%></td>
			<td align="left" colspan="3"><INPUT class="inputFieldOblig" TYPE="TEXT" NAME="CodigoPostal" readonly="readonly" VALUE="<%=comun.mostrarTexto(rs.getString("CODIGO_POSTAL"))%>" size="10"/></td>
		</tr>
		<tr>
			<td width="15%" class="inputFieldTitle"><%= res.getString("etPais")%></td>
			<td align="left" colspan="3"><INPUT class="inputFieldOblig" TYPE="TEXT" NAME="Pais" readonly="readonly" VALUE="<%=comun.mostrarTexto(rs.getString("PAIS"))%>" size="40"/></td>
		</tr>
		<tr>
			<td width="15%" class="inputFieldTitle"><%= res.getString("etResidenteExtranjero")%></td>
			<td align="left" colspan="3">
				<%if (rs.getString("RESIDENTE_EXTRANJERO") != null
					  && rs.getString("RESIDENTE_EXTRANJERO").equals("1")) {%>
				<INPUT type="checkbox" disabled="disabled" checked="checked">
				<%} else {%>
				<INPUT type="checkbox" disabled="disabled">
				<%}%>
			</td>
		</tr>

		<tr>
		</tr>

		<%if (rs2.next()) {%>
		<tr>
			<td width="10%" class="inputFieldTitle"><%= res.getString("etTelefono")%></td>
			<td align="left"><INPUT class="inputFieldOblig" TYPE="TEXT" NAME="Telefono" readonly="readonly" VALUE="<%=comun.mostrarTexto(rs2.getString("TELEF_21"))%>" size="20"/></td>
			<%--
			<td width="10%" class="inputFieldTitle"><%= res.getString("etTelefonoMovil")%></td>
			<td align="left" colspan="5"><INPUT class="inputFieldOblig" TYPE="TEXT" NAME="TelefonoMovil" readonly="readonly" VALUE="<%=comun.mostrarTexto(rs2.getString("TELEF_21"))%>" size="20"/></td>
			--%>
		</tr>
		<%} else {%>
		<tr>
			<td width="10%" class="inputFieldTitle"><%= res.getString("etTelefono")%></td>
			<td align="left"><INPUT class="inputFieldOblig" TYPE="TEXT" NAME="Telefono" readonly="readonly" VALUE="" size="20"/></td>
			<%--
			<td width="10%" class="inputFieldTitle"><%= res.getString("etTelefonoMovil")%></td>
			<td align="left" colspan="5"><INPUT class="inputFieldOblig" TYPE="TEXT" NAME="TelefonoMovil" readonly="readonly" VALUE="" size="20"/></td>
			--%>
		</tr>
		<%}%>

	</TABLE>

	<%} else {
		noEncontrado = true;
	}%>

<%
	} catch (Exception SQLException) {
		miLog.addTraza(SQLException);
	} finally {
		if (rs != null)
			rs.close();
		if (rs2 != null)
			rs2.close();
		if (pstmt != null)
			pstmt.close();
		if (conn != null)
			conn.close();
	}
%>
</BODY>
</HTML>

<%if (noEncontrado) { %>
	<script>
		alert(dameAlerta(idioma, 280));
		self.close();
	</script>
<%}%>