From bd9dfbff850f72aaa3421f24b73131c0606bf0a0 Mon Sep 17 00:00:00 2001 From: Wahyudin Date: Thu, 15 Oct 2026 14:22:20 +0700 Subject: [PATCH] feat(qma): redesign QMA dashboard matching HSE dashboard UI layout and pastel metric cards --- .../Controllers/Qma/VehicleController.php | 46 ++- resources/views/qma/dashboard.blade.php | 337 +++++++++++++++--- 2 files changed, 328 insertions(+), 55 deletions(-) diff --git a/app/Http/Controllers/Qma/VehicleController.php b/app/Http/Controllers/Qma/VehicleController.php index aaf258c..50ccef3 100644 --- a/app/Http/Controllers/Qma/VehicleController.php +++ b/app/Http/Controllers/Qma/VehicleController.php @@ -5,8 +5,11 @@ namespace App\Http\Controllers\Qma; use App\Http\Controllers\Controller; use App\Models\Employee; use App\Models\Gate; +use App\Models\P2hRecord; use App\Models\P2hTemplate; use App\Models\Vehicle; +use App\Models\VehicleActivity; +use Carbon\Carbon; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; @@ -21,10 +24,49 @@ class VehicleController extends Controller public function dashboard(): View { $totalLv = Vehicle::lightVehicles()->count(); - $totalSupport = Vehicle::unitSupports()->count(); + $totalSupport = Vehicle::unitSupportPhysical()->count() ?: Vehicle::unitSupports()->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' + )); } /** diff --git a/resources/views/qma/dashboard.blade.php b/resources/views/qma/dashboard.blade.php index 5fb701b..d5c160d 100644 --- a/resources/views/qma/dashboard.blade.php +++ b/resources/views/qma/dashboard.blade.php @@ -4,67 +4,298 @@ @section('content')
- -
+ + +
+
+ + SISTEM ADMINISTRATOR + + + +
+

+ Selamat datang, {{ auth()->user()->name }} +

+

+ Berikut ringkasan operasional aset kendaraan dan pencatatan log aktivitas armada PT Kerinci Merangin Hidro secara keseluruhan. +

+
+ + +
+
-
- - SISTEM ADMINISTRATOR - - - +
+ {{ $totalLv }}
-

- Selamat datang, {{ auth()->user()->name }} -

-

- Berikut ringkasan operasional aset kendaraan dan pencatatan log aktivitas armada PT Kerinci Merangin Hidro. -

+

ARMADA LIGHT VEHICLE

+
+ + +
+
+ {{ $totalSupport }} +
+

UNIT SUPPORT

+
+ + +
+
+ {{ $todayActivitiesCount }} +
+

TIMESHEET HARI INI

+
+ + +
+
+ {{ $todayP2hCount }} +
+

INSPEKSI P2H HARI INI

- -
-
- + +
+ + +
+
+
+

Log Aktivitas Kendaraan Terkini

+

Catatan pergerakan armada Light Vehicle di pos gerbang

+
+ + Kelola Data + + +
+ +
+ @forelse($recentActivities as $act) +
+ + @if($act->direction === 'in') +
+ +
+ @else +
+ +
+ @endif + +
+
+ + {{ $act->vehicle->code ?? 'LV' }} + + @if(!empty($act->vehicle->license_plate)) + + {{ $act->vehicle->license_plate }} + + @endif + + • {{ $act->driver->name ?? 'Driver' }} + +
+

+ {{ $act->gate->name ?? 'Pos Gerbang' }} • Keperluan: {{ Str::limit($act->purpose, 35) }} +

+

+ {{ $act->recorded_at->locale('id')->translatedFormat('H:i') }} WIB ({{ $act->recorded_at->locale('id')->diffForHumans() }}) + • + {{ number_format($act->current_km, 0, ',', '.') }} KM + @if($act->distance > 0) + (+{{ number_format($act->distance, 1, ',', '.') }} KM) + @endif +

+
+ + +
+ @if($act->validation_status === 'approved') + + + Approved + + @elseif($act->validation_status === 'rejected') + + + Rejected + + @else + + + Pending + + @endif +
+
+ @empty +

Belum ada catatan aktivitas pergerakan kendaraan hari ini.

+ @endforelse +
-

Konten Dashboard Sedang Disiapkan

-

- Halaman dashboard utama admin QMA untuk sementara dikosongkan sesuai instruksi. Seluruh pengelolaan master kendaraan dialihkan ke menu Data Aset Kendaraan dan pemantauan pergerakan pos gerbang ke menu Log Aktivitas Kendaraan. -

-
- - - Buka Light Vehicle - - - - - Buka Unit Support - - + +
+ + +
+
+
+

Monitoring Kelayakan P2H

+

Prioritas kondisi lembar periksa pra-harian unit support

+
+ + Filter Data + + +
- - - Log Timesheet LV - - +
+ @forelse($recentP2hRecords as $p2h) + @php + $hasDefect = $p2h->summary_condition === 'has_defect' || $p2h->defect_count > 0; + @endphp +
+ + @if($hasDefect) +
+ +
+ @else +
+ +
+ @endif + +
+
+ + {{ $p2h->vehicle->code ?? 'Unit' }} + + + {{ $p2h->vehicle->unit_category ?? ($p2h->template->name ?? 'Unit Support') }} + +
+

+ Operator: {{ $p2h->employee->name ?? 'Operator' }} • {{ number_format($p2h->start_hm, 1, ',', '.') }} HM +

+ + @if($hasDefect) +

+ + Terdeteksi {{ $p2h->defect_count }} butir temuan abnormalitas +

+ @else +

+ + Seluruh butir periksa dalam kondisi normal +

+ @endif +
+ + +
+ @if($hasDefect) + + Ada Temuan ({{ $p2h->defect_count }}) + + @else + + Kondisi Baik + + @endif +
+
+ @empty +

Belum ada data riwayat inspeksi P2H unit support.

+ @endforelse +
+
+ + +
+
+
+

Kesiapan Unit Support

+

Kesiapan operasional armada alat berat & unit bantu

+
+ + Lihat Semua + + +
+ + +
+
+ {{ $supportOperation }} + Operation +
+
+ {{ $supportStandby }} + Standby +
+
+ {{ $supportBreakdown }} + Breakdown +
+
+ +
+ @forelse($recentUnits as $unit) +
+ +
+ {{ strtoupper(substr($unit->code, 0, 2)) }} +
+ +
+
+ + {{ $unit->code }} + + + {{ $unit->brand_type }} + +
+

+ Lokasi: {{ $unit->location ?? 'Area Proyek' }} • {{ number_format($unit->current_km, 1, ',', '.') }} HM +

+
+ +
+ @if($unit->status === 'Operation') + + Operation + + @elseif($unit->status === 'Standby') + + Standby + + @else + + Breakdown + + @endif +
+
+ @empty +

Belum ada data unit support terdaftar.

+ @endforelse +
+
- - - Log P2H Unit Support - -
@@ -132,7 +363,7 @@
-

Monitoring Log & Summary Aktivitas

+

Log Aktivitas Kendaraan & Monitoring Timesheet

Melihat log pergerakan kendaraan riil yang terverifikasi di pos gerbang dan rekapitulasi analitik kilometer perjalanan.