<?php
session_start();
$mensaje = '';
//RESTRICCIÓN DE ACCESO A TRABAJADOR (ACCESO INDIVIDUAL)
if (isset($_SESSION['tipousuario'])) {
	if ($_SESSION['tipousuario'] == '1')
		header('location:menu_personal.php');
}

if (trim($_SESSION['nombre_validar']) == '') header('location:index.php');
require('fphp.php');
if (array_key_exists('imprime', $_POST) && $_POST['imprime'] == 1) {
	///////////////////////////////////////////////// imprimir registros ////////////////////////////////////////////////////////////////
	$enlace = cargar_conexion();
	$consulta = mysqli_query($enlace, "select * from empresa where id='" . $_SESSION['id_validar'] . "'");
	if (mysqli_num_rows($consulta) != 0) {
		$row = mysqli_fetch_array($consulta);
		$_POST['pie'] = $row['pie'];
		$_POST['encabeza'] = $row['encabeza'];
		$_POST['empresa'] = (substr(obtener_valor_diccionario($_POST, 'nomina'), 6, 100) == "" ? $_SESSION['empresa_validar'] : substr(obtener_valor_diccionario($_POST, 'nomina'), 6, 100));
	}

	require('fpdf.php');

	class PDF extends FPDF
	{
		function Header()
		{
			$usuario = '';
			$this->Image($_SESSION['logo_validar'], 10, 10, 20, 20);
			$this->SetFont('arial', '', 12);
			$this->Ln(2);
			$this->Cell(0, 0, $_POST['empresa'], 0, 1, 'R');
			$this->Ln(5);
			$this->Cell(0, 0, $_POST['encabeza'], 0, 1, 'R');
			$this->Ln(5);
			$this->SetFont('arial', '', 10);
			$this->Cell(140);
			$this->Cell(0, 0, 'Fecha: ' . hoy(), 0, 1, 'L');
			$this->Ln(5);
			$this->Cell(140);
			$this->Cell(0, 0, 'Usuario: ' . $usuario, 0, 1, 'L');
			$this->Ln(5);

			$this->Ln(10);
			$this->SetFont('arial', 'B', 8);
			$this->Cell(0, 0, 'Reporte General de Empleados', 0, 1, 'C');
			$this->Ln(5);
			$header = array('Item', 'Cédula', 'Nombres', 'Apellidos', 'Cargo', 'Status', 'F_ingreso');
			$this->SetFillColor(255, 0, 0);
			$this->SetTextColor(255);
			$this->SetDrawColor(128, 0, 0);
			$this->SetLineWidth(.3);
			$this->SetFont('', '');
			//Cabecera
			$w = array(15, 20, 30, 30, 50, 20, 20);
			for ($i = 0; $i < count($header); $i++)
				$this->Cell($w[$i], 5, $header[$i], 1, 0, 'C', 1);
			$this->Ln();
			//Restauración de colores y fuentes
			$this->SetFillColor(224, 235, 255);
			$this->SetTextColor(0);
			$this->SetFont('');
		}


		//Pie de página ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		function Footer()
		{
			$this->SetY(-15);
			$this->Cell(0, 0, '', 1, 1, 'C');
			$this->SetFont('Times', 'I', 8);
			$this->ln(2);
			$this->Cell(20);
			$this->Cell(0, 0, $_POST['pie'], 0, 1, 'C');
			$this->Cell(0, 10, 'Página ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
		}
	}
	//Cuerpo ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	$pdf = new PDF();
	$pdf->AddPage();
	$pdf->AliasNbPages();
	$pdf->SetFont('Arial', '', 6);
	$pdf->SetFillColor(224, 235, 255);
	$pdf->SetTextColor(0);
	$consulta = mysqli_query($enlace, "SELECT * from personal where status<>'I' and id='" . $_SESSION['id_validar'] . "'  order by codigo");
	$linea = 0;
	$color = 0;
	while ($row = mysqli_fetch_array($consulta)) {
		$linea++;
		$tcargo = $row['cargo'];
		$pdf->cell(15, 5, $linea, 0, 0, 'C', $color);
		$pdf->cell(20, 5, $row['codigo'], 0, 0, 'C', $color);
		$pdf->cell(30, 5, $row['nombres'], 0, 0, '', $color);
		$pdf->cell(28, 5, $row['apellidos'], 0, 0, '', $color);
		$cons1 = mysqli_query($enlace, "select tablas.detalle as car from tablas where codigo='" . $row['cargo'] . "' and tabla='CARGO' and id='" . $_SESSION['id_validar'] . "'");
		while ($row1 = mysqli_fetch_array($cons1))
			$pdf->cell(60, 5, $row1['car'], 0, 0, 'L', $color);
		$pdf->cell(15, 5, $row['status'], 0, 0, 'L', $color);
		$pdf->cell(20, 5, $row['fechai'], 0, 1, 'C', $color);
		$color = !$color;
	}
	$pdf->Output();
} else {
	/*	
$accion=$_REQUEST["accion"];
$codigo=$_REQUEST["codigo"];
$cedula=$_REQUEST["cedula"];
*/

	$accion = array_key_exists('accion', $_REQUEST) ? (int)$_REQUEST["accion"]  : "";
	$codigo = array_key_exists('codigo', $_REQUEST) ? $_REQUEST["codigo"] : "";
	$cedula = array_key_exists('cedula', $_REQUEST) ? $_REQUEST["cedula"] : "";

	$enlace = cargar_conexion();
	$consulta = mysqli_query($enlace, "select * from periodo where id='" . $_SESSION['id_validar'] . "' order by nomina,periodo desc limit 1");
	if (mysqli_num_rows($consulta) != 0) {
		$row = mysqli_fetch_array($consulta);
		$_SESSION['per_validar'] = mostrar_fecha($row['desde']) . ' al ' . mostrar_fecha($row['hasta']) . " (Nom:" . $row['nomina'] . ")";
	} else $_SESSION['per_validar'] = '';

	///////////////////////////////////////////////// inicio del programa ////////////////////////////////////////////////////////////////
	menu();
	$entra = 0;

	///////////////////////////////////////////////// bajar foto ////////////////////////////////////////////////////////////////
	if (array_key_exists('bandera', $_POST) && $_POST['bandera'] == 33) {
		$tamano = $_FILES["archivo"]['size'];
		$tipo = $_FILES["archivo"]['type'];
		$archivo = $_FILES["archivo"]['name'];
		$prefijo = substr(md5(uniqid(rand())), 0, 6);
		if ($archivo != "") {
			$destino =  "fotos/" . $_POST['cedulafoto'] . ".jpg";
			if (copy($_FILES['archivo']['tmp_name'], $destino)) {
				$status = "Archivo subido: <b>" . $archivo . "</b>";
			} else {
				$status = "Error al subir el archivo";
			}
		} else {
			$status = "Error al subir archivo";
		}
	}

	///////////////////////////////////////////////// cargar fotos ////////////////////////////////////////////////////////////////
	if ($accion == 33) {
		echo "<b>Opciones:</b> &nbsp;&nbsp;<img border = 0 src='images/b_regresa.png' alt='Regresar'><a href='" . $_SERVER['PHP_SELF'] . "'>Regresar</a>";
		echo "<hr><h2>Cargar Foto de la C&eacute;dula Nro: " . $cedula . "</h2>";
		echo "<form name = 'entrada4' action = '" . $_SERVER['PHP_SELF'] . "' method = 'POST'  enctype='multipart/form-data'>";
		echo "<input type = 'hidden' name = 'bandera' value = '33'>";
		echo "<input type = 'hidden' name = 'cedulafoto' value = '" . $cedula . "'>";
		echo "<table cellpadding=2 cellspacing=0 >";
		echo "<tr>";
		echo "<td align=right> Archivo de Foto? (Imagen formato: JPG):</td>";
		echo "<td> <input name='archivo' type='file' size='35' /></td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=2><input name='contrato' type = 'submit' value = 'Bajar Foto a SAIREH? / Regresar'></td>";
		echo "</tr>";
		echo "</table>";
		echo "</form>";
	} else {

		///////////////////////////////////////////////// ACTUALIZAR TRABAJADOR ////////////////////////////////////////////////////////////////
		echo "<table border=1 text align=right>";
		/* echo "<tr>";
		echo "<td><b>Acciones por trabajador:</b></td>";
		echo "<td><img border = 0 src='img2/trabajador_inactivo.png' alt='Elimina'> Eliminar </td>";
		echo "<td><img border = 0 src='img2/modificar_editar.png' alt='Modificar'title='Texto informativo'> Modificar </td>";
		echo "<td><img border = 0 src='img2/ficha_empleado.png' alt='Constancia'> Ficha </td>";
		echo "<td><img border = 0 src='img2/constancia_trabajo.png' alt='Constancia'> Constancia </td>";
		echo "<td><img border = 0 src='img2/sueldos.png' alt='Sueldo'> Sueldo </td>";
		echo "<td><img border = 0 src='img2/contrato.png' alt='Contrato'> Contrato </td>";
		echo "<td><img border = 0 src='img2/sincontrato.png' alt='Contrato'> Sin Contrato </td>";

		echo "</tr>"; */

		echo "</table>";
		echo "</br>";
		

		/* echo "&nbsp;&nbsp;<a href='archivo_trabajador_reporte.php'><img border = 0 src='img2/reporte.png' alt='Reporte'>&nbsp;Reportes</a>";
		if (substr($_SESSION['acceso_validar'], 16, 1) == '1')
			echo "&nbsp;&nbsp;<a href='" . $_SERVER['PHP_SELF'] . "?accion=11'><img border = 0 src='img2/icono_04.png' alt='Nuevo Trabajador'>&nbsp;Nuevo Trabajador</a>";
		if (substr($_SESSION['acceso_validar'], 7, 1) == '1')
			echo "&nbsp;&nbsp;<a href='archivo_trabajador_sueldo.php'><img border = 0 src='img2/icono_05.png' alt='Sueldo'>&nbsp;Actualizar Sueldos</a>";
		if (substr($_SESSION['acceso_validar'], 6, 1) == '1')
			echo "&nbsp;&nbsp;<a href='archivo_trabajador_estructura.php'><img border = 0 src='img2/icono_03.png' alt='Estructuras'>&nbsp;Estructuras</a>"; */



		echo "<h2><center>Actualizaci&oacute;n de Trabajadores</center></h2>";
		echo "<center>Status: <img src='img2/status_ver_doble_zaul.png'>(Fijo-Indefinido)  -  <img src='img2/status_ver.png'>(Contratado)  -  <img src='img2/status_ver_naranja.png'>(Suspendido)</center><br>";


		///////////////////////////////////////////////// graba registros  ////////////////////////////////////////////////////////////////
		if (array_key_exists('graba', $_POST) && $_POST['graba'] == 1) {
			$consulta3 = mysqli_query($enlace, "select * from periodo where nomina='" . substr($_POST['nomina'], 0, 3) . "' and id='" . $_SESSION['id_validar'] . "' order by periodo DESC limit 1");
			if (mysqli_num_rows($consulta3) != 0) {
				$row3 = mysqli_fetch_array($consulta3);
				if ($row3['pre'] == 1) $nograbar = 1;
				else $nograbar = 0;
			}
			if ($nograbar == 1)
				echo "<center><font color=red>" . ($nograbar == 1 ? "No se puede procesar al trabajador porque la Nómina esta en Pre-Cierre" : "") . "</font></center>";
			else {

				$query = "select * from personal where codigo = '" . $_POST['cedula'] . "' and id='" . $_SESSION['id_validar'] . "' ";
				$consulta = mysqli_query($enlace, $query) or die("no se pudo realizar la consulta...");
				$resultado = mysqli_num_rows($consulta);
				if ($resultado == 0) {

					if ($_POST['nrocontrato'] != '') {
						$consulta = "update empresa set contrato=contrato+1 where id='" . $_SESSION['id_validar'] . "' ";
						$resultado = mysqli_query($enlace, $consulta) or die('verificaci&oacute; del c&oacute;digo fall&oacute;: ' . mysqli_error($enlace));
					}

					$fnac = crear_fecha($_POST['fecnac']);
					$fing = crear_fecha($_POST['fecing']);
					$fegr = crear_fecha($_POST['fecegr']);
					$fcon = crear_fecha($_POST['feccon']);
					$flic = crear_fecha($_POST['fechalic']);
					$fcar = crear_fecha($_POST['fechacar']);
					$fsal = crear_fecha($_POST['fechasal']);
					$fman = crear_fecha($_POST['fechaman']);
					$fec_dota = crear_fecha($_POST['fec_dota']);

					$query = "insert into personal  ( id, fechac, tallazapato,tallacamisa,tallapantalon,fec_dota,mano,nrocontrato, contrato,justicontrato, clave, fechalic, fechacar, fechasal, fechaman, pasaporte, pais, edo_nac, ciudad_nac, apellidos1, nombres1,  mensaje,codigo,nombres,apellidos,dir,telefono,sexo,position_number,cuenta_labor,hijo,conyugue,id_conyugue, tel_conyug, gerencia,departamento,cargo,tp,empl_type,skill_team,unidad,";
					$query .= "nomina, turno, banco, agencia_banco, digito_verifbanco, fechan, global_id, gpid, cdsid, fechai, tipoingreso, fechae, cuentacorto, cuenta,cuenta_mercantil,tipo_mercantil, smes,sdia, bono1, bono2, division, sector, grado_salar, lider, estado, pago, parroquia, nacionalidad, municipio, gsanguineo, ";
					$query .= "area, edocivil, tipo, profesion, direccion, sso, motivoretiro, supervisor, gerente, status) values ( '" . $_SESSION['id_validar'] . "', ";
					$query .= "ucase(trim('" . $fcon . "')), ";
					$query .= "ucase(trim('" . $_POST['tallazapato'] . "')), ";
					$query .= "ucase(trim('" . $_POST['tallacamisa'] . "')), ";
					$query .= "ucase(trim('" . $_POST['tallapantalon'] . "')), ";
					$query .= "ucase(trim('" . $fec_dota . "')), ";
					$query .= "ucase(trim('" . $_POST['mano'] . "')), ";
					$query .= "ucase(trim('" . $_POST['nrocontrato'] . "')), ";
					$query .= "ucase(trim('" . $_POST['contrato'] . "')), ";
					$query .= "ucase(trim('" . $_POST['justicontrato'] . "')), ";
					$query .= "trim('" . $_POST['clave'] . "'), ";
					$query .= "ucase(trim('" . $flic . "')), ";
					$query .= "ucase(trim('" . $fcar . "')), ";
					$query .= "ucase(trim('" . $fsal . "')), ";
					$query .= "ucase(trim('" . $fman . "')), ";
					$query .= "ucase(trim('" . $_POST['pasaporte'] . "')), ";
					$query .= "ucase(trim('" . $_POST['pais'] . "')), ";
					$query .= "ucase(trim('" . $_POST['edonac'] . "')), ";
					$query .= "ucase(trim('" . $_POST['ciudnac'] . "')), ";
					$query .= "ucase(trim('" . $_POST['apellidos1'] . "')), ";
					$query .= "ucase(trim('" . $_POST['nombres1'] . "')), ";
					$query .= "ucase(trim('" . $_POST['email'] . "')), ";
					$query .= "ucase(trim('" . $_POST['cedula'] . "')), ";
					$query .= "ucase(trim('" . $_POST['nombres'] . "')), ";
					$query .= "ucase(trim('" . $_POST['apellidos'] . "')), ";
					$query .= "ucase(trim('" . $_POST['dir'] . "')), ";
					$query .= "ucase(trim('" . $_POST['telefono'] . "')), ";
					$query .= "ucase(trim('" . $_POST['sexo'] . "')), ";
					$query .= "ucase(trim('" . $_POST['position_number'] . "')), ";
					$query .= "ucase(trim('" . $_POST['cuentalabor'] . "')), ";

					if (strlen($_POST['hijo']) == 0) $query .= "'0', ";
					else $query .= trim($_POST['hijo']) . ", ";
					$query .= "ucase(trim('" . $_POST['conyugue'] . "')), ";
					$query .= "ucase(trim('" . $_POST['id_conyugue'] . "')), ";
					$query .= "ucase(trim('" . $_POST['tel_conyug'] . "')), ";
					$query .= "ucase(trim('" . $_POST['gerencia'] . "')), ";
					$query .= "ucase(trim('" . $_POST['departamento'] . "')), ";
					$query .= "ucase(trim('" . $_POST['cargo'] . "')), ";
					$query .= "ucase(trim('" . $_POST['tp'] . "')), ";
					$query .= "ucase(trim('" . $_POST['empl_type'] . "')), ";
					$query .= "ucase(trim('" . $_POST['skill_team'] . "')), ";
					$query .= "ucase(trim('" . $_POST['unidad'] . "')), ";
					$query .= "ucase(trim('" . $_POST['nomina'] . "')), ";
					$query .= "ucase(trim('" . $_POST['turno'] . "')), ";
					$query .= "ucase(trim('" . $_POST['banco'] . "')), ";
					$query .= "ucase(trim('" . $_POST['agencia_banco'] . "')), ";
					$query .= "ucase(trim('" . $_POST['digito_verifbanco'] . "')), ";
					$query .= "ucase(trim('" . $fnac . "')), ";
					$query .= "ucase(trim('" . $_POST['globalid'] . "')), ";
					$query .= "ucase(trim('" . $_POST['gp_id'] . "')), ";
					$query .= "ucase(trim('" . $_POST['cds_id'] . "')), ";
					$query .= "ucase(trim('" . $fing . "')), ";
					$query .= "ucase(trim('" . $_POST['tipoingreso'] . "')), ";
					$query .= "ucase(trim('" . $fegr . "')), ";
					$query .= "ucase(trim('" . $_POST['cuentacorto'] . "')), ";
					$query .= "ucase(trim('" . $_POST['cuenta'] . "')), ";
					$query .= "ucase(trim('" . $_POST['cuenta_mercantil'] . "')), ";
					$query .= "ucase(trim('" . $_POST['tipo_mercantil'] . "')), ";
					$query .= "'" . $_POST['smes'] . "', ";
					$query .= "'" . $_POST['sdia'] . "', ";

					$query .= "'" . $_POST['bono1'] . "', ";
					$query .= "'" . $_POST['bono2'] . "', ";
					$query .= "ucase(trim('" . $_POST['division'] . "')), ";
					$query .= "ucase(trim('" . $_POST['sector'] . "')), ";
					$query .= "ucase(trim('" . $_POST['grado_salar'] . "')), ";
					$query .= "ucase(trim('" . $_POST['lider'] . "')), ";
					$query .= "ucase(trim('" . $_POST['estado'] . "')), ";
					$query .= "ucase(trim('" . $_POST['pago'] . "')), ";
					$query .= "ucase(trim('" . $_POST['parroquia'] . "')), ";
					$query .= "ucase(trim('" . $_POST['nacionalidad'] . "')), ";
					$query .= "ucase(trim('" . $_POST['municipio'] . "')), ";
					$query .= "ucase(trim('" . $_POST['gsanguineo'] . "')), ";
					$query .= "ucase(trim('" . $_POST['area'] . "')), ";
					$query .= "ucase(trim('" . $_POST['edocivil'] . "')), ";
					$query .= "ucase(trim('" . $_POST['tipo'] . "')), ";
					$query .= "ucase(trim('" . $_POST['profesion'] . "')), ";
					$query .= "ucase(trim('" . $_POST['direccion'] . "')), ";
					$query .= "ucase(trim('" . $_POST['sso'] . "')), ";
					$query .= "ucase(trim('" . $_POST['motivoretiro'] . "')), ";
					$query .= "ucase(trim('" . $_POST['supervisor'] . "')), ";
					$query .= "ucase(trim('" . $_POST['gerente'] . "')), ";
					$query .= "ucase(trim('" . $_POST['status'] . "')))";


					$consulta = mysqli_query($enlace, $query) or die("no se pudo ingresar los datos..." . mysqli_error($enlace) . $query);

					$consulta = "select * from personal_sueldo where codigo='" . $_POST['cedula'] . "' and fec='" . $fing . "' and id='" . $_SESSION['id_validar'] . "' ";
					$resultado = mysqli_query($enlace, $consulta) or die($consulta . mysqli_error($enlace));
					if (mysqli_num_rows($resultado) == 0) {
						$query = "insert into personal_sueldo  ( id, codigo, fec, sueldo) values('" . $_SESSION['id_validar'] . "', ucase(trim('" . $_POST['cedula'] . "')), '" . $fing . "', '" . $_POST['smes'] . "') ";
						$consulta = mysqli_query($enlace, $query) or die("no se pudo ingresar los datos..." . mysqli_error($enlace) . $query);
					} else {
						$query = "update personal_sueldo  set sueldo='" . $_POST['smes'] . "' where codigo='" . $_POST['cedula'] . "' and fec='" . $fing . "' and id='" . $_SESSION['id_validar'] . "' ";
						$consulta = mysqli_query($enlace, $query) or die("no se pudo ingresar los datos..." . mysqli_error($enlace) . $query);
					}

					$_POST['cedula'] = '';
				}
			}
		}

		///////////////////////////////////////////////// actualizar registros  ////////////////////////////////////////////////////////////////
		if (array_key_exists('modifica', $_POST) && $_POST['modifica'] == 1) {
			$consulta3 = mysqli_query($enlace, "select * from periodo where nomina='" . substr($_POST['nomina'], 0, 3) . "' and id='" . $_SESSION['id_validar'] . "' order by periodo DESC limit 1");
			if (mysqli_num_rows($consulta3) != 0) {
				$row3 = mysqli_fetch_array($consulta3);
				if ($row3['pre'] == 1) $nograbar = 1;
				else $nograbar = 0;
			}
			if ($nograbar == 1)
				echo "<center><font color=red>" . ($nograbar == 1 ? "No se puede procesar al trabajador porque la Nómina esta en Pre-Cierre" : "") . "</font></center>";
			else {

				if ($_POST['nrocontrato'] != '') {
					$consulta = "select contrato from empresa where id='" . $_SESSION['id_validar'] . "' ";
					$resultado = mysqli_query($enlace, $consulta) or die('verificaci&oacute; del c&oacute;digo fall&oacute;: ' . mysqli_error($enlace));
					$row1 = mysqli_fetch_array($resultado);
					$numerocontrato = $row1['contrato'] + 1;
					if ($_POST['nrocontrato'] == $numerocontrato) {
						$consulta = "update empresa set contrato=contrato+1 where id='" . $_SESSION['id_validar'] . "' ";
						$resultado = mysqli_query($enlace, $consulta) or die('verificaci&oacute; del c&oacute;digo fall&oacute;: ' . mysqli_error($enlace));
					}
				}

				$fnac = crear_fecha($_POST['fecnac']);
				$fing = crear_fecha($_POST['fecing']);
				$fegr = crear_fecha($_POST['fecegr']);
				$fcon = crear_fecha($_POST['feccon']);
				$flic = crear_fecha($_POST['fechalic']);
				$fcar = crear_fecha($_POST['fechacar']);
				$fsal = crear_fecha($_POST['fechasal']);
				$fman = crear_fecha($_POST['fechaman']);
				$fec_dota = crear_fecha($_POST['fec_dota']);

				$query = "update personal set ";
				$query .= "clave = trim('" . $_POST['clave'] . "'), ";
				$query .= "contrato = ucase(trim('" . $_POST['contrato'] . "')), ";
				$query .= "justicontrato = ucase(trim('" . $_POST['justicontrato'] . "')), ";
				$query .= "tallazapato = ucase(trim('" . $_POST['tallazapato'] . "')), ";
				$query .= "tallacamisa = ucase(trim('" . $_POST['tallacamisa'] . "')), ";
				$query .= "tallapantalon = ucase(trim('" . $_POST['tallapantalon'] . "')), ";
				$query .= "fec_dota = ucase(trim('" . $fec_dota . "')), ";

				$query .= "mano = ucase(trim('" . $_POST['mano'] . "')), ";
				$query .= "nrocontrato = ucase(trim('" . $_POST['nrocontrato'] . "')), ";
				$query .= "mensaje = ucase(trim('" . $_POST['email'] . "')), ";
				$query .= "pasaporte = ucase(trim('" . $_POST['pasaporte'] . "')), ";
				$query .= "pais = ucase(trim('" . $_POST['pais'] . "')), ";
				$query .= "edo_nac = ucase(trim('" . $_POST['edonac'] . "')), ";
				$query .= "ciudad_nac = ucase(trim('" . $_POST['ciudnac'] . "')), ";
				$query .= "nombres = ucase(trim('" . $_POST['nombres'] . "')), ";
				$query .= "apellidos = ucase(trim('" . $_POST['apellidos'] . "')), ";
				$query .= "nombres1 = ucase(trim('" . $_POST['nombres1'] . "')), ";
				$query .= "apellidos1 = ucase(trim('" . $_POST['apellidos1'] . "')), ";
				$query .= "dir = ucase(trim('" . $_POST['dir'] . "')), ";
				$query .= "telefono = ucase(trim('" . $_POST['telefono'] . "')), ";
				$query .= "sexo = ucase(trim('" . $_POST['sexo'] . "')), ";
				$query .= "position_number = ucase(trim('" . $_POST['position_number'] . "')), ";
				$query .= "cuenta_labor = ucase(trim('" . $_POST['cuentalabor'] . "')), ";

				if (strlen($_POST['hijo']) == 0) $query .= "hijo = '0', ";
				else $query .= "hijo = trim('" . $_POST['hijo'] . "'), ";
				$query .= "conyugue = ucase(trim('" . $_POST['conyugue'] . "')), ";
				$query .= "id_conyugue = ucase(trim('" . $_POST['id_conyugue'] . "')), ";
				$query .= "tel_conyug = ucase(trim('" . $_POST['tel_conyug'] . "')), ";
				$query .= "gerencia = ucase(trim('" . $_POST['gerencia'] . "')), ";
				$query .= "departamento = ucase(trim('" . $_POST['departamento'] . "')), ";
				$query .= "cargo = ucase(trim('" . $_POST['cargo'] . "')), ";
				$query .= "supervisor = ucase(trim('" . $_POST['supervisor'] . "')), ";
				$query .= "gerente = ucase(trim('" . $_POST['gerente'] . "')), ";
				$query .= "tp = ucase(trim('" . $_POST['tp'] . "')), ";
				$query .= "empl_type = ucase(trim('" . $_POST['empl_type'] . "')), ";
				$query .= "skill_team = ucase(trim('" . $_POST['skill_team'] . "')), ";
				$query .= "unidad = ucase(trim('" . $_POST['unidad'] . "')), ";
				$query .= "nomina = ucase(trim('" . $_POST['nomina'] . "')), ";
				$query .= "turno = ucase(trim('" . $_POST['turno'] . "')), ";
				$query .= "banco = ucase(trim('" . $_POST['banco'] . "')), ";
				$query .= "agencia_banco = ucase(trim('" . $_POST['agencia_banco'] . "')), ";
				$query .= "digito_verifbanco = ucase(trim('" . $_POST['digito_verifbanco'] . "')), ";
				$query .= "fechalic = ucase(trim('" . $flic . "')), ";
				$query .= "fechacar = ucase(trim('" . $fcar . "')), ";
				$query .= "fechasal = ucase(trim('" . $fsal . "')), ";
				$query .= "fechaman = ucase(trim('" . $fman . "')), ";
				$query .= "fechai = ucase(trim('" . $fing . "')), ";
				$query .= "tipoingreso = ucase(trim('" . $_POST['tipoingreso'] . "')), ";
				$query .= "fechac = ucase(trim('" . $fcon . "')), ";
				$query .= "fechan = ucase(trim('" . $fnac . "')), ";
				$query .= "global_id = ucase(trim('" . $_POST['globalid'] . "')), ";
				$query .= "gpid = ucase(trim('" . $_POST['gp_id'] . "')), ";
				$query .= "cdsid = ucase(trim('" . $_POST['cds_id'] . "')), ";
				$query .= "fechae = ucase(trim('" . $fegr . "')), ";
				$query .= "cuentacorto = ucase(trim('" . $_POST['cuentacorto'] . "')), ";
				$query .= "cuenta = ucase(trim('" . $_POST['cuenta'] . "')), ";
				$query .= "cuenta_mercantil = ucase(trim('" . $_POST['cuenta_mercantil'] . "')), ";
				$query .= "tipo_mercantil = ucase(trim('" . $_POST['tipo_mercantil'] . "')), ";
				$query .= "smes = '" . $_POST['smes'] . "', ";
				$query .= "sdia = '" . $_POST['sdia'] . "', ";

				$query .= "bono1 = '" . $_POST['bono1'] . "', ";
				$query .= "bono2 = '" . $_POST['bono2'] . "', ";
				$query .= "division = ucase(trim('" . $_POST['division'] . "')), ";
				$query .= "sector = ucase(trim('" . $_POST['sector'] . "')), ";
				$query .= "grado_salar = ucase(trim('" . $_POST['grado_salar'] . "')), ";
				$query .= "lider = ucase(trim('" . $_POST['lider'] . "')), ";
				$query .= "estado = ucase(trim('" . $_POST['estado'] . "')), ";
				$query .= "pago = ucase(trim('" . $_POST['pago'] . "')), ";
				$query .= "parroquia = ucase(trim('" . $_POST['parroquia'] . "')), ";
				$query .= "nacionalidad = ucase(trim('" . $_POST['nacionalidad'] . "')), ";
				$query .= "municipio = ucase(trim('" . $_POST['municipio'] . "')), ";
				$query .= "gsanguineo = ucase(trim('" . $_POST['gsanguineo'] . "')), ";
				$query .= "area = ucase(trim('" . $_POST['area'] . "')), ";
				$query .= "edocivil = ucase(trim('" . $_POST['edocivil'] . "')), ";
				$query .= "tipo = ucase(trim('" . $_POST['tipo'] . "')), ";
				$query .= "profesion = ucase(trim('" . $_POST['profesion'] . "')), ";
				$query .= "direccion = ucase(trim('" . $_POST['direccion'] . "')), ";
				$query .= "sso = ucase(trim('" . $_POST['sso'] . "')), ";
				$query .= "motivoretiro = ucase(trim('" . $_POST['motivoretiro'] . "')), ";
				$query .= "status = ucase(trim('" . $_POST['status'] . "')) ";
				$query .= " where codigo = '" . $_POST['cedula'] . "' and id='" . $_SESSION['id_validar'] . "' ";
				mysqli_query($enlace, $query) or die(mysqli_error($enlace) . $query);
				$_POST['cedula'] = '';
			}
		}

		///////////////////////////////////////////////// eliminar registros ////////////////////////////////////////////////////////////////
		if ($accion == 2) {
			$consulta = "select cedula from historico where cedula='" . $cedula . "' and id='" . $_SESSION['id_validar'] . "' ";
			$resultado = mysqli_query($enlace, $consulta) or die('verificaci&oacute; del c&oacute;digo fall&oacute;: ' . mysqli_error($enlace));
			if (mysqli_num_rows($resultado) != 0) $mensaje = 'Trabajador NO puede eliminarse por tener informaci&oacute;n en Historicos...';
			else {
				$consulta = "delete from personal where codigo='" . $cedula . "' and id='" . $_SESSION['id_validar'] . "' ";
				$resultado = mysqli_query($enlace, $consulta) or die('verificaci&oacute; del c&oacute;digo fall&oacute;: ' . mysqli_error($enlace));
			}
		}

		///////////////////////////////////////////////// mostrar entrada de datos  ////////////////////////////////////////////////////////////////
		if ((!$_POST || $accion == 2 || $_POST['graba'] == 1 || $_POST['modifica'] == 1 || $_POST['bandera'] == 33) && $accion != 3 && $accion != 11) {
			echo "<form name = 'entrada' action = '" . $_SERVER['PHP_SELF'] . "' method = 'POST'  enctype='multipart/form-data'>";
			
			echo "<input type = 'hidden' name = 'busca' value = '1'>";
			echo "<table cellpadding=2 cellspacing=0 width='500' align='center'>";
			echo "<tr>";
			echo "<td align=right> C&eacute;dula/Nombre/Apellido:</td>";
			echo "<td> <input name='cedula' id='cedula' size='30' maxlength='12' onkeyup='buscarEmpleado(this.value)'>
			<div id='sugerencias' style='background:white; border:0px solid #ccc; position:absolute; width:300px; z-index:1000;'></div></td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td align=right> Ordenado por:</td>";
			echo "<td>";
			echo "	<input type = 'radio' name = 'orden' value = 'ced' " . (obtener_valor_diccionario($_POST, 'orden') == 'ced' ? 'checked' : '') . "> cedula";
			echo "	<input type = 'radio' name = 'orden' value = 'nom' " . (obtener_valor_diccionario($_POST, 'orden') == 'nom' ? 'checked' : '') . "> nombre";
			echo "	<input type = 'radio' name = 'orden' value = 'ape' " . (obtener_valor_diccionario($_POST, 'orden') == 'ape' ? 'checked' : '') . "> apellido";
			echo "	<input type = 'radio' name = 'orden' value = 'fechai' " . (obtener_valor_diccionario($_POST, 'orden') == 'fechai' ? 'checked' : '') . "> Fecha Ingreso";
			echo "</tr>";

			/* 
			echo "<tr>";
			$consulta = "Select * from tablas where tabla=ucase('GERENCIA') and id='" . $_SESSION['id_validar'] . "' order by codigo,detalle";
			$consulta = mysqli_query($enlace, $consulta) or die("no se pudo realizar la consulta..." . $consulta . '=' . mysqli_error($enlace));
			$resultado = mysqli_num_rows($consulta);

			echo "<td align = 'right'> Gerencia: </td>";
			echo "<td align = 'left'> <select style='width:280px;' name = 'gerenciax'><option>";
			if ($resultado != 0) {
				for ($i = 0; $i < $resultado; $i++) {
					$row1 = mysqli_fetch_array($consulta);
					echo "<option width = '30%' value='" . $row1['codigo'] . "' " . ($_POST['gerenciax'] == $row1['codigo'] ? 'selected' : '') . ">" . $row1['codigo'] . " - " . $row1['detalle'];
				}
			}

			echo "</select>";
			echo "</td>";
			echo "</tr>";
			echo "<tr>";
			*/
			echo "<td> </td>";
			echo "<td colspan='3'><input type='submit' class='boton' value='Buscar'></td>";
			echo "</tr>";
			echo "</table></form>";
			echo "<script language='javascript' type='text/javascript'>document.entrada.cedula.focus();</script>";
			if ($mensaje != '') echo "<br><br><center><font style='color:black; font-size:1em;' face='Verdana' ><b>" . $mensaje . "</b></font></center>";
		}

		///////////////////////////////////////////////// agregar registros ////////////////////////////////////////////////////////////////
		if ((array_key_exists('agrega', $_POST) && $_POST['agrega'] == 1) || $accion == 11) {
			//if ($_POST['agrega']==1 || $accion==11 ) {
			if ((array_key_exists('cedula', $_POST) && $_POST['cedula'] == '') || $accion == 11) {
				//if ($_POST['cedula']=='' ) {
				echo "<form name = 'entrada3' action = '" . $_SERVER['PHP_SELF'] . "' method = 'POST'  enctype='multipart/form-data' onsubmit='return validar_cedula(this)'>";
				echo "<input type = 'hidden' name = 'agrega' value = '1'>";
				echo "<input type = 'hidden' name = 'orden' value = '" . $_POST['orden'] . "'>";
				echo "<input type = 'hidden' name = 'gerenciax' value = '" . $_POST['gerenciax'] . "'>";
				echo "<table align ='center'>";
				echo "<tr>";
				echo "<td align = 'right'> C&eacute;dula a ingresar: </td>";
				echo "<td align = 'left'> <input type = 'text' name = 'cedula' size = '30' maxlength = '8' onkeyup='verificar_cedula(this.form)'> * </td>";
				echo "<td ><input name='procesar' type = 'submit' class='boton' value = 'Procesar Registro Nuevo' disabled></td></form>";
				echo "<script language='javascript' type='text/javascript'>document.entrada3.cedula.focus();</script>";
				echo "<form name = 'entrada2' method = 'POST' action = '" . $_SERVER['PHP_SELF'] . "'>";
				echo "<td ><input type = 'submit' class='boton' value = 'Regresar al Inicio'></td>";
				echo "</tr>";
				echo "</table></form>";
			} else {
				$consulta = "select contrato from empresa where id='" . $_SESSION['id_validar'] . "' ";
				$resultado = mysqli_query($enlace, $consulta) or die('verificaci&oacute; del c&oacute;digo fall&oacute;: ' . mysqli_error($enlace));
				$row1 = mysqli_fetch_array($resultado);
				$numerocontrato = $row1['contrato'] + 1;
				$cedula = isset($_GET['cedula']) ? $_GET['cedula'] : "";
				$consulta = "select * from personal where codigo='" . $cedula . "' and id='" . $_SESSION['id_validar'] . "' ";
				$resultado = mysqli_query($enlace, $consulta) or die('verificaci&oacute; del c&oacute;digo fall&oacute;: ' . mysqli_error($enlace));
				$num_rows = mysqli_num_rows($resultado);

				if ($num_rows != 0) {
					echo "<form name = 'entrada' action = '" . $_SERVER['PHP_SELF'] . "' method = 'POST'  enctype='multipart/form-data' onsubmit='return validar_cedula_nombre_apellido(this)'>";
					echo "<input type = 'hidden' name = 'agrega' value = '1'>";
					echo "<input type = 'hidden' name = 'orden' value = '" . $_POST['orden'] . "'>";
					echo "<input type = 'hidden' name = 'gerenciax' value = '" . $_POST['gerenciax'] . "'>";
					echo "<table width = '100%' align ='center'>";
					echo "<tr>";
					echo "<td width = '20%' align = 'right'> C&eacute;dula a ingresar: </td>";
					echo "<td width = '36%' align = 'left'> <input type = 'text' name = 'cedula' size = '30' maxlength = '8' > * </td>";
					echo "</tr>";
					echo "</table>";
					echo "<table width = '20%' align ='center'>";
					echo "<tr><td><input type = 'submit' value = 'Procesar'></td></form>";
					echo "<form action = '" . $_SERVER['PHP_SELF'] . "'>";
					echo "<td><input type = 'submit' value = 'Regresar'></td></tr></table></form>";
					echo "<center>registro existente.....</center>";
					echo "	<script language='javascript' type='text/javascript'> document.entrada.cedula.focus(); </script>";
				} else {
					include("calendario/calendario.php");
					$orden = isset($_GET['orden']) ? $_GET['orden'] : "";
					$gerenciax = isset($_GET['gerenciax']) ? $_GET['gerenciax'] : "";

					echo "<form name = 'entrada' action = '" . $_SERVER['PHP_SELF'] . "' method = 'POST'  enctype='multipart/form-data' onsubmit='return validar_cedula_nombre_apellido(this)'>";
					echo "<input type = 'hidden' name = 'graba' value = '1'>";
					echo "<input type = 'hidden' name = 'orden' value = '" . $orden . "'>";
					echo "<input type = 'hidden' name = 'gerenciax' value = '" . $gerenciax . "'>";

					echo "<table rules=none border=0 cellpadding=2 cellspacing=0 align='center' style='border-width: 1px; border-color: 75263C;border-style: solid;'>";

					//=================================================================================================///
					echo "<tr bgcolor='#43bced' height='25'>";
					echo "<td colspan=4 align = center><font color='white'><b> DATOS PERSONALES </b></font></td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";

					echo "<td align = 'right' > Nacionalidad y No. C&eacute;dula: ";
					echo "<select name = 'nacionalidad'>";
					# FIXME ¿De donde viene esta nacionalidad en el row 1?
					echo "<option value='V' " . (obtener_valor_diccionario($row, 'nacionalidad') != 'E' ? 'selected' : '') . "> VE ";
					echo "<option value='E' " . (obtener_valor_diccionario($row, 'nacionalidad') == 'E' ? 'selected' : '') . "> EX ";
					echo  "</select></td>";

					echo "<td  align = 'left'> <input type = 'text' name = 'cedula' size = '30' maxlength = '8' readonly value = '" . obtener_valor_diccionario($_POST, 'cedula') . "' readonly> * </td>";

					echo "<td align = 'right' > Global ID: </td>";
					echo "<td  align = 'left'> <input type = 'text' name = 'globalid' size = '30' maxlength = '7' value = '" . obtener_valor_diccionario($row, 'global_id') . "'>  </td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";

					echo "<td align = 'right' > GPID: </td>";
					echo "<td  align = 'left'> <input type = 'text' name = 'gp_id' size = '30' maxlength = '8' value = '" . obtener_valor_diccionario($row, 'gpid') . "'>  </td>";

					echo "<td align = 'right' > CDS ID: </td>";
					echo "<td  align = 'left'> <input type = 'text' name = 'cds_id' size = '30' maxlength = '8' value = '" . obtener_valor_diccionario($row, 'cdsid') . "'>  </td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td  align = 'right'> Nombre: </td>";
					echo "<td  align = 'left'> <input type = 'text' name = 'nombres' size = '30' maxlength = '50' value = '" . obtener_valor_diccionario($row, 'nombres') . "'><font color='red'> ** </td>";
					echo "<td  align = 'right'> Segundo Nombre: </td>";
					echo "<td  align = 'left'> <input type = 'text' name = 'nombres1' size = '30' maxlength = '50' value = '" . obtener_valor_diccionario($row, 'nombres1') . "'>  </td>";
					echo "</tr>";
					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right'> Apellido: </td>";
					echo "<td align = 'left'> <input type = 'text' name = 'apellidos' size = '30' maxlength = '50' value = '" . obtener_valor_diccionario($row, 'apellidos') . "'><font color='red'> ** </td>";
					echo "<td align = 'right'> Segundo Apellido: </td>";
					echo "<td align = 'left'> <input type = 'text' name = 'apellidos1' size = '30' maxlength = '50' value = '" . obtener_valor_diccionario($row, 'apellidos1') . "'>  </td>";
					echo "</tr>";
					echo "<tr bgcolor='#ffffffff'>";

					echo "<td align = 'right' > RIF: </td>";
					echo "<td align = 'left' > <input type = 'text' name = 'sso' size = '30' maxlength = '30' value = '" . obtener_valor_diccionario($row, 'sso') . "'></td>";


					echo "<td align = 'right' > Sexo: </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'sexo'>";

					echo "<option " . (obtener_valor_diccionario($row, 'sexo') == 'M' ? 'selected' : '') . "> Masculino";
					echo "<option " . (obtener_valor_diccionario($row, 'sexo') == 'F' ? 'selected' : '') . "> Femenino";
					echo  "</select></td>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right'> Position number: </td>";
					echo "<td align = 'left'> <input type = 'text' name = 'position_number' size = '8' maxlength = '8' value = '" . obtener_valor_diccionario($row, 'position_number') . "'><font color='red'> ** </td>";
					echo "<td></td>";

					echo "<td></td>";
					echo "</tr>";
					echo "<tr bgcolor='#43bced' height='25'>";
					echo "<td colspan=4 align = center><font color='white'> <b> DATOS NACIMIENTO </b></font></td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Fecha de Nacimiento (ddmmaaaa): </td>";
					echo "<td align = 'left'>";
					escribe_formulario_fecha_vacio("fecnac", "entrada");
					echo "</td>";
					echo  "</select></td>";

					cargar_select_paises($enlace, "pais", "Pais Nacimiento: ", obtener_valor_diccionario($row, 'pais'));
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					cargar_select_estados_nac($enlace, "edonac", " Edo. Nacimiento: ", obtener_valor_diccionario($row, 'estado'));

					echo "<td align = 'right'> Ciudad Nacimiento:</td>";
					echo "<td align = 'left'> <input type = 'text' name = 'ciudnac' size = '30' maxlength = '50' value = '" . obtener_valor_diccionario($row, 'ciudad_nac') . "'></td>";
					echo "</tr>";
					//=================================================================================================///
					echo "<tr bgcolor='#43bced' height='25'>";
					echo "<td colspan=4 align = center><font color='white'><b> DATOS DE RESIDENCIA Y CONTACTO </b></font></td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Direcci&oacute;n de habitaci&oacute;n: </td>";
					echo "<td colspan=3 align = 'left' ><input type = 'text' name = 'dir' size = '100' maxlength = '100' value = '" . obtener_valor_diccionario($row, 'dir') . "'> </td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					cargar_select_estados_ven($enlace, "estado", "Estado:", obtener_valor_diccionario($row, 'estado'));
					cargar_select_municipios_ven($enlace, "municipio", "Municipio:", obtener_valor_diccionario($row, 'municipio'));

					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					//	cargar_select("parroquia","Parroquia", $row['parroquia']);
					echo "<td align = 'right' > Tel&eacute;fono: </td>";
					echo "<td align = 'left' > <input type = 'text' name = 'telefono' size = '30' maxlength = '50' value = '" . obtener_valor_diccionario($row, 'telefono') . "'></td>";
					echo "<td > </td>";
					echo "<td > </td>";
					echo "</tr>";
					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Email: </td>";
					echo "<td align = 'left' ><input type = 'text' name = 'email' size = '30' maxlength = '50' value = '" . obtener_valor_diccionario($row, 'mensaje') . "'> </td>";
					echo "<td align = 'right' > Clave Acceso WEB: </td>";
					echo "<td align = 'left' ><input type = 'text' name = 'clave' size = '10' maxlength = '10' value = '" . obtener_valor_diccionario($row, 'clave') . "'></td>";
					echo "</tr>";
					/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

					echo "<tr bgcolor='#43bced' height='25'>";
					echo "<td colspan=4 align = center><font color='white'><b> CARGA FAMILIAR </b></font></td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Estado Civil: </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'edocivil'>";
					echo "<option value='1' " . (obtener_valor_diccionario($row, 'edocivil') == '' || obtener_valor_diccionario($row, 'edocivil') == '1' ? 'selected' : '') . ">Soltero(a)";
					echo "<option value='2' " . (obtener_valor_diccionario($row, 'edocivil') == '2' ? 'selected' : '') . "> Casado(a)";
					echo "<option value='3' " . (obtener_valor_diccionario($row, 'edocivil') == '3' ? 'selected' : '') . "> Viudo(a)";
					echo "<option value='4' " . (obtener_valor_diccionario($row, 'edocivil') == '4' ? 'selected' : '') . "> Divorciado(a)";
					echo "<option value='5' " . (obtener_valor_diccionario($row, 'edocivil') == '5' ? 'selected' : '') . "> Concubino(a)";
					echo  "</select></td>";

					echo "<td align = 'right' >  </td>";
					///////////espacio en blanco
					echo "<td align = 'left' ></td>";

					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Conyugue (Nombre y Apellido): </td>";
					echo "<td colspan=3 align = 'left' ><input type = 'text' name = 'conyugue' size = '100' maxlength = '100' value = '" . obtener_valor_diccionario($row, 'conyugue') . "'> </td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Nº Documento: </td>";
					echo "<td align = 'left' ><input type = 'text' name = 'id_conyugue' size = '20' maxlength = '20' value = '" . obtener_valor_diccionario($row, 'id_conyugue') . "'> </td>";

					echo "<td align = 'right' > Telf. Conyugue: </td>";
					echo "<td align = 'left' ><input type = 'text' name = 'tel_conyug' size = '20' maxlength = '20' value = '" . obtener_valor_diccionario($row, 'tel_conyug') . "'> </td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";


					echo "<td align = 'right'> Nro. de Hijos: </td>";
					echo "<td align = 'left'> <input type = 'text' name = 'hijo' size = '30' maxlength = '30' value = '" . obtener_valor_diccionario($row, 'hijo') . "'></td>";

					echo "<td align = 'right' >  </td>";
					///////////espacio en blanco
					echo "<td align = 'left' ></td>";

					echo "</tr>";
					/*echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Pasaporte: </td>";
					echo "<td align = 'left'> <input type = 'text' name = 'pasaporte' size = '30' maxlength = '30' value = '".$_POST['pasaporte']."' > </td>";
					echo "<td align = 'right'> Pa&iacute;s de Origen: </td>";
					echo "<td align = 'left'> <input type = 'text' name = 'pais' size = '30' maxlength = '30' value = '".$_POST['pais']."' > </td>";
				echo "</tr>";*/

					/////////////////////////////////////////////////////////////////////////////////////////

					echo "<tr bgcolor='#43bced' height='25'>";
					echo "<td colspan=4 align = center><font color='white'><b> DATOS SEGURIDAD SOCIAL Y SST </b></font></td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";

					echo "<td align = 'right'> Mano dominante: </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'mano'>";
					echo "<option " . (obtener_valor_diccionario($row, 'mano') == ' ' ? 'selected' : '') . "> ";
					echo "<option " . (obtener_valor_diccionario($row, 'mano') == 'D' ? 'selected' : '') . "> Derecha";
					echo "<option " . (obtener_valor_diccionario($row, 'mano') == 'I' ? 'selected' : '') . "> Izquierda";
					echo "</select></td>";

					echo "<td align ='right'> Tipo de sangre</td>";
					echo "<td align = 'left'>";
					echo "<select name = 'gsanguineo'>";
					echo "<option value='' " . (obtener_valor_diccionario($row, 'gsanguineo') == '' ? 'selected' : '') . "> ";
					echo "<option value='1' " . (obtener_valor_diccionario($row, 'gsanguineo') == '1' ? 'selected' : '') . "> O-";
					echo "<option value='2' " . (obtener_valor_diccionario($row, 'gsanguineo') == '2' ? 'selected' : '') . "> O+";
					echo "<option value='3' " . (obtener_valor_diccionario($row, 'gsanguineo') == '3' ? 'selected' : '') . "> A-";
					echo "<option value='4' " . (obtener_valor_diccionario($row, 'gsanguineo') == '4' ? 'selected' : '') . "> A+";
					echo "<option value='5' " . (obtener_valor_diccionario($row, 'gsanguineo') == '5' ? 'selected' : '') . "> B-";
					echo "<option value='6' " . (obtener_valor_diccionario($row, 'gsanguineo') == '6' ? 'selected' : '') . "> B+";
					echo "<option value='7' " . (obtener_valor_diccionario($row, 'gsanguineo') == '7' ? 'selected' : '') . "> AB-";
					echo "<option value='8' " . (obtener_valor_diccionario($row, 'gsanguineo') == '8' ? 'selected' : '') . "> AB+";
					echo  "</select></td>";
					echo "</tr>";
					//=================================================================================================///

					echo "<tr bgcolor='#43bced' height='25'>";
					echo "<td colspan=4 align = center><font color='white'><b> Segumiento Médico </b></font></td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";

					echo "<td align = 'right' > Exámen Médico anual (ddmmaaaa): </td>";
					echo "<td align = 'left'>";
					escribe_formulario_fecha_vacio("fechaman", "entrada");
					echo "</td>";

					echo "<td align = 'right' > Certificado de Salud (ddmmaaaa): </td>";
					echo "<td align = 'left'>";
					escribe_formulario_fecha_vacio("fechasal", "entrada");
					echo "</td>";

					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Licencia de Conducir (ddmmaaaa): </td>";
					echo "<td align = 'left'>";
					escribe_formulario_fecha_vacio("fechalic", "entrada");
					echo "</td>";
					echo "<td align = 'right' > Certificado M&eacute;dico (ddmmaaaa): </td>";
					echo "<td align = 'left'>";
					escribe_formulario_fecha_vacio("fechacar", "entrada");
					echo "</td>";
					echo "</tr>";


					//=================================================================================================///
					echo "<tr bgcolor='#43bced' height='25'>";
					echo "<td colspan=4 align = center><font color='white'><b>Datos de Dotación </b></font></td>";
					echo "</tr>";
					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Talla Zapato: </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'tallazapato'>";

					echo "<option value='' " . (obtener_valor_diccionario($row, 'tallazapato') == '' ? 'selected' : '') . "> ";
					echo "<option " . (obtener_valor_diccionario($row, 'tallazapato') == '35' ? 'selected' : '') . "> 35";
					echo "<option " . (obtener_valor_diccionario($row, 'tallazapato') == '36' ? 'selected' : '') . "> 36";
					echo "<option " . (obtener_valor_diccionario($row, 'tallazapato') == '37' ? 'selected' : '') . "> 37";
					echo "<option " . (obtener_valor_diccionario($row, 'tallazapato') == '38' ? 'selected' : '') . "> 38";
					echo "<option " . (obtener_valor_diccionario($row, 'tallazapato') == '39' ? 'selected' : '') . "> 39";
					echo "<option " . (obtener_valor_diccionario($row, 'tallazapato') == '40' ? 'selected' : '') . "> 40";
					echo "<option " . (obtener_valor_diccionario($row, 'tallazapato') == '41' ? 'selected' : '') . "> 41";
					echo "<option " . (obtener_valor_diccionario($row, 'tallazapato') == '42' ? 'selected' : '') . "> 42";
					echo "<option " . (obtener_valor_diccionario($row, 'tallazapato') == '43' ? 'selected' : '') . "> 43";
					echo "<option " . (obtener_valor_diccionario($row, 'tallazapato') == '44' ? 'selected' : '') . "> 44";
					echo "<option " . (obtener_valor_diccionario($row, 'tallazapato') == '45' ? 'selected' : '') . "> 45";
					echo  "</select></td>";




					echo "<td align = 'right'> Talla Camisa: </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'tallacamisa'>";
					echo "<option value='' " . (obtener_valor_diccionario($row, 'tallacamisa') == '' ? 'selected' : '') . "> ";
					echo "<option " . (obtener_valor_diccionario($row, 'tallacamisa') == 'XS' ? 'selected' : '') . "> XS";
					echo "<option " . (obtener_valor_diccionario($row, 'tallacamisa') == 'S' ? 'selected' : '') . "> S";
					echo "<option " . (obtener_valor_diccionario($row, 'tallacamisa') == 'M' ? 'selected' : '') . "> M";
					echo "<option " . (obtener_valor_diccionario($row, 'tallacamisa') == 'L' ? 'selected' : '') . "> L";
					echo "<option " . (obtener_valor_diccionario($row, 'tallacamisa') == 'XL' ? 'selected' : '') . "> XL";
					echo "<option " . (obtener_valor_diccionario($row, 'tallacamisa') == 'XXL' ? 'selected' : '') . "> XXL";
					echo  "</select></td>";
					echo "</tr>";


					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Talla Pantal&oacute;n: </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'tallapantalon'>";
					echo "<option value='' " . (obtener_valor_diccionario($row, 'tallapantalon') == '' ? 'selected' : '') . "> ";
					echo "<option " . (obtener_valor_diccionario($row, 'tallapantalon') == '8' ? 'selected' : '') . "> 8";
					echo "<option " . (obtener_valor_diccionario($row, 'tallapantalon') == '10' ? 'selected' : '') . "> 10";
					echo "<option " . (obtener_valor_diccionario($row, 'tallapantalon') == '12' ? 'selected' : '') . "> 12";
					echo "<option " . (obtener_valor_diccionario($row, 'tallapantalon') == '14' ? 'selected' : '') . "> 14";
					echo "<option " . (obtener_valor_diccionario($row, 'tallapantalon') == '26' ? 'selected' : '') . "> 26";
					echo "<option " . (obtener_valor_diccionario($row, 'tallapantalon') == '28' ? 'selected' : '') . "> 28";
					echo "<option " . (obtener_valor_diccionario($row, 'tallapantalon') == '30' ? 'selected' : '') . "> 30";
					echo "<option " . (obtener_valor_diccionario($row, 'tallapantalon') == '32' ? 'selected' : '') . "> 32";
					echo "<option " . (obtener_valor_diccionario($row, 'tallapantalon') == '34' ? 'selected' : '') . "> 34";
					echo "<option " . (obtener_valor_diccionario($row, 'tallapantalon') == '36' ? 'selected' : '') . "> 36";
					echo "<option " . (obtener_valor_diccionario($row, 'tallapantalon') == '38' ? 'selected' : '') . "> 38";
					echo  "</select></td>";



					echo "<td align = 'right' > Fecha &uacute;ltima Dotaci&oacute;n (ddmmaaaa): </td>";
					echo "<td align = 'left'>";
					escribe_formulario_fecha_vacio("fec_dota", "entrada");
					echo "</td>";
					echo "</tr>";


					//=================================================================================================///

					echo "<tr bgcolor='#43bced' height='25'>";
					echo "<td colspan=4 align=center>
						<font color='white'> <b>DATOS BANCO MERCANTIL </b></font>
					</td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align='right'> Tipo de Cuenta: </td>";
					echo "<td align='left'>";
					echo "<select name='tipo_mercantil'>";
					echo "<option value='' " . (obtener_valor_diccionario($row, 'tipo_mercantil') == '' ? 'selected' : '') . "> ";
					echo "
							<option value='1' " . (obtener_valor_diccionario($row, 'tipo_mercantil') != '2' && obtener_valor_diccionario($row, 'tipo_mercantil') != '' ? 'selected' : '') . "> Ahorro";
					echo "
							<option value='2' " . (obtener_valor_diccionario($row, 'tipo_mercantil') == '2' ? 'selected' : '') . "> Corriente";
					echo "
						</select></td>";

					echo "<td align='right'> Cuenta Bancaria: </td>";
					echo "<td align='left'><input type='text' name='cuenta_mercantil' size='30' maxlength='20' value='" . obtener_valor_diccionario($row, 'cuenta_mercantil') . "'></td>";
					echo "</tr>";


					//=================================================================================================///

					echo "<tr bgcolor='#43bced' height='25'>";
					echo "<td colspan=4 align = center><font color='white'><b> DATOS BANCARIOS </b></font></td>";
					echo "</tr>";


					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Forma de Pago: </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'pago'>";
					echo "<option value='1' " . (obtener_valor_diccionario($row, 'pago') != '2' ? 'selected' : '') . "> Efectivo";
					echo "<option value='2' " . (obtener_valor_diccionario($row, 'pago') == '2' ? 'selected' : '') . "> Banco";
					echo  "</select></td>";

					////Espacio en Blanco
					echo "<td></td>";
					echo "<td></td>";

					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";

					echo "<td align = 'right' > Entidad Bancaria: </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'banco'>";
					echo "<option value='' " . (obtener_valor_diccionario($row, 'banco') == '' ? 'selected' : '') . ">";
					echo "<option value='0156' " . (obtener_valor_diccionario($row, 'banco') == '0156' ? 'selected' : '') . "> 100%BANCO";
					echo "<option value='0196' " . (obtener_valor_diccionario($row, 'banco') == '0196' ? 'selected' : '') . "> ABN AMRO BANK";
					echo "<option value='0172' " . (obtener_valor_diccionario($row, 'banco') == '0172' ? 'selected' : '') . "> BANCAMIGA BANCO MICROFINANCIERO, C.A.";
					echo "<option value='0171' " . (obtener_valor_diccionario($row, 'banco') == '0171' ? 'selected' : '') . "> BANCO ACTIVO BANCO COMERCIAL, C.A.";
					echo "<option value='0166' " . (obtener_valor_diccionario($row, 'banco') == '0166' ? 'selected' : '') . "> BANCO AGRICOLA";
					echo "<option value='0175' " . (obtener_valor_diccionario($row, 'banco') == '0175' ? 'selected' : '') . "> BANCO BICENTENARIO";
					echo "<option value='0128' " . (obtener_valor_diccionario($row, 'banco') == '0128' ? 'selected' : '') . "> BANCO CARONI, C.A. BANCO UNIVERSAL";
					echo "<option value='0164' " . (obtener_valor_diccionario($row, 'banco') == '0164' ? 'selected' : '') . "> BANCO DE DESARROLLO DEL MICROEMPRESARIO";
					echo "<option value='0102' " . (obtener_valor_diccionario($row, 'banco') == '0102' ? 'selected' : '') . "> BANCO DE VENEZUELA";
					echo "<option value='0114' " . (obtener_valor_diccionario($row, 'banco') == '0114' ? 'selected' : '') . "> BANCO DEL CARIBE C.A.";
					echo "<option value='0149' " . (obtener_valor_diccionario($row, 'banco') == '0149' ? 'selected' : '') . "> BANCO DEL PUEBLO SOBERANO C.A.";
					echo "<option value='0163' " . (obtener_valor_diccionario($row, 'banco') == '0163' ? 'selected' : '') . "> BANCO DEL TESORO";
					echo "<option value='0176' " . (obtener_valor_diccionario($row, 'banco') == '0176' ? 'selected' : '') . "> BANCO ESPIRITO SANTO, S.A.";
					echo "<option value='0115' " . (obtener_valor_diccionario($row, 'banco') == '0115' ? 'selected' : '') . "> BANCO EXTERIOR C.A.";
					echo "<option value='0003' " . (obtener_valor_diccionario($row, 'banco') == '0003' ? 'selected' : '') . "> BANCO INDUSTRIAL DE VENEZUELA.";
					echo "<option value='0173' " . (obtener_valor_diccionario($row, 'banco') == '0173' ? 'selected' : '') . "> BANCO INTERNACIONAL DE DESARROLLO, C.A.";
					echo "<option value='0105' " . (obtener_valor_diccionario($row, 'banco') == '0105' ? 'selected' : '') . "> BANCO MERCANTIL C.A.";
					echo "<option value='0191' " . (obtener_valor_diccionario($row, 'banco') == '0191' ? 'selected' : '') . "> BANCO NACIONAL DE CREDITO";
					echo "<option value='0116' " . (obtener_valor_diccionario($row, 'banco') == '0116' ? 'selected' : '') . "> BANCO OCCIDENTAL DE DESCUENTO.";
					echo "<option value='0138' " . (obtener_valor_diccionario($row, 'banco') == '0138' ? 'selected' : '') . "> BANCO PLAZA";
					echo "<option value='0108' " . (obtener_valor_diccionario($row, 'banco') == '0108' ? 'selected' : '') . "> BANCO PROVINCIAL BBVA";
					echo "<option value='0104' " . (obtener_valor_diccionario($row, 'banco') == '0104' ? 'selected' : '') . "> BANCO VENEZOLANO DE CREDITO S.A.";
					echo "<option value='0168' " . (obtener_valor_diccionario($row, 'banco') == '0168' ? 'selected' : '') . "> BANCRECER S.A. BANCO DE DESARROLLO";
					echo "<option value='0134' " . (obtener_valor_diccionario($row, 'banco') == '0134' ? 'selected' : '') . "> BANESCO BANCO UNIVERSAL";
					echo "<option value='0177' " . (obtener_valor_diccionario($row, 'banco') == '0177' ? 'selected' : '') . "> BANFANB";
					echo "<option value='0146' " . (obtener_valor_diccionario($row, 'banco') == '0146' ? 'selected' : '') . "> BANGENTE";
					echo "<option value='0174' " . (obtener_valor_diccionario($row, 'banco') == '0174' ? 'selected' : '') . "> BANPLUS BANCO COMERCIAL C.A.";
					echo "<option value='0190' " . (obtener_valor_diccionario($row, 'banco') == '0190' ? 'selected' : '') . "> CITIBANK";
					echo "<option value='0121' " . (obtener_valor_diccionario($row, 'banco') == '0121' ? 'selected' : '') . "> CORP BANCA";
					echo "<option value='0157' " . (obtener_valor_diccionario($row, 'banco') == '0157' ? 'selected' : '') . "> DELSUR BANCO UNIVERSAL";
					echo "<option value='0151' " . (obtener_valor_diccionario($row, 'banco') == '0151' ? 'selected' : '') . "> FONDO COMUN";
					echo "<option value='0169' " . (obtener_valor_diccionario($row, 'banco') == '0169' ? 'selected' : '') . "> MIBANCO BANCO DE DESARROLLO, C.A.";
					echo "<option value='0137' " . (obtener_valor_diccionario($row, 'banco') == '0137' ? 'selected' : '') . "> SOFITASA";
					echo  "</select></td>";

					echo "<td align = 'right' > Agencia Cód: </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'agencia_banco'>";

					echo "<option value='' " . (obtener_valor_diccionario($row, 'agencia_banco') == '' ? 'selected' : '') . ">";
					echo "<option value='0968' " . (obtener_valor_diccionario($row, 'agencia_banco') == '0968' ? 'selected' : '') . "> FORD";
					echo "<option value='0532' " . (obtener_valor_diccionario($row, 'agencia_banco') == '0532' ? 'selected' : '') . "> FORD DIARIA VALENCIA";
					echo "<option value='0945' " . (obtener_valor_diccionario($row, 'agencia_banco') == '0945' ? 'selected' : '') . "> FORD DIARIA VALENCIA VI";
					echo "<option value='0946' " . (obtener_valor_diccionario($row, 'agencia_banco') == '0946' ? 'selected' : '') . "> FORD VALENCIA CUENTA ECOL";

					echo  "</select></td>";

					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Dígito verificador: </td>";
					echo "<td align = 'left' ><input type = 'text' name = 'digito_verifbanco' size = '5' maxlength = '2' value = '" . obtener_valor_diccionario($row, 'digito_verifbanco') . "'></td>";

					echo "<td align = 'right' > # Cuenta Bancaria (corto): </td>";
					echo "<td align = 'left' ><input type = 'text' name = 'cuentacorto' size = '30' maxlength = '10' value = '" . obtener_valor_diccionario($row, 'cuentacorto') . "'></td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Tipo de Cuenta: </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'tipo'>";
					echo "<option value='' " . (obtener_valor_diccionario($row, 'tipo') == '' ? 'selected' : '') . "> ";
					echo "<option value='1' " . (obtener_valor_diccionario($row, 'tipo') != '2' && obtener_valor_diccionario($row, 'tipo') != '' ? 'selected' : '') . "> Ahorro";
					echo "<option value='2' " . (obtener_valor_diccionario($row, 'tipo') == '2' ? 'selected' : '') . "> Corriente";
					echo  "</select></td>";

					echo "<td align = 'right' > Cuenta Bancaria: </td>";
					echo "<td align = 'left' ><input type = 'text' name = 'cuenta' size = '30'maxlength = '20' value = '" . obtener_valor_diccionario($row, 'cuenta') . "'></td>";
					echo "</tr>";

					//=================================================================================================///
					echo "<tr bgcolor='#43bced' height='25'>";
					echo "<td colspan=4 align = center><font color='white'><b> DATOS DE CARGO/ORGANIGRAMA </b></font></td>";
					echo "</tr>";
					/*
				echo "<tr bgcolor='#ffffffff'>";
					cargar_select("gerencia","Gerencia", $row['gerencia']);
					cargar_select("direccion","Direcci&oacute;n", $row['direccion']);
				echo "</tr>";
				echo "<tr bgcolor='#ffffffff'>";
					cargar_select("division","Divisi&oacute;n", $row['division']);

					echo "</tr>";
					*/
					echo "<tr bgcolor='#ffffffff'>";
					cargar_select($enlace, "unidad", "Unidad", obtener_valor_diccionario($row, 'unidad'));
					cargar_select($enlace, "departamento", "Departamento", obtener_valor_diccionario($row, 'departamento'));
					echo "</tr>";
					echo "<tr bgcolor='#ffffffff'>";
					cargar_select($enlace, "area", "&Aacute;rea", obtener_valor_diccionario($row, 'area'));
					cargar_select($enlace, "cargo", "Cargo", obtener_valor_diccionario($row, 'cargo'));

					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					//Carga supervisores
					echo "<td align = 'right'> Supervisor: </td>";
					$query_sup_ger = "SELECT detalle AS nombre, position_number FROM tab_usuario WHERE rol IN ('supervisor','rrhh','gerente') AND id =  '" . $row['id'] . "' ";
					$consulta_sup_ger = mysqli_query($enlace, $query_sup_ger) or die($query_sup_ger . " " . mysqli_error($enlace));

					echo "<td align = 'left'>";
					echo "<select name = 'supervisor' id = 'supervisor'>";
					echo "<option width = '30%'>";
					while ($row_sup_ger = mysqli_fetch_array($consulta_sup_ger)) {
						if (obtener_valor_diccionario($row, 'supervisor') == $row_sup_ger['position_number']) {
							echo "<option value= " . $row_sup_ger['position_number'] . " selected= 'selected'> " . quitar_espacios($row_sup_ger['nombre']) . " - " . $row_sup_ger['position_number'];
						} else {
							echo "<option value= " . $row_sup_ger['position_number'] . "> " . quitar_espacios($row_sup_ger['nombre']) . " - " . $row_sup_ger['position_number'];
						}
					}
					echo "</select>";
					echo " </td>";

					//Carga gerentes
					echo "<td align = 'right'> Gerente: </td>";
					$query_sup_ger = "SELECT detalle AS nombre, position_number FROM tab_usuario WHERE rol = 'gerente' AND id = '" . $row['id'] . "' ";
					$consulta_sup_ger = mysqli_query($enlace, $query_sup_ger) or die($query_sup_ger . " " . mysqli_error($enlace));

					echo "<td align = 'left'>";
					echo "<select name = 'gerente' id = 'gerente'>";
					echo "<option width = '30%'>";
					while ($row_sup_ger = mysqli_fetch_array($consulta_sup_ger)) {
						if (obtener_valor_diccionario($row, 'gerente') == $row_sup_ger['position_number']) {
							echo "<option value= " . $row_sup_ger['position_number'] . " selected= 'selected'> " . quitar_espacios($row_sup_ger['nombre']);
						} else {
							echo "<option value= " . $row_sup_ger['position_number'] . "> " . quitar_espacios($row_sup_ger['nombre']);
						}
					}
					echo "</select>";
					echo " </td>";

					echo "</tr>";

					//=================================================================================================///
					echo "<tr bgcolor='#43bced' height='25'>";
					echo "<td colspan=4 align = center><font color='white'><b> DATOS DE CONTRATO </b></font></td>";
					echo "</tr>";
					echo "<tr bgcolor='#ffffffff'>";

					echo "<td align = 'right' > Fecha de Ingreso (ddmmaaaa): </td>";
					echo "<td align = 'left'>";
					escribe_formulario_fecha_vacio("fecing", "entrada");
					echo "</td>";

					/////Tipo de Ingreso
					cargar_select($enlace, "tipoingreso", "Tipo de Ingreso", obtener_valor_diccionario($row, 'tipoingreso'));
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					$query = "select * from contrato where id='" . $_SESSION['id_validar'] . "' ";
					$consulta = mysqli_query($enlace, $query) or die("no se pudo realizar la consulta...");
					$resultado = mysqli_num_rows($consulta);
					echo "<td align = 'right'> <font color=red>Contrato:</font> </td>";
					echo "<td align = 'left'> <select name = 'contrato'><option>";
					if ($resultado != 0) {
						for ($i = 0; $i < $resultado; $i++) {
							$row1 = mysqli_fetch_array($consulta);
							if ($row1['codigo'] == obtener_valor_diccionario($row, 'contrato')) echo "<option width = '30%' selected>" . $row1['codigo'] . " - " . $row1['detalle'];
							else echo "<option width = '30%'>" . $row1['codigo'] . " - " . $row1['detalle'];
						}
					}
					echo "</select>";
					echo "</td>";

					echo "<td align = 'right' > Numero de Contrato: </td>";
					echo "<td align = 'left' > <select name = 'nrocontrato'>
												<option value=''>SIN CONTRATO
												<option value = '" . $numerocontrato . "'>Contrato No. " . $numerocontrato . "
												</select></td>";

					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Justificaci&oacute;n del Contrato: </td>";
					echo "<td colspan=3 align = 'left' ><input type = 'text' name = 'justicontrato' size = '100' maxlength = '100' value = '" . obtener_valor_diccionario($row, 'justicontrato') . "'> </td>";

					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";

					echo "<td align = 'right' > Fecha Final Contrato: </td>";
					echo "<td align = 'left'>";
					escribe_formulario_fecha_vacio("feccon", "entrada");
					echo "</td>";

					echo "<td align = 'right'>  </td>";
					///////////espacio en blanco
					echo "<td align = 'right'>  </td>";

					echo "</tr>";




					//=================================================================================================///
					echo "<tr bgcolor='#43bced' height='25'>";
					echo "<td colspan=4 align = center><font color='white'><b> DATOS DE NÓMINA Y SALARIO </b></font></td>";
					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right'> <font color=red>STATUS:</font> </td>";
					echo "<td align = 'left'> <select name = 'status'>";
					if (obtener_valor_diccionario($row, 'status') == "A") echo "<option selected>Activos";
					else echo "<option>Activos";
					if (obtener_valor_diccionario($row, 'status') == "V") echo "<option selected>Vacaciones";
					else echo "<option>Vacaciones";
					if (obtener_valor_diccionario($row, 'status') == "S") echo "<option selected>Suspendidos";
					else echo "<option>Suspendidos";
					if (obtener_valor_diccionario($row, 'status') == "I") echo "<option selected>Inactivos";
					else echo "<option>Inactivos";
					if (obtener_valor_diccionario($row, 'status') == "C") echo "<option selected>Contratados";
					else echo "<option>Contratados";
					echo "</select>";
					echo "</td>";

					/////////Tipo Vinculo
					cargar_select($enlace, "tp", "Tipo vínculo", obtener_valor_diccionario($row, 'tp'));

					echo "<tr bgcolor='#ffffffff'>";

					$query = "select * from nomina where id='" . $_SESSION['id_validar'] . "' ";
					$consulta = mysqli_query($enlace, $query) or die("no se pudo realizar la consulta...");
					$resultado = mysqli_num_rows($consulta);
					echo "<td align = 'right'> <font color=red>N&Oacute;MINA:</font> </td>";
					echo "<td align = 'left'> <select name = 'nomina'>";
					if ($resultado != 0) {
						for ($i = 0; $i < $resultado; $i++) {
							$row1 = mysqli_fetch_array($consulta);
							if ($row1['codigo'] == obtener_valor_diccionario($row, 'nomina')) echo "<option width = '30%' selected>" . $row1['codigo'] . " - " . $row1['detalle'];
							else echo "<option width = '30%'>" . $row1['codigo'] . " - " . $row1['detalle'];
						}
					}
					echo "</select>";
					echo "</td>";

					$query = "select * from turno where id='" . $_SESSION['id_validar'] . "' order by detalle";
					$consulta = mysqli_query($enlace, $query) or die("no se pudo realizar la consulta...");
					$resultado = mysqli_num_rows($consulta);
					echo "<td align = 'right'> Jornada:</font> </td>";
					echo "<td align = 'left'> <select name = 'turno'><option>";
					if ($resultado != 0) {
						for ($i = 0; $i < $resultado; $i++) {
							$row1 = mysqli_fetch_array($consulta);
							if ($row1['codigo'] == obtener_valor_diccionario($row, 'turno')) echo "<option width = '30%' selected>" . $row1['codigo'] . " - " . $row1['detalle'];
							else echo "<option width = '30%'>" . $row1['codigo'] . " - " . $row1['detalle'];
						}
					}
					echo "</select>";

					echo "</tr>";


					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > <font color=blue>Salario Mes: </td></font>";
					echo "<td align = 'left'  > <input type = 'text' name = 'smes' size = '30' maxlength = '30' value = '" . obtener_valor_diccionario($row, 'smes') . "'><font color='red'> ** </td>";

					//cargar_select("sector","Tipo Salario", $row['sector']);
					echo "<td align = 'right' >Tipo Salario: </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'sector'>";
					echo "<option value='' " . (obtener_valor_diccionario($row, 'sector') == '' ? 'selected' : '') . ">";
					echo "<option value='1000' " . (obtener_valor_diccionario($row, 'sector') == '1000' ? 'selected' : '') . "> SALARIO FIJO";
					echo "<option value='2000' " . (obtener_valor_diccionario($row, 'sector') == '2000' ? 'selected' : '') . "> SALARIO VARIABLE";
					echo  "</select></td>";

					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > <font color=blue>Salario Diario: </td></font>";
					echo "<td align = 'left'  > <input type = 'text' name = 'sdia' size = '30' maxlength = '30' value = '" . obtener_valor_diccionario($row, 'sdia') . "'><font color='red'> ** </td>";

					//cargar_select("sector","Tipo Salario", $row['sector']);
					echo "<td align = 'right' > </td>";
					echo "<td align = 'left'> </td>";

					echo "</tr>";
					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > <font color=blue>PXCP: </td></font>";
					echo "<td align = 'left'  > <input type = 'text' name = 'bono1' size = '30' maxlength = '30' value = '" . obtener_valor_diccionario($row, 'bono1') . "'></td>";
					echo "<td align = 'right' > <font color=blue>PXLG: </td></font>";
					echo "<td align = 'left'  > <input type = 'text' name = 'bono2' size = '30' maxlength = '30' value = '" . obtener_valor_diccionario($row, 'bono2') . "'></td>";
					echo "</tr>";
					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Grado salarial: </td></font>";
					echo "<td align = 'left'>";
					echo "<select name = 'grado_salar'>";

					echo "<option value='' " . (obtener_valor_diccionario($row, 'grado_salar') == '' ? 'selected' : '') . ">";
					echo "<option value='001' " . (obtener_valor_diccionario($row, 'grado_salar')  == '001' ? 'selected' : '') . "> 001";
					echo "<option value='002' " . (obtener_valor_diccionario($row, 'grado_salar')  == '002' ? 'selected' : '') . "> 002";
					echo "<option value='003' " . (obtener_valor_diccionario($row, 'grado_salar')  == '003' ? 'selected' : '') . "> 003";
					echo "<option value='004' " . (obtener_valor_diccionario($row, 'grado_salar')  == '004' ? 'selected' : '') . "> 004";
					echo "<option value='005' " . (obtener_valor_diccionario($row, 'grado_salar')  == '005' ? 'selected' : '') . "> 005";
					echo "<option value='006' " . (obtener_valor_diccionario($row, 'grado_salar')  == '006' ? 'selected' : '') . "> 006";
					echo "<option value='007' " . (obtener_valor_diccionario($row, 'grado_salar')  == '007' ? 'selected' : '') . "> 007";
					echo "<option value='008' " . (obtener_valor_diccionario($row, 'grado_salar')  == '008' ? 'selected' : '') . "> 008";
					echo "<option value='LL5' " . (obtener_valor_diccionario($row, 'grado_salar')  == 'LL5' ? 'selected' : '') . "> LL5";
					echo "<option value='LL6' " . (obtener_valor_diccionario($row, 'grado_salar')  == 'LL6' ? 'selected' : '') . "> LL6";

					echo  "</select></td>";

					echo "<td align = 'right' >Líder: </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'lider'>";
					echo "<option value='' " . (obtener_valor_diccionario($row, 'lider') == '' ? 'selected' : '') . ">";
					echo "<option value='LG' " . (obtener_valor_diccionario($row, 'lider') == 'LG' ? 'selected' : '') . "> Líder grupo";
					echo "<option value='LM' " . (obtener_valor_diccionario($row, 'lider') == 'LM' ? 'selected' : '') . "> Líder manufac";
					echo  "</select></td>";

					echo "</tr>";

					echo "<tr bgcolor='#ffffffff'>";
					echo "<td align = 'right' > Employee Type: </td></font>";
					echo "<td align = 'left'>";
					echo "<select name = 'empl_type'>";

					echo "<option value='' " . (obtener_valor_diccionario($row, 'empl_type') == '' ? 'selected' : '') . ">";
					echo "<option value='1' " . (obtener_valor_diccionario($row, 'empl_type') == '1' ? 'selected' : '') . "> Hourly";
					echo "<option value='2' " . (obtener_valor_diccionario($row, 'empl_type') == '2' ? 'selected' : '') . "> Salaried";


					echo  "</select></td>";

					echo "<td align = 'right' >Skill Team (Job Function): </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'skill_team'>";

					echo "<option value='' " . (obtener_valor_diccionario($row, 'skill_team') == '' ? 'selected' : '') . ">";
					echo "<option value='CSV' " . (obtener_valor_diccionario($row, 'skill_team') == 'CSV' ? 'selected' : '') . "> CSV";
					echo "<option value='FIN' " . (obtener_valor_diccionario($row, 'skill_team') == 'FIN' ? 'selected' : '') . "> FIN";
					echo "<option value='GCR' " . (obtener_valor_diccionario($row, 'skill_team') == 'GCR' ? 'selected' : '') . "> GCR";
					echo "<option value='HRS' " . (obtener_valor_diccionario($row, 'skill_team') == 'HRS' ? 'selected' : '') . "> HRS";
					echo "<option value='ITS' " . (obtener_valor_diccionario($row, 'skill_team') == 'ITS' ? 'selected' : '') . "> ITS";
					echo "<option value='MFG' " . (obtener_valor_diccionario($row, 'skill_team') == 'MFG' ? 'selected' : '') . "> MFG";
					echo "<option value='MSS' " . (obtener_valor_diccionario($row, 'skill_team') == 'MSS' ? 'selected' : '') . "> MSS";
					echo "<option value='OGC' " . (obtener_valor_diccionario($row, 'skill_team') == 'OGC' ? 'selected' : '') . "> OGC";
					echo "<option value='OTH' " . (obtener_valor_diccionario($row, 'skill_team') == 'OTH' ? 'selected' : '') . "> OTH";
					echo "<option value='PUR' " . (obtener_valor_diccionario($row, 'skill_team') == 'PUR' ? 'selected' : '') . "> PUR";

					echo "</tr>";

					echo "</table><br><br>";


					echo "<table width = '20%' align ='center'>";
					echo "<tr><td><input type = 'submit' class='boton' value = 'Grabar Nuevo Registro' " . (substr($_SESSION['acceso_validar'], 16, 1) == '1' ? '' : 'disabled') . "></td></form>";
					echo "<form name = 'regresar' method = 'POST' action = '" . $_SERVER['PHP_SELF'] . "'>";
					echo "<td><input type = 'submit' class='boton' value = 'Regresar al Inicio'></td></tr></form>";
					echo "	<script language='javascript' type='text/javascript'>";
					echo "		document.entrada.nombres.focus()";
					echo "	</script>";
				}
			}
		}

		//////////////////////******************************************************//////////////////////////////////////////////////////////////////////////////////////
		///////////////////////////////////////////////// ACTUALIZAR  TRABAJADORES (FICHA TRABAJADOR///////////////////////////////////////
		//////////////////////******************************************************//////////////////////////////////////////////////////////////////////////////////////
		//////////////////////******************************************************//////////////////////////////////////////////////////////////////////////////////////
		//////////////////////******************************************************//////////////////////////////////////////////////////////////////////////////////////

		if ($accion == 3) {

			$consulta = "select contrato from empresa where id='" . $_SESSION['id_validar'] . "' ";
			$resultado = mysqli_query($enlace, $consulta) or die('verificaci&oacute; del c&oacute;digo fall&oacute;: ' . mysqli_error($enlace));
			$row1 = mysqli_fetch_array($resultado);
			$numerocontrato = $row1['contrato'] + 1;

			$consulta = "select * from personal where codigo='" . $cedula . "' and id='" . $_SESSION['id_validar'] . "' ";
			$resultado = mysqli_query($enlace, $consulta) or die('verificaci&oacute; del c&oacute;digo fall&oacute;: ' . mysqli_error($enlace));
			$num_rows = mysqli_num_rows($resultado);
			if ($num_rows != 0) {
				include("calendario/calendario.php");
				$row = mysqli_fetch_array($resultado);
				echo "<center><font color=black size=5>&nbsp;" . trim($row['nombres']) . " " . trim($row['nombres1']) . ' ' . trim($row['apellidos']) . " " . trim($row['apellidos1']) . "</font></center><br>";
				echo "<form name = 'entrada' action = '" . $_SERVER['PHP_SELF'] . "' method = 'POST'  enctype='multipart/form-data' onsubmit='return validar_cedula_nombre_apellido(this)'>";
				echo "<input type = 'hidden' name = 'modifica' value = '1'>";
				echo "<input type = 'hidden' name = 'orden' value = '" . $_REQUEST['orden'] . "'>";
				echo "<input type = 'hidden' name = 'gerenciax' value = '" . $_REQUEST['gerencia'] . "'>";

				echo "<table rules=none border=0 cellpadding=2 cellspacing=0 align='center' style='border-width: 1px; border-color: 75263C;border-style: solid;'>";
				//=================================================================================================///
				echo "<tr bgcolor='#43bced' height='25'>";
				echo "<td colspan=4 align = center><font color='white'><b> DATOS PESONALES </b></font></td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td  align = 'right'> Nacionalidad y No. C&eacute;dula: ";
				echo "<select name = 'nacionalidad'>";
				echo "<option value='V' " . ($row['nacionalidad'] != 'E' ? 'selected' : '') . "> VE ";
				echo "<option value='E' " . ($row['nacionalidad'] == 'E' ? 'selected' : '') . "> EX ";
				echo  "</select></td>";

				echo "<td  align = 'left'> <input type = 'text' name = 'cedula' size = '30' maxlength = '8' readonly value = '" . $row['codigo'] . "' readonly> * </td>";

				echo "<td align = 'right' > Global ID: </td>";
				echo "<td  align = 'left'> <input type = 'text' name = 'globalid' size = '30' maxlength = '7' value = '" . $row['global_id'] . "'>  </td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > GPID: </td>";
				echo "<td  align = 'left'> <input type = 'text' name = 'gp_id' size = '30' maxlength = '8' value = '" . $row['gpid'] . "'>  </td>";

				echo "<td align = 'right' > CDS ID: </td>";
				echo "<td  align = 'left'> <input type = 'text' name = 'cds_id' size = '30' maxlength = '8' value = '" . $row['cdsid'] . "'>  </td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td  align = 'right'> Nombre: </td>";
				echo "<td  align = 'left'> <input type = 'text' name = 'nombres' size = '30' maxlength = '50' value = '" . $row['nombres'] . "'> <font color='red'> **  </td>";
				echo "<td  align = 'right'> Segundo Nombre: </td>";
				echo "<td  align = 'left'> <input type = 'text' name = 'nombres1' size = '30' maxlength = '50' value = '" . $row['nombres1'] . "'>  </td>";
				echo "</tr>";
				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right'> Apellido: </td>";
				echo "<td align = 'left'> <input type = 'text' name = 'apellidos' size = '30' maxlength = '50' value = '" . $row['apellidos'] . "'> <font color='red'> ** </td>";
				echo "<td align = 'right'> Segundo Apellido: </td>";
				echo "<td align = 'left'> <input type = 'text' name = 'apellidos1' size = '30' maxlength = '50' value = '" . $row['apellidos1'] . "'>  </td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";

				echo "<td align = 'right' > RIF: </td>";
				echo "<td align = 'left' > <input type = 'text' name = 'sso' size = '30' maxlength = '30' value = '" . $row['sso'] . "'></td>";
				echo "<td align = 'right'> Sexo: </td>";

				echo "<td align = 'left'>";
				echo "<select name = 'sexo'>";
				echo "<option " . ($row['sexo'] == 'M' ? 'selected' : '') . "> Masculino";
				echo "<option " . ($row['sexo'] == 'F' ? 'selected' : '') . "> Femenino";
				echo  "</select></td>";

				echo "</tr>";
				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right'> Position number: </td>";
				echo "<td align = 'left'> <input type = 'text' name = 'position_number' size = '8' maxlength = '50' value = '" . $row['position_number'] . "'><font color='red'> ** </td>";

				echo "<td align = 'right'> Cuenta Labor: </td>";
				echo "<td align = 'left'> <input type = 'text' name = 'cuentalabor' size = '8' maxlength = '50' value = '" . $row['cuenta_labor'] . "'><font color='red'> ** </td>";
				echo "<td></td>";
				echo "</tr>";

				echo "<tr bgcolor='#43bced' height='25'>";
				echo "<td colspan=4 align = center><font color='white'><b> DATOS NACIMIENTO </b></font></td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";

				echo "<td align = 'right' > Fecha de Nacimiento (ddmmaaaa): </td>";
				echo "<td align = 'left'>";
				$valor = (unir_fecha($row['fechan']) == '00000000' ? '' : unir_fecha($row['fechan']));
				escribe_formulario_fecha_modifica("fecnac", "entrada", $valor);
				echo "</td>";

				cargar_select_modificar_paises($enlace, "pais", "Pais Nacimiento: ", obtener_valor_diccionario($row, 'pais'));

				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				cargar_select_modificar_estados_nac($enlace, "edonac", " Edo. Nacimiento: ", $row['edo_nac']);

				echo "<td align = 'right'> Ciudad Nacimiento:</td>";
				echo "<td align = 'left' ><input type = 'text' name = 'ciudnac' size = '30' maxlength = '50' value = '" . $row['ciudad_nac'] . "'> </td>";

				echo "</tr>";
				//=================================================================================================///
				echo "<tr bgcolor='#43bced' height='25'>";
				echo "<td colspan=4 align = center><font color='white'> <b>DATOS DE RESIDENCIA Y CONTACTO </b></font></td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > Direcci&oacute;n de habitaci&oacute;n: </td>";

				echo "<td colspan=3 align = 'left' ><input type = 'text' name = 'dir' size = '100' maxlength = '100' value = '" . $row['dir'] . "'> </td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				cargar_select_modificar_estados_ven($enlace, "estado", "Estado: ", $row['estado']);
				cargar_select_modificar_municipios_ven($enlace, "municipio", "Municipio: ", $row['municipio']);

				//cargar_select_modificar($enlace, "municipio","Municipio", $row['municipio']);Antes desde la tabla "tablas"
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				//cargar_select_modificar($enlace, "parroquia","Parroquia", $row['parroquia']);
				echo "<td align = 'right' > Tel&eacute;fono: </td>";
				echo "<td align = 'left' > <input type = 'text' name = 'telefono' size = '30' maxlength = '50' value = '" . $row['telefono'] . "'></td>";
				echo "<td></td>";
				echo "<td></td>";

				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > Email: </td>";
				echo "<td align = 'left' ><input type = 'text' name = 'email' size = '30' maxlength = '50' value = '" . $row['mensaje'] . "'> </td>";
				echo "<td align = 'right' > Clave Acceso WEB:</td>";
				echo "<td align = 'left' ><input type = 'text' name = 'clave' size = '10' maxlength = '10' value = '" . $row['clave'] . "'></td>";
				echo "</tr>";


				//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				echo "<tr bgcolor='#43bced' height='25'>";
				echo "<td colspan=4 align = center><font color='white'> <b>CARGA FAMILIAR </b></font></td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";

				echo "<td align = 'right' > Estado Civil: </td>";
				echo "<td align = 'left'>";
				echo "<select name = 'edocivil'>";
				echo "<option value='1' " . ($row['edocivil'] == '' || $row['edocivil'] == '1' ? 'selected' : '') . ">Soltero(a)";
				echo "<option value='2' " . ($row['edocivil'] == '2' ? 'selected' : '') . "> Casado(a)";
				echo "<option value='3' " . ($row['edocivil'] == '3' ? 'selected' : '') . "> Viudo(a)";
				echo "<option value='4' " . ($row['edocivil'] == '4' ? 'selected' : '') . "> Divorciado(a)";
				echo "<option value='5' " . ($row['edocivil'] == '5' ? 'selected' : '') . "> Concubino(a)";
				echo  "</select></td>";

				echo "<td align = 'right'>  </td>";
				///////////espacio en blanco
				echo "<td align = 'right'>  </td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > Conyugue (Nombre y Apellido): </td>";
				echo "<td colspan=3 align = 'left' ><input type = 'text' name = 'conyugue' size = '100' maxlength = '100' value = '" . $row['conyugue'] . "'> </td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > Nº Documento: </td>";
				echo "<td align = 'left' ><input type = 'text' name = 'id_conyugue' size = '20' maxlength = '20' value = '" . $row['id_conyugue'] . "'> </td>";

				echo "<td align = 'right' > Telf. Conyugue: </td>";
				echo "<td align = 'left' ><input type = 'text' name = 'tel_conyug' size = '20' maxlength = '20' value = '" . $row['tel_conyug'] . "'> </td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";

				echo "<td align = 'right'> Nro. de Hijos: </td>";
				echo "<td align = 'left'> <input type = 'text' name = 'hijo' size = '30' maxlength = '30' value = '" . $row['hijo'] . "'></td>";
				//cargar_select_modificar($enlace, "profesion","Profesi&oacute;n", $row['profesion']);
				echo "<td align = 'right'>  </td>";
				///////////espacio en blanco
				echo "<td align = 'right'>  </td>";
				echo "</tr>";
				/////////////////////////////////////////////////////////////////////////////////////////////////////////7

				echo "<tr bgcolor='#ffffffff'>";
				echo "<tr bgcolor='#43bced' height='25'>";
				echo "<td colspan=4 align = center><font color='white'><b> DATOS SEGURIDAD SOCIAL Y SST</b></font></td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";

				echo "<td align = 'right'> Mano dominante: </td>";
				echo "<td align = 'left'>";
				echo "<select name = 'mano'>";
				echo "<option " . ($row['mano'] == ' ' ? 'selected' : '') . "> ";
				echo "<option " . ($row['mano'] == 'D' ? 'selected' : '') . "> Derecha";
				echo "<option " . ($row['mano'] == 'I' ? 'selected' : '') . "> Izquierda";
				echo "</select></td>";

				echo "<td align ='right'> Tipo de sangre</td>";
				echo "<td align = 'left'>";
				echo "<select name = 'gsanguineo'>";
				echo "<option value='' " . ($row['gsanguineo'] == '' ? 'selected' : '') . "> ";
				echo "<option value='1' " . ($row['gsanguineo'] == '1' ? 'selected' : '') . "> O-";
				echo "<option value='2' " . ($row['gsanguineo'] == '2' ? 'selected' : '') . "> O+";
				echo "<option value='3' " . ($row['gsanguineo'] == '3' ? 'selected' : '') . "> A-";
				echo "<option value='4' " . ($row['gsanguineo'] == '4' ? 'selected' : '') . "> A+";
				echo "<option value='5' " . ($row['gsanguineo'] == '5' ? 'selected' : '') . "> B-";
				echo "<option value='6' " . ($row['gsanguineo'] == '6' ? 'selected' : '') . "> B+";
				echo "<option value='7' " . ($row['gsanguineo'] == '7' ? 'selected' : '') . "> AB-";
				echo "<option value='8' " . ($row['gsanguineo'] == '8' ? 'selected' : '') . "> AB+";
				echo  "</select></td>";


				echo "</tr>";
				/*echo "<tr bgcolor='#ffffffff'>";
			echo "<td align = 'right' > Pasaporte: </td>";
			echo "<td align = 'left'> <input type = 'text' name = 'pasaporte' size = '30' maxlength = '30' value = '".$row['pasaporte']."' > </td>";
			echo "<td align = 'right'> Pa&iacute;s de Origen: </td>";
			echo "<td align = 'left'> <input type = 'text' name = 'pais' size = '30' maxlength = '30' value = '".$row['pais']."' > </td>";
		echo "</tr>";
		*/
				//=================================================================================================///
				echo "<tr bgcolor='#43bced' height='25'>";
				echo "<td colspan=4 align = center><font color='white'><b> Segumiento Médico </b></font></td>";
				echo "</tr>";


				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > Exámen Médico anual (ddmmaaaa): </td>";
				echo "<td align = 'left'>";
				$valor = (unir_fecha($row['fechaman']) == '00000000' ? '' : unir_fecha($row['fechaman']));
				escribe_formulario_fecha_modifica("fechaman", "entrada", $valor);
				echo "</td>";

				echo "<td align = 'right' > Certificado de Salud (ddmmaaaa): </td>";
				echo "<td align = 'left'>";
				$valor = (unir_fecha($row['fechasal']) == '00000000' ? '' : unir_fecha($row['fechasal']));
				escribe_formulario_fecha_modifica("fechasal", "entrada", $valor);
				echo "</td>";

				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > Licencia de Conducir (ddmmaaaa): </td>";
				echo "<td align = 'left'>";
				$valor = (unir_fecha($row['fechalic']) == '00000000' ? '' : unir_fecha($row['fechalic']));
				escribe_formulario_fecha_modifica("fechalic", "entrada", $valor);
				echo "</td>";
				echo "<td align = 'right' > Certificado M&eacute;dico (ddmmaaaa): </td>";
				echo "<td align = 'left'>";
				$valor = (unir_fecha($row['fechacar']) == '00000000' ? '' : unir_fecha($row['fechacar']));
				escribe_formulario_fecha_modifica("fechacar", "entrada", $valor);
				echo "</td>";
				echo "</tr>";


				//=================================================================================================///

				echo "<tr bgcolor='#43bced' height='25'>";
				echo "<td colspan=4 align = center><font color='white'><b>Datos de Dotaci&oacute;n </b></font></td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > Talla Zapato: </td>";
				echo "<td align = 'left'>";
				echo "<select name = 'tallazapato'>";
				echo "<option value='' " . ($row['tallazapato'] == '' ? 'selected' : '') . "> ";
				echo "<option " . ($row['tallazapato'] == '35' ? 'selected' : '') . "> 35";
				echo "<option " . ($row['tallazapato'] == '36' ? 'selected' : '') . "> 36";
				echo "<option " . ($row['tallazapato'] == '37' ? 'selected' : '') . "> 37";
				echo "<option " . ($row['tallazapato'] == '38' ? 'selected' : '') . "> 38";
				echo "<option " . ($row['tallazapato'] == '39' ? 'selected' : '') . "> 39";
				echo "<option " . ($row['tallazapato'] == '40' ? 'selected' : '') . "> 40";
				echo "<option " . ($row['tallazapato'] == '41' ? 'selected' : '') . "> 41";
				echo "<option " . ($row['tallazapato'] == '42' ? 'selected' : '') . "> 42";
				echo "<option " . ($row['tallazapato'] == '43' ? 'selected' : '') . "> 43";
				echo "<option " . ($row['tallazapato'] == '44' ? 'selected' : '') . "> 44";
				echo "<option " . ($row['tallazapato'] == '45' ? 'selected' : '') . "> 45";
				echo  "</select></td>";

				echo "<td align = 'right'> Talla Camisa: </td>";
				echo "<td align = 'left'>";
				echo "<select name = 'tallacamisa'>";
				echo "<option value='' " . ($row['tallacamisa'] == '' ? 'selected' : '') . "> ";
				echo "<option " . ($row['tallacamisa'] == 'XS' ? 'selected' : '') . "> XS";
				echo "<option " . ($row['tallacamisa'] == 'S' ? 'selected' : '') . "> S";
				echo "<option " . ($row['tallacamisa'] == 'M' ? 'selected' : '') . "> M";
				echo "<option " . ($row['tallacamisa'] == 'L' ? 'selected' : '') . "> L";
				echo "<option " . ($row['tallacamisa'] == 'XL' ? 'selected' : '') . "> XL";
				echo "<option " . ($row['tallacamisa'] == 'XXL' ? 'selected' : '') . "> XXL";
				echo  "</select></td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > Talla Pantal&oacute;n: </td>";
				echo "<td align = 'left'>";
				echo "<select name = 'tallapantalon'>";
				echo "<option value='' " . ($row['tallapantalon'] == '' ? 'selected' : '') . "> ";
				echo "<option " . ($row['tallapantalon'] == '8' ? 'selected' : '') . "> 8";
				echo "<option " . ($row['tallapantalon'] == '10' ? 'selected' : '') . "> 10";
				echo "<option " . ($row['tallapantalon'] == '12' ? 'selected' : '') . "> 12";
				echo "<option " . ($row['tallapantalon'] == '14' ? 'selected' : '') . "> 14";
				echo "<option " . ($row['tallapantalon'] == '26' ? 'selected' : '') . "> 26";
				echo "<option " . ($row['tallapantalon'] == '28' ? 'selected' : '') . "> 28";
				echo "<option " . ($row['tallapantalon'] == '30' ? 'selected' : '') . "> 30";
				echo "<option " . ($row['tallapantalon'] == '32' ? 'selected' : '') . "> 32";
				echo "<option " . ($row['tallapantalon'] == '34' ? 'selected' : '') . "> 34";
				echo "<option " . ($row['tallapantalon'] == '36' ? 'selected' : '') . "> 36";
				echo "<option " . ($row['tallapantalon'] == '38' ? 'selected' : '') . "> 38";
				echo  "</select></td>";

				echo "<td align = 'right' > Fecha &uacute;ltima Dotaci&oacute;n (ddmmaaaa): </td>";
				echo "<td align = 'left'>";
				$valor = (unir_fecha($row['fec_dota	']) == '00000000' ? '' : unir_fecha($row['fec_dota']));
				escribe_formulario_fecha_modifica("fec_dota", "entrada", $valor);
				echo "</td>";
				echo "</tr>";

				//=================================================================================================///

				echo "<tr bgcolor='#43bced' height='25'>";
				echo "<td colspan=4 align=center>
				<font color='white'> <b> DATOS BANCO MERCANTIL </b></font>
			</td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align='right'> Tipo de Cuenta: </td>";
				echo "<td align='left'>";
				echo "<select name='tipo_mercantil'>";
				echo "<option value='' " . ($row['tipo_mercantil'] == '' ? 'selected' : '') . "> ";
				echo "
					<option value='1' " . ($row['tipo_mercantil'] != '2' && $row['tipo_mercantil'] != '' ? 'selected' : '') . "> Ahorro";
				echo "
					<option value='2' " . ($row['tipo_mercantil'] == '2' ? 'selected' : '') . "> Corriente";
				echo "
				</select></td>";

				echo "<td align='right'> Cuenta Bancaria: </td>";
				echo "<td align='left'><input type='text' name='cuenta_mercantil' size='30' maxlength='20' value='" . $row['cuenta_mercantil'] . "'></td>";
				echo "</tr>";

				//=================================================================================================///
				echo "<tr bgcolor='#43bced' height='25'>";
				echo "<td colspan=4 align = center><font color='white'><b> DATOS BANCARIOS </b></font></td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";

				echo "<td align = 'right' > Forma de Pago: </td>";
				echo "<td align = 'left'>";
				echo "<select name = 'pago'>";
				echo "<option value='1' " . ($row['pago'] != '2' ? 'selected' : '') . "> Efectivo";
				echo "<option value='2' " . ($row['pago'] == '2' ? 'selected' : '') . "> Banco";
				echo  "</select></td>";

				echo "<td align = 'right'>  </td>";
				///////////espacio en blanco
				echo "<td align = 'right'>  </td>";

				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";

				echo "<td align = 'right' > Entidad Bancaria: </td>";
				echo "<td align = 'left'>";
				echo "<select name = 'banco'>";
				echo "<option value='' " . ($row['banco'] == '' ? 'selected' : '') . ">";
				echo "<option value='0156' " . ($row['banco'] == '0156' ? 'selected' : '') . "> 100%BANCO";
				echo "<option value='0196' " . ($row['banco'] == '0196' ? 'selected' : '') . "> ABN AMRO BANK";
				echo "<option value='0172' " . ($row['banco'] == '0172' ? 'selected' : '') . "> BANCAMIGA BANCO MICROFINANCIERO, C.A.";
				echo "<option value='0171' " . ($row['banco'] == '0171' ? 'selected' : '') . "> BANCO ACTIVO BANCO COMERCIAL, C.A.";
				echo "<option value='0166' " . ($row['banco'] == '0166' ? 'selected' : '') . "> BANCO AGRICOLA";
				echo "<option value='0175' " . ($row['banco'] == '0175' ? 'selected' : '') . "> BANCO BICENTENARIO";
				echo "<option value='0128' " . ($row['banco'] == '0128' ? 'selected' : '') . "> BANCO CARONI, C.A. BANCO UNIVERSAL";
				echo "<option value='0164' " . ($row['banco'] == '0164' ? 'selected' : '') . "> BANCO DE DESARROLLO DEL MICROEMPRESARIO";
				echo "<option value='0102' " . ($row['banco'] == '0102' ? 'selected' : '') . "> BANCO DE VENEZUELA";
				echo "<option value='0114' " . ($row['banco'] == '0114' ? 'selected' : '') . "> BANCO DEL CARIBE C.A.";
				echo "<option value='0149' " . ($row['banco'] == '0149' ? 'selected' : '') . "> BANCO DEL PUEBLO SOBERANO C.A.";
				echo "<option value='0163' " . ($row['banco'] == '0163' ? 'selected' : '') . "> BANCO DEL TESORO";
				echo "<option value='0176' " . ($row['banco'] == '0176' ? 'selected' : '') . "> BANCO ESPIRITO SANTO, S.A.";
				echo "<option value='0115' " . ($row['banco'] == '0115' ? 'selected' : '') . "> BANCO EXTERIOR C.A.";
				echo "<option value='0003' " . ($row['banco'] == '0003' ? 'selected' : '') . "> BANCO INDUSTRIAL DE VENEZUELA.";
				echo "<option value='0173' " . ($row['banco'] == '0173' ? 'selected' : '') . "> BANCO INTERNACIONAL DE DESARROLLO, C.A.";
				echo "<option value='0105' " . ($row['banco'] == '0105' ? 'selected' : '') . "> BANCO MERCANTIL C.A.";
				echo "<option value='0191' " . ($row['banco'] == '0191' ? 'selected' : '') . "> BANCO NACIONAL DE CREDITO";
				echo "<option value='0116' " . ($row['banco'] == '0116' ? 'selected' : '') . "> BANCO OCCIDENTAL DE DESCUENTO.";
				echo "<option value='0138' " . ($row['banco'] == '0138' ? 'selected' : '') . "> BANCO PLAZA";
				echo "<option value='0108' " . ($row['banco'] == '0108' ? 'selected' : '') . "> BANCO PROVINCIAL BBVA";
				echo "<option value='0104' " . ($row['banco'] == '0104' ? 'selected' : '') . "> BANCO VENEZOLANO DE CREDITO S.A.";
				echo "<option value='0168' " . ($row['banco'] == '0168' ? 'selected' : '') . "> BANCRECER S.A. BANCO DE DESARROLLO";
				echo "<option value='0134' " . ($row['banco'] == '0134' ? 'selected' : '') . "> BANESCO BANCO UNIVERSAL";
				echo "<option value='0177' " . ($row['banco'] == '0177' ? 'selected' : '') . "> BANFANB";
				echo "<option value='0146' " . ($row['banco'] == '0146' ? 'selected' : '') . "> BANGENTE";
				echo "<option value='0174' " . ($row['banco'] == '0174' ? 'selected' : '') . "> BANPLUS BANCO COMERCIAL C.A.";
				echo "<option value='0190' " . ($row['banco'] == '0190' ? 'selected' : '') . "> CITIBANK";
				echo "<option value='0121' " . ($row['banco'] == '0121' ? 'selected' : '') . "> CORP BANCA";
				echo "<option value='0157' " . ($row['banco'] == '0157' ? 'selected' : '') . "> DELSUR BANCO UNIVERSAL";
				echo "<option value='0151' " . ($row['banco'] == '0151' ? 'selected' : '') . "> FONDO COMUN";
				echo "<option value='0169' " . ($row['banco'] == '0169' ? 'selected' : '') . "> MIBANCO BANCO DE DESARROLLO, C.A.";
				echo "<option value='0137' " . ($row['banco'] == '0137' ? 'selected' : '') . "> SOFITASA";
				echo  "</select></td>";


				echo "<td align = 'right' > Agencia Cód: </td>";
				echo "<td align = 'left'>";
				echo "<select name = 'agencia_banco'>";

				echo "<option value='' " . ($row['agencia_banco'] == '' ? 'selected' : '') . ">";
				echo "<option value='0968' " . ($row['agencia_banco'] == '0968' ? 'selected' : '') . "> FORD";
				echo "<option value='0532' " . ($row['agencia_banco'] == '0532' ? 'selected' : '') . "> FORD DIARIA VALENCIA";
				echo "<option value='0945' " . ($row['agencia_banco'] == '0945' ? 'selected' : '') . "> FORD DIARIA VALENCIA VI";
				echo "<option value='0946' " . ($row['agencia_banco'] == '0946' ? 'selected' : '') . "> FORD VALENCIA CUENTA ECOL";
				echo "<option value='0866' " . ($row['agencia_banco'] == '0866' ? 'selected' : '') . "> OTRA AGENCIA 0866";


				echo  "</select></td>";

				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > Dígito verificador: </td>";
				echo "<td align = 'left' ><input type = 'text' name = 'digito_verifbanco' size = '5' maxlength = '2' value = '" . $row['digito_verifbanco'] . "'></td>";

				echo "<td align = 'right' > # Cuenta Bancaria (corto): </td>";
				echo "<td align = 'left' ><input type = 'text' name = 'cuentacorto' size = '30' maxlength = '10' value = '" . $row['cuentacorto'] . "'></td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > Tipo de Cuenta: </td>";
				echo "<td align = 'left'>";
				echo "<select name = 'tipo'>";
				echo "<option value='' " . ($row['tipo'] == '' ? 'selected' : '') . "> ";
				echo "<option value='1' " . ($row['tipo'] != '2' && $row['tipo'] != '' ? 'selected' : '') . "> Ahorro";
				echo "<option value='2' " . ($row['tipo'] == '2' ? 'selected' : '') . "> Corriente";
				echo  "</select></td>";
				echo "<td align = 'right' > Cuenta Bancaria: </td>";
				echo "<td align = 'left' ><input type = 'text' name = 'cuenta' size = '30' maxlength = '20' value = '" . $row['cuenta'] . "'></td>";
				echo "</tr>";


				//=================================================================================================///
				echo "<tr bgcolor='#43bced' height='25'>";
				echo "<td colspan=4 align = center><font color='white'> <b>DATOS DE CARGO/ORGANIGRAMA </b></font></td>";
				echo "</tr>";
				/*
		echo "<tr bgcolor='#ffffffff'>";
			cargar_select_modificar($enlace, "gerencia","Gerencia", $row['gerencia']);
			cargar_select_modificar($enlace, "direccion","Direcci&oacute;n", $row['direccion']);
		echo "</tr>";
		echo "<tr bgcolor='#ffffffff'>";
			cargar_select_modificar($enlace, "division","Divisi&oacute;n", $row['division']);

		echo "</tr>";
		*/
				echo "<tr bgcolor='#ffffffff'>";
				cargar_select_modificar($enlace, "unidad", "Unidad", $row['unidad']);
				cargar_select_modificar($enlace, "departamento", "Departamento", $row['departamento']);
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				cargar_select_modificar($enlace, "area", "&Aacute;rea", $row['area']);
				cargar_select_modificar($enlace, "cargo", "Cargo", $row['cargo']);

				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				//Carga supervisores
				echo "<td align = 'right'> Supervisor: </td>";
				$query_sup_ger = "SELECT detalle AS nombre, position_number FROM tab_usuario WHERE rol IN ('supervisor','rrhh','gerente') AND id =  '" . $row['id'] . "' order by nombre";
				$consulta_sup_ger = mysqli_query($enlace, $query_sup_ger) or die($query_sup_ger . " " . mysqli_error($enlace));

				echo "<td align = 'left'>";
				echo "<select name = 'supervisor' id = 'supervisor'>";
				echo "<option width = '30%'>";
				while ($row_sup_ger = mysqli_fetch_array($consulta_sup_ger)) {
					if ($row['supervisor'] == $row_sup_ger['position_number']) {
						echo "<option value= " . $row_sup_ger['position_number'] . " selected= 'selected'> " . quitar_espacios($row_sup_ger['nombre']) . " - " . $row_sup_ger['position_number'];
					} else {
						echo "<option value= " . $row_sup_ger['position_number'] . "> " . quitar_espacios($row_sup_ger['nombre']) . " - " . $row_sup_ger['position_number'];
					}
				}
				echo "</select>";
				echo " </td>";

				//Carga gerentes
				echo "<td align = 'right'> Gerente: </td>";
				$query_sup_ger = "SELECT detalle AS nombre, position_number FROM tab_usuario WHERE rol = 'gerente' OR usuario='ASALAZ14' AND id = '" . $row['id'] . "' order by nombre";
				$consulta_sup_ger = mysqli_query($enlace, $query_sup_ger) or die($query_sup_ger . " " . mysqli_error($enlace));

				echo "<td align = 'left'>";
				echo "<select name = 'gerente' id = 'gerente'>";
				echo "<option width = '30%'>";
				while ($row_sup_ger = mysqli_fetch_array($consulta_sup_ger)) {
					if ($row['gerente'] == $row_sup_ger['position_number']) {
						echo "<option value= " . $row_sup_ger['position_number'] . " selected= 'selected'> " . quitar_espacios($row_sup_ger['nombre']);
					} else {
						echo "<option value= " . $row_sup_ger['position_number'] . "> " . quitar_espacios($row_sup_ger['nombre']);
					}
				}
				echo "</select>";
				echo " </td>";

				echo "</tr>";		//=================================================================================================///
				echo "<tr bgcolor='#43bced' height='25'>";
				echo "<td colspan=4 align = center><font color='white'> <b> DATOS DE CONTRATO </b> </font></td>";
				echo "</tr>";

				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";


				echo "<td align = 'right' > Fecha de Ingreso (ddmmaaaa): </td>";
				echo "<td align = 'left'>";
				$valor = (unir_fecha($row['fechai']) == '00000000' ? '' : unir_fecha($row['fechai']));
				escribe_formulario_fecha_modifica("fecing", "entrada", $valor);
				echo "</td>";

				//////////Tipo de Ingreso
				cargar_select_modificar($enlace, "tipoingreso", "Tipo de Ingreso", $row['tipoingreso']);
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";

				$query = "select * from contrato where id='" . $_SESSION['id_validar'] . "' order by detalle";
				$consulta = mysqli_query($enlace, $query) or die("no se pudo realizar la consulta...");
				$resultado = mysqli_num_rows($consulta);
				echo "<td align = 'right'> <font color=red>Contrato:</font> </td>";
				echo "<td align = 'left'> <select name = 'contrato'><option>";
				if ($resultado != 0) {
					for ($i = 0; $i < $resultado; $i++) {
						$row1 = mysqli_fetch_array($consulta);
						if ($row1['codigo'] == $row['contrato']) echo "<option width = '30%' selected>" . $row1['codigo'] . " - " . $row1['detalle'];
						else echo "<option width = '30%'>" . $row1['codigo'] . " - " . $row1['detalle'];
					}
				}
				echo "</select>";
				echo "</td>";

				echo "<td align = 'right' > Numero de Contrato: </td>";
				echo "<td align = 'left' > <select name = 'nrocontrato'>";
				if ($row['nrocontrato'] == '') echo "<option value='' selected>SIN CONTRATO";
				else echo "<option value = '" . $row['nrocontrato'] . "'>Contrato No. " . $row['nrocontrato'];
				echo "<option value = '" . $numerocontrato . "'>Contrato Nuevo No. " . $numerocontrato;
				echo "</select></td>";

				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > Justificaci&oacute;n del Contrato: </td>";
				echo "<td colspan=3 align = 'left' ><input type = 'text' name = 'justicontrato' size = '100' maxlength = '100' value = '" . $row['justicontrato'] . "'> </td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";

				echo "<td align = 'right' > Fecha Final Contrato: </td>";
				echo "<td align = 'left'>";
				$valor = (unir_fecha($row['fechac']) == '00000000' ? '' : unir_fecha($row['fechac']));
				escribe_formulario_fecha_modifica("feccon", "entrada", $valor);
				echo "</td>";

				echo "<td align = 'right'>  </td>";
				///////////espacio en blanco
				echo "<td align = 'right'>  </td>";

				echo "</tr>";



				//=================================================================================================///
				echo "<tr bgcolor='#43bced' height='25'>";
				echo "<td colspan=4 align = center><font color='white'><b> DATOS DE NÓMINA Y SALARIOS </b> </font></td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right'> <font color=red>STATUS:</font> </td>";
				echo "<td align = 'left'> <select name = 'status'>";
				if ($row['status'] == "A") echo "<option selected>Activos";
				else echo "<option>Activos";
				if ($row['status'] == "V") echo "<option selected>Vacaciones";
				else echo "<option>Vacaciones";
				if ($row['status'] == "S") echo "<option selected>Suspendidos";
				else echo "<option>Suspendidos";
				if ($row['status'] == "I") echo "<option selected>Inactivos";
				else echo "<option>Inactivos";
				if ($row['status'] == "C") echo "<option selected>Contratados";
				else echo "<option>Contratados";
				echo "</select>";
				echo "</td>";

				////Tipo de Vinculo
				cargar_select_modificar($enlace, "tp", "Tipo vínculo", $row['tp']);

				echo "<tr bgcolor='#ffffffff'>";

				$query = "select * from nomina where id='" . $_SESSION['id_validar'] . "' order by detalle";
				$consulta = mysqli_query($enlace, $query) or die("no se pudo realizar la consulta...");
				$resultado = mysqli_num_rows($consulta);
				echo "<td align = 'right'> <font color=red>N&Oacute;MINA:</font> </td>";
				echo "<td align = 'left'> <select name = 'nomina'>";
				if ($resultado != 0) {
					for ($i = 0; $i < $resultado; $i++) {
						$row1 = mysqli_fetch_array($consulta);
						if ($row1['codigo'] == $row['nomina']) echo "<option width = '30%' selected>" . $row1['codigo'] . " - " . $row1['detalle'];
						else echo "<option width = '30%'>" . $row1['codigo'] . " - " . $row1['detalle'];
					}
				}
				echo "</select>";
				echo "</td>";

				$query = "select * from turno where id='" . $_SESSION['id_validar'] . "' order by detalle";
				$consulta = mysqli_query($enlace, $query) or die("no se pudo realizar la consulta...");
				$resultado = mysqli_num_rows($consulta);

				echo "<td align = 'right'> <font color=blue>Jornada:</font> </td>";
				echo "<td align = 'left'> <select name = 'turno'><option>";
				if ($resultado != 0) {
					for ($i = 0; $i < $resultado; $i++) {
						$row1 = mysqli_fetch_array($consulta);
						if ($row1['codigo'] == $row['turno']) echo "<option width = '30%' selected>" . $row1['codigo'] . " - " . $row1['detalle'];
						else echo "<option width = '30%'>" . $row1['codigo'] . " - " . $row1['detalle'];
					}
				}
				echo "</select>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > <font color=blue>Salario Mes: </td></font>";
				echo "<td align = 'left'  > <input type = 'text' name = 'smes' size = '30' maxlength = '30' value = '" . $row['smes'] . "' readonly><font color='red'> ** </td>";
				//cargar_select_modificar($enlace,"sector","Tipo de Salario", $row['sector']);

				echo "<td align = 'right' >Tipo Salario: </td>";
				echo "<td align = 'left'>";
				echo "<select name = 'sector'>";
				echo "<option value='' " . ($row['sector'] == '' ? 'selected' : '') . ">";
				echo "<option value='1000' " . ($row['sector'] == '1000' ? 'selected' : '') . "> SALARIO FIJO";
				echo "<option value='2000' " . ($row['sector'] == '2000' ? 'selected' : '') . "> SALARIO VARIABLE";
				echo  "</select></td>";
				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > <font color=blue>Salario Diario: </td></font>";
				echo "<td align = 'left'  > <input type = 'text' name = 'sdia' size = '30' maxlength = '30' value = '" . $row['sdia'] . "' readonly><font color='red'> ** </td>";
				//cargar_select_modificar($enlace,"sector","Tipo de Salario", $row['sector']);

				echo "<td align = 'right' > </td>";
				echo "<td align = 'left'> </td>";
				echo "</tr>";

				echo "</tr>";
				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > <font color=blue>PXCP: </td></font>";
				echo "<td align = 'left'  > <input type = 'text' name = 'bono1' size = '30' maxlength = '30' value = '" . $row['bono1'] . "'></td>";
				echo "<td align = 'right' > <font color=blue>PXLG: </td></font>";
				echo "<td align = 'left'  > <input type = 'text' name = 'bono2' size = '30' maxlength = '30' value = '" . $row['bono2'] . "'></td>";
				echo "</tr>";
				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > <font color=blue>Grado salarial: </td></font>";
				echo "<td align = 'left'>";
				echo "<select name = 'grado_salar'>";

				echo "<option value='' " . ($row['grado_salar'] == '' ? 'selected' : '') . ">";
				echo "<option value='001' " . ($row['grado_salar'] == '001' ? 'selected' : '') . "> 001";
				echo "<option value='002' " . ($row['grado_salar'] == '002' ? 'selected' : '') . "> 002";
				echo "<option value='003' " . ($row['grado_salar'] == '003' ? 'selected' : '') . "> 003";
				echo "<option value='004' " . ($row['grado_salar'] == '004' ? 'selected' : '') . "> 004";
				echo "<option value='005' " . ($row['grado_salar'] == '005' ? 'selected' : '') . "> 005";
				echo "<option value='006' " . ($row['grado_salar'] == '006' ? 'selected' : '') . "> 006";
				echo "<option value='007' " . ($row['grado_salar'] == '007' ? 'selected' : '') . "> 007";
				echo "<option value='008' " . ($row['grado_salar'] == '008' ? 'selected' : '') . "> 008";
				echo "<option value='051' " . ($row['grado_salar'] == '051' ? 'selected' : '') . "> 051";
				echo "<option value='LL5' " . ($row['grado_salar'] == 'LL5' ? 'selected' : '') . "> LL5";
				echo "<option value='LL6' " . ($row['grado_salar'] == 'LL6' ? 'selected' : '') . "> LL6";

				echo  "</select></td>";

				echo "<td align = 'right' >Líder: </td>";
				echo "<td align = 'left'>";
				echo "<select name = 'lider'>";
				echo "<option value='' " . ($row['lider'] == '' ? 'selected' : '') . ">";
				echo "<option value='LG' " . ($row['lider'] == 'LG' ? 'selected' : '') . "> Líder grupo";
				echo "<option value='LM' " . ($row['lider'] == 'LM' ? 'selected' : '') . "> Líder manufac";
				echo  "</select></td>";

				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";
				echo "<td align = 'right' > Employee Type: </td></font>";
				echo "<td align = 'left'>";
				echo "<select name = 'empl_type'>";

				echo "<option value='' " . ($row['empl_type'] == '' ? 'selected' : '') . ">";
				echo "<option value='1' " . ($row['empl_type'] == '1' ? 'selected' : '') . "> Hourly";
				echo "<option value='2' " . ($row['empl_type'] == '2' ? 'selected' : '') . "> Salaried";


				echo  "</select></td>";

				echo "<td align = 'right' >Skill Team (Job Function): </td>";
				echo "<td align = 'left'>";
				echo "<select name = 'skill_team'>";

				echo "<option value='' " . ($row['skill_team'] == '' ? 'selected' : '') . ">";
				echo "<option value='CSV' " . ($row['skill_team'] == 'CSV' ? 'selected' : '') . "> CSV";
				echo "<option value='FIN' " . ($row['skill_team'] == 'FIN' ? 'selected' : '') . "> FIN";
				echo "<option value='GCR' " . ($row['skill_team'] == 'GCR' ? 'selected' : '') . "> GCR";
				echo "<option value='HRS' " . ($row['skill_team'] == 'HRS' ? 'selected' : '') . "> HRS";
				echo "<option value='ITS' " . ($row['skill_team'] == 'ITS' ? 'selected' : '') . "> ITS";
				echo "<option value='MFG' " . ($row['skill_team'] == 'MFG' ? 'selected' : '') . "> MFG";
				echo "<option value='MSS' " . ($row['skill_team'] == 'MSS' ? 'selected' : '') . "> MSS";
				echo "<option value='OGC' " . ($row['skill_team'] == 'OGC' ? 'selected' : '') . "> OGC";
				echo "<option value='OTH' " . ($row['skill_team'] == 'OTH' ? 'selected' : '') . "> OTH";
				echo "<option value='PUR' " . ($row['skill_team'] == 'PUR' ? 'selected' : '') . "> PUR";

				echo "</tr>";

				echo "<tr bgcolor='#ffffffff'>";

				echo "<td align = 'right' > Fecha de Egreso: </td>";
				echo "<td align = 'left'>";
				$valor = (unir_fecha($row['fechae']) == '00000000' ? '' : unir_fecha($row['fechae']));
				escribe_formulario_fecha_modifica("fecegr", "entrada", $valor);
				echo "</td>";

				echo "<td align = 'right' ><font color=red>Motivo de retiro : <font color='red'> * </td>";
				echo "<td align = 'left'>";
				echo "<select name = 'motivoretiro'>";
				echo "<option value='' " . ($row['motivoretiro'] == '?' ? 'selected' : '') . ">";
				echo "<option value='50' " . ($row['motivoretiro'] == '50' ? 'selected' : '') . "> DESPIDO";
				echo "<option value='51' " . ($row['motivoretiro'] == '51' ? 'selected' : '') . "> RENUNCIA";
				echo "<option value='52' " . ($row['motivoretiro'] == '52' ? 'selected' : '') . "> MUERTE ACCIDENTAL";
				echo "<option value='53' " . ($row['motivoretiro'] == '53' ? 'selected' : '') . "> MUERTE NATURAL";
				echo "<option value='54' " . ($row['motivoretiro'] == '54' ? 'selected' : '') . "> MUERTE RAZONES DESCONOCIDAS";
				echo "<option value='55' " . ($row['motivoretiro'] == '55' ? 'selected' : '') . "> DESPIDO ART NRO ????";
				echo "<option value='56' " . ($row['motivoretiro'] == '56' ? 'selected' : '') . "> REDUCCION PERSONAL";
				echo "<option value='57' " . ($row['motivoretiro'] == '57' ? 'selected' : '') . "> CULMINACION PRACTICA/SERVICIOS";
				echo "<option value='58' " . ($row['motivoretiro'] == '58' ? 'selected' : '') . "> CULMINACION CONTRATO/TIEMPO DETERMINADO";
				echo "<option value='59' " . ($row['motivoretiro'] == '59' ? 'selected' : '') . "> MUTUO ACUERDO/JUBILACION";
				echo "<option value='60' " . ($row['motivoretiro'] == '60' ? 'selected' : '') . "> CULMINACION PASANTIAS";
				echo "<option value='61' " . ($row['motivoretiro'] == '61' ? 'selected' : '') . "> RENUNCIA APRENDIZ";
				echo "<option value='62' " . ($row['motivoretiro'] == '62' ? 'selected' : '') . "> CULMINACION ASIGNACION";
				echo "</tr>";

				echo "</table><br><br>";

				echo "<table width = '20%' align ='center'>";
				echo "<tr><td><input type = 'submit' class='boton' value = 'Guardar Cambios' " . (substr($_SESSION['acceso_validar'], 17, 1) == '1' ? '' : 'disabled') . "></td></form><td>&nbsp;&nbsp;&nbsp;</td>";
				echo "<form name = 'regresar' method = 'POST' action = '" . $_SERVER['PHP_SELF'] . "'>";
				echo "<td><input type = 'submit' class='boton' value = 'Regresar al Inicio'></td></tr></form>";
				echo "	<script language='javascript' type='text/javascript'>";
				echo "		document.entrada.nombres.focus()";
				echo "	</script>";
			}
		}

		////////////////////////////////////////// busca por filtros en tabla de registros ////////////////////////////////////////////////////////////////
		if ((!$_POST || $_POST['busca'] == 1 || $_POST['graba'] == 1 || $_POST['modifica'] == 1 || $_POST['bandera'] == 3 || $_POST['bandera'] == 33) && $accion != 3 && $accion != 11) {

			if (obtener_valor_diccionario($_POST, 'modifica') == 1) obtener_valor_diccionario($_POST, 'cedula') == '';

			if (obtener_valor_diccionario($_POST, 'busca') == 1) {
				echo "<form name = 'entrada' action = '" . $_SERVER['PHP_SELF'] . "' method = 'POST'  enctype='multipart/form-data'>";
				echo "<input type = 'hidden' name = 'busca' value = '1'>";
				echo "<table cellpadding=2 cellspacing=0 width='500' align='center'>";
				echo "<tr>";
				echo "<td align=right> C&eacute;dula/Nombre/Apellido:</td>";
				echo "<td> <input name='cedula' id='cedula' size='30' maxlength='12' onkeyup='buscarEmpleado(this.value)'>
			<div id='sugerencias' style='background:white; border:0px solid #ccc; position:absolute; width:300px; z-index:1000;'></div></td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td align=right> Ordenado por:</td>";
				echo "<td>";
				echo "	<input type = 'radio' name = 'orden' value = 'ced' " . ($_POST['orden'] == 'ced' ? 'checked' : '') . "> cedula";
				echo "	<input type = 'radio' name = 'orden' value = 'nom' " . ($_POST['orden'] == 'nom' ? 'checked' : '') . "> nombre";
				echo "	<input type = 'radio' name = 'orden' value = 'ape' " . ($_POST['orden'] == 'ape' ? 'checked' : '') . "> apellido";
				echo "	<input type = 'radio' name = 'orden' value = 'fechai' " . ($_POST['fechai'] == 'fechai' ? 'checked' : '') . "> Fecha Ingreso";
				echo "</td>";
				echo "</tr>";
				echo "</table>";
				echo "	<script language='javascript' type='text/javascript'>";
				echo "		document.entrada.cedula.focus()";
				echo "	</script>";
				echo "<table border=0  align = 'center'><tr>";
				echo "<td colspan='3'><input type='submit' class='boton' value='Buscar'></td>";
				echo "</form></table>";
			}

			$query1 = "";
			if (obtener_valor_diccionario($_POST, 'cedula') != "") {
				$query1 .= " and (codigo like '%" . $_POST['cedula'] . "%' or nombres like '%" . $_POST['cedula'] . "%' or apellidos like '%" . $_POST['cedula'] . "%') ";
			}
			if (obtener_valor_diccionario($_POST, 'orden') == "ced") $query2 = " order by codigo";
			else if (obtener_valor_diccionario($_POST, 'orden') == "nom") $query2 = " order by nombres";
			else if (obtener_valor_diccionario($_POST, 'orden') == "ape") $query2 = " order by apellidos";
			else if (obtener_valor_diccionario($_POST, 'orden') == "fechai") $query2 = " order by fechai";
			else $query2 = " order by nombres";

			$query3 = '';
			if ($_SESSION['nom01_validar'] != '') $query3 = " and nomina!='" . $_SESSION['nom01_validar'] . "' ";

			$consulta = "select * from personal where status<>'I' and id='" . $_SESSION['id_validar'] . "' " . $query1 . $query3 . $query2;
			$resultado = mysqli_query($enlace, $consulta) or die('verificaci&oacute; del c&oacute;digo fall&oacute;: ' . mysqli_error($enlace));
			$num_rows = mysqli_num_rows($resultado);
			if ($num_rows != 0) {
				echo "<table rules=none border=0 cellpadding=2 cellspacing=0 align='center'>";
				echo "<tr class='encabezadoTabla'>";
				echo "<th>#</th>";
				echo "<th>Foto</th>";
				echo "<th>Cédula</th>";
				echo "<th>Nombres</th>";
				echo "<th>Apellidos</th>";
				echo "<th>Sueldo</th>";
				echo "<th>Status</th>";
				echo "<th>Fec. Ingreso</th>";
				echo "<th colspan = 6 align = right><font color='white'> Acci&oacute;n</th>";
				echo "</tr>";
				
				for ($cont = 0; $cont < $num_rows; $cont++) {
					$row = mysqli_fetch_array($resultado);
					$cedula = $row['codigo'];
					if ($color) {
						$tcolor = "#CFE7DE";
						if (file_exists('fotos/' . $cedula . '.jpg')) $imagen = 'fotos/' . $cedula . '.jpg';
						else $imagen = 'img2/nohay2.jpg';
					} else {
						$tcolor = "white";
						if (file_exists('fotos/' . $cedula . '.jpg')) $imagen = 'fotos/' . $cedula . '.jpg';
						else $imagen = 'img2/nohay.jpg';
					}
					echo '<tr bgcolor=' . $tcolor . ' >';
					echo "<td width='20' class='numeroFila'>" . ($cont + 1) . "</td>";
					echo "<td align'center'><a href='" . $_SERVER['PHP_SELF'] . "?accion=33&cedula=" . $cedula . "'><img src='" . $imagen . "' height='64' width='64' style='border-radius:50%;'></a></td>";
					//echo "<td width='100'>".$row['sso']."</td>";
					echo "<td width='100'><a href='" . $_SERVER['PHP_SELF'] . "?accion=3&cedula=" . $cedula . "&orden=" . obtener_valor_diccionario($_POST, 'orden') . "&gerencia=" . obtener_valor_diccionario($_POST, 'gerenciax') . "'>" . obtener_valor_diccionario($row, 'codigo') . "</a></td>";
					echo "<td width='250'>" . (trim($row['nombres']) . " " . $row['nombres1']) . "</td>";
					echo "<td width='250'>" . (trim($row['apellidos']) . " " . $row['apellidos1']) . "</td>";
					echo "<td width='100'>" . number_format($row['smes'], 2) . "</td>";
					//echo "<td width='50' align='center'>".($row['status']=='A'?'<img src="img2/status_ver.png">':'<img src="img2/status_ver_naranja.png">')."</td>";
					if ($row['status'] == 'A') {
						echo "<td width='50' align='center'><img src=img2/status_ver_doble_zaul.png></td>";
					} elseif ($row['status'] == 'C') {
						echo "<td width='50' align='center'><img src=img2/status_ver.png></td>";
					} elseif ($row['status'] == 'S') {
						echo "<td width='50' align='center'><img src=img2/status_ver_naranja.png></td>";
					}
					echo "<td width='120' align=center>" . mostrar_fecha($row['fechai']) . "</td>";

					if (substr($_SESSION['acceso_validar'], 18, 1) == '1')
						echo "<td width='30' align='center'><a onclick='return validar_elimina()' href='" . $_SERVER['PHP_SELF'] . "?accion=2&cedula=" . $cedula . "'><img  border = 0  src='img2/trabajador_inactivo.png'alt='eliminar éste registro' ></a></td>";
					else echo "<td width='30' align='center'>--</td>";

					if (substr($_SESSION['acceso_validar'], 17, 1) == '1')
						echo "<td width='30' align='center'><a href='" . $_SERVER['PHP_SELF'] . "?accion=3&cedula=" . $cedula . "&orden=" . obtener_valor_diccionario($_POST, 'orden') . "&gerencia=" . obtener_valor_diccionario($_POST, 'gerenciax') . "'><img border = 0 src='img2/modificar_editar.png' alt='modificar éste registro' title='Actualizar datos'></a></td>";
					else echo "<td width='30' align='center'>--</td>";

					echo "<td width='30' align='center'><a href='archivo_trabajador_ficha.php?cedula=" . $cedula . "' target='_blank'><img border = 0 src='img2/ficha_empleado.png' alt='Ficha' title='Imprimir Ficha Trabajador'></a></td>";

					echo "<td width='30' align='center'><a href='archivo_trabajador_constancia.php?accion=1&cedula=" . $cedula . "'><img border = 0 src='img2/constancia_trabajo.png' alt='Constancia' title='Constancia de Trabajo'></a></td>";

					if (substr($_SESSION['acceso_validar'], 7, 1) == '1')
						echo "<td width='30' align='center'><a href='archivo_trabajador_sueldo_cambiar.php?cedula=" . $cedula . "'><img border = 0 src='img2/sueldos.png' alt='modificar Sueldo' title='Modificar Sueldo'></a></td>";
					else echo "<td width='30' align='center'>--</td>";

					if ($row['contrato'] == '') {
						if (substr($_SESSION['acceso_validar'], 17, 1) == '1')
							echo "<td width='30' align='center'><a href='" . $_SERVER['PHP_SELF'] . "?accion=3&cedula=" . $cedula . "&orden=" . obtener_valor_diccionario($_POST, 'orden') . "&gerencia=" . obtener_valor_diccionario($_POST, 'gerenciax') . "'><img border = 0 src='img2/sincontrato.png' alt='Contrato' title='Agregar contarto'></a></td>";
						else echo "<td width='30' align='center'>--</td>";
						
					} else echo "<td width='30' align='center'><a href='archivo_trabajador_contratos_imprimir.php?cedula=" . $cedula . "&contrato=" . $row['nrocontrato'] . "' target='blank'><img border = 0 src='img2/contrato.png' alt='Contrato' title='Imprimir Contrato'></a></td>";

					echo '</tr>';
					$color=!$color;
				}
				echo '</table>';
				echo "<center>Status: <img src='img2/status_ver_doble_zaul.png'>(Fijo-Indefinido)  -  <img src='img2/status_ver.png'>(Contratado)  -  <img src='img2/status_ver_naranja.png'>(Suspendido)</center><br>";

				/* echo "<form name='imprimir' method='post' target ='_blank' action='" . $_SERVER['PHP_SELF'] . "' enctype='multipart/form-data'>";
				echo "  <input type = 'hidden' name = 'imprime' value = '1'>";
				echo "<center><input type = 'submit' value = 'Imprimir Resultado'></center></form>"; */
			} else echo "<hr>";
			mysqli_free_result($resultado);
		}
	} //=========================== CARGAR FOTOS=================================
	mysqli_close($enlace);
	echo "</font>";
	echo "</body>";
	echo "</html>";
}
?>
	<style>
	.numeroFila {
		color: black;
		font-weight: bold;
	}

	.boton {
    border-radius: 8px;      /* Bordes redondeados */
    padding: 8px 16px;       /* Más espacio interno */
    border: none;            /* Quita el borde feo por defecto */
    cursor: pointer;         /* Mano al pasar */
    transition: 0.2s ease;   /* Animación suave */
	}

	.boton:hover {
	transform: scale(1.03);  /* Efecto sutil al pasar el mouse */
	}

/*Encabezado tablas */
	.encabezadoTabla {
    background: #43bced;
    height: 35px;
}

.encabezadoTabla th {
    padding: 8px 12px;
    text-align: left;
    color: white;
    font-weight: bold;
    font-size: 14px;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #2fa3c9;
}

.encabezadoTabla th:nth-child(1),
.encabezadoTabla th:nth-child(2),
.encabezadoTabla th:nth-child(7),
.encabezadoTabla th:nth-child(8) {
    text-align: center;
}
/*hasta aquí Encabezado tablas */

</style>

<!--Script JavaScript para hacer predictivo el cuadro de búsqueda de empleados -->
<script>
function buscarEmpleado(texto) {
    if (texto.length < 2) {
        document.getElementById("sugerencias").innerHTML = "";
        return;
    }

    var xhr = new XMLHttpRequest();
    xhr.open("POST", "buscar_empleado.php", true);
    xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

    xhr.onreadystatechange = function() {
        if (xhr.readyState == 4 && xhr.status == 200) {
            document.getElementById("sugerencias").innerHTML = xhr.responseText;
        }
    };

    xhr.send("q=" + texto);
}
</script>
