<script type="text/javascript">
	$(document).ready(function(){
	    $(".detalhes").colorbox({iframe:true, width:"60%", height:"100%"});
	});
</script>

<?php
	
	require('../../connect/db.php');
	db_connect() or die ("Houve erro ao acessar estes dados!");

	$criterio = '';

	if($_GET['busca'] != ''){
		$queryColunas = "SELECT 
						  COLUMN_NAME 
						FROM
						  information_schema.COLUMNS AS c 
						WHERE c.TABLE_NAME = 'curriculo' 
						  AND COLUMN_NAME <> 'id' 
						  AND COLUMN_NAME <> 'statusCurriculo'";

		$selectColuna = mysql_query($queryColunas);

		$numColunas = mysql_num_rows($selectColuna);

		$colunas = array();
		for($i = 0; $i < $numColunas; $i++){
			$coluna = mysql_result($selectColuna, $i, 0);
			$colunas[] = $coluna." like '%".$_GET['busca']."%'";
		}

		$criterio = " (".implode(" OR ", $colunas).") AND ";
	}
	
	$queryBusca = "SELECT * FROM curriculo WHERE $criterio statusCurriculo = '1'";

	// echo $queryBusca;

	$selectBusca = mysql_query($queryBusca);
?>

<table border="0" cellspacing="10" class="tabela-conteudo">
	<tbody>
		<tr class="linha-topo">
			<th>Nome</th>
			<th>Ver</th>
			<th>Deletar</th>
		</tr>
		<?php
			$aux = 1;
			while ($linhaBusca = mysql_fetch_array($selectBusca)) {
			?>
			<tr <?php if($aux % 2 == 0){ echo"bgcolor='f2eaea'"; }else{ echo"bgcolor='edeaea'"; } ?>>
				<td class="nomeTabelaExibir"><? echo ($linhaBusca['nome']);?></td>
				<td class="icons-categorias"><a href='paineis/curriculos/detalhes-curriculo.php?id=<? echo $linhaBusca['id'];?>' class="detalhes"><img src="images/lupa2.png" width="20px" height="20px" alt="" border='0'></a></td>
				<td class="icons-categorias"><a href='miolo.php?miolo=curriculos&acao=excluir&id=<? echo $linhaBusca['id'];?>'><img src="images/lixo.png" width="20px" height="20px" alt="" border='0'></a></td>
			</tr>
			<?
			}
			$aux += 1;
		?>	
	</tbody>
</table>