feat: replace gate verification with verification logs for Admin PG and restrict gate inspection to gate officers

This commit is contained in:
Wahyudin
2026-10-13 14:54:50 +07:00
parent 40d44a631f
commit 342d03722e
6 changed files with 578 additions and 14 deletions
@@ -0,0 +1,101 @@
<?php
namespace App\Http\Controllers\Pg;
use App\Http\Controllers\Controller;
use App\Models\Gate;
use App\Models\SecurityGuard;
use App\Models\VehicleActivity;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\View\View;
class VerificationLogController extends Controller
{
/**
* Tampilkan rekapitulasi audit dan log riwayat verifikasi gerbang oleh petugas Satpam.
*/
public function index(Request $request): View
{
$query = VehicleActivity::with(['vehicle', 'driver', 'gate', 'securityGuard'])
->orderByRaw('COALESCE(validated_at, recorded_at) DESC');
// Filter Rentang Tanggal
if ($request->filled('start_date') && $request->filled('end_date')) {
$startDate = Carbon::parse($request->input('start_date'))->startOfDay();
$endDate = Carbon::parse($request->input('end_date'))->endOfDay();
$query->whereBetween('recorded_at', [$startDate, $endDate]);
}
// Filter Regu Satpam (1, 2, 3)
if ($request->filled('team')) {
$team = (int) $request->input('team');
$query->whereHas('securityGuard', function ($sq) use ($team) {
$sq->where('team', $team);
});
}
// Filter Petugas Satpam Spesifik
if ($request->filled('security_guard_id')) {
$query->where('security_guard_id', $request->input('security_guard_id'));
}
// Filter Pos Gerbang
if ($request->filled('gate_id')) {
$query->where('gate_id', $request->input('gate_id'));
}
// Filter Arah Gerbang (in / out)
if ($request->filled('direction')) {
$query->where('direction', $request->input('direction'));
}
// Filter Status Verifikasi (approved, rejected, pending)
if ($request->filled('status')) {
$query->where('validation_status', $request->input('status'));
}
// Filter Kata Kunci Pencarian (No Transaksi, Petugas Satpam, Badge, Driver, NIK, Plat, Kode LV)
if ($request->filled('search')) {
$search = trim($request->input('search'));
$query->where(function ($q) use ($search) {
$q->where('transaction_no', 'like', "%{$search}%")
->orWhere('purpose', 'like', "%{$search}%")
->orWhere('rejection_note', 'like', "%{$search}%")
->orWhereHas('securityGuard', function ($sq) use ($search) {
$sq->where('name', 'like', "%{$search}%")
->orWhere('badge_id', 'like', "%{$search}%");
})
->orWhereHas('vehicle', function ($vq) use ($search) {
$vq->where('code', 'like', "%{$search}%")
->orWhere('brand_type', 'like', "%{$search}%")
->orWhere('license_plate', 'like', "%{$search}%");
})
->orWhereHas('driver', function ($dq) use ($search) {
$dq->where('name', 'like', "%{$search}%")
->orWhere('nik', 'like', "%{$search}%");
});
});
}
// Data Statistik Ringkas untuk Admin PG
$totalApproved = VehicleActivity::where('validation_status', 'approved')->count();
$totalRejected = VehicleActivity::where('validation_status', 'rejected')->count();
$totalPending = VehicleActivity::where('validation_status', 'pending')->count();
$todayInspections = VehicleActivity::whereDate('recorded_at', Carbon::today())->count();
$activities = $query->paginate(20)->withQueryString();
$gates = Gate::where('is_active', true)->orderBy('name')->get();
$guards = SecurityGuard::orderBy('name')->get();
return view('pg.verification_logs', compact(
'activities',
'gates',
'guards',
'totalApproved',
'totalRejected',
'totalPending',
'todayInspections'
));
}
}
+12 -8
View File
@@ -94,7 +94,7 @@
</svg> </svg>
<span>Dashboard</span> <span>Dashboard</span>
</a> </a>
@elseif(auth()->user()->isPgAdmin() || auth()->user()->isGateOfficer()) @elseif(auth()->user()->isGateOfficer())
<a href="{{ route('pg.gate.inspection') }}" <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' }}"> 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' }}">
<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"> <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">
@@ -183,13 +183,11 @@
<i class="fa-solid fa-user-shield text-base w-5 text-center"></i> <i class="fa-solid fa-user-shield text-base w-5 text-center"></i>
<span>Data Satpam</span> <span>Data Satpam</span>
</a> </a>
@endif
@if(auth()->user()->isGateOfficer() || auth()->user()->isPgAdmin() || auth()->user()->isAdmin()) <a href="{{ route('pg.logs.index') }}"
<a href="{{ route('pg.gate.inspection') }}" 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' }}">
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-clock-rotate-left text-base w-5 text-center"></i>
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i> <span>Log Verifikasi Gerbang</span>
<span>Verifikasi Gerbang</span>
</a> </a>
@endif @endif
</nav> </nav>
@@ -320,8 +318,12 @@
<i class="fa-solid fa-user-shield w-5 text-center"></i> <i class="fa-solid fa-user-shield w-5 text-center"></i>
<span>Data Satpam</span> <span>Data Satpam</span>
</a> </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 @endif
@if(auth()->user()->isGateOfficer() || auth()->user()->isPgAdmin() || auth()->user()->isAdmin()) @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' }}"> <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> <i class="fa-solid fa-shield-halved w-5 text-center"></i>
<span>Pos Gerbang</span> <span>Pos Gerbang</span>
@@ -384,6 +386,8 @@
Verifikasi Pos Gerbang Verifikasi Pos Gerbang
@elseif(request()->routeIs('pg.guards.*')) @elseif(request()->routeIs('pg.guards.*'))
Data Satpam Data Satpam
@elseif(request()->routeIs('pg.logs.*'))
Log Verifikasi Gerbang
@else @else
Dashboard Dashboard
@endif @endif
@@ -0,0 +1,410 @@
@extends('layouts.app')
@section('title', 'Log Riwayat Verifikasi Gerbang - Admin Private Guard | PT Kerinci Merangin Hidro')
@section('content')
<div class="space-y-6">
<!-- Header Judul & Tombol Aksi Cepat -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20] block mb-1">
MANAJEMEN SISTEM
</span>
<div class="flex items-center space-x-3">
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight">
Log Riwayat Verifikasi Gerbang
</h2>
<!-- Info Icon Badge -->
<span class="w-6 h-6 rounded-full bg-slate-200/90 text-slate-500 text-xs inline-flex items-center justify-center font-bold shadow-sm" title="Rekapitulasi lengkap riwayat pemeriksaan fisik kendaraan dan validasi pos gerbang oleh satpam">
<i class="fa-solid fa-info"></i>
</span>
</div>
</div>
<div class="flex items-center space-x-3 w-full sm:w-auto">
<a href="{{ route('pg.guards.index') }}" class="inline-flex items-center px-4 py-2.5 rounded-xl text-xs font-bold text-white bg-[#1b5e20] hover:bg-[#144919] shadow-sm transition group">
<i class="fa-solid fa-user-shield mr-2 group-hover:scale-110 transition-transform"></i>
<span>Kelola Data Satpam</span>
</a>
</div>
</div>
<!-- 4 Kartu Statistik Ringkas Audit Satpam -->
<div class="grid grid-cols-2 lg:grid-cols-4 gap-4">
<!-- Kartu 1: Total Disetujui (Approved) -->
<div class="bg-white rounded-2xl border border-slate-200 p-4 shadow-sm flex items-center space-x-3.5">
<div class="w-11 h-11 rounded-xl bg-emerald-50 text-[#1b5e20] flex items-center justify-center flex-shrink-0 text-lg font-bold">
<i class="fa-solid fa-circle-check"></i>
</div>
<div class="min-w-0">
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider">Disetujui</p>
<h3 class="text-xl font-extrabold text-slate-800">{{ number_format($totalApproved, 0, ',', '.') }}</h3>
</div>
</div>
<!-- Kartu 2: Total Ditolak (Rejected) -->
<div class="bg-white rounded-2xl border border-slate-200 p-4 shadow-sm flex items-center space-x-3.5">
<div class="w-11 h-11 rounded-xl bg-rose-50 text-rose-600 flex items-center justify-center flex-shrink-0 text-lg font-bold">
<i class="fa-solid fa-circle-xmark"></i>
</div>
<div class="min-w-0">
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider">Ditolak</p>
<h3 class="text-xl font-extrabold text-slate-800">{{ number_format($totalRejected, 0, ',', '.') }}</h3>
</div>
</div>
<!-- Kartu 3: Total Antrean (Pending) -->
<div class="bg-white rounded-2xl border border-slate-200 p-4 shadow-sm flex items-center space-x-3.5">
<div class="w-11 h-11 rounded-xl bg-amber-50 text-amber-600 flex items-center justify-center flex-shrink-0 text-lg font-bold">
<i class="fa-solid fa-hourglass-half"></i>
</div>
<div class="min-w-0">
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider">Menunggu</p>
<h3 class="text-xl font-extrabold text-slate-800">{{ number_format($totalPending, 0, ',', '.') }}</h3>
</div>
</div>
<!-- Kartu 4: Pemeriksaan Hari Ini -->
<div class="bg-white rounded-2xl border border-slate-200 p-4 shadow-sm flex items-center space-x-3.5">
<div class="w-11 h-11 rounded-xl bg-[#06213f]/10 text-[#06213f] flex items-center justify-center flex-shrink-0 text-lg font-bold">
<i class="fa-solid fa-calendar-day"></i>
</div>
<div class="min-w-0">
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider">Hari Ini</p>
<h3 class="text-xl font-extrabold text-slate-800">{{ number_format($todayInspections, 0, ',', '.') }}</h3>
</div>
</div>
</div>
<!-- Filter Bar Card Komprehensif -->
<div class="bg-white rounded-2xl border border-slate-200 shadow-sm p-4 sm:p-5">
<form method="GET" action="{{ route('pg.logs.index') }}" class="space-y-4">
<!-- Header Filter & Tombol Reset -->
<div class="flex items-center justify-between pb-3 border-b border-slate-100">
<div class="flex items-center space-x-2 text-slate-800 font-bold text-xs uppercase tracking-wider">
<i class="fa-solid fa-sliders text-[#1b5e20]"></i>
<span>Filter & Pencarian Log Audit</span>
</div>
@if(request()->hasAny(['search', 'team', 'security_guard_id', 'gate_id', 'direction', 'status', 'start_date', 'end_date']))
<a href="{{ route('pg.logs.index') }}" class="text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center space-x-1 transition">
<i class="fa-solid fa-rotate-left"></i>
<span>Reset Semua Filter</span>
</a>
@endif
</div>
<!-- Baris Input Filter (Grid 12 Kolom) -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-12 gap-3.5">
<!-- Pencarian Kata Kunci -->
<div class="lg:col-span-4">
<label class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center gap-1.5">
<i class="fa-solid fa-magnifying-glass text-slate-400"></i>
<span>Pencarian Cepat</span>
</label>
<input type="text"
name="search"
value="{{ request('search') }}"
placeholder="Cari TRX, Plat, Driver, Satpam, Catatan..."
class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
</div>
<!-- Filter Regu Satpam (Regu 1, 2, 3) -->
<div class="lg:col-span-2">
<label class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center gap-1.5">
<i class="fa-solid fa-users text-slate-400"></i>
<span>Regu Satpam</span>
</label>
<select name="team" class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
<option value="">Semua Regu</option>
<option value="1" {{ request('team') == '1' ? 'selected' : '' }}>Regu 1</option>
<option value="2" {{ request('team') == '2' ? 'selected' : '' }}>Regu 2</option>
<option value="3" {{ request('team') == '3' ? 'selected' : '' }}>Regu 3</option>
</select>
</div>
<!-- Filter Petugas Satpam Spesifik -->
<div class="lg:col-span-3">
<label class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center gap-1.5">
<i class="fa-solid fa-user-shield text-slate-400"></i>
<span>Petugas Satpam</span>
</label>
<select name="security_guard_id" class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
<option value="">Semua Petugas Satpam</option>
@foreach($guards as $guard)
<option value="{{ $guard->id }}" {{ request('security_guard_id') == $guard->id ? 'selected' : '' }}>
{{ $guard->badge_id }} - {{ $guard->name }} (Regu {{ $guard->team }})
</option>
@endforeach
</select>
</div>
<!-- Filter Pos Gerbang -->
<div class="lg:col-span-3">
<label class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center gap-1.5">
<i class="fa-solid fa-torii-gate text-slate-400"></i>
<span>Pos Gerbang</span>
</label>
<select name="gate_id" class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
<option value="">Semua Gerbang</option>
@foreach($gates as $g)
<option value="{{ $g->id }}" {{ request('gate_id') == $g->id ? 'selected' : '' }}>{{ $g->name }}</option>
@endforeach
</select>
</div>
<!-- Filter Arah Gerbang -->
<div class="lg:col-span-2">
<label class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center gap-1.5">
<i class="fa-solid fa-arrows-left-right text-slate-400"></i>
<span>Arah Gerbang</span>
</label>
<select name="direction" class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
<option value="">Semua Arah</option>
<option value="in" {{ request('direction') === 'in' ? 'selected' : '' }}>Masuk (In)</option>
<option value="out" {{ request('direction') === 'out' ? 'selected' : '' }}>Keluar (Out)</option>
</select>
</div>
<!-- Filter Status Verifikasi -->
<div class="lg:col-span-2">
<label class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center gap-1.5">
<i class="fa-solid fa-circle-check text-slate-400"></i>
<span>Status</span>
</label>
<select name="status" class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
<option value="">Semua Status</option>
<option value="approved" {{ request('status') === 'approved' ? 'selected' : '' }}>Disetujui (Approved)</option>
<option value="rejected" {{ request('status') === 'rejected' ? 'selected' : '' }}>Ditolak (Rejected)</option>
<option value="pending" {{ request('status') === 'pending' ? 'selected' : '' }}>Menunggu (Pending)</option>
</select>
</div>
<!-- Rentang Mulai Tanggal -->
<div class="lg:col-span-3">
<label class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center gap-1.5">
<i class="fa-regular fa-calendar text-slate-400"></i>
<span>Mulai Tanggal</span>
</label>
<input type="date"
name="start_date"
value="{{ request('start_date') }}"
class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3 py-2 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
</div>
<!-- Rentang Sampai Tanggal -->
<div class="lg:col-span-3">
<label class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center gap-1.5">
<i class="fa-regular fa-calendar-check text-slate-400"></i>
<span>Sampai Tanggal</span>
</label>
<input type="date"
name="end_date"
value="{{ request('end_date') }}"
class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3 py-2 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
</div>
<!-- Tombol Submit Terapkan Filter -->
<div class="lg:col-span-2 flex items-end">
<button type="submit" class="w-full bg-[#1b5e20] hover:bg-[#144919] text-white py-2.5 px-4 rounded-xl text-xs font-bold flex items-center justify-center space-x-2 shadow-sm transition">
<i class="fa-solid fa-filter text-xs"></i>
<span>Terapkan</span>
</button>
</div>
</div>
</form>
</div>
<!-- Tabel Lengkap Log Verifikasi Gerbang (Navy Header #06213f) -->
<div class="bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full text-xs text-left border-collapse">
<!-- Header Navy Solid #06213f -->
<thead class="bg-[#06213f] text-white font-bold text-[11px] uppercase tracking-wider">
<tr>
<th class="py-3.5 px-4 text-center w-12">NO</th>
<th class="py-3.5 px-4">WAKTU VERIFIKASI</th>
<th class="py-3.5 px-4">NO. TRANSAKSI</th>
<th class="py-3.5 px-4">PETUGAS SATPAM</th>
<th class="py-3.5 px-4">POS GERBANG</th>
<th class="py-3.5 px-4">KENDARAAN</th>
<th class="py-3.5 px-4">DRIVER / PENGEMUDI</th>
<th class="py-3.5 px-4 text-center">ARAH</th>
<th class="py-3.5 px-4 text-right">ODOMETER</th>
<th class="py-3.5 px-4 text-center">STATUS & CATATAN</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100 font-medium text-slate-700">
@forelse($activities as $index => $item)
@php
$rowNum = $activities->firstItem() ? ($activities->firstItem() + $index) : ($index + 1);
$validatedTime = $item->validated_at ?? $item->recorded_at;
@endphp
<tr class="hover:bg-slate-50/80 transition-colors {{ $loop->even ? 'bg-slate-50/30' : 'bg-white' }}">
<!-- No -->
<td class="py-3 px-4 text-center text-slate-400 font-bold">
{{ $rowNum }}
</td>
<!-- Waktu Verifikasi -->
<td class="py-3 px-4 whitespace-nowrap">
<div class="font-bold text-slate-900">
{{ $validatedTime ? $validatedTime->format('d/m/Y') : '-' }}
</div>
<div class="text-[11px] text-slate-500 flex items-center gap-1 font-mono">
<i class="fa-regular fa-clock text-[10px]"></i>
{{ $validatedTime ? $validatedTime->format('H:i') . ' WIB' : '-' }}
</div>
</td>
<!-- No Transaksi -->
<td class="py-3 px-4 whitespace-nowrap">
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-lg bg-slate-100 text-slate-800 font-mono font-bold text-[11px] border border-slate-200">
<i class="fa-solid fa-qrcode text-slate-400 text-[10px]"></i>
{{ $item->transaction_no }}
</span>
</td>
<!-- Petugas Satpam Pemeriksa -->
<td class="py-3 px-4">
@if($item->securityGuard)
<div class="flex items-center space-x-2">
<div>
<p class="font-bold text-slate-900 leading-tight">
{{ $item->securityGuard->name }}
</p>
<div class="flex items-center gap-1.5 mt-0.5">
<span class="text-[10px] text-slate-500 font-mono">
{{ $item->securityGuard->badge_id }}
</span>
<span class="inline-flex items-center px-1.5 py-0.2 rounded text-[10px] font-bold {{ $item->securityGuard->team == 1 ? 'bg-blue-100 text-blue-700' : ($item->securityGuard->team == 2 ? 'bg-amber-100 text-amber-700' : 'bg-purple-100 text-purple-700') }}">
Regu {{ $item->securityGuard->team }}
</span>
</div>
</div>
</div>
@else
<span class="text-slate-400 italic text-[11px]">- Belum ada -</span>
@endif
</td>
<!-- Pos Gerbang -->
<td class="py-3 px-4 whitespace-nowrap font-bold text-slate-800">
<div class="flex items-center gap-1.5">
<i class="fa-solid fa-torii-gate text-slate-400 text-xs"></i>
<span>{{ $item->gate ? $item->gate->name : '-' }}</span>
</div>
</td>
<!-- Kendaraan -->
<td class="py-3 px-4">
@if($item->vehicle)
<div class="font-bold text-slate-900">
{{ $item->vehicle->license_plate }}
</div>
<div class="text-[11px] text-slate-500 flex items-center gap-1">
<span class="font-bold text-emerald-700">{{ $item->vehicle->code }}</span>
<span>•</span>
<span>{{ $item->vehicle->brand_type }}</span>
</div>
@else
<span class="text-slate-400">-</span>
@endif
</td>
<!-- Driver / Pengemudi -->
<td class="py-3 px-4">
@if($item->driver)
<div class="font-bold text-slate-900">
{{ $item->driver->name }}
</div>
<div class="text-[11px] text-slate-500 font-mono">
{{ $item->driver->nik }}
</div>
@else
<span class="text-slate-400">-</span>
@endif
</td>
<!-- Arah Gerbang -->
<td class="py-3 px-4 text-center whitespace-nowrap">
@if($item->direction === 'in')
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[11px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
<i class="fa-solid fa-arrow-down-left text-[10px]"></i>
<span>Masuk</span>
</span>
@else
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[11px] font-bold bg-amber-50 text-amber-700 border border-amber-200">
<i class="fa-solid fa-arrow-up-right text-[10px]"></i>
<span>Keluar</span>
</span>
@endif
</td>
<!-- Odometer -->
<td class="py-3 px-4 text-right whitespace-nowrap font-mono">
<div class="font-bold text-slate-900">
{{ number_format($item->current_km, 0, ',', '.') }} KM
</div>
<div class="text-[10px] text-slate-400">
Awal: {{ number_format($item->previous_km, 0, ',', '.') }} KM
@if($item->distance > 0)
<span class="text-emerald-600 font-bold">(+{{ number_format($item->distance, 0, ',', '.') }})</span>
@endif
</div>
</td>
<!-- Status & Catatan -->
<td class="py-3 px-4 text-center whitespace-nowrap">
@if($item->validation_status === 'approved')
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[11px] font-bold bg-emerald-100 text-emerald-800">
<i class="fa-solid fa-check text-[10px]"></i>
<span>Disetujui</span>
</span>
@elseif($item->validation_status === 'rejected')
<div>
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[11px] font-bold bg-rose-100 text-rose-800" title="{{ $item->rejection_note }}">
<i class="fa-solid fa-xmark text-[10px]"></i>
<span>Ditolak</span>
</span>
@if($item->rejection_note)
<p class="text-[10px] text-rose-600 max-w-xs truncate mx-auto mt-0.5" title="{{ $item->rejection_note }}">
{{ $item->rejection_note }}
</p>
@endif
</div>
@else
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[11px] font-bold bg-amber-100 text-amber-800">
<i class="fa-regular fa-clock text-[10px]"></i>
<span>Menunggu</span>
</span>
@endif
</td>
</tr>
@empty
<tr>
<td colspan="10" class="py-12 text-center text-slate-400">
<div class="flex flex-col items-center justify-center space-y-2">
<div class="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 text-lg">
<i class="fa-solid fa-clipboard-question"></i>
</div>
<p class="text-sm font-bold text-slate-600">Belum ada catatan log riwayat verifikasi gerbang</p>
<p class="text-xs text-slate-400">Aktivitas kendaraan yang diverifikasi oleh petugas Satpam akan tercatat otomatis di sini.</p>
</div>
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<!-- Pagination Bar -->
@if($activities->hasPages())
<div class="p-4 border-t border-slate-100 bg-slate-50/50">
{{ $activities->links() }}
</div>
@endif
</div>
</div>
@endsection
+6 -4
View File
@@ -4,6 +4,7 @@ use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Hse\EmployeeController; use App\Http\Controllers\Hse\EmployeeController;
use App\Http\Controllers\Pg\GateInspectionController; use App\Http\Controllers\Pg\GateInspectionController;
use App\Http\Controllers\Pg\SecurityGuardController; use App\Http\Controllers\Pg\SecurityGuardController;
use App\Http\Controllers\Pg\VerificationLogController;
use App\Http\Controllers\ProfileController; use App\Http\Controllers\ProfileController;
use App\Http\Controllers\Public\VehicleActivityFormController; use App\Http\Controllers\Public\VehicleActivityFormController;
use App\Http\Controllers\Qma\ActivityLogController; use App\Http\Controllers\Qma\ActivityLogController;
@@ -68,18 +69,19 @@ Route::middleware('auth')->group(function () {
Route::get('/activity-summary', [ActivityLogController::class, 'summary'])->name('activity.summary'); Route::get('/activity-summary', [ActivityLogController::class, 'summary'])->name('activity.summary');
}); });
// 4. Modul Private Guard (PG): Admin PG (Admin PG - AdminPG) & Pos Gerbang Satpam // 4. Modul Private Guard (PG): Admin PG & Pos Gerbang Satpam
Route::prefix('pg')->name('pg.')->group(function () { Route::prefix('pg')->name('pg.')->group(function () {
// Master Satpam (Hanya Admin PG) // Modul Admin PG (Data Satpam & Log Verifikasi Gerbang)
Route::middleware('role:pg_admin')->group(function () { Route::middleware('role:pg_admin')->group(function () {
Route::get('/guards', [SecurityGuardController::class, 'index'])->name('guards.index'); Route::get('/guards', [SecurityGuardController::class, 'index'])->name('guards.index');
Route::post('/guards', [SecurityGuardController::class, 'store'])->name('guards.store'); Route::post('/guards', [SecurityGuardController::class, 'store'])->name('guards.store');
Route::post('/guards/{id}', [SecurityGuardController::class, 'update'])->name('guards.update'); Route::post('/guards/{id}', [SecurityGuardController::class, 'update'])->name('guards.update');
Route::post('/guards/{id}/toggle', [SecurityGuardController::class, 'toggleStatus'])->name('guards.toggle'); Route::post('/guards/{id}/toggle', [SecurityGuardController::class, 'toggleStatus'])->name('guards.toggle');
Route::get('/verification-logs', [VerificationLogController::class, 'index'])->name('logs.index');
}); });
// Verifikasi Pos Gerbang (Petugas Pos Gerbang & Admin PG) // Verifikasi Pos Gerbang (Khusus Petugas Satpam Pos Gerbang)
Route::middleware('role:gate_officer,pg_admin')->group(function () { Route::middleware('role:gate_officer')->group(function () {
Route::get('/gate-inspection', [GateInspectionController::class, 'index'])->name('gate.inspection'); Route::get('/gate-inspection', [GateInspectionController::class, 'index'])->name('gate.inspection');
Route::post('/gate-inspection/{id}/approve', [GateInspectionController::class, 'approve'])->name('gate.approve'); Route::post('/gate-inspection/{id}/approve', [GateInspectionController::class, 'approve'])->name('gate.approve');
Route::post('/gate-inspection/{id}/reject', [GateInspectionController::class, 'reject'])->name('gate.reject'); Route::post('/gate-inspection/{id}/reject', [GateInspectionController::class, 'reject'])->name('gate.reject');
+9 -2
View File
@@ -124,10 +124,17 @@ class AuthenticationTest extends TestCase
$this->actingAs($qmaUser)->get('/hse/employees')->assertStatus(403); $this->actingAs($qmaUser)->get('/hse/employees')->assertStatus(403);
$this->actingAs($qmaUser)->get('/pg/guards')->assertStatus(403); $this->actingAs($qmaUser)->get('/pg/guards')->assertStatus(403);
// 4. Admin PG dapat akses modul PG guards & gate inspection, ditolak dari HSE // 4. Admin PG dapat akses modul PG guards & log verifikasi, ditolak dari pos gerbang verifikasi & HSE
$this->actingAs($pgUser)->get('/pg/guards')->assertStatus(200); $this->actingAs($pgUser)->get('/pg/guards')->assertStatus(200);
$this->actingAs($pgUser)->get('/pg/gate-inspection')->assertStatus(200); $this->actingAs($pgUser)->get('/pg/verification-logs')->assertStatus(200);
$this->actingAs($pgUser)->get('/pg/gate-inspection')->assertStatus(403);
$this->actingAs($pgUser)->get('/hse/employees')->assertStatus(403); $this->actingAs($pgUser)->get('/hse/employees')->assertStatus(403);
// 5. Petugas Satpam Pos Gerbang dapat akses verifikasi pos gerbang, ditolak dari master guards & logs
$gateOfficer = User::where('role', 'gate_officer')->first();
$this->actingAs($gateOfficer)->get('/pg/gate-inspection')->assertStatus(200);
$this->actingAs($gateOfficer)->get('/pg/guards')->assertStatus(403);
$this->actingAs($gateOfficer)->get('/pg/verification-logs')->assertStatus(403);
} }
/** /**
+40
View File
@@ -251,4 +251,44 @@ class VehicleActivityTest extends TestCase
'security_guard_id' => $guard->id, 'security_guard_id' => $guard->id,
]); ]);
} }
public function test_admin_pg_can_view_and_filter_verification_logs(): void
{
$pgUser = User::where('role', 'pg_admin')->first();
$guard = SecurityGuard::first();
$vehicle = Vehicle::first();
$driver = Employee::first();
// Buat data aktivitas verifikasi
VehicleActivity::create([
'transaction_no' => 'TRX-LOG-PG-001',
'vehicle_id' => $vehicle->id,
'driver_id' => $driver->id,
'gate_id' => $guard->gate_id,
'direction' => 'out',
'previous_km' => 1000,
'current_km' => 1050,
'distance' => 50,
'purpose' => 'Dinas Luar',
'recorded_at' => Carbon::now(),
'validated_at' => Carbon::now(),
'security_guard_id' => $guard->id,
'validation_status' => 'approved',
]);
$response = $this->actingAs($pgUser)->get(route('pg.logs.index'));
$response->assertStatus(200);
$response->assertSee('Log Riwayat Verifikasi Gerbang');
$response->assertSee('TRX-LOG-PG-001');
$response->assertSee($guard->name);
// Test filter parameter
$filterResponse = $this->actingAs($pgUser)->get(route('pg.logs.index', [
'team' => $guard->team,
'status' => 'approved',
'search' => 'TRX-LOG-PG',
]));
$filterResponse->assertStatus(200);
$filterResponse->assertSee('TRX-LOG-PG-001');
}
} }