<?php 
session_start();
//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 ($_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($_POST['nomina'],6,100)==""?$_SESSION['empresa_validar']:substr($_POST['nomina'],6,100)) ;
	}   
	require('fpdf.php');

	class PDF extends FPDF {
	function Header()
	{
	    $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 RETIRADOS',0,1,'C');$this->Ln(5);
	    $header=array('Item','Cédula','Nombres','Apellidos','Cargo','Fecha ingreso','Fecha egreso');
	    $this->SetFillColor(255,0,0);
	    $this->SetTextColor(255);
	    $this->SetDrawColor(128,0,0);
	    $this->SetLineWidth(.3);
	    $this->SetFont('','');
	    //Cabecera
	    $w=array(10,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 id='".$_SESSION['id_validar']."' and status='I' order by codigo");
	$linea=0;
	$color=0;
	while($row=mysqli_fetch_array($consulta)) {
		$linea++;
		$tcargo=$row['cargo'];
		$pdf->cell(10,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(30,5,$row['apellidos'],0,0,'',$color);
		$cons1=mysqli_query($enlace,"select tablas.detalle as car from tablas where id='".$_SESSION['id_validar']."' and codigo='".$row['cargo']."' and tabla='CARGO'" ) ;
		while($row1=mysqli_fetch_array($cons1))
		$pdf->cell(50,5,$row1['car'],0,0,'L',$color);
		$pdf->cell(20,5,$row['fechai'],0,0,'C',$color);
		$pdf->cell(20,5,$row['fechae'],0,1,'C',$color);
		$color=!$color;
	}
	$pdf->Output();
}
else {
$accion=$_REQUEST["accion"];
$codigo=$_REQUEST["codigo"];
$cedula=$_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;


///////////////////////////////////////////////// ACTUALIZAR TRABAJADOR ////////////////////////////////////////////////////////////////
echo "<b>Opciones:</b>&nbsp;&nbsp;<img border = 0 src='img2/desactivar.png' alt='Modificar'>&nbsp;Seleccionar Trabajador";
//echo "&nbsp;&nbsp;<img border = 0 src='img2/icono_06.png' alt='Constancia'>&nbsp;Imprimir Constancia de trabajo";
echo "<hr><h2 align = 'center'>REACTIVACI&Oacute;N DE TRABAJADORES RETIRADOS</h2>";
echo "<tr bgcolor='#F5F6CE'>";
			echo "<td><h3 align='center'><font color=red>IMPORTANTE</h3></td>";
		echo "</tr>";
		
		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td ><h5 align='center'>La reactivaci&oacute;n de cualquier trabajador conlleva a la continuidad de su &uacute;ltimo contrato, esta acci&oacute;n har&aacute; que se conserve su hist&oacute;rico de prestaciones sociales, hist&oacute;rico</h5></td>";
		echo "</tr>";
		
		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td  ><h5 align='center'>de salarios, vacaciones y todo su historial, el trabajador voler&aacute; a estar activo en la n&oacute;mina y conservar&aacute; la misma fecha de ingreso y antig&uuml;edad en la empresa.</h5></td>";
		echo "</tr>";

		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td  ><h5 align='center'>Si desea REINGRESAR o RECONTRATAR a un trabajador vinculado a un nuevo contrato, debe solicitar la desvinculaci&oacute;n con su contato e historial anterior a trav&eacute;s de </h5></td>";
		echo "</tr>";
		
		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td  ><h5 align='center'>una solicitud de SOPORTE indicando su Nro. de C.I. haciendo <a style='color:red;text-decoration:none' href='menu_soporte.php'><font color=blue><b>CLICK AQU&Iacute;</b></font></a></h5></td></font>";
		echo "</tr>";


///////////////////////////////////////////////// actualizar registros  ////////////////////////////////////////////////////////////////
if ($_POST['modifica']==1 ) {
	$consulta3=mysqli_query($enlace,"select * from periodo where id='".$_SESSION['id_validar']."' and nomina='".substr($_POST['nomina'],0,3)."' 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 = "update personal set status = ucase(trim('".$_POST['status']."')) where id='".$_SESSION['id_validar']."' and codigo = '".$_POST['cedula']."'";
		mysqli_query($enlace, $query) or die (mysqli_error($enlace).$query);
	}	
}

///////////////////////////////////////////////// eliminar registros ////////////////////////////////////////////////////////////////
if ($accion==2) { 
	$consulta="select cedula from historico where id='".$_SESSION['id_validar']."' and cedula='".$cedula."' ";
	$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 id='".$_SESSION['id_validar']."' and codigo='".$cedula."' ";
		$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' size = '30' maxlength = '8'></td>";
	echo "</tr>";
	echo "<tr>";
		echo "<td align=right> Ordenado por:</td>";
		echo "<td>";
		echo "	<input type = 'radio' name = 'orden' value = 'ced' checked> cedula";
		echo "	<input type = 'radio' name = 'orden' value = 'nom'> nombre";
		echo "	<input type = 'radio' name = 'orden' value = 'ape'> apellido";
		echo "	<input type = 'radio' name = 'orden' value = 'fechae'> Fecha Egreso";
	echo "</tr>";
	echo "<tr>";
		echo "<td> </td>";
		echo "<td colspan=3><input type='image' src='img2/boton_buscar.jpg' value='Entrar' ></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>";	
	
}

	
///////////////////////////////////////////////// modificar registros ////////////////////////////////////////////////////////////////
if ($accion==3) {
	include ("calendario/calendario.php");
	$consulta="select * from personal where id='".$_SESSION['id_validar']."' and codigo='".$cedula."' ";
	$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) {
		$row=mysqli_fetch_array($resultado);
		echo "<form name = 'entrada' action = '".$_SERVER['PHP_SELF']."' method = 'POST'  enctype='multipart/form-data' >";
		echo "<input type = 'hidden' name = 'modifica' value = '1'>";

		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='red' height='25'>";
		echo "<td colspan=4 align = center><font color='white'> Datos Personales </font></td>";
		echo "</tr>";

		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td  align = 'right'> C&eacute;dula: </td>";
			echo "<td  align = 'left'> <input type = 'text' name = 'cedula' size = '30' maxlength = '8' readonly value = '".$row['codigo']."' readonly> * </td>";
			echo "<td align = 'right' > Nacionalidad: </td>";
			echo "<td align = 'left'>";
			echo "<select name = 'nacionalidad'>";
				echo "<option value='V' ".($row['nacionalidad'] != 'E'?'selected':'')."> Venezolano(a)"; 
				echo "<option value='E' ".($row['nacionalidad'] == 'E'?'selected':'')."> Extranjero(a)"; 
			echo  "</select></td>";				
		echo "</tr>";
		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td  align = 'right'> Nombre: </td>";
			echo "<td  align = 'left'> <input type = 'text' name = 'nombres' size = '30' maxlength = '50' value = '".$row['nombres']."' readonly> * </td>";
			echo "<td  align = 'right'> Segundo Nombre: </td>";
			echo "<td  align = 'left'> <input type = 'text' name = 'nombres1' size = '30' maxlength = '50' value = '".$row['nombres1']."' readonly>  </td>";
		echo "</tr>";
		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td align = 'right'> Apellido: </td>";
			echo "<td align = 'left'> <input type = 'text' name = 'apellidos' size = '30' maxlength = '50' value = '".$row['apellidos']."' readonly> * </td>";
			echo "<td align = 'right'> Segundo Apellido: </td>";
			echo "<td align = 'left'> <input type = 'text' name = 'apellidos1' size = '30' maxlength = '50' value = '".$row['apellidos1']."' readonly>  </td>";
		echo "</tr>";
		
			////////////////////DESACTIVADOS ESTOS CAMPOS EN LA VISTA --- MIGUELANGEL 27/08/2020
			/*

		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td align = 'right'> Edo. Civil: </td>";
			if ($row['edocivil']=='1'){
				echo "<td align = 'left'> <input type = 'text' name = 'edocivil' size = '30' maxlength = '50' value = 'Soltero(a)' readonly> </td>";
				}
			elseif ($row['edocivil']=='2'){
				echo "<td align = 'left'> <input type = 'text' name = 'edocivil' size = '30' maxlength = '50' value = 'Casado(a)' readonly> </td>";
				}
			elseif ($row['edocivil']=='3'){
				echo "<td align = 'left'> <input type = 'text' name = 'edocivil' size = '30' maxlength = '50' value = 'Viudo(a)' readonly> </td>";
				}
			elseif ($row['edocivil']=='4'){
				echo "<td align = 'left'> <input type = 'text' name = 'edocivil' size = '30' maxlength = '50' value = 'Divorciado(a)' readonly> </td>";
				}
			elseif ($row['edocivil']=='5'){
				echo "<td align = 'left'> <input type = 'text' name = 'edocivil' size = '30' maxlength = '50' value = 'Uni&oacute;n Libre' readonly> </td>";
				}
			else 
				echo "<td align = 'left'> <input type = 'text' name = 'edocivil' size = '30' maxlength = '50' value = '--' readonly> </td>";
				
			echo "<td align = 'right'> Fecha Nacimiento: </td>";
			echo "<td align = 'left'> <input type = 'text' name = 'fechan' size = '30' maxlength = '50' value = '".$row['fechan']."' readonly> * </td>";
		echo "</tr>";
		
		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td align = 'right'> Sexo: </td>";
			echo "<td align = 'left'> <input type = 'text' name = 'sexo' size = '30' maxlength = '50' value = '".$row['sexo']."' readonly> * </td>";
			echo "<td align = 'right'> Nro. de Hijos: </td>";
			echo "<td align = 'left'> <input type = 'text' name = 'hijo' size = '30' maxlength = '50' value = '".$row['hijo']."' readonly>  </td>";
		echo "</tr>";
		*/ 
		///////////////////////////////////////CAMPOS DESACTIVADOS EN LA VISTA
		
		
		echo "<tr bgcolor='red' height='25'>";
		echo "<td colspan=4 align = center><font color='white'> Datos de N&oacute;mina y Contrato</font></td>";
		echo "</tr>";
		
		echo "<tr bgcolor='#F5F6CE' readonly>";	
			cargar_select_modificar($enlace,"departamento","Departamento:", $row['departamento']); 
			cargar_select_modificar($enlace,"cargo","Cargo", $row['cargo']); 
		echo "</tr>";
		
		echo "<tr bgcolor='#F5F6CE' readonly>";
				echo "<td align = 'right' > Fecha de Ingreso: </td>";
				echo "<td align = 'left'> <input type = 'text' name = 'fechai' size = '30' maxlength = '50' value = '".$row['fechai']."' readonly> * </td>";
				echo "<td align = 'right' > Fecha de Retiro: </td>";
				echo "<td align = 'left'> <input type = 'text' name = 'fechae' size = '30' maxlength = '50' value = '".$row['fechae']."' readonly> * </td>";
		echo "</tr>";
		
		echo "<tr bgcolor='#F5F6CE' readonly>";

				echo "<td align = 'right' >Salario Mes: </td>";
				echo "<td align = 'left'> <input type = 'text' name = 'smes' size = '30' maxlength = '30' value = '".$row['smes']."' readonly></td>";
				
				cargar_select_modificar($enlace,"sector","Tipo Salario", $row['sector']);
				
			echo "</tr>";
		echo "</tr>";
		
		echo "<tr bgcolor='#F5F6CE' readonly>";
					$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'> Contrato: </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' >Nro. Contrato: </td>";
					echo "<td align = 'left'> <input type = 'text' name = 'nrocontrato' size = '30' maxlength = '30' value = '".$row['nrocontrato']."' readonly></td>";

		echo "</tr>";

			/* 
			////////////////////DESACTIVADOS ESTOS CAMPOS EN LA VISTA --- MIGUELANGEL 27/08/2020
		echo "<tr bgcolor='red' height='25'>";
		echo "<td colspan=4 align = center><font color='white'> Datos de Direcci&oacute;n y contacto</font></td>";
		echo "</tr>";
		
		echo "<tr bgcolor='#F5F6CE'>";	
			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']."' readonly></td>";		
		echo "</tr>";
		
		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td align = 'right' > Tel&eacute;fono: </td>";
			echo "<td align = 'left' > <input type = 'text' name = 'telefono' size = '30' maxlength = '50' value = '".$row['telefono']."'readonly></td>";
			
			echo "<td align = 'right' > Email: </td>";
			echo "<td align = 'left' ><input type = 'text' name = 'email' size = '30' maxlength = '50' value = '".$row['mensaje']."'readonly> </td>";

		echo "</tr>";
		
		echo "<tr bgcolor='red' height='25'>";
		echo "<td colspan=4 align = center><font color='white'> Datos Bancarios</font></td>";
		echo "</tr>";
		
				echo "<tr bgcolor='#F5F6CE' readonly>";
					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' > Entidad Bancaria: </td>";
					echo "<td align = 'left'>";
					echo "<select name = 'banco'>";
						echo "<option value='' ".($row['banco'] == ''?'selected':'').">"; 
						echo "<option value='1' ".($row['banco'] == '1'?'selected':'')."> 100%BANCO"; 
						echo "<option value='2' ".($row['banco'] == '2'?'selected':'')."> BANCAMIGA BANCO MICROFINANCIERO, C.A."; 
						echo "<option value='3' ".($row['banco'] == '3'?'selected':'')."> BANCO AGRICOLA"; 
						echo "<option value='4' ".($row['banco'] == '4'?'selected':'')."> BANCO BICENTENARIO"; 
						echo "<option value='5' ".($row['banco'] == '5'?'selected':'')."> BANCO CARONI, C.A. BANCO UNIVERSAL"; 
						echo "<option value='6' ".($row['banco'] == '6'?'selected':'')."> BANCO DE VENEZUELA";
						echo "<option value='7' ".($row['banco'] == '7'?'selected':'')."> BANCO DEL CARIBE C.A.";
						echo "<option value='8' ".($row['banco'] == '8'?'selected':'')."> BANCO DEL PUEBLO SOBERANO C.A.";
						echo "<option value='9' ".($row['banco'] == '9'?'selected':'')."> BANCO DEL TESORO";
						echo "<option value='10' ".($row['banco'] == '10'?'selected':'')."> BANCO EXTERIOR C.A.";
						echo "<option value='11' ".($row['banco'] == '11'?'selected':'')."> BANCO INDUSTRIAL DE VENEZUELA.";
						echo "<option value='12' ".($row['banco'] == '12'?'selected':'')."> BANCO MERCANTIL C.A.";
						echo "<option value='13' ".($row['banco'] == '13'?'selected':'')."> BANCO NACIONAL DE CREDITO";
						echo "<option value='14' ".($row['banco'] == '14'?'selected':'')."> BANCO OCCIDENTAL DE DESCUENTO.";
						echo "<option value='15' ".($row['banco'] == '15'?'selected':'')."> BANCO PLAZA";
						echo "<option value='16' ".($row['banco'] == '16'?'selected':'')."> BANCO PROVINCIAL BBVA";
						echo "<option value='17' ".($row['banco'] == '17'?'selected':'')."> BANCO VENEZOLANO DE CREDITO S.A.";
						echo "<option value='18' ".($row['banco'] == '18'?'selected':'')."> BANCRECER S.A. BANCO DE DESARROLLO";
						echo "<option value='19' ".($row['banco'] == '19'?'selected':'')."> BANESCO BANCO UNIVERSAL";
						echo "<option value='20' ".($row['banco'] == '20'?'selected':'')."> BANFANB";
						echo "<option value='21' ".($row['banco'] == '21'?'selected':'')."> BANPLUS BANCO COMERCIAL C.A.";
						echo "<option value='22' ".($row['banco'] == '22'?'selected':'')."> CITIBANK";
						echo "<option value='23' ".($row['banco'] == '23'?'selected':'')."> DELSUR BANCO UNIVERSAL";
						echo "<option value='24' ".($row['banco'] == '24'?'selected':'')."> FONDO COMUN";
						echo "<option value='25' ".($row['banco'] == '25'?'selected':'')."> SOFITASA";
					echo  "</select></td>";				
				echo "</tr>";
				echo "<tr bgcolor='#F5F6CE' readonly>";
					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 = '30' value = '".$row['cuenta']."'></td>";
				echo "</tr>";

			*/ /////////////////////////////////////////////////////////////////CAMPOS DESACTIVADOS EN LA VISTA
		
		echo "<tr bgcolor='red' height='25'>";
		echo "<td colspan=4 align = center><font color='white'> CAMBIO DE ESTATUS/REACTIVACI&Oacute;N</font></td>";
		echo "</tr>";		
		
		
		echo "<tr bgcolor='#F5F6CE'>";
			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>";
			
			echo "<td>";
			echo "</td>";
			echo "<td>";
			echo "</td>";			
		echo "</tr>";
			
		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td colspan=4><h3 align='center'>IMPORTANTE</h3></td>";
		echo "</tr>";
		
		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td colspan=4 align='left'><h5>La reactivaci&oacute;n de cualquier trabajador conlleva a la continuidad de su &uacute;ltimo contrato, esta acci&oacute;n har&aacute; que se conserve su hist&oacute;rico de prestaciones sociales, hist&oacute;rico</h5></td>";
		echo "</tr>";
		
		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td colspan=4 align='left'><h5>de salarios, vacaciones y todo su historial, el trabajador voler&aacute; a estar activo en la n&oacute;mina y conservar&aacute; la misma fecha de ingreso y antig&uuml;edad en la empresa.</h5></td>";
		echo "</tr>";

		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td colspan=4 align='left'><h5>Si desea REINGRESAR o RECONTRATAR a un trabajador vinculado a un nuevo contrato, debe solicitar la desvinculaci&oacute;n con su contato e historial anterior a trav&eacute;s de </h5></td>";
		echo "</tr>";
		
		echo "<tr bgcolor='#F5F6CE'>";
			echo "<td colspan=4 align='left'><h5>una solicitud de SOPORTE indicando su Nro. de C.I..haciendo <a style='color:red;text-decoration:none' href='menu_soporte.php'><font color=blue><b>CLICK AQU&Iacute;</b></font></a></h5></td>";
		echo "</tr>";
		
		echo "</table><br><br>";
					
		echo "<table width = '20%' align ='center'>";
		echo "<tr><td><input type = 'submit' value = 'Cambiar Estatus' ".(substr($_SESSION['acceso_validar'],17,1)=='1'?'':'disabled')."></td></form>";
		echo "<form name = 'regresar' method = 'POST' action = '".$_SERVER['PHP_SELF']."'>";
		echo "<td><input type = 'submit' value = 'Regresar al Inicio'></td></tr></form>";
		//echo "	<script language='javascript' type='text/javascript'>";
		//echo "		document.entrada.status.focus()";
		//echo "	</script>";
	}
}

////////////////////////////////////////// busca por filtros en tabla de registros ////////////////////////////////////////////////////////////////
if ( (!$_POST || $_POST['busca']==1 || $_POST['graba']==1 || $_POST['modifica']==1 || $_POST['bandera']==3) && $accion!=3 && $accion!=11) {
	
	if ($_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' size = '30' maxlength = '8'></td>";
		echo "</tr>";
		echo "<tr>";
			echo "<td align=right> Ordenado por:</td>";
			echo "<td>";
			echo "	<input type = 'radio' name = 'orden' value = 'ced' checked> cedula";
			echo "	<input type = 'radio' name = 'orden' value = 'nom'> nombre";
			echo "	<input type = 'radio' name = 'orden' value = 'ape'> apellido";
			echo "	<input type = 'radio' name = 'orden' value = 'fechae'> Fecha Egreso";
		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><input type = 'submit' value = 'Buscar Registros'></td>";
		echo "</form></table>";
	}
	
	$query1 = "";
	if ($_POST['cedula'] != "") {
		$query1 = " and (codigo like '%".$_POST['cedula']."%' or nombres like '%".$_POST['cedula']."%' or apellidos like '%".$_POST['cedula']."%') ";
	}
	if ($_POST['orden'] == "ced") $query2 = " order by codigo";
	else if ($_POST['orden'] == "nom") $query2 = " order by nombres";
	else if ($_POST['orden'] == "ape") $query2 = " order by apellidos";
	else if ($_POST['orden'] == "fechae") $query2 = " order by fechae DESC";
	else $query2 = " order by nombres"; 
	
	$consulta="select * from personal where id='".$_SESSION['id_validar']."' and status='I' ".$query1.$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 bgcolor='#43bced' height='35'>";
			echo "<th align = center><font color='white'> Foto </font></th>";
			echo "<th align = left><font color='white'> C&eacute;dula </font></th>";
			echo "<th align = left><font color='white'> Nombres </font></th>";
			echo "<th align = left><font color='white'> Apellidos </font></th>";
			echo "<th align = center><font color='white'> Status </font></th>";
			echo "<th align = center><font color='white'> Fec/Ingreso </font></th>";
			echo "<th align = center><font color='white'> Fec/Egreso </font></th>";
			echo "<th colspan = 1 align = center><font color='white'> Acci&oacute;n </font></th>";
			for ($cont=0;$cont<$num_rows;$cont++) {
				$row = mysqli_fetch_array($resultado);
				$cedula = $row['codigo'];
				if ($color) {
					$tcolor="#dfdfd0";
					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 align'center'><a href='".$_SERVER['PHP_SELF']."?accion=33&cedula=".$cedula."'><img src='".$imagen."' height='64' width='64'></a></td>";
				echo "<td width='100'>".$row['codigo']."</td>";
				echo "<td width='250'>".trim($row['nombres'])." ".$row['nombres1']."</td>";
				echo "<td width='250'>".trim($row['apellidos'])." ".$row['apellidos1']."</td>";
				echo "<td width='50' align='center'>".($row['status']=='A'?'<img src="img2/status_ver.png">':'<img src="img2/status_fal.png">')."</td>";
				echo "<td width='120' align=center>".$row['fechai']."</td>";
				echo "<td width='120' align=center>".$row['fechae']."</td>";
								
				if (substr($_SESSION['acceso_validar'],17,1)=='1')
				echo "<td width='30' align='center'><a href='".$_SERVER['PHP_SELF']."?accion=3&cedula=".$cedula."'><img border = 0 src='img2/desactivar.png' alt='modificar éste registro'></a></td>";
				else echo "<td width='30' align='center'>&nbsp;</td>";
				
				//echo "<td width='30' align='center'><a target='_blank' href='archivo_trabajador_retirado_constancia.php?cedula=".$cedula."'><img border = 0 src='img2/icono_06.png' alt='Imprimir éste registro'></a></td>";
				echo '</tr>';
				$color=!$color;
			}
			echo '</table>';
			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);
}	
mysqli_close($enlace);
echo "</font>";
echo "</body>";
echo "</html>";
}
?>