feat(qma): redesign QMA dashboard matching HSE dashboard UI layout and pastel metric cards

This commit is contained in:
Wahyudin
2026-10-15 14:22:20 +07:00
parent 4d7d76a428
commit bd9dfbff85
2 changed files with 328 additions and 55 deletions
+44 -2
View File
@@ -5,8 +5,11 @@ namespace App\Http\Controllers\Qma;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Employee; use App\Models\Employee;
use App\Models\Gate; use App\Models\Gate;
use App\Models\P2hRecord;
use App\Models\P2hTemplate; use App\Models\P2hTemplate;
use App\Models\Vehicle; use App\Models\Vehicle;
use App\Models\VehicleActivity;
use Carbon\Carbon;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@@ -21,10 +24,49 @@ class VehicleController extends Controller
public function dashboard(): View public function dashboard(): View
{ {
$totalLv = Vehicle::lightVehicles()->count(); $totalLv = Vehicle::lightVehicles()->count();
$totalSupport = Vehicle::unitSupports()->count(); $totalSupport = Vehicle::unitSupportPhysical()->count() ?: Vehicle::unitSupports()->count();
$totalVehicles = Vehicle::count(); $totalVehicles = Vehicle::count();
return view('qma.dashboard', compact('totalLv', 'totalSupport', 'totalVehicles')); $today = Carbon::today()->toDateString();
$todayActivitiesCount = VehicleActivity::whereDate('recorded_at', $today)->count();
$todayP2hCount = P2hRecord::whereDate('inspected_at', $today)->count();
// 1. Log Pergerakan Gerbang Terkini (6 data pergerakan armada terbaru)
$recentActivities = VehicleActivity::with(['vehicle', 'driver', 'gate', 'securityGuard'])
->latest('recorded_at')
->take(6)
->get();
// 2. Monitoring Kelayakan P2H Terkini (5 checksheet inspeksi terbaru)
$recentP2hRecords = P2hRecord::with(['vehicle', 'employee', 'template'])
->latest('inspected_at')
->take(5)
->get();
// 3. Status Kesiapan Unit Support
$supportOperation = Vehicle::unitSupports()->where('status', 'Operation')->count();
$supportStandby = Vehicle::unitSupports()->where('status', 'Standby')->count();
$supportBreakdown = Vehicle::unitSupports()->where('status', 'Breakdown')->count();
$recentUnits = Vehicle::unitSupports()
->orderByRaw("CASE WHEN status = 'Breakdown' THEN 0 WHEN status = 'Standby' THEN 1 ELSE 2 END")
->latest('updated_at')
->take(4)
->get();
return view('qma.dashboard', compact(
'totalLv',
'totalSupport',
'totalVehicles',
'todayActivitiesCount',
'todayP2hCount',
'recentActivities',
'recentP2hRecords',
'supportOperation',
'supportStandby',
'supportBreakdown',
'recentUnits'
));
} }
/** /**
+284 -53
View File
@@ -4,67 +4,298 @@
@section('content') @section('content')
<div class="w-full space-y-6"> <div class="w-full space-y-6">
<!-- Header Admin QMA (Gaya Elegan Sistem IT All Role, Selaras dengan Admin HSE) -->
<div class="bg-white p-6 rounded-2xl border border-slate-200 shadow-sm flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4"> <!-- Header Admin QMA (Persis Gaya Referensi IT KMH - Bebas Card Wrapper) -->
<div>
<div class="flex items-center space-x-1.5 mb-1">
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20]">
SISTEM ADMINISTRATOR
</span>
<!-- Tombol Info Panduan Halaman Sejajar Kicker -->
<button type="button"
onclick="openGuideModal()"
class="w-3.5 h-3.5 rounded-full bg-slate-200/90 hover:bg-slate-300 text-slate-500 hover:text-slate-800 text-[8px] inline-flex items-center justify-center font-bold transition shadow-2xs cursor-pointer focus:outline-none"
title="Panduan Halaman Dashboard QMA">
<i class="fa-solid fa-info"></i>
</button>
</div>
<h2 class="text-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Selamat datang, {{ auth()->user()->name }}
</h2>
<p class="text-xs sm:text-sm text-slate-500 mt-1">
Berikut ringkasan operasional aset kendaraan dan pencatatan log aktivitas armada PT Kerinci Merangin Hidro secara keseluruhan.
</p>
</div>
<!-- 4 Kartu Metrik Ringkasan (Persis Gaya Kotak Warna Pastel Referensi HSE) -->
<div class="grid grid-cols-2 lg:grid-cols-4 gap-4">
<!-- 1. Total Armada LV (Pastel Hijau) -->
<div> <div>
<div class="flex items-center space-x-1.5 mb-1"> <div class="bg-[#eef7ee] border border-[#d6ebd7] rounded-3xl h-28 flex items-center justify-center shadow-xs">
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20]"> <span class="text-4xl sm:text-5xl font-black text-[#2e7d32]">{{ $totalLv }}</span>
SISTEM ADMINISTRATOR
</span>
<!-- Tombol Info Panduan Halaman Sejajar Kicker -->
<button type="button"
onclick="openGuideModal()"
class="w-3.5 h-3.5 rounded-full bg-slate-200/90 hover:bg-slate-300 text-slate-500 hover:text-slate-800 text-[8px] inline-flex items-center justify-center font-bold transition shadow-2xs cursor-pointer focus:outline-none"
title="Panduan Halaman Dashboard QMA">
<i class="fa-solid fa-info"></i>
</button>
</div> </div>
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight"> <p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">ARMADA LIGHT VEHICLE</p>
Selamat datang, {{ auth()->user()->name }} </div>
</h2>
<p class="text-xs text-slate-500 mt-1"> <!-- 2. Unit Support & Alat Berat (Pastel Biru Muda) -->
Berikut ringkasan operasional aset kendaraan dan pencatatan log aktivitas armada PT Kerinci Merangin Hidro. <div>
</p> <div class="bg-[#edf5fd] border border-[#d2e4fb] rounded-3xl h-28 flex items-center justify-center shadow-xs">
<span class="text-4xl sm:text-5xl font-black text-[#1976d2]">{{ $totalSupport }}</span>
</div>
<p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">UNIT SUPPORT</p>
</div>
<!-- 3. Log Timesheet Hari Ini (Pastel Soft Blue) -->
<div>
<div class="bg-[#f0f4fe] border border-[#dae5fd] rounded-3xl h-28 flex items-center justify-center shadow-xs">
<span class="text-4xl sm:text-5xl font-black text-[#2563eb]">{{ $todayActivitiesCount }}</span>
</div>
<p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">TIMESHEET HARI INI</p>
</div>
<!-- 4. Inspeksi P2H Hari Ini (Pastel Amber / Yellow) -->
<div>
<div class="bg-[#fef9e8] border border-[#feefc7] rounded-3xl h-28 flex items-center justify-center shadow-xs">
<span class="text-4xl sm:text-5xl font-black text-[#f59e0b]">{{ $todayP2hCount }}</span>
</div>
<p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">INSPEKSI P2H HARI INI</p>
</div> </div>
</div> </div>
<!-- Area Konten Dashboard Sementara Dikosongkan (Placeholder Bersih - Sama seperti Admin HSE) --> <!-- Layout 2 Kolom Bawah: Log Pergerakan & Status Unit Support (Persis Layout 2 Kolom HSE) -->
<div class="bg-white rounded-2xl border border-dashed border-slate-300 p-12 text-center shadow-sm"> <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 items-start">
<div class="w-16 h-16 rounded-2xl bg-emerald-50 text-emerald-700 flex items-center justify-center mx-auto mb-4 border border-emerald-100 shadow-sm">
<i class="fa-solid fa-layer-group text-2xl"></i> <!-- Kolom Kiri: Log Aktivitas Kendaraan Terkini (Gerbang Pos) -->
<div class="bg-white rounded-2xl border border-slate-200 p-6 shadow-sm">
<div class="flex items-center justify-between mb-5 pb-3 border-b border-slate-100">
<div>
<h3 class="text-sm font-bold text-slate-900">Log Aktivitas Kendaraan Terkini</h3>
<p class="text-[11px] text-slate-500">Catatan pergerakan armada Light Vehicle di pos gerbang</p>
</div>
<a href="{{ route('qma.activity.log') }}" class="text-xs font-bold text-[#1b5e20] hover:underline flex items-center gap-1">
<span>Kelola Data</span>
<i class="fa-solid fa-arrow-right text-[10px]"></i>
</a>
</div>
<div class="space-y-3.5">
@forelse($recentActivities as $act)
<div class="flex items-start space-x-3.5 py-2.5 border-b border-slate-50 last:border-b-0 hover:bg-slate-50/60 rounded-xl px-2.5 transition">
<!-- Icon Arah Gerbang Pastel -->
@if($act->direction === 'in')
<div class="w-10 h-10 rounded-2xl bg-[#eef7ee] text-[#1b5e20] font-bold text-xs flex items-center justify-center flex-shrink-0 mt-0.5 border border-[#d6ebd7]" title="Kendaraan Masuk (IN)">
<i class="fa-solid fa-arrow-right-to-bracket text-sm"></i>
</div>
@else
<div class="w-10 h-10 rounded-2xl bg-[#edf5fd] text-[#1976d2] font-bold text-xs flex items-center justify-center flex-shrink-0 mt-0.5 border border-[#d2e4fb]" title="Kendaraan Keluar (OUT)">
<i class="fa-solid fa-arrow-right-from-bracket text-sm"></i>
</div>
@endif
<div class="min-w-0 flex-1">
<div class="flex items-center gap-2 flex-wrap">
<span class="text-xs font-bold text-slate-900 leading-tight">
{{ $act->vehicle->code ?? 'LV' }}
</span>
@if(!empty($act->vehicle->license_plate))
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-mono font-bold bg-slate-100 text-slate-700 border border-slate-200">
{{ $act->vehicle->license_plate }}
</span>
@endif
<span class="text-xs text-slate-700 font-semibold truncate max-w-[130px]">
&bull; {{ $act->driver->name ?? 'Driver' }}
</span>
</div>
<p class="text-[11px] text-slate-600 mt-0.5">
{{ $act->gate->name ?? 'Pos Gerbang' }} &bull; Keperluan: <span class="text-slate-800 font-medium">{{ Str::limit($act->purpose, 35) }}</span>
</p>
<p class="text-[10px] text-slate-500 mt-1 flex items-center gap-2 font-mono">
<span><i class="fa-regular fa-clock text-slate-400 mr-1"></i>{{ $act->recorded_at->locale('id')->translatedFormat('H:i') }} WIB ({{ $act->recorded_at->locale('id')->diffForHumans() }})</span>
<span>&bull;</span>
<span class="text-slate-700 font-bold">{{ number_format($act->current_km, 0, ',', '.') }} KM</span>
@if($act->distance > 0)
<span class="text-[#1b5e20] font-semibold">(+{{ number_format($act->distance, 1, ',', '.') }} KM)</span>
@endif
</p>
</div>
<!-- Badge Status Validasi -->
<div class="flex-shrink-0">
@if($act->validation_status === 'approved')
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
<i class="fa-solid fa-circle-check text-[9px]"></i>
<span>Approved</span>
</span>
@elseif($act->validation_status === 'rejected')
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[10px] font-bold bg-rose-50 text-rose-700 border border-rose-200">
<i class="fa-solid fa-circle-xmark text-[9px]"></i>
<span>Rejected</span>
</span>
@else
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[10px] font-bold bg-amber-50 text-amber-700 border border-amber-200">
<i class="fa-solid fa-hourglass-half text-[9px]"></i>
<span>Pending</span>
</span>
@endif
</div>
</div>
@empty
<p class="text-xs text-slate-400 text-center py-6">Belum ada catatan aktivitas pergerakan kendaraan hari ini.</p>
@endforelse
</div>
</div> </div>
<h3 class="text-base font-bold text-slate-800">Konten Dashboard Sedang Disiapkan</h3>
<p class="text-xs text-slate-400 max-w-lg mx-auto mt-1.5 leading-relaxed">
Halaman dashboard utama admin QMA untuk sementara dikosongkan sesuai instruksi. Seluruh pengelolaan master kendaraan dialihkan ke menu <strong class="text-slate-600 font-semibold">Data Aset Kendaraan</strong> dan pemantauan pergerakan pos gerbang ke menu <strong class="text-slate-600 font-semibold">Log Aktivitas Kendaraan</strong>.
</p>
<div class="mt-6 flex flex-wrap items-center justify-center gap-3">
<a href="{{ route('qma.vehicles.lv') }}"
class="inline-flex items-center space-x-2 bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-xs py-3 px-5 rounded-xl shadow-md hover:shadow-lg transition">
<i class="fa-solid fa-car"></i>
<span>Buka Light Vehicle</span>
<i class="fa-solid fa-arrow-right text-[10px] ml-1"></i>
</a>
<a href="{{ route('qma.vehicles.support') }}" <!-- Kolom Kanan: 2 Kartu Stacked (Monitoring Kelayakan P2H & Status Unit Support) -->
class="inline-flex items-center space-x-2 bg-blue-700 hover:bg-blue-800 text-white font-bold text-xs py-3 px-5 rounded-xl shadow-md hover:shadow-lg transition"> <div class="space-y-6">
<i class="fa-solid fa-tractor"></i>
<span>Buka Unit Support</span> <!-- Kartu Atas: Monitoring Kelayakan P2H Terkini -->
<i class="fa-solid fa-arrow-right text-[10px] ml-1"></i> <div class="bg-white rounded-2xl border border-slate-200 p-6 shadow-sm">
</a> <div class="flex items-center justify-between mb-5 pb-3 border-b border-slate-100">
<div>
<h3 class="text-sm font-bold text-slate-900">Monitoring Kelayakan P2H</h3>
<p class="text-[11px] text-slate-500">Prioritas kondisi lembar periksa pra-harian unit support</p>
</div>
<a href="{{ route('qma.p2h.index') }}" class="text-xs font-bold text-[#1b5e20] hover:underline flex items-center gap-1">
<span>Filter Data</span>
<i class="fa-solid fa-arrow-right text-[10px]"></i>
</a>
</div>
<a href="{{ route('qma.activity.log') }}" <div class="space-y-3.5">
class="inline-flex items-center space-x-2 bg-slate-800 hover:bg-slate-900 text-white font-bold text-xs py-3 px-5 rounded-xl shadow-md hover:shadow-lg transition"> @forelse($recentP2hRecords as $p2h)
<i class="fa-solid fa-clipboard-list"></i> @php
<span>Log Timesheet LV</span> $hasDefect = $p2h->summary_condition === 'has_defect' || $p2h->defect_count > 0;
<i class="fa-solid fa-arrow-right text-[10px] ml-1"></i> @endphp
</a> <div class="flex items-start space-x-3.5 py-2.5 border-b border-slate-50 last:border-b-0 hover:bg-slate-50/60 rounded-xl px-2.5 transition">
<!-- Icon Status P2H Berwarna -->
@if($hasDefect)
<div class="w-10 h-10 rounded-2xl bg-rose-50 text-rose-600 flex items-center justify-center flex-shrink-0 mt-0.5 border border-rose-100" title="Ada Kerusakan / Temuan">
<i class="fa-solid fa-triangle-exclamation text-sm"></i>
</div>
@else
<div class="w-10 h-10 rounded-2xl bg-emerald-50 text-emerald-600 flex items-center justify-center flex-shrink-0 mt-0.5 border border-emerald-100" title="Kondisi Prima / Baik">
<i class="fa-solid fa-shield-halved text-sm"></i>
</div>
@endif
<div class="min-w-0 flex-1">
<div class="flex items-center gap-2 flex-wrap">
<span class="text-xs font-bold text-slate-900 leading-tight">
{{ $p2h->vehicle->code ?? 'Unit' }}
</span>
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-bold bg-amber-50 text-amber-800 border border-amber-200">
{{ $p2h->vehicle->unit_category ?? ($p2h->template->name ?? 'Unit Support') }}
</span>
</div>
<p class="text-[11px] text-slate-600 mt-0.5">
Operator: <strong class="text-slate-800">{{ $p2h->employee->name ?? 'Operator' }}</strong> &bull; <span class="font-mono">{{ number_format($p2h->start_hm, 1, ',', '.') }} HM</span>
</p>
@if($hasDefect)
<p class="text-[10px] font-bold text-rose-600 mt-1 flex items-center gap-1 font-mono">
<i class="fa-solid fa-circle-xmark text-[9px]"></i>
<span>Terdeteksi {{ $p2h->defect_count }} butir temuan abnormalitas</span>
</p>
@else
<p class="text-[10px] font-medium text-emerald-700 mt-1 flex items-center gap-1 font-mono">
<i class="fa-solid fa-circle-check text-[9px] text-emerald-600"></i>
<span>Seluruh butir periksa dalam kondisi normal</span>
</p>
@endif
</div>
<!-- Badge Kanan -->
<div class="flex-shrink-0">
@if($hasDefect)
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-rose-100 text-rose-800 border border-rose-200">
Ada Temuan ({{ $p2h->defect_count }})
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
Kondisi Baik
</span>
@endif
</div>
</div>
@empty
<p class="text-xs text-slate-400 text-center py-4">Belum ada data riwayat inspeksi P2H unit support.</p>
@endforelse
</div>
</div>
<!-- Kartu Bawah: Status Kesiapan Unit Support (Format Rapi Persis HSE) -->
<div class="bg-white rounded-2xl border border-slate-200 p-6 shadow-sm">
<div class="flex items-center justify-between mb-4 pb-3 border-b border-slate-100">
<div>
<h3 class="text-sm font-bold text-slate-900">Kesiapan Unit Support</h3>
<p class="text-[11px] text-slate-500">Kesiapan operasional armada alat berat & unit bantu</p>
</div>
<a href="{{ route('qma.vehicles.support') }}" class="text-xs font-bold text-[#1b5e20] hover:underline flex items-center gap-1">
<span>Lihat Semua</span>
<i class="fa-solid fa-arrow-right text-[10px]"></i>
</a>
</div>
<!-- 3 Mini Metric Indicator -->
<div class="grid grid-cols-3 gap-2 mb-4 pb-3 border-b border-slate-100 text-center">
<div class="p-2 rounded-xl bg-emerald-50/80 border border-emerald-200/60">
<span class="text-xs text-emerald-700 font-bold block">{{ $supportOperation }}</span>
<span class="text-[9px] font-bold text-emerald-600 uppercase">Operation</span>
</div>
<div class="p-2 rounded-xl bg-amber-50/80 border border-amber-200/60">
<span class="text-xs text-amber-700 font-bold block">{{ $supportStandby }}</span>
<span class="text-[9px] font-bold text-amber-600 uppercase">Standby</span>
</div>
<div class="p-2 rounded-xl bg-rose-50/80 border border-rose-200/60">
<span class="text-xs text-rose-700 font-bold block">{{ $supportBreakdown }}</span>
<span class="text-[9px] font-bold text-rose-600 uppercase">Breakdown</span>
</div>
</div>
<div class="space-y-3.5">
@forelse($recentUnits as $unit)
<div class="flex items-start space-x-3.5 py-2 border-b border-slate-50 last:border-b-0 hover:bg-slate-50/60 rounded-xl px-2.5 transition">
<!-- Icon Bulat Netral -->
<div class="w-10 h-10 rounded-2xl bg-slate-100 text-slate-600 font-bold text-xs flex items-center justify-center flex-shrink-0 mt-0.5 border border-slate-200">
{{ strtoupper(substr($unit->code, 0, 2)) }}
</div>
<div class="min-w-0 flex-1">
<div class="flex items-center gap-2 flex-wrap">
<span class="text-xs font-bold text-slate-900 leading-tight">
{{ $unit->code }}
</span>
<span class="text-[11px] text-slate-600 font-medium truncate max-w-[150px]">
{{ $unit->brand_type }}
</span>
</div>
<p class="text-[10px] text-slate-500 mt-0.5">
Lokasi: {{ $unit->location ?? 'Area Proyek' }} &bull; <span class="font-mono font-bold text-slate-700">{{ number_format($unit->current_km, 1, ',', '.') }} HM</span>
</p>
</div>
<div class="flex-shrink-0">
@if($unit->status === 'Operation')
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
Operation
</span>
@elseif($unit->status === 'Standby')
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-amber-50 text-amber-700 border border-amber-200">
Standby
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-rose-50 text-rose-700 border border-rose-200">
Breakdown
</span>
@endif
</div>
</div>
@empty
<p class="text-xs text-slate-400 text-center py-4">Belum ada data unit support terdaftar.</p>
@endforelse
</div>
</div>
<a href="{{ route('qma.p2h.index') }}"
class="inline-flex items-center space-x-2 bg-amber-600 hover:bg-amber-700 text-white font-bold text-xs py-3 px-5 rounded-xl shadow-md hover:shadow-lg transition">
<i class="fa-solid fa-clipboard-check"></i>
<span>Log P2H Unit Support</span>
<i class="fa-solid fa-arrow-right text-[10px] ml-1"></i>
</a>
</div> </div>
</div> </div>
</div> </div>
@@ -132,7 +363,7 @@
<i class="fa-solid fa-chart-line"></i> <i class="fa-solid fa-chart-line"></i>
</div> </div>
<div class="min-w-0 flex-1"> <div class="min-w-0 flex-1">
<h4 class="text-xs font-bold text-slate-900">Monitoring Log & Summary Aktivitas</h4> <h4 class="text-xs font-bold text-slate-900">Log Aktivitas Kendaraan & Monitoring Timesheet</h4>
<p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed"> <p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed">
Melihat log pergerakan kendaraan riil yang terverifikasi di pos gerbang dan rekapitulasi analitik kilometer perjalanan. Melihat log pergerakan kendaraan riil yang terverifikasi di pos gerbang dan rekapitulasi analitik kilometer perjalanan.
</p> </p>