<?
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');
include "fphp.php";	
$enlace=cargar_conexion();
menu();

			echo "<br><br>";			
			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> Buscar Empresa:</td>";
				echo "<td > <input name='cedula' size = '30' maxlength = '8'>";
				echo "<input type = 'submit' value = 'Buscar?'></td>";
			echo "</tr>";
			echo "</table>";
			echo "	<script language='javascript' type='text/javascript'>";
			echo "		document.entrada.cedula.focus()";
			echo "	</script>";
			echo "</form>";
		
			$query1 = "";
			if ($_POST['cedula'] != "") {
				$query1 = " and empresa like '%".$_POST['cedula']."%' ";
			}
			
			if ($_SESSION['usuario_validar']=='RDAVILA') $consulta="Select * from tab_usuario ".($query1==''?'':'where 1=0 '.$query1)." order by empresa,xxx";
			else $consulta="Select * from tab_usuario where tipo=0 ".$query1." order by empresa,xxx";
			$resultado = mysqli_query($enlace,$consulta) or die($consulta . 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 = left><font color='white'> # </font></th>";
						echo "<th align = left><font color='white'> Detalle de la Empresa </font></th>";
						echo "<th align = left><font color='white'> Contacto Principal </font></th>";
						echo "<th align = left><font color='white'> Id de Empresa </font></th>";
						echo "<th align = left><font color='white'> Elegir? </font></th>";
					echo "</tr>";
					$van=0;
					for ($cont=0;$cont<$num_rows;$cont++) {
						$row = mysqli_fetch_array($resultado);
						if ($cont==0) $db='XX';
						if ($db!=$row['id']) { 
							if ($color) $tcolor="#dfdfd0";
							else $tcolor="white";
							$cedula = $row['xxx'];
							$van++;
							echo '<tr bgcolor='.$tcolor.' >';
								echo "<td width='35'>".($van)."</td>";
								echo "<td width='300' height='40'><a style='color:red;text-decoration:none' href='menu.php?empresa=".$cedula."'>".$row['empresa']."</a></td>";
								echo "<td width='300'>".$row['detalle']."</td>";
								echo "<td width='200'>".$row['id']."</td>";
								echo "<td width='50' align=center><a style='color:red;text-decoration:none' href='menu.php?empresa=".$cedula."'><img src='img2/icono_01.png'></a></td>";
							echo '</tr>';
							$color=!$color;
						}	
						$db=$row['id'];	
					}
					echo '</table>';
			}  		
			mysqli_free_result($resultado);
			mysqli_close($enlace);
?>			
<br><table border=0 align=center width='100%'>
	<tr>
				<td align=center width='100%'>		
					<p align='center'><a href='http://www.consultarh.com' target='_blank'><img src='img2/logoc.png' /></a></p>
				</td>		
	</tr>
</body>
</html>