|
|
@ -2,9 +2,9 @@ |
|
|
|
|
|
|
|
@section('content') |
|
|
|
<div class="container mx-auto px-4 py-6"> |
|
|
|
<!-- Encabezado --> |
|
|
|
<!-- Mensajes de éxito y error --> |
|
|
|
@if(session('success')) |
|
|
|
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mb-4" role="alert"> |
|
|
|
<div id="success-message" class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mb-4" role="alert"> |
|
|
|
<span class="block sm:inline">{{ session('success') }}</span> |
|
|
|
</div> |
|
|
|
@endif |
|
|
@ -16,8 +16,35 @@ |
|
|
|
@endif |
|
|
|
|
|
|
|
<div class="bg-white rounded-lg shadow-lg"> |
|
|
|
<!-- Encabezado con título y botones de acción --> |
|
|
|
<div class="p-4 border-b border-gray-200 flex justify-between items-center"> |
|
|
|
<h2 class="text-2xl font-bold">Gestión de Usuarios</h2> |
|
|
|
<div class="flex items-center space-x-6"> |
|
|
|
<!-- Íconos de exportación y agregar --> |
|
|
|
<div class="flex space-x-4"> |
|
|
|
<!-- Exportar a Excel --> |
|
|
|
<a href="{{ route('usuarios.excel') }}" |
|
|
|
class="text-green-600 hover:text-green-700 transition-colors duration-200" |
|
|
|
title="Exportar a Excel"> |
|
|
|
<i class="fas fa-file-excel text-xl"></i> |
|
|
|
</a> |
|
|
|
|
|
|
|
<!-- Exportar a PDF --> |
|
|
|
<a href="{{ route('usuarios.pdf') }}" |
|
|
|
class="text-red-600 hover:text-red-700 transition-colors duration-200" |
|
|
|
title="Exportar a PDF"> |
|
|
|
<i class="fas fa-file-pdf text-xl"></i> |
|
|
|
</a> |
|
|
|
|
|
|
|
<!-- Agregar nuevo usuario --> |
|
|
|
<a href="{{ route('usuarios.create') }}" |
|
|
|
class="text-blue-500 hover:text-blue-600 transition-colors duration-200" |
|
|
|
title="Agregar nuevo usuario"> |
|
|
|
<i class="fas fa-plus text-xl"></i> |
|
|
|
</a> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- Barra de búsqueda --> |
|
|
@ -44,6 +71,7 @@ |
|
|
|
</form> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- Tabla de usuarios --> |
|
|
|
<div class="overflow-x-auto"> |
|
|
|
<table class="min-w-full divide-y divide-gray-200"> |
|
|
|
<thead class="bg-gray-50"> |
|
|
@ -51,31 +79,71 @@ |
|
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th> |
|
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nombre</th> |
|
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th> |
|
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Apellido</th> |
|
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Puesto</th> |
|
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Carrera</th> |
|
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Teléfono</th> |
|
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Estado</th> |
|
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Acciones</th> |
|
|
|
</tr> |
|
|
|
</thead> |
|
|
|
<tbody class="bg-white divide-y divide-gray-200"> |
|
|
|
@if($usuarios->isEmpty()) |
|
|
|
<tr> |
|
|
|
<td colspan="4" class="px-6 py-4 text-center text-gray-500">No hay usuarios registrados.</td> |
|
|
|
<td colspan="9" class="px-6 py-4 text-center text-gray-500">No hay usuarios registrados.</td> |
|
|
|
</tr> |
|
|
|
@else |
|
|
|
@foreach($usuarios as $usuario) |
|
|
|
<tr class="hover:bg-gray-50"> |
|
|
|
<td class="px-6 py-4 whitespace-nowrap">{{ $usuario->id }}</td> |
|
|
|
<td class="px-6 py-4 whitespace-nowrap">{{ $usuario->name }}</td> |
|
|
|
<td class="px-6 py-4 whitespace-nowrap">{{ $usuario->email }}</td> |
|
|
|
<td class="px-6 py-4 whitespace-nowrap"> |
|
|
|
<div class="flex gap-2"> |
|
|
|
<div class="flex gap-2"> |
|
|
|
<form action="{{ route('usuarios.destroy', $usuario->id) }}" method="POST" class="inline" onsubmit="return false;"> |
|
|
|
@csrf |
|
|
|
@method('DELETE') |
|
|
|
<button type="button" onclick="confirmarEliminacion(this)" class="text-red-600 hover:text-red-900"> |
|
|
|
<i class="fas fa-trash"></i> <!-- Icono de eliminación --> |
|
|
|
</button> |
|
|
|
</form> |
|
|
|
</div> |
|
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $usuario->id }}</td> |
|
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900"> |
|
|
|
<i class="fas fa-user text-blue-500 mr-2"></i> |
|
|
|
{{ $usuario->name }} |
|
|
|
</td> |
|
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $usuario->email }}</td> |
|
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $usuario->apellido }}</td> |
|
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $usuario->puesto }}</td> |
|
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $usuario->carrera }}</td> |
|
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $usuario->telefono }}</td> |
|
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm"> |
|
|
|
@if($usuario->eliminado == 0) |
|
|
|
<span class="flex items-center"> |
|
|
|
<span class="h-2 w-2 bg-green-500 rounded-full mr-2"></span> Activo |
|
|
|
</span> |
|
|
|
@else |
|
|
|
<span class="flex items-center"> |
|
|
|
<span class="h-2 w-2 bg-red-500 rounded-full mr-2"></span> Inactivo |
|
|
|
</span> |
|
|
|
@endif |
|
|
|
</td> |
|
|
|
<td class="flex space-x-2 px-6 py-4 whitespace-nowrap text-sm"> |
|
|
|
@if($usuario->eliminado == 1) |
|
|
|
<form action="{{ route('usuarios.update', $usuario->id) }}" method="POST" class="d-inline"> |
|
|
|
@csrf |
|
|
|
@method('PUT') |
|
|
|
<input type="hidden" name="recuperar" value="1"> |
|
|
|
<a href="#" onclick="event.preventDefault(); this.closest('form').submit();" |
|
|
|
class="text-green-600 hover:text-green-700 transition-colors duration-200" |
|
|
|
title="Recuperar usuario"> |
|
|
|
<i class="fas fa-undo"></i> |
|
|
|
</a> |
|
|
|
</form> |
|
|
|
@else |
|
|
|
<a href="{{ route('usuarios.edit', $usuario->id) }}" |
|
|
|
class="text-yellow-600 hover:text-yellow-700 transition-colors duration-200" |
|
|
|
title="Editar usuario"> |
|
|
|
<i class="fas fa-edit"></i> |
|
|
|
</a> |
|
|
|
<form action="{{ route('usuarios.destroy', $usuario->id) }}" method="POST" class="d-inline"> |
|
|
|
@csrf |
|
|
|
@method('DELETE') |
|
|
|
<a href="#" onclick="event.preventDefault(); confirmarEliminacion(this);" |
|
|
|
class="text-red-600 hover:text-red-700 transition-colors duration-200" |
|
|
|
title="Eliminar usuario"> |
|
|
|
<i class="fas fa-trash"></i> |
|
|
|
</a> |
|
|
|
</form> |
|
|
|
@endif |
|
|
|
</td> |
|
|
|
</tr> |
|
|
|
@endforeach |
|
|
@ -87,22 +155,33 @@ |
|
|
|
</div> |
|
|
|
|
|
|
|
<script> |
|
|
|
function confirmarEliminacion(button) { |
|
|
|
Swal.fire({ |
|
|
|
title: '¿Estás seguro?', |
|
|
|
text: "Esta acción no se puede deshacer", |
|
|
|
icon: 'warning', |
|
|
|
showCancelButton: true, |
|
|
|
confirmButtonColor: '#3085d6', |
|
|
|
cancelButtonColor: '#d33', |
|
|
|
confirmButtonText: 'Sí, eliminar', |
|
|
|
cancelButtonText: 'Cancelar' |
|
|
|
}).then((result) => { |
|
|
|
if (result.isConfirmed) { |
|
|
|
button.closest('form').onsubmit = null; |
|
|
|
button.closest('form').submit(); |
|
|
|
// Desaparecer el mensaje después de 3 segundos |
|
|
|
setTimeout(function() { |
|
|
|
var message = document.getElementById('success-message'); |
|
|
|
if (message) { |
|
|
|
message.style.transition = 'opacity 0.5s ease'; |
|
|
|
message.style.opacity = '0'; |
|
|
|
setTimeout(function() { |
|
|
|
message.remove(); |
|
|
|
}, 500); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}, 3000); |
|
|
|
|
|
|
|
function confirmarEliminacion(button) { |
|
|
|
Swal.fire({ |
|
|
|
title: '¿Estás seguro?', |
|
|
|
text: "Esta acción no se puede deshacer", |
|
|
|
icon: 'warning', |
|
|
|
showCancelButton: true, |
|
|
|
confirmButtonColor: '#3085d6', |
|
|
|
cancelButtonColor: '#d33', |
|
|
|
confirmButtonText: 'Sí, eliminar', |
|
|
|
cancelButtonText: 'Cancelar' |
|
|
|
}).then((result) => { |
|
|
|
if (result.isConfirmed) { |
|
|
|
button.closest('form').submit(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
</script> |
|
|
|
@endsection |
|
|
|