<?php
require('conexion.php');
$where = "";
if(!empty($_POST))
{
$valor = $_POST['dato'];
if(!empty($valor)){
$where = "WHERE e.IDempleado LIKE '%$valor%";
}
}
$sql = "SELECT e.IDempleado, e.Nombre, e.Apaterno, e.Amaterno, em.NOMemp, d.NOMdepto, p.NOMpuesto, p.Jdepto, d.Darea, pl.NOMpta, e.Correo, e.Telefono FROM datos_empleados e
INNER JOIN empresa em ON e.Empresa = em.IDemp
INNER JOIN departamentos d ON e.Departamento = d.IDdepto
INNER JOIN puestos p ON e.Puesto = p.IDpuesto
INNER JOIN plantas pl ON e.Planta =pl.IDpta $where";
$resultado = $mysqli->query($sql);
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-theme.css" rel="stylesheet">
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<title>Tabla de empleados</title>
</head>
<body>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="text" name="dato" id="dato" autocomplete="off" maxlength="5">
<input type="submit" id="buscar" name="buscar" value="Buscar" class="btn btn-info">
<a href="reg_empleados.php" class="btn btn-primary">Nuevo Registro</a></br>
</form>
<h2 style="text-align:center">Catalogo de empleados</h2>
<div class="table-responsive">
<table class="table table-hover" style="font-size:10px" >
<tbody>
<tr>
<th>No. de Empleado</th>
<th>Nombre</th>
<th>Empresa</th>
<th>Departamento</th>
<th>Puesto</th>
<th>Jefe inmediato</th>
<th>Director de area</th>
<th>Planta</th>
<th>Correo electronico</th>
<th>Telefono</th>
</tr>
<?php while($mostrar = $resultado->fetch_array(MYSQLI_ASSOC)) { ?>
<td><?php echo $mostrar['IDempleado']?></td>
<td><?php echo $mostrar['Nombre'].' '.$mostrar['Apaterno'].' '.$mostrar['Amaterno']?></td>
<td><?php echo $mostrar['NOMemp']?></td>
<td><?php echo $mostrar['NOMdepto']?></td>
<td><?php echo $mostrar['NOMpuesto']?></td>
<td><?php echo $mostrar['Jdepto']?></td>
<td><?php echo $mostrar['Darea']?></td>
<td><?php echo $mostrar['NOMpta']?></td>
<td><?php echo $mostrar['Correo']?></td>
<td><?php echo $mostrar['Telefono']?></td>
<td><a href="mod_empleado.php?IDempleado=<?php echo $mostrar['IDempleado']; ?>"><button type="button" class="btn btn-success">Editar</button></a></td>
<td><a href="#" data-href="includes/eliminar_empleados.php?IDempleado=<?php echo $mostrar['IDempleado']; ?>" data-toggle="modal" data-target="#confirm-delete"><button type="button" class="btn btn-danger">Eliminar</button></a></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<!-- Modal -->
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Eliminar Registro</h4>
</div>
<div class="modal-body">
¿Desea eliminar este registro?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
<a class="btn btn-danger btn-ok">Eliminar</a>
</div>
</div>
</div>
</div>
<script>
$('#confirm-delete').on('show.bs.modal', function(e) {
$(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
$('.debug-url').html('Delete URL: <strong>' + $(this).find('.btn-ok').attr('href') + '</strong>');
});
</script>
</body>
</html>