193 lines
11 KiB
PHP
193 lines
11 KiB
PHP
<div>
|
|
<!-- Controles de columnas -->
|
|
<div class="mb-4 flex items-center gap-4">
|
|
<div class="relative" x-data="{ open: false }">
|
|
<button @click="open = !open" class="bg-gray-100 px-4 py-2 rounded-lg hover:bg-gray-200">
|
|
Columnas ▼
|
|
</button>
|
|
|
|
<div x-show="open" @click.outside="open = false"
|
|
class="absolute bg-white shadow-lg rounded-lg p-4 mt-2 min-w-[200px] z-10">
|
|
@foreach($available_columns as $key => $label)
|
|
<label class="flex items-center gap-2 mb-2">
|
|
<input type="checkbox" wire:model.live="columns.{{ $key }}"
|
|
class="rounded border-gray-300">
|
|
{{ $label }}
|
|
</label>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Tabla -->
|
|
<div class="bg-white rounded-lg shadow overflow-x-auto">
|
|
<table class="min-w-full">
|
|
<thead class="bg-gray-50">
|
|
<tr>
|
|
@foreach($available_columns as $key => $label)
|
|
@if($columns[$key])
|
|
@if($key !== 'is_active')
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase cursor-pointer" >
|
|
<div class="flex items-center justify-between">
|
|
<div class="flex flex-col">
|
|
<span wire:click="sortBy('{{ $key }}')">{{ $label }}</span>
|
|
<input type="text"
|
|
wire:model.live.debounce.300ms="filters.{{ $key }}"
|
|
class="mt-1 text-xs w-full border rounded px-2 py-1"
|
|
placeholder="Filtrar...">
|
|
</div>
|
|
@if($sortField === $key)
|
|
<span class="ml-2">
|
|
@if($sortDirection === 'asc')
|
|
↑
|
|
@else
|
|
↓
|
|
@endif
|
|
</span>
|
|
@endif
|
|
</div>
|
|
</th>
|
|
@else
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">
|
|
<div class="flex flex-col">
|
|
<span>Estado</span>
|
|
<select wire:model.live="filters.status" class="mt-1 text-xs w-full border rounded px-2 py-1">
|
|
<option value="">Todos</option>
|
|
<option value="active">Activo</option>
|
|
<option value="inactive">Inactivo</option>
|
|
</select>
|
|
</div>
|
|
</th>
|
|
@endif
|
|
@endif
|
|
@endforeach
|
|
|
|
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Acciones</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-200">
|
|
@foreach($users as $user)
|
|
<tr>
|
|
@if($columns['full_name'])
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<a href="{{ route('users.show', $user) }}" class="flex items-center hover:text-blue-600 hover:underline group">
|
|
<!-- Foto del usuario -->
|
|
@if($user->profile_photo_path)
|
|
<div class="mr-3 flex-shrink-0">
|
|
<img src="{{ asset($user->profile_photo_path) }}"
|
|
alt="{{ $user->full_name }}"
|
|
class="w-8 h-8 rounded-full object-cover transition-transform group-hover:scale-110">
|
|
</div>
|
|
@else
|
|
<div class="w-8 h-8 rounded-full bg-gray-200 mr-3 flex items-center justify-center transition-colors group-hover:bg-blue-100">
|
|
<svg class="w-4 h-4 text-gray-500 group-hover:text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
|
|
</svg>
|
|
</div>
|
|
@endif
|
|
|
|
<!-- Nombre completo con efecto hover -->
|
|
<span class="group-hover:text-blue-600 transition-colors">
|
|
{{ $user->full_name }}
|
|
@if(!$user->is_active)
|
|
<span class="text-xs text-red-500 ml-2">(Inactivo)</span>
|
|
@endif
|
|
</span>
|
|
</a>
|
|
</td>
|
|
@endif
|
|
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
@if($columns['username'])
|
|
{{ $user->username }}
|
|
@else
|
|
N/A
|
|
@endif
|
|
</td>
|
|
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
@if($columns['email'])
|
|
|
|
<div class="flex items-center gap-2">
|
|
<svg class="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
|
|
</svg>
|
|
{{ $user->email }}
|
|
</div>
|
|
@else
|
|
N/A
|
|
@endif
|
|
</td>
|
|
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
@if($columns['phone'])
|
|
|
|
<div class="flex items-center gap-2">
|
|
<svg class="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/>
|
|
</svg>
|
|
{{ $user->phone ?? 'N/A' }}
|
|
</div>
|
|
@else
|
|
N/A
|
|
@endif
|
|
</td>
|
|
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
@if($columns['access_start'])
|
|
{{ $user->access_start?->format('d/m/Y') }}
|
|
@else
|
|
N/A
|
|
@endif
|
|
</td>
|
|
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
@if($columns['created_at'])
|
|
{{ $user->created_at->format('d/m/Y H:i') }}
|
|
@else
|
|
N/A
|
|
@endif
|
|
</td>
|
|
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
@if($columns['is_active'])
|
|
{{ $user->is_active ? 'Activo' : 'Inactivo' }}
|
|
@else
|
|
N/A
|
|
@endif
|
|
</td>
|
|
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<!-- Acciones -->
|
|
<div class="flex items-center gap-2">
|
|
<!-- Botón Editar -->
|
|
<a href="{{ route('users.edit', $user) }}"
|
|
class="text-blue-600 hover:text-blue-900"
|
|
title="Editar usuario">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"/>
|
|
</svg>
|
|
</a>
|
|
|
|
<!-- Botón Eliminar -->
|
|
<button wire:click="confirmDelete({{ $user->id }})"
|
|
class="text-red-600 hover:text-red-900"
|
|
title="Eliminar usuario">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Paginación -->
|
|
<div class="mt-4">
|
|
{{ $users->links() }}
|
|
</div>
|
|
</div> |