feat: implement super admin role with spatie rbac and categorize sidebar by management

This commit is contained in:
Ray1111-aa
2026-10-15 15:03:24 +07:00
parent 9c00515a73
commit 2e1f05b494
29 changed files with 5334 additions and 144 deletions
+278
View File
@@ -0,0 +1,278 @@
@extends('layouts.app')
@section('title', 'Dashboard Super Admin - RKM KMH')
@section('content')
<div class="space-y-6">
<!-- Header Halaman -->
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
<div>
<h1 class="text-2xl font-black text-slate-800 tracking-tight flex items-center gap-2.5">
<span class="w-2.5 h-7 rounded-full bg-indigo-600 inline-block"></span>
Dashboard Super Admin & RBAC
</h1>
<p class="text-xs text-slate-500 mt-1">
Pusat kendali arsitektur sistem, pengelolaan pengguna, dan matriks hak akses Role-Based Access Control (RBAC).
</p>
</div>
<div class="flex items-center gap-2.5">
<a href="{{ route('admin.users.index') }}"
class="inline-flex items-center gap-2 px-4 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
<i class="fa-solid fa-users-gear text-sm"></i>
<span>Kelola Pengguna</span>
</a>
<a href="{{ route('admin.roles.index') }}"
class="inline-flex items-center gap-2 px-4 py-2.5 bg-white border border-slate-200 hover:bg-slate-50 text-slate-700 rounded-xl text-xs font-bold shadow-sm transition">
<i class="fa-solid fa-shield-halved text-indigo-600 text-sm"></i>
<span>Matriks Role & Izin</span>
</a>
</div>
</div>
<!-- Alert Notifikasi Flash -->
@if(session('success'))
<div class="p-4 bg-emerald-50 border border-emerald-200 rounded-2xl flex items-center justify-between text-emerald-800 text-xs font-semibold">
<div class="flex items-center gap-2.5">
<i class="fa-solid fa-circle-check text-emerald-600 text-base"></i>
<span>{{ session('success') }}</span>
</div>
<button type="button" onclick="this.parentElement.remove()" class="text-emerald-500 hover:text-emerald-700">
<i class="fa-solid fa-xmark"></i>
</button>
</div>
@endif
<!-- Kartu Metrik Utama -->
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
<!-- Total Pengguna -->
<div class="bg-white p-4 sm:p-5 rounded-2xl border border-slate-200/80 shadow-sm relative overflow-hidden group hover:border-indigo-300 transition">
<div class="flex items-center justify-between mb-2">
<span class="text-[11px] font-bold text-slate-400 uppercase tracking-wider">Total Akun</span>
<div class="w-8 h-8 rounded-xl bg-indigo-50 text-indigo-600 flex items-center justify-center text-sm">
<i class="fa-solid fa-users"></i>
</div>
</div>
<div class="text-2xl font-black text-slate-800">{{ $metrics['total_users'] }}</div>
<p class="text-[11px] text-slate-500 mt-1">Terdaftar dalam sistem</p>
</div>
<!-- Total Roles Spatie -->
<div class="bg-white p-4 sm:p-5 rounded-2xl border border-slate-200/80 shadow-sm relative overflow-hidden group hover:border-violet-300 transition">
<div class="flex items-center justify-between mb-2">
<span class="text-[11px] font-bold text-slate-400 uppercase tracking-wider">Total Role RBAC</span>
<div class="w-8 h-8 rounded-xl bg-violet-50 text-violet-600 flex items-center justify-center text-sm">
<i class="fa-solid fa-shield-halved"></i>
</div>
</div>
<div class="text-2xl font-black text-slate-800">{{ $metrics['total_roles'] }}</div>
<p class="text-[11px] text-slate-500 mt-1">Tingkatan wewenang</p>
</div>
<!-- Master Data Operasional (HSE & QMA) -->
<div class="bg-white p-4 sm:p-5 rounded-2xl border border-slate-200/80 shadow-sm relative overflow-hidden group hover:border-emerald-300 transition">
<div class="flex items-center justify-between mb-2">
<span class="text-[11px] font-bold text-slate-400 uppercase tracking-wider">Master Data</span>
<div class="w-8 h-8 rounded-xl bg-emerald-50 text-emerald-600 flex items-center justify-center text-sm">
<i class="fa-solid fa-database"></i>
</div>
</div>
<div class="flex items-baseline gap-2">
<span class="text-2xl font-black text-slate-800">{{ $metrics['total_vehicles'] }}</span>
<span class="text-xs text-slate-400 font-semibold">Unit</span>
<span class="text-slate-300">/</span>
<span class="text-lg font-black text-slate-700">{{ $metrics['total_employees'] }}</span>
<span class="text-xs text-slate-400 font-semibold">Karyawan</span>
</div>
<p class="text-[11px] text-slate-500 mt-1">Kendaraan & Simper</p>
</div>
<!-- Aktivitas Hari Ini -->
<div class="bg-white p-4 sm:p-5 rounded-2xl border border-slate-200/80 shadow-sm relative overflow-hidden group hover:border-amber-300 transition">
<div class="flex items-center justify-between mb-2">
<span class="text-[11px] font-bold text-slate-400 uppercase tracking-wider">Aktivitas Hari Ini</span>
<div class="w-8 h-8 rounded-xl bg-amber-50 text-amber-600 flex items-center justify-center text-sm">
<i class="fa-solid fa-clock-rotate-left"></i>
</div>
</div>
<div class="flex items-baseline gap-2">
<span class="text-2xl font-black text-slate-800">{{ $metrics['activities_today'] }}</span>
<span class="text-xs text-slate-400 font-semibold">Total</span>
@if($metrics['activities_pending'] > 0)
<span class="px-2 py-0.5 rounded-full text-[10px] font-black bg-amber-100 text-amber-700">
{{ $metrics['activities_pending'] }} antre
</span>
@endif
</div>
<p class="text-[11px] text-slate-500 mt-1">{{ $metrics['activities_approved'] }} sudah diverifikasi</p>
</div>
</div>
<!-- Shortcut Lintas Modul Sistem (Super Admin Quick Nav) -->
<div class="bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm">
<h2 class="text-sm font-bold text-slate-800 mb-3 flex items-center gap-2">
<i class="fa-solid fa-compass text-indigo-600"></i>
Akses Langsung ke Seluruh Modul Operasional (Super Admin Bypass)
</h2>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3">
<!-- HSE Card -->
<a href="{{ route('hse.dashboard') }}" class="p-3.5 rounded-xl border border-slate-100 bg-slate-50/70 hover:bg-emerald-50/60 hover:border-emerald-200 transition group flex items-start gap-3">
<div class="w-9 h-9 rounded-lg bg-emerald-600 text-white flex items-center justify-center flex-shrink-0 group-hover:scale-105 transition">
<i class="fa-solid fa-id-card text-sm"></i>
</div>
<div>
<h3 class="text-xs font-bold text-slate-800 group-hover:text-emerald-800">Modul HSE</h3>
<p class="text-[11px] text-slate-500 mt-0.5">Kelola SIMPER & Data Karyawan</p>
</div>
</a>
<!-- QMA Card -->
<a href="{{ route('qma.dashboard') }}" class="p-3.5 rounded-xl border border-slate-100 bg-slate-50/70 hover:bg-blue-50/60 hover:border-blue-200 transition group flex items-start gap-3">
<div class="w-9 h-9 rounded-lg bg-blue-600 text-white flex items-center justify-center flex-shrink-0 group-hover:scale-105 transition">
<i class="fa-solid fa-car text-sm"></i>
</div>
<div>
<h3 class="text-xs font-bold text-slate-800 group-hover:text-blue-800">Modul QMA</h3>
<p class="text-[11px] text-slate-500 mt-0.5">Master Kendaraan & Log Aktivitas</p>
</div>
</a>
<!-- PG Card -->
<a href="{{ route('pg.dashboard') }}" class="p-3.5 rounded-xl border border-slate-100 bg-slate-50/70 hover:bg-purple-50/60 hover:border-purple-200 transition group flex items-start gap-3">
<div class="w-9 h-9 rounded-lg bg-purple-600 text-white flex items-center justify-center flex-shrink-0 group-hover:scale-105 transition">
<i class="fa-solid fa-user-shield text-sm"></i>
</div>
<div>
<h3 class="text-xs font-bold text-slate-800 group-hover:text-purple-800">Modul Private Guard</h3>
<p class="text-[11px] text-slate-500 mt-0.5">Data Satpam & Log Verifikasi</p>
</div>
</a>
<!-- Pos Gerbang -->
<a href="{{ route('pg.gate.inspection') }}" class="p-3.5 rounded-xl border border-slate-100 bg-slate-50/70 hover:bg-amber-50/60 hover:border-amber-200 transition group flex items-start gap-3">
<div class="w-9 h-9 rounded-lg bg-amber-600 text-white flex items-center justify-center flex-shrink-0 group-hover:scale-105 transition">
<i class="fa-solid fa-shield-halved text-sm"></i>
</div>
<div>
<h3 class="text-xs font-bold text-slate-800 group-hover:text-amber-800">Inspeksi Pos Gerbang</h3>
<p class="text-[11px] text-slate-500 mt-0.5">Layar Verifikasi Antrean Unit</p>
</div>
</a>
</div>
</div>
<!-- Grid Dua Kolom: Distribusi Role & Pengguna Terbaru -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Distribusi Role Pengguna -->
<div class="bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm lg:col-span-1">
<h2 class="text-sm font-bold text-slate-800 mb-4 flex items-center justify-between">
<span>Distribusi Pengguna per Role</span>
<span class="text-[11px] font-semibold text-slate-400">{{ $metrics['total_users'] }} User</span>
</h2>
<div class="space-y-3">
@foreach($usersByRole as $roleName => $count)
@php
$percentage = $metrics['total_users'] > 0 ? round(($count / $metrics['total_users']) * 100) : 0;
$badgeColor = match($roleName) {
'super_admin' => 'bg-indigo-500',
'hse_admin' => 'bg-emerald-500',
'qma_admin' => 'bg-blue-500',
'pg_admin' => 'bg-purple-500',
'gate_officer' => 'bg-amber-500',
default => 'bg-slate-400'
};
@endphp
<div>
<div class="flex items-center justify-between text-xs mb-1">
<span class="font-semibold text-slate-700 capitalize">
{{ str_replace('_', ' ', $roleName) }}
</span>
<span class="font-bold text-slate-900">{{ $count }} ({{ $percentage }}%)</span>
</div>
<div class="w-full bg-slate-100 rounded-full h-2 overflow-hidden">
<div class="{{ $badgeColor }} h-2 rounded-full transition-all duration-500" style="width: {{ $percentage }}%"></div>
</div>
</div>
@endforeach
</div>
<div class="mt-6 pt-4 border-t border-slate-100">
<a href="{{ route('admin.roles.index') }}" class="text-xs font-bold text-indigo-600 hover:text-indigo-800 flex items-center justify-between">
<span>Lihat Konfigurasi Matriks Role</span>
<i class="fa-solid fa-arrow-right text-[11px]"></i>
</a>
</div>
</div>
<!-- Akun Pengguna Terbaru -->
<div class="bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm lg:col-span-2">
<div class="flex items-center justify-between mb-4">
<h2 class="text-sm font-bold text-slate-800 flex items-center gap-2">
<i class="fa-solid fa-user-clock text-slate-400"></i>
Pengguna Sistem Terdaftar Terbaru
</h2>
<a href="{{ route('admin.users.index') }}" class="text-xs font-bold text-indigo-600 hover:text-indigo-800">
Lihat Semua User &rarr;
</a>
</div>
<div class="overflow-x-auto">
<table class="w-full text-left text-xs">
<thead>
<tr class="border-b border-slate-100 text-slate-400 font-semibold">
<th class="pb-2.5">Nama & Username</th>
<th class="pb-2.5">Email</th>
<th class="pb-2.5">Role</th>
<th class="pb-2.5">Pos Gerbang</th>
<th class="pb-2.5 text-right">Terdaftar</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-50">
@forelse($recentUsers as $user)
<tr class="hover:bg-slate-50/60 transition">
<td class="py-2.5 pr-2">
<div class="flex items-center gap-2">
<div class="w-7 h-7 rounded-full bg-indigo-50 text-indigo-700 font-bold flex items-center justify-center text-[10px] flex-shrink-0">
{{ strtoupper(substr($user->name, 0, 1)) }}
</div>
<div>
<p class="font-bold text-slate-800">{{ $user->name }}</p>
<p class="text-[10px] text-slate-400 font-mono">{{ $user->username }}</p>
</div>
</div>
</td>
<td class="py-2.5 pr-2 text-slate-600">{{ $user->email }}</td>
<td class="py-2.5 pr-2">
@php
$primaryRole = $user->roles->first()?->name ?? $user->role;
$badgeStyle = match($primaryRole) {
'super_admin' => 'bg-indigo-50 text-indigo-700 border-indigo-200',
'hse_admin' => 'bg-emerald-50 text-emerald-700 border-emerald-200',
'qma_admin' => 'bg-blue-50 text-blue-700 border-blue-200',
'pg_admin' => 'bg-purple-50 text-purple-700 border-purple-200',
'gate_officer' => 'bg-amber-50 text-amber-700 border-amber-200',
default => 'bg-slate-100 text-slate-600 border-slate-200',
};
@endphp
<span class="px-2 py-0.5 rounded-full text-[10px] font-bold border {{ $badgeStyle }} capitalize">
{{ str_replace('_', ' ', $primaryRole) }}
</span>
</td>
<td class="py-2.5 pr-2 text-slate-600">
{{ $user->gate?->name ?? '-' }}
</td>
<td class="py-2.5 text-right text-slate-400 text-[11px]">
{{ $user->created_at->diffForHumans() }}
</td>
</tr>
@empty
<tr>
<td colspan="5" class="py-4 text-center text-slate-400">Belum ada data pengguna.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
+286
View File
@@ -0,0 +1,286 @@
@extends('layouts.app')
@section('title', 'Matriks Role & Permission (RBAC) - Super Admin RKM')
@section('content')
<div class="space-y-6">
<!-- Header Halaman -->
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
<div>
<h1 class="text-2xl font-black text-slate-800 tracking-tight flex items-center gap-2.5">
<span class="w-2.5 h-7 rounded-full bg-indigo-600 inline-block"></span>
Matriks Role & Hak Akses (RBAC)
</h1>
<p class="text-xs text-slate-500 mt-1">
Konfigurasi izin wewenang (permissions) untuk setiap role pengguna menggunakan paket Spatie Laravel Permission.
</p>
</div>
<div class="flex items-center gap-2.5">
<button type="button"
onclick="openCreateRoleModal()"
class="inline-flex items-center gap-2 px-4 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
<i class="fa-solid fa-plus text-sm"></i>
<span>Tambah Role Baru</span>
</button>
<a href="{{ route('admin.users.index') }}"
class="inline-flex items-center gap-2 px-4 py-2.5 bg-white border border-slate-200 hover:bg-slate-50 text-slate-700 rounded-xl text-xs font-bold shadow-sm transition">
<i class="fa-solid fa-users text-indigo-600 text-sm"></i>
<span>Kelola Pengguna</span>
</a>
</div>
</div>
<!-- Alert Notifikasi Flash -->
@if(session('success'))
<div class="p-4 bg-emerald-50 border border-emerald-200 rounded-2xl flex items-center justify-between text-emerald-800 text-xs font-semibold">
<div class="flex items-center gap-2.5">
<i class="fa-solid fa-circle-check text-emerald-600 text-base"></i>
<span>{{ session('success') }}</span>
</div>
<button type="button" onclick="this.parentElement.remove()" class="text-emerald-500 hover:text-emerald-700">
<i class="fa-solid fa-xmark"></i>
</button>
</div>
@endif
@if(session('error'))
<div class="p-4 bg-rose-50 border border-rose-200 rounded-2xl flex items-center justify-between text-rose-800 text-xs font-semibold">
<div class="flex items-center gap-2.5">
<i class="fa-solid fa-triangle-exclamation text-rose-600 text-base"></i>
<span>{{ session('error') }}</span>
</div>
<button type="button" onclick="this.parentElement.remove()" class="text-rose-500 hover:text-rose-700">
<i class="fa-solid fa-xmark"></i>
</button>
</div>
@endif
<!-- Info Box: Super Admin Priviledge -->
<div class="p-4 bg-indigo-50/70 border border-indigo-100 rounded-2xl flex items-start gap-3.5 text-xs text-indigo-900">
<div class="w-8 h-8 rounded-xl bg-indigo-600 text-white flex items-center justify-center flex-shrink-0 text-sm shadow-sm">
<i class="fa-solid fa-crown"></i>
</div>
<div>
<h2 class="font-bold text-indigo-950">Privilese Khusus Super Administrator (Gate::before Bypass)</h2>
<p class="text-indigo-800/80 mt-0.5 leading-relaxed">
Role <strong>super_admin</strong> secara otomatis memiliki hak akses tak terbatas ke seluruh modul sistem (HSE, QMA, PG, dan Pengaturan RBAC) melalui interceptor gerbang Laravel. Matriks centang di bawah ini berlaku aktif untuk role operasional lainnya.
</p>
</div>
</div>
<!-- Ringkasan Role Cards -->
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3">
@foreach($roles as $role)
@php
$isCoreRole = in_array($role->name, ['super_admin', 'hse_admin', 'qma_admin', 'pg_admin', 'gate_officer']);
$badgeColor = match($role->name) {
'super_admin' => 'bg-indigo-600 text-white',
'hse_admin' => 'bg-emerald-600 text-white',
'qma_admin' => 'bg-blue-600 text-white',
'pg_admin' => 'bg-purple-600 text-white',
'gate_officer' => 'bg-amber-600 text-white',
default => 'bg-slate-700 text-white'
};
@endphp
<div class="bg-white border border-slate-200/80 rounded-2xl p-4 shadow-sm flex flex-col justify-between">
<div>
<div class="flex items-center justify-between mb-2">
<span class="w-2.5 h-2.5 rounded-full {{ $badgeColor }}"></span>
@if(!$isCoreRole)
<button type="button"
onclick='openDeleteRoleModal({{ $role->id }}, "{{ $role->name }}")'
class="text-slate-400 hover:text-rose-600 transition"
title="Hapus Role Kustom">
<i class="fa-solid fa-trash-can text-xs"></i>
</button>
@else
<span class="text-[9px] font-bold text-slate-400 uppercase tracking-wider">Core</span>
@endif
</div>
<h2 class="text-xs font-bold text-slate-800 capitalize">{{ str_replace('_', ' ', $role->name) }}</h2>
<p class="text-[10px] text-slate-400 mt-0.5 font-mono">{{ $role->name }}</p>
</div>
<div class="mt-3 pt-2.5 border-t border-slate-100 flex items-center justify-between text-[11px]">
<span class="text-slate-500">Izin Aktif:</span>
<span class="font-bold text-indigo-700">
{{ $role->name === 'super_admin' ? 'Semua' : $role->permissions->count() }}
</span>
</div>
</div>
@endforeach
</div>
<!-- Matriks Role & Permissions Table -->
<div class="space-y-6">
@foreach($roles as $role)
<div class="bg-white border border-slate-200/80 rounded-2xl shadow-sm overflow-hidden">
<div class="px-5 py-3.5 bg-slate-50 border-b border-slate-100 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
<div class="flex items-center gap-3">
<div class="w-8 h-8 rounded-xl bg-indigo-50 border border-indigo-100 text-indigo-700 flex items-center justify-center font-bold text-xs">
<i class="fa-solid fa-shield-halved"></i>
</div>
<div>
<h2 class="text-sm font-bold text-slate-900 capitalize flex items-center gap-2">
<span>Role: {{ str_replace('_', ' ', $role->name) }}</span>
@if($role->name === 'super_admin')
<span class="px-2 py-0.5 rounded-full text-[9px] font-black bg-indigo-100 text-indigo-800">UNRESTRICTED</span>
@endif
</h2>
<p class="text-[11px] text-slate-400">Atur centang hak akses yang diizinkan untuk peran pengguna ini.</p>
</div>
</div>
@if($role->name !== 'super_admin')
<button type="submit"
form="form-role-{{ $role->id }}"
class="inline-flex items-center gap-1.5 px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition self-end sm:self-auto">
<i class="fa-solid fa-floppy-disk"></i>
<span>Simpan Hak Akses</span>
</button>
@endif
</div>
<form id="form-role-{{ $role->id }}"
action="{{ route('admin.roles.permissions.update', $role->id) }}"
method="POST"
class="p-5">
@csrf
@php
$rolePermNames = $role->permissions->pluck('name')->toArray();
@endphp
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
@foreach($modules as $moduleKey => $module)
<div class="bg-slate-50/70 border border-slate-200/60 rounded-xl p-4 space-y-3">
<h3 class="text-xs font-bold text-slate-800 flex items-center justify-between pb-2 border-b border-slate-200/60">
<span class="flex items-center gap-1.5">
<i class="{{ $module['icon'] }} text-indigo-600 text-xs"></i>
<span>{{ $module['name'] }}</span>
</span>
<span class="text-[10px] text-slate-400 font-semibold">{{ count($module['permissions']) }} izin</span>
</h3>
<div class="space-y-2">
@foreach($module['permissions'] as $permKey => $permMeta)
@php
$isChecked = $role->name === 'super_admin' || in_array($permKey, $rolePermNames);
@endphp
<label class="flex items-start gap-2.5 text-xs text-slate-700 cursor-pointer select-none group p-2 rounded-lg hover:bg-white hover:shadow-xs border border-transparent hover:border-slate-200/60 transition">
<input type="checkbox"
name="permissions[]"
value="{{ $permKey }}"
{{ $isChecked ? 'checked' : '' }}
{{ $role->name === 'super_admin' ? 'disabled' : '' }}
class="mt-1 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500 transition">
<div>
<span class="text-xs font-bold text-slate-800 group-hover:text-indigo-600 transition block">
{{ $permMeta['label'] }}
</span>
<p class="text-[11px] text-slate-500 mt-0.5 leading-snug">
{{ $permMeta['description'] }}
</p>
<span class="font-mono text-[10px] text-slate-400 mt-1 block">
{{ $permKey }}
</span>
</div>
</label>
@endforeach
</div>
</div>
@endforeach
</div>
</form>
</div>
@endforeach
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: TAMBAH ROLE BARU -->
<!-- ========================================================================= -->
<div id="createRoleModal" class="fixed inset-0 z-50 hidden overflow-y-auto bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-2xl max-w-sm w-full shadow-2xl overflow-hidden animate-scale-in">
<div class="px-5 py-4 border-b border-slate-100 flex items-center justify-between">
<h3 class="text-sm font-bold text-slate-800 flex items-center gap-2">
<i class="fa-solid fa-shield-plus text-indigo-600"></i>
Tambah Role Baru
</h3>
<button type="button" onclick="closeCreateRoleModal()" class="text-slate-400 hover:text-slate-600">
<i class="fa-solid fa-xmark text-base"></i>
</button>
</div>
<form action="{{ route('admin.roles.store') }}" method="POST" class="p-5 space-y-4">
@csrf
<div>
<label class="block text-xs font-bold text-slate-700 mb-1">Nama Role *</label>
<input type="text" name="name" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white" placeholder="Contoh: auditor_internal">
<p class="text-[10px] text-slate-400 mt-1">Gunakan huruf kecil atau underscore (contoh: staff_logistik).</p>
</div>
<div class="pt-3 border-t border-slate-100 flex items-center justify-end gap-2">
<button type="button" onclick="closeCreateRoleModal()" class="px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-bold transition">
Batal
</button>
<button type="submit" class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
Simpan Role
</button>
</div>
</form>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: HAPUS ROLE -->
<!-- ========================================================================= -->
<div id="deleteRoleModal" class="fixed inset-0 z-50 hidden overflow-y-auto bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-2xl max-w-sm w-full shadow-2xl overflow-hidden p-6 text-center animate-scale-in">
<div class="w-12 h-12 rounded-full bg-rose-50 text-rose-600 flex items-center justify-center mx-auto mb-3 text-xl">
<i class="fa-solid fa-trash-can"></i>
</div>
<h3 class="text-sm font-bold text-slate-800 mb-1">Hapus Role Kustom</h3>
<p class="text-xs text-slate-500 mb-5">
Apakah Anda yakin ingin menghapus role <strong id="deleteRoleName" class="text-slate-800"></strong>?
</p>
<form id="deleteRoleForm" method="POST">
@csrf
@method('DELETE')
<div class="flex items-center justify-center gap-2.5">
<button type="button" onclick="closeDeleteRoleModal()" class="px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-bold transition">
Batal
</button>
<button type="submit" class="px-4 py-2 bg-rose-600 hover:bg-rose-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
Ya, Hapus Role
</button>
</div>
</form>
</div>
</div>
<script>
function openCreateRoleModal() {
document.getElementById('createRoleModal').classList.remove('hidden');
document.documentElement.classList.add('modal-open');
}
function closeCreateRoleModal() {
document.getElementById('createRoleModal').classList.add('hidden');
document.documentElement.classList.remove('modal-open');
}
function openDeleteRoleModal(roleId, roleName) {
document.getElementById('deleteRoleForm').action = `/admin/roles/${roleId}`;
document.getElementById('deleteRoleName').textContent = roleName;
document.getElementById('deleteRoleModal').classList.remove('hidden');
document.documentElement.classList.add('modal-open');
}
function closeDeleteRoleModal() {
document.getElementById('deleteRoleModal').classList.add('hidden');
document.documentElement.classList.remove('modal-open');
}
</script>
@endsection
+490
View File
@@ -0,0 +1,490 @@
@extends('layouts.app')
@section('title', 'Manajemen Pengguna - Super Admin RKM')
@section('content')
<div class="space-y-6">
<!-- Header Halaman -->
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
<div>
<h1 class="text-2xl font-black text-slate-800 tracking-tight flex items-center gap-2.5">
<span class="w-2.5 h-7 rounded-full bg-indigo-600 inline-block"></span>
Manajemen Pengguna Sistem
</h1>
<p class="text-xs text-slate-500 mt-1">
Kelola akun pengguna, ganti kata sandi, dan tetapkan role wewenang pada sistem RKM-KMH.
</p>
</div>
<div>
<button type="button"
onclick="openCreateUserModal()"
class="inline-flex items-center gap-2 px-4 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
<i class="fa-solid fa-user-plus text-sm"></i>
<span>Tambah Pengguna Baru</span>
</button>
</div>
</div>
<!-- Alert Notifikasi Flash -->
@if(session('success'))
<div class="p-4 bg-emerald-50 border border-emerald-200 rounded-2xl flex items-center justify-between text-emerald-800 text-xs font-semibold">
<div class="flex items-center gap-2.5">
<i class="fa-solid fa-circle-check text-emerald-600 text-base"></i>
<span>{{ session('success') }}</span>
</div>
<button type="button" onclick="this.parentElement.remove()" class="text-emerald-500 hover:text-emerald-700">
<i class="fa-solid fa-xmark"></i>
</button>
</div>
@endif
@if(session('error'))
<div class="p-4 bg-rose-50 border border-rose-200 rounded-2xl flex items-center justify-between text-rose-800 text-xs font-semibold">
<div class="flex items-center gap-2.5">
<i class="fa-solid fa-triangle-exclamation text-rose-600 text-base"></i>
<span>{{ session('error') }}</span>
</div>
<button type="button" onclick="this.parentElement.remove()" class="text-rose-500 hover:text-rose-700">
<i class="fa-solid fa-xmark"></i>
</button>
</div>
@endif
@if($errors->any())
<div class="p-4 bg-rose-50 border border-rose-200 rounded-2xl text-rose-800 text-xs">
<div class="flex items-center gap-2 font-bold mb-1">
<i class="fa-solid fa-circle-xmark text-rose-600"></i>
<span>Terdapat kesalahan pada input Anda:</span>
</div>
<ul class="list-disc list-inside space-y-0.5 text-rose-700">
@foreach($errors->all() as $err)
<li>{{ $err }}</li>
@endforeach
</ul>
</div>
@endif
<!-- Card Filter & Pencarian -->
<div class="bg-white border border-slate-200/80 rounded-2xl p-4 shadow-sm">
<form method="GET" action="{{ route('admin.users.index') }}" class="flex flex-col sm:flex-row gap-3">
<div class="flex-1 relative">
<i class="fa-solid fa-magnifying-glass absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
<input type="text"
name="search"
value="{{ request('search') }}"
placeholder="Cari nama, username, atau email pengguna..."
class="w-full pl-9 pr-4 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white transition">
</div>
<div class="w-full sm:w-48">
<select name="role" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white transition">
<option value="">-- Semua Role --</option>
@foreach($roles as $role)
<option value="{{ $role->name }}" {{ request('role') === $role->name ? 'selected' : '' }}>
{{ ucwords(str_replace('_', ' ', $role->name)) }}
</option>
@endforeach
</select>
</div>
<div class="flex gap-2">
<button type="submit" class="px-4 py-2 bg-slate-800 hover:bg-slate-900 text-white rounded-xl text-xs font-bold transition flex items-center gap-2">
<i class="fa-solid fa-filter"></i>
<span>Filter</span>
</button>
@if(request()->hasAny(['search', 'role']))
<a href="{{ route('admin.users.index') }}" class="px-3 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-semibold transition" title="Reset Filter">
<i class="fa-solid fa-arrow-rotate-left"></i>
</a>
@endif
</div>
</form>
</div>
<!-- Tabel Data Pengguna -->
<div class="bg-white border border-slate-200/80 rounded-2xl shadow-sm overflow-hidden">
<div class="overflow-x-auto">
<table class="w-full text-left text-xs">
<thead>
<tr class="bg-slate-50 border-b border-slate-100 text-slate-500 font-bold uppercase tracking-wider text-[11px]">
<th class="py-3 px-4">Pengguna</th>
<th class="py-3 px-4">Email</th>
<th class="py-3 px-4">Role RBAC</th>
<th class="py-3 px-4">Penempatan Pos</th>
<th class="py-3 px-4">Terdaftar</th>
<th class="py-3 px-4 text-center">Aksi</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100 font-medium">
@forelse($users as $user)
@php
$primaryRole = $user->roles->first()?->name ?? $user->role;
$badgeStyle = match($primaryRole) {
'super_admin' => 'bg-indigo-50 text-indigo-700 border-indigo-200',
'hse_admin' => 'bg-emerald-50 text-emerald-700 border-emerald-200',
'qma_admin' => 'bg-blue-50 text-blue-700 border-blue-200',
'pg_admin' => 'bg-purple-50 text-purple-700 border-purple-200',
'gate_officer' => 'bg-amber-50 text-amber-700 border-amber-200',
default => 'bg-slate-100 text-slate-600 border-slate-200',
};
@endphp
<tr class="hover:bg-slate-50/70 transition">
<td class="py-3 px-4">
<div class="flex items-center gap-3">
<div class="w-8 h-8 rounded-full bg-indigo-50 border border-indigo-100 text-indigo-700 font-black flex items-center justify-center text-xs flex-shrink-0">
{{ strtoupper(substr($user->name, 0, 1)) }}
</div>
<div>
<p class="font-bold text-slate-900 text-xs">{{ $user->name }}</p>
<p class="text-[11px] text-slate-400 font-mono">@<span>{{ $user->username }}</span></p>
</div>
</div>
</td>
<td class="py-3 px-4 text-slate-600 font-normal">
{{ $user->email }}
</td>
<td class="py-3 px-4">
<div class="flex flex-col gap-1 items-start">
<span class="px-2.5 py-1 rounded-full text-[10px] font-bold border {{ $badgeStyle }} capitalize">
{{ str_replace('_', ' ', $primaryRole) }}
</span>
@if($user->permissions->count() > 0)
<span class="inline-flex items-center gap-1 text-[10px] font-semibold text-indigo-700 bg-indigo-50/90 px-2 py-0.5 rounded-md border border-indigo-100" title="{{ $user->permissions->pluck('name')->implode(', ') }}">
<i class="fa-solid fa-key text-[9px]"></i>
+{{ $user->permissions->count() }} Izin Khusus
</span>
@endif
</div>
</td>
<td class="py-3 px-4 text-slate-600">
@if($user->gate)
<span class="inline-flex items-center gap-1.5 text-xs text-slate-700">
<i class="fa-solid fa-location-dot text-slate-400"></i>
{{ $user->gate->name }}
</span>
@else
<span class="text-slate-400 text-[11px]">-</span>
@endif
</td>
<td class="py-3 px-4 text-slate-500 text-[11px]">
{{ $user->created_at->format('d M Y') }}
</td>
<td class="py-3 px-4 text-center">
<div class="inline-flex items-center gap-1.5">
<button type="button"
onclick='openEditUserModal(@json($user), "{{ $primaryRole }}", @json($user->permissions->pluck("name")))'
class="w-7 h-7 rounded-lg bg-slate-100 hover:bg-indigo-50 text-slate-600 hover:text-indigo-600 flex items-center justify-center transition"
title="Edit Pengguna">
<i class="fa-solid fa-pen-to-square text-xs"></i>
</button>
@if($user->id !== auth()->id() && $user->username !== 'superadmin')
<button type="button"
onclick='openDeleteUserModal({{ $user->id }}, "{{ addslashes($user->name) }}")'
class="w-7 h-7 rounded-lg bg-slate-100 hover:bg-rose-50 text-slate-600 hover:text-rose-600 flex items-center justify-center transition"
title="Hapus Pengguna">
<i class="fa-solid fa-trash-can text-xs"></i>
</button>
@endif
</div>
</td>
</tr>
@empty
<tr>
<td colspan="6" class="py-8 text-center text-slate-400">
<i class="fa-solid fa-user-slash text-2xl mb-2 text-slate-300 block"></i>
Tidak ada data pengguna yang sesuai kriteria pencarian.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@if($users->hasPages())
<div class="p-4 border-t border-slate-100">
{{ $users->links() }}
</div>
@endif
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: TAMBAH PENGGUNA BARU -->
<!-- ========================================================================= -->
<div id="createUserModal" class="fixed inset-0 z-50 hidden overflow-y-auto bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-2xl max-w-lg w-full shadow-2xl overflow-hidden animate-scale-in">
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between">
<h3 class="text-sm font-bold text-slate-800 flex items-center gap-2">
<i class="fa-solid fa-user-plus text-indigo-600"></i>
Tambah Pengguna Baru
</h3>
<button type="button" onclick="closeCreateUserModal()" class="text-slate-400 hover:text-slate-600">
<i class="fa-solid fa-xmark text-base"></i>
</button>
</div>
<form action="{{ route('admin.users.store') }}" method="POST" class="p-6 space-y-4">
@csrf
<div>
<label class="block text-xs font-bold text-slate-700 mb-1">Nama Lengkap *</label>
<input type="text" name="name" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white" placeholder="Contoh: Ahmad Rizky">
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1">Username *</label>
<input type="text" name="username" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white" placeholder="Contoh: ahmad.rizky">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1">Email *</label>
<input type="email" name="email" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white" placeholder="[email protected]">
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1">Password *</label>
<input type="password" name="password" required minlength="6" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white" placeholder="Minimal 6 karakter">
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1">Role RBAC *</label>
<select name="role" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
<option value="">-- Pilih Role --</option>
@foreach($roles as $role)
<option value="{{ $role->name }}">{{ ucwords(str_replace('_', ' ', $role->name)) }}</option>
@endforeach
</select>
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1">Penempatan Pos Gerbang</label>
<select name="gate_id" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
<option value="">-- Tanpa Pos Gerbang --</option>
@foreach($gates as $gate)
<option value="{{ $gate->id }}">{{ $gate->name }} ({{ $gate->code }})</option>
@endforeach
</select>
</div>
</div>
<div class="pt-4 border-t border-slate-100 flex items-center justify-end gap-2.5">
<button type="button" onclick="closeCreateUserModal()" class="px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-bold transition">
Batal
</button>
<button type="submit" class="px-5 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
Simpan Pengguna
</button>
</div>
</form>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: EDIT PENGGUNA -->
<!-- ========================================================================= -->
<div id="editUserModal" class="fixed inset-0 z-50 hidden overflow-y-auto bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-2xl max-w-lg w-full shadow-2xl overflow-hidden animate-scale-in">
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between">
<h3 class="text-sm font-bold text-slate-800 flex items-center gap-2">
<i class="fa-solid fa-user-pen text-indigo-600"></i>
Edit Data Pengguna
</h3>
<button type="button" onclick="closeEditUserModal()" class="text-slate-400 hover:text-slate-600">
<i class="fa-solid fa-xmark text-base"></i>
</button>
</div>
<form id="editUserForm" method="POST" class="p-6 space-y-4">
@csrf
<div>
<label class="block text-xs font-bold text-slate-700 mb-1">Nama Lengkap *</label>
<input type="text" id="edit_name" name="name" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1">Username *</label>
<input type="text" id="edit_username" name="username" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1">Email *</label>
<input type="email" id="edit_email" name="email" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1">
Ganti Password <span class="text-slate-400 font-normal">(Kosongkan jika tidak ingin mengubah)</span>
</label>
<input type="password" name="password" minlength="6" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white" placeholder="Masukkan password baru">
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1">Role RBAC *</label>
<select id="edit_role" name="role" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
@foreach($roles as $role)
<option value="{{ $role->name }}">{{ ucwords(str_replace('_', ' ', $role->name)) }}</option>
@endforeach
</select>
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1">Penempatan Pos Gerbang</label>
<select id="edit_gate_id" name="gate_id" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
<option value="">-- Tanpa Pos Gerbang --</option>
@foreach($gates as $gate)
<option value="{{ $gate->id }}">{{ $gate->name }} ({{ $gate->code }})</option>
@endforeach
</select>
</div>
</div>
<!-- Accordion: Izin Tambahan Khusus (Direct Permissions) -->
<div class="border border-slate-200 rounded-xl overflow-hidden bg-slate-50/50">
<button type="button"
onclick="toggleDirectPermsAccordion()"
class="w-full px-4 py-2.5 bg-slate-100/70 hover:bg-slate-100 flex items-center justify-between text-xs font-bold text-slate-700 transition">
<span class="flex items-center gap-2">
<i class="fa-solid fa-key text-indigo-600"></i>
<span>Izin Tambahan Khusus (Direct Permissions)</span>
</span>
<i id="directPermsChevron" class="fa-solid fa-chevron-down text-[10px] text-slate-400 transition-transform duration-200"></i>
</button>
<div id="directPermsContainer" class="hidden p-4 space-y-4 max-h-56 overflow-y-auto bg-white border-t border-slate-200 text-xs">
<p class="text-[11px] text-slate-500 mb-1">
Pilih izin individual tambahan di luar wewenang role bawaan pengguna ini:
</p>
@foreach($modules as $moduleKey => $module)
<div class="space-y-1.5 pb-2.5 border-b border-slate-100 last:border-0">
<p class="font-bold text-[11px] text-indigo-950 flex items-center gap-1.5">
<i class="{{ $module['icon'] }} text-[10px] text-indigo-600"></i>
<span>{{ $module['name'] }}</span>
</p>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-1.5 pl-3">
@foreach($module['permissions'] as $permKey => $permMeta)
<label class="flex items-start gap-2 text-[11px] text-slate-700 cursor-pointer select-none group">
<input type="checkbox"
name="direct_permissions[]"
value="{{ $permKey }}"
id="edit_perm_{{ str_replace('.', '_', $permKey) }}"
class="mt-0.5 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500 user-direct-perm-checkbox">
<div>
<span class="font-medium text-slate-800 group-hover:text-indigo-600 transition block">
{{ $permMeta['label'] }}
</span>
<span class="font-mono text-[9px] text-slate-400 block">{{ $permKey }}</span>
</div>
</label>
@endforeach
</div>
</div>
@endforeach
</div>
</div>
<div class="pt-4 border-t border-slate-100 flex items-center justify-end gap-2.5">
<button type="button" onclick="closeEditUserModal()" class="px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-bold transition">
Batal
</button>
<button type="submit" class="px-5 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
Simpan Perubahan
</button>
</div>
</form>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: HAPUS PENGGUNA -->
<!-- ========================================================================= -->
<div id="deleteUserModal" class="fixed inset-0 z-50 hidden overflow-y-auto bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-2xl max-w-sm w-full shadow-2xl overflow-hidden p-6 text-center animate-scale-in">
<div class="w-12 h-12 rounded-full bg-rose-50 text-rose-600 flex items-center justify-center mx-auto mb-3 text-xl">
<i class="fa-solid fa-trash-can"></i>
</div>
<h3 class="text-sm font-bold text-slate-800 mb-1">Hapus Pengguna</h3>
<p class="text-xs text-slate-500 mb-5">
Apakah Anda yakin ingin menghapus pengguna <strong id="deleteUserName" class="text-slate-800"></strong>? Tindakan ini tidak dapat dibatalkan.
</p>
<form id="deleteUserForm" method="POST">
@csrf
@method('DELETE')
<div class="flex items-center justify-center gap-2.5">
<button type="button" onclick="closeDeleteUserModal()" class="px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-bold transition">
Batal
</button>
<button type="submit" class="px-4 py-2 bg-rose-600 hover:bg-rose-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
Ya, Hapus Pengguna
</button>
</div>
</form>
</div>
</div>
<script>
function openCreateUserModal() {
document.getElementById('createUserModal').classList.remove('hidden');
document.documentElement.classList.add('modal-open');
}
function closeCreateUserModal() {
document.getElementById('createUserModal').classList.add('hidden');
document.documentElement.classList.remove('modal-open');
}
function toggleDirectPermsAccordion() {
const container = document.getElementById('directPermsContainer');
const chevron = document.getElementById('directPermsChevron');
if (container) {
container.classList.toggle('hidden');
}
if (chevron) {
chevron.classList.toggle('rotate-180');
}
}
function openEditUserModal(user, primaryRole, userDirectPerms) {
document.getElementById('editUserForm').action = `/admin/users/${user.id}`;
document.getElementById('edit_name').value = user.name;
document.getElementById('edit_username').value = user.username;
document.getElementById('edit_email').value = user.email;
document.getElementById('edit_role').value = primaryRole;
document.getElementById('edit_gate_id').value = user.gate_id || '';
// Uncheck all direct permission checkboxes first
document.querySelectorAll('.user-direct-perm-checkbox').forEach(cb => cb.checked = false);
// Check assigned direct permissions
if (Array.isArray(userDirectPerms)) {
userDirectPerms.forEach(permName => {
const el = document.getElementById('edit_perm_' + permName.replace(/\./g, '_'));
if (el) el.checked = true;
});
}
document.getElementById('editUserModal').classList.remove('hidden');
document.documentElement.classList.add('modal-open');
}
function closeEditUserModal() {
document.getElementById('editUserModal').classList.add('hidden');
document.documentElement.classList.remove('modal-open');
}
function openDeleteUserModal(userId, userName) {
document.getElementById('deleteUserForm').action = `/admin/users/${userId}`;
document.getElementById('deleteUserName').textContent = userName;
document.getElementById('deleteUserModal').classList.remove('hidden');
document.documentElement.classList.add('modal-open');
}
function closeDeleteUserModal() {
document.getElementById('deleteUserModal').classList.add('hidden');
document.documentElement.classList.remove('modal-open');
}
</script>
@endsection
@@ -37,12 +37,14 @@
</button>
<!-- Tombol Tambah Karyawan (+ Tambah Karyawan Hijau Tua) -->
@can('hse.employees.create')
<button type="button"
onclick="document.getElementById('addKaryawanModal').classList.remove('hidden')"
class="w-full sm:w-auto bg-[#1b5e20] hover:bg-[#144919] text-white px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold flex items-center justify-center space-x-2 transition shadow-sm">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Karyawan</span>
</button>
@endcan
</div>
</div>
@@ -173,6 +175,7 @@
<!-- Aksi (Edit Data Simper & Perpanjang SIMPER) -->
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@can('hse.employees.edit')
<div class="flex items-center justify-center space-x-2">
<button onclick='openEditModal(@json($emp))'
class="inline-flex items-center space-x-1 text-amber-500 hover:text-amber-700 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
@@ -187,6 +190,9 @@
Perpanjang
</button>
</div>
@else
<span class="text-xs text-slate-400 italic">Hanya lihat</span>
@endcan
</td>
</tr>
@empty
+257 -99
View File
@@ -139,7 +139,19 @@
<!-- Grup: Navigasi Utama -->
<div>
<nav class="space-y-1">
@if(auth()->user()->isHseAdmin())
@if(auth()->user()->isSuperAdmin())
<a href="{{ route('admin.dashboard') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('admin.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Dashboard Admin</span>
</a>
@elseif(auth()->user()->isHseAdmin())
@can('hse.employees.view')
<a href="{{ route('hse.dashboard') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('hse.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
@@ -150,7 +162,9 @@
</svg>
<span>Dashboard</span>
</a>
@endcan
@elseif(auth()->user()->isQmaAdmin())
@can('qma.vehicles.view')
<a href="{{ route('qma.dashboard') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('qma.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
@@ -161,7 +175,9 @@
</svg>
<span>Dashboard</span>
</a>
@endcan
@elseif(auth()->user()->isPgAdmin())
@can('pg.guards.view')
<a href="{{ route('pg.dashboard') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
@@ -172,32 +188,64 @@
</svg>
<span>Dashboard</span>
</a>
@endcan
@elseif(auth()->user()->isGateOfficer())
@can('gate.inspect')
<a href="{{ route('pg.gate.inspection') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
<span>Verifikasi Pos Gerbang</span>
</a>
@endcan
@endif
</nav>
</div>
<!-- Grup: Modul Operasional RKM -->
@if(!auth()->user()->isGateOfficer())
@if(auth()->user()->isSuperAdmin())
<div>
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
MANAJEMEN SISTEM
SUPER ADMIN & RBAC
</p>
<nav class="space-y-1">
@if(auth()->user()->isHseAdmin() || auth()->user()->isAdmin())
<a href="{{ route('hse.employees.index') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('hse.employees.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-id-card text-base w-5 text-center"></i>
<span>Data Simper</span>
</a>
@endif
<a href="{{ route('admin.users.index') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('admin.users.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-users-gear text-base w-5 text-center"></i>
<span>Kelola Pengguna</span>
</a>
@if(auth()->user()->isQmaAdmin() || auth()->user()->isAdmin())
<a href="{{ route('admin.roles.index') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('admin.roles.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
<span>Role & Permission</span>
</a>
</nav>
</div>
@endif
<!-- Grup: Manajemen HSE -->
@can('hse.employees.view')
<div>
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
MANAJEMEN HSE
</p>
<nav class="space-y-1">
<a href="{{ route('hse.employees.index') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('hse.employees.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-id-card text-base w-5 text-center"></i>
<span>Data Simper</span>
</a>
</nav>
</div>
@endcan
<!-- Grup: Manajemen QMA -->
@if(auth()->user()->canAny(['qma.vehicles.view', 'qma.logs.view', 'qma.summary.view']))
<div>
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
MANAJEMEN QMA
</p>
<nav class="space-y-1">
@can('qma.vehicles.view')
@php
$isVehicleRoute = request()->routeIs('qma.vehicles.*');
@endphp
@@ -226,32 +274,58 @@
</a>
</div>
</div>
@endcan
@can('qma.logs.view')
<a href="{{ route('qma.activity.log') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('qma.activity.log') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-clipboard-list text-base w-5 text-center"></i>
<span>Log Aktivitas Kendaraan</span>
</a>
@endcan
@can('qma.summary.view')
<a href="{{ route('qma.activity.summary') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('qma.activity.summary') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-chart-pie text-base w-5 text-center"></i>
<span>Summary Aktivitas</span>
</a>
@endif
@endcan
</nav>
</div>
@endif
@if(auth()->user()->isPgAdmin() || auth()->user()->isAdmin())
<!-- Grup: Manajemen Private Guard (PG) -->
@if(auth()->user()->canAny(['pg.guards.view', 'pg.logs.view', 'gate.inspect']))
<div>
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
MANAJEMEN PRIVATE GUARD (PG)
</p>
<nav class="space-y-1">
@can('pg.guards.view')
<a href="{{ route('pg.guards.index') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.guards.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-user-shield text-base w-5 text-center"></i>
<span>Data Satpam</span>
</a>
@endcan
@can('pg.logs.view')
<a href="{{ route('pg.logs.index') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.logs.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-clock-rotate-left text-base w-5 text-center"></i>
<span>Log Verifikasi Gerbang</span>
</a>
@endcan
@if(!auth()->user()->isGateOfficer())
@can('gate.inspect')
<a href="{{ route('pg.gate.inspection') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
<span>Verifikasi Pos Gerbang</span>
</a>
@endcan
@endif
</nav>
</div>
@@ -312,97 +386,181 @@
</div>
<div class="p-4 space-y-4 flex-1 overflow-y-auto">
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider px-2">NAVIGASI</p>
<div class="space-y-1">
@if(auth()->user()->isHseAdmin() || auth()->user()->isAdmin())
<a href="{{ route('hse.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('hse.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Dashboard</span>
<div>
<nav class="space-y-1">
@if(auth()->user()->isSuperAdmin())
<a href="{{ route('admin.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('admin.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Dashboard Admin</span>
</a>
@elseif(auth()->user()->isHseAdmin())
@can('hse.employees.view')
<a href="{{ route('hse.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('hse.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Dashboard</span>
</a>
@endcan
@elseif(auth()->user()->isQmaAdmin())
@can('qma.vehicles.view')
<a href="{{ route('qma.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Dashboard</span>
</a>
@endcan
@elseif(auth()->user()->isPgAdmin())
@can('pg.guards.view')
<a href="{{ route('pg.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Dashboard</span>
</a>
@endcan
@elseif(auth()->user()->isGateOfficer())
@can('gate.inspect')
<a href="{{ route('pg.gate.inspection') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
<span>Verifikasi Pos Gerbang</span>
</a>
@endcan
@endif
</nav>
</div>
@if(auth()->user()->isSuperAdmin())
<div>
<p class="px-2 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
SUPER ADMIN & RBAC
</p>
<nav class="space-y-1">
<a href="{{ route('admin.users.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('admin.users.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-users-gear w-5 text-center"></i>
<span>Kelola Pengguna</span>
</a>
<a href="{{ route('admin.roles.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('admin.roles.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-shield-halved w-5 text-center"></i>
<span>Role & Permission</span>
</a>
</nav>
</div>
@endif
<!-- Grup: Manajemen HSE -->
@can('hse.employees.view')
<div>
<p class="px-2 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
MANAJEMEN HSE
</p>
<nav class="space-y-1">
<a href="{{ route('hse.employees.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('hse.employees.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-id-card w-5 text-center"></i>
<span>Data Simper</span>
</a>
@endif
@if(auth()->user()->isQmaAdmin() || auth()->user()->isAdmin())
<a href="{{ route('qma.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Dashboard</span>
</a>
@php
$isVehicleRouteMob = request()->routeIs('qma.vehicles.*');
@endphp
<div>
<button type="button"
onclick="toggleVehicleMenu('mobile')"
class="w-full flex items-center justify-between px-3 py-2.5 text-sm rounded-xl transition group {{ $isVehicleRouteMob ? 'bg-emerald-50/70 text-[#1b5e20] font-bold' : 'sidebar-item-inactive' }}">
<div class="flex items-center space-x-3">
<i class="fa-solid fa-car w-5 text-center {{ $isVehicleRouteMob ? 'text-[#1b5e20]' : '' }}"></i>
<span>Data Kendaraan</span>
</div>
<i id="vehicleChevronMobile" class="fa-solid fa-chevron-down text-[11px] transition-transform duration-200 {{ $isVehicleRouteMob ? 'rotate-180 text-[#1b5e20]' : 'text-slate-400 group-hover:text-slate-600' }}"></i>
</button>
<div id="vehicleSubmenuMobile" class="{{ $isVehicleRouteMob ? '' : 'hidden' }} mt-1 pl-7 pr-1 space-y-1">
<a href="{{ route('qma.vehicles.lv') }}"
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.vehicles.lv') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
<span>Light Vehicle</span>
</a>
<a href="{{ route('qma.vehicles.support') }}"
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.vehicles.support') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
<span>Unit Support</span>
</a>
</div>
</div>
<a href="{{ route('qma.activity.log') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.activity.log') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-clipboard-list w-5 text-center"></i>
<span>Log Aktivitas Kendaraan</span>
</a>
<a href="{{ route('qma.activity.summary') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.activity.summary') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-chart-pie w-5 text-center"></i>
<span>Summary Aktivitas</span>
</a>
@endif
@if(auth()->user()->isPgAdmin() || auth()->user()->isAdmin())
<a href="{{ route('pg.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Dashboard</span>
</a>
<a href="{{ route('pg.guards.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.guards.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-user-shield w-5 text-center"></i>
<span>Data Satpam</span>
</a>
<a href="{{ route('pg.logs.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.logs.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-clock-rotate-left w-5 text-center"></i>
<span>Log Verifikasi Gerbang</span>
</a>
@endif
@if(auth()->user()->isGateOfficer())
<a href="{{ route('pg.gate.inspection') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-shield-halved w-5 text-center"></i>
<span>Verifikasi Pos Gerbang</span>
</a>
@endif
</nav>
</div>
@endcan
<!-- Grup: Manajemen QMA -->
@if(auth()->user()->canAny(['qma.vehicles.view', 'qma.logs.view', 'qma.summary.view']))
<div>
<p class="px-2 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
MANAJEMEN QMA
</p>
<nav class="space-y-1">
@can('qma.vehicles.view')
@php
$isVehicleRouteMob = request()->routeIs('qma.vehicles.*');
@endphp
<div>
<button type="button"
onclick="toggleVehicleMenu('mobile')"
class="w-full flex items-center justify-between px-3 py-2.5 text-sm rounded-xl transition group {{ $isVehicleRouteMob ? 'bg-emerald-50/70 text-[#1b5e20] font-bold' : 'sidebar-item-inactive' }}">
<div class="flex items-center space-x-3">
<i class="fa-solid fa-car w-5 text-center {{ $isVehicleRouteMob ? 'text-[#1b5e20]' : '' }}"></i>
<span>Data Kendaraan</span>
</div>
<i id="vehicleChevronMobile" class="fa-solid fa-chevron-down text-[11px] transition-transform duration-200 {{ $isVehicleRouteMob ? 'rotate-180 text-[#1b5e20]' : 'text-slate-400 group-hover:text-slate-600' }}"></i>
</button>
<div id="vehicleSubmenuMobile" class="{{ $isVehicleRouteMob ? '' : 'hidden' }} mt-1 pl-7 pr-1 space-y-1">
<a href="{{ route('qma.vehicles.lv') }}"
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.vehicles.lv') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
<span>Light Vehicle</span>
</a>
<a href="{{ route('qma.vehicles.support') }}"
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.vehicles.support') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
<span>Unit Support</span>
</a>
</div>
</div>
@endcan
@can('qma.logs.view')
<a href="{{ route('qma.activity.log') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.activity.log') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-clipboard-list w-5 text-center"></i>
<span>Log Aktivitas Kendaraan</span>
</a>
@endcan
@can('qma.summary.view')
<a href="{{ route('qma.activity.summary') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.activity.summary') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-chart-pie w-5 text-center"></i>
<span>Summary Aktivitas</span>
</a>
@endcan
</nav>
</div>
@endif
<!-- Grup: Manajemen Private Guard (PG) -->
@if(auth()->user()->canAny(['pg.guards.view', 'pg.logs.view', 'gate.inspect']))
<div>
<p class="px-2 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
MANAJEMEN PRIVATE GUARD (PG)
</p>
<nav class="space-y-1">
@can('pg.guards.view')
<a href="{{ route('pg.guards.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.guards.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-user-shield w-5 text-center"></i>
<span>Data Satpam</span>
</a>
@endcan
@can('pg.logs.view')
<a href="{{ route('pg.logs.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.logs.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-clock-rotate-left w-5 text-center"></i>
<span>Log Verifikasi Gerbang</span>
</a>
@endcan
@if(!auth()->user()->isGateOfficer())
@can('gate.inspect')
<a href="{{ route('pg.gate.inspection') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-shield-halved w-5 text-center"></i>
<span>Verifikasi Pos Gerbang</span>
</a>
@endcan
@endif
</nav>
</div>
@endif
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider px-2 mt-4">PENGATURAN</p>
<div class="space-y-1">
+12
View File
@@ -27,12 +27,14 @@
<!-- Tombol Aksi Kanan (+ Tambah Satpam Hijau Tua) -->
<div class="flex items-center space-x-3 w-full sm:w-auto">
@can('pg.guards.create')
<button type="button"
onclick="document.getElementById('addGuardModal').classList.remove('hidden')"
class="w-full sm:w-auto bg-[#1b5e20] hover:bg-[#144919] text-white px-5 py-2.5 rounded-xl text-xs font-bold flex items-center justify-center space-x-2 transition shadow-sm">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Petugas Satpam</span>
</button>
@endcan
</div>
</div>
@@ -169,6 +171,7 @@
<!-- Aksi (Ikon Edit Oranye & Ikon Status Merah Selaras Format Gambar) -->
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<div class="flex items-center justify-center space-x-2">
@can('pg.guards.edit')
<!-- Tombol Edit Oranye -->
<button type="button"
onclick="openEditGuardModal({{ json_encode($g) }})"
@@ -176,7 +179,9 @@
title="Edit Data / Reset Password">
<i class="fa-regular fa-pen-to-square text-sm"></i>
</button>
@endcan
@can('pg.guards.toggle')
<!-- Tombol Toggle Nonaktifkan/Aktifkan Merah/Hijau -->
<button type="button"
onclick="openToggleStatusModal({{ $g->id }}, '{{ addslashes($g->name) }}', '{{ $g->badge_id ?? 'SEC-' . str_pad($g->id, 3, '0', STR_PAD_LEFT) }}', {{ $g->is_active ? 'true' : 'false' }})"
@@ -184,7 +189,9 @@
class="{{ $g->is_active ? 'text-rose-500 hover:text-rose-700' : 'text-emerald-600 hover:text-emerald-800' }} p-1.5 transition cursor-pointer">
<i class="fa-solid fa-power-off text-sm"></i>
</button>
@endcan
@can('pg.guards.delete')
<!-- Tombol Hapus Merah -->
<button type="button"
onclick="openDeleteGuardModal({{ $g->id }}, '{{ addslashes($g->name) }}', '{{ $g->badge_id ?? 'SEC-' . str_pad($g->id, 3, '0', STR_PAD_LEFT) }}')"
@@ -192,6 +199,11 @@
class="text-rose-600 hover:text-rose-800 p-1.5 transition cursor-pointer">
<i class="fa-regular fa-trash-can text-sm"></i>
</button>
@endcan
@if(!auth()->user()->can('pg.guards.edit') && !auth()->user()->can('pg.guards.toggle') && !auth()->user()->can('pg.guards.delete'))
<span class="text-xs text-slate-400 italic">Hanya lihat</span>
@endif
</div>
</td>
</tr>
@@ -94,6 +94,7 @@
<span>Cek fisik kendaraan lalu klik verifikasi untuk membuka portal</span>
</span>
@can('gate.approve')
<form action="{{ route('pg.gate.approve', $act->id) }}" method="POST" class="w-full sm:w-auto m-0">
@csrf
@if($currentGuard)
@@ -109,6 +110,9 @@
<span>Verifikasi</span>
</button>
</form>
@else
<span class="text-xs text-slate-400 italic">Tidak memiliki izin verifikasi</span>
@endcan
</div>
</div>
@@ -35,11 +35,13 @@
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
</button>
@can('qma.vehicles.create')
<button onclick="openAddModal()"
class="bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Light Vehicle</span>
</button>
@endcan
</div>
</div>
@@ -182,17 +184,21 @@
title="Lihat Detail Kendaraan">
<i class="fa-regular fa-eye text-sm"></i>
</button>
@can('qma.vehicles.edit')
<button onclick='openEditModal(@json($v))'
class="inline-flex items-center space-x-1 text-amber-600 hover:text-amber-800 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
title="Edit Data Light Vehicle">
<i class="fa-regular fa-pen-to-square text-sm"></i>
</button>
@endcan
@can('qma.vehicles.delete')
<button type="button"
onclick="openDeleteModal('{{ $v->id }}', '{{ $v->code }}', '{{ addslashes($v->brand_type ?? '') }}')"
class="inline-flex items-center space-x-1 text-rose-600 hover:text-rose-800 hover:bg-rose-50 px-2 py-1 rounded-lg transition"
title="Hapus Kendaraan">
<i class="fa-regular fa-trash-can text-sm"></i>
</button>
@endcan
</div>
</td>
</tr>
@@ -35,11 +35,13 @@
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
</button>
@can('qma.vehicles.create')
<button onclick="openAddModal()"
class="bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Unit Support</span>
</button>
@endcan
</div>
</div>
@@ -214,17 +216,21 @@
title="Lihat Detail & Perizinan">
<i class="fa-regular fa-eye text-sm"></i>
</button>
@can('qma.vehicles.edit')
<button onclick='openEditModal(@json($v))'
class="inline-flex items-center space-x-1 text-amber-600 hover:text-amber-800 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
title="Edit Data Unit Support">
<i class="fa-regular fa-pen-to-square text-sm"></i>
</button>
@endcan
@can('qma.vehicles.delete')
<button type="button"
onclick="openDeleteModal('{{ $v->id }}', '{{ $v->code }}', '{{ addslashes($v->brand_type ?? '') }}')"
class="inline-flex items-center space-x-1 text-rose-600 hover:text-rose-800 hover:bg-rose-50 px-2 py-1 rounded-lg transition"
title="Hapus Unit">
<i class="fa-regular fa-trash-can text-sm"></i>
<i class="fa-regular fa-trash-can text-sm"></i>
</button>
@endcan
</div>
</td>
</tr>