netgescon-day0/resources/views/superadmin/users/index.blade.php

93 lines
5.0 KiB
PHP

@extends('admin.layouts.netgescon')
@section('title', 'Utenti')
@section('breadcrumb')
<a href="{{ route('superadmin.dashboard') }}">SuperAdmin</a>
<i class="fas fa-chevron-right text-xs"></i>
<span>Utenti</span>
@endsection
@section('content')
<div class="space-y-4">
<div class="flex items-center justify-between">
<h2 class="text-xl font-semibold">Gestione Utenti</h2>
<a href="{{ route('superadmin.users.create') }}" class="netgescon-btn netgescon-btn-primary"><i class="fas fa-plus"></i> Nuovo Utente</a>
</div>
<div class="netgescon-card">
<div class="overflow-x-auto">
<table class="table">
<thead>
<tr>
<th>Nome</th>
<th>Email</th>
<th>Ruoli</th>
<th>Stato</th>
<th>Attivo</th>
<th>Piano</th>
<th>Azioni</th>
</tr>
</thead>
<tbody>
@foreach($users as $u)
<tr>
<td>{{ $u->name }}</td>
<td>{{ $u->email }}</td>
<td>{{ $u->roles->pluck('name')->join(', ') }}</td>
<td>
<span class="text-xs px-2 py-1 rounded bg-gray-100 text-gray-700">{{ $u->registration_status ?? 'approved' }}</span>
</td>
<td>
@if($u->is_active)
<span class="text-xs px-2 py-1 rounded bg-green-100 text-green-700">si</span>
@else
<span class="text-xs px-2 py-1 rounded bg-red-100 text-red-700">no</span>
@endif
</td>
<td>
<form action="{{ route('superadmin.users.assign-plan', $u) }}" method="POST" class="flex items-center gap-2">
@csrf
<select name="subscription_plan_id" class="netgescon-input text-xs py-1">
<option value="">Nessuno</option>
@foreach($plans as $plan)
<option value="{{ $plan->id }}" @selected($u->subscription_plan_id === $plan->id)>{{ $plan->name }}</option>
@endforeach
</select>
<button class="netgescon-btn netgescon-btn-sm netgescon-btn-outline-secondary">Ok</button>
</form>
</td>
<td class="space-x-2">
<a href="{{ route('superadmin.users.edit', $u) }}" class="netgescon-btn netgescon-btn-sm netgescon-btn-outline-secondary">Modifica</a>
@if(($u->registration_status ?? 'approved') === 'pending')
<form action="{{ route('superadmin.users.approve', $u) }}" method="POST" class="inline">
@csrf
<button class="netgescon-btn netgescon-btn-sm netgescon-btn-primary">Approva</button>
</form>
<form action="{{ route('superadmin.users.reject', $u) }}" method="POST" class="inline" onsubmit="return confirm('Rifiutare questa registrazione?')">
@csrf
<button class="netgescon-btn netgescon-btn-sm netgescon-btn-outline-dark">Rifiuta</button>
</form>
@endif
<form action="{{ route('superadmin.users.toggle-active', $u) }}" method="POST" class="inline">
@csrf
<button class="netgescon-btn netgescon-btn-sm netgescon-btn-outline-secondary">{{ $u->is_active ? 'Disattiva' : 'Attiva' }}</button>
</form>
@if(auth()->id() !== $u->id && auth()->user()?->hasRole('super-admin') && $u->canBeImpersonated())
<a href="{{ route('superadmin.users.impersonate', $u) }}" class="netgescon-btn netgescon-btn-sm netgescon-btn-outline-secondary">Impersona</a>
@endif
<form action="{{ route('superadmin.users.destroy', $u) }}" method="POST" class="inline" onsubmit="return confirm('Eliminare utente?')">
@csrf @method('DELETE')
<button class="netgescon-btn netgescon-btn-sm netgescon-btn-outline-dark">Elimina</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="p-3">{{ $users->links() }}</div>
</div>
</div>
@endsection