<?php
$filtros = '';
$fill_paginador = "&fil=".$_GET["fil"];
if($_GET["fil"] == 1){ $filtros = " AND acepto = '' "; }
if($_GET["fil"] == 2){ $filtros = " AND acepto = 'on' AND origen = 1 "; }
if($_GET["fil"] == 3){ $filtros = " AND origen = 2 "; }
?>


<div align="left" style="padding: 10px 0px;">
	<table width="100%">
    	<tr>
        	<td><h5 style="margin-top: 8px;"><i class="fas fa-check"></i> ASISTENTES VALIDAR</h5></td>
            <td align="right" width="200">
            	<input class="form-control" type="text" placeholder="Búsqueda rápida..." id="buscador" />
            </td>
        </tr>
    </table>
</div>


<div class="table-responsive">
	<table class="table table-bordered table-sm">
		<thead class="thead-dark">
		<tr>
			<th scope="col">#</th>
			<th scope="col">Nombre</th>
			<th scope="col">Correo</th>
			<th scope="col">Documento</th>
			<th scope="col">Equipo</th>
		</tr>
		</thead>

		<tbody id="tabla_lista">
		<?php
			$count = 1;
			$query = mysqli_query($connect,"SELECT * FROM Equipos ");
			while($data = mysqli_fetch_array($query)){
 
                 $queryAsis = mysqli_query($connect,"SELECT * FROM Asistentes WHERE cedula = '".$data["documento"]."' ");
			     $dataAsis = mysqli_fetch_array($queryAsis);
                
                mysqli_query($connect,"UPDATE Asistentes SET equipo = '".$data["equipo"]."' WHERE cedula = '".$data["documento"]."' ");
                
				echo '
				<tr>
					<td scope="row">'.$count.'</td>
					<td>'.$dataAsis["nombre"].' '.$dataAsis["apellidos"].'</td>
					<td>'.$dataAsis["correo"].'</td>
					<td>'.$dataAsis["cedula"].'</td>
					<td>'.$data["equipo"].'</td>
				</tr>
				';
				$count++;

			}
		?>
		</tbody>
	</table>
</div>

<script>
$(document).ready(function(){
	$("#buscador").on("keyup", function() {
		var value = $(this).val().toLowerCase();
		$("#tabla_lista tr").filter(function() {
		  $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
		});
	});	  
});
</script>

<script src="js/functions.js"></script>