feat: initial commit Sistem RKM Laravel (HSE, QMA, Pos Gerbang, QR Activity)

This commit is contained in:
Wahyudin
2026-10-12 23:47:41 +07:00
commit 21ce908199
94 changed files with 17600 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
@import 'tailwindcss';
@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
@source '../../storage/framework/views/*.php';
@source '../**/*.blade.php';
@source '../**/*.js';
@theme {
--font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol', 'Noto Color Emoji';
}
+1
View File
@@ -0,0 +1 @@
import './bootstrap';
+4
View File
@@ -0,0 +1,4 @@
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
+260
View File
@@ -0,0 +1,260 @@
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Masuk ke Sistem RKM - PT Kerinci Merangin Hidro</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,400&display=swap" rel="stylesheet">
<style>
* { font-family: 'Inter', sans-serif; }
/* Panel kiri: pola garis diagonal halus di atas gradasi */
.brand-panel {
background: linear-gradient(160deg, #1a3a1a 0%, #1b5e20 60%, #256127 100%);
position: relative;
overflow: hidden;
}
/* Pola grid titik-titik elegan di background */
.brand-panel::before {
content: '';
position: absolute;
inset: 0;
background-image: radial-gradient(circle, rgba(255,255,255,0.07) 1px, transparent 1px);
background-size: 28px 28px;
}
/* Cahaya sorot lembut dari tengah atas */
.brand-panel::after {
content: '';
position: absolute;
top: -80px;
left: 50%;
transform: translateX(-50%);
width: 320px;
height: 320px;
background: radial-gradient(circle, rgba(255,255,255,0.09) 0%, transparent 70%);
pointer-events: none;
}
/* Input focus state */
.form-input {
border: 1.5px solid #e2e8f0;
background: #f9fafb;
transition: all 0.18s ease;
}
.form-input:focus {
outline: none;
border-color: #1b5e20;
background: #fff;
box-shadow: 0 0 0 3px rgba(27, 94, 32, 0.1);
}
/* Tombol login */
.btn-login {
background: #1b5e20;
transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
box-shadow: 0 4px 12px rgba(27, 94, 32, 0.30);
}
.btn-login:hover {
background: #155117;
box-shadow: 0 6px 18px rgba(27, 94, 32, 0.38);
transform: translateY(-1px);
}
.btn-login:active { transform: translateY(0); }
/* Logo putih di panel kiri */
.logo-white {
filter: brightness(0) invert(1);
opacity: 0.92;
}
/* Animasi ikon panah tombol */
.btn-login:hover .arrow-icon { transform: translateX(4px); }
.arrow-icon { transition: transform 0.18s ease; display: inline-block; }
</style>
</head>
<body class="min-h-screen bg-slate-100 flex items-center justify-center p-4">
<!-- Container: Card split dua kolom -->
<div class="w-full max-w-[880px] bg-white rounded-[28px] shadow-2xl shadow-slate-300/60 overflow-hidden flex flex-col md:flex-row">
<!-- ============================================================
PANEL KIRI — Branding (Hanya tampil di layar MD ke atas)
============================================================ -->
<div class="brand-panel hidden md:flex flex-col items-center justify-center text-center md:w-[42%] p-10 gap-0">
<!-- Logo -->
<div class="relative z-10 mb-7">
<img src="{{ asset('images/logo-kerinci.png') }}"
alt="Kerinci Hydropower"
class="logo-white h-8 w-auto object-contain mx-auto">
</div>
<!-- Identitas Sistem -->
<div class="relative z-10">
<p class="text-emerald-300/70 text-[11px] font-semibold tracking-[0.25em] uppercase mb-2">
Sistem Operasional
</p>
<h1 class="text-white font-black leading-none tracking-tight" style="font-size: clamp(52px, 7vw, 72px);">
RKM
</h1>
<!-- Garis aksen tipis -->
<div class="flex items-center justify-center space-x-2 mt-5">
<span class="block h-[2px] w-8 rounded-full bg-white/30"></span>
<span class="block h-[2px] w-3 rounded-full bg-[#d4af37]/80"></span>
</div>
<p class="text-white/40 text-xs font-medium mt-5 leading-relaxed">
PT Kerinci Merangin Hidro<br>PLTA Merangin 350 MW
</p>
</div>
<!-- Badge Sistem Aktif -->
<div class="relative z-10 mt-8">
<span class="inline-flex items-center space-x-1.5 bg-white/10 border border-white/15 rounded-full px-3 py-1.5">
<span class="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"></span>
<span class="text-white/60 text-[10px] font-medium tracking-wide">Sistem Aktif</span>
</span>
</div>
</div>
<!-- ============================================================
PANEL KANAN — Form Login
============================================================ -->
<div class="flex flex-col justify-center flex-1 px-8 py-10 sm:px-12 sm:py-12">
<!-- Header Mobile: Logo + nama sistem (Hanya tampil di layar kecil) -->
<div class="flex flex-col items-center mb-8 md:hidden">
<img src="{{ asset('images/logo-kerinci.png') }}"
alt="Kerinci Hydropower"
class="h-7 w-auto object-contain mb-4">
<div class="text-center">
<p class="text-[10px] font-semibold text-slate-400 tracking-[0.2em] uppercase">Sistem Operasional</p>
<h1 class="text-2xl font-black text-[#1b5e20] tracking-tight">RKM</h1>
</div>
<div class="w-px h-5 bg-slate-200 mt-4"></div>
</div>
<!-- Sambutan -->
<div class="mb-7">
<h2 class="text-[22px] font-bold text-slate-900 tracking-tight">Selamat Datang</h2>
<p class="text-sm text-slate-500 mt-1">Masuk menggunakan akun yang telah terdaftar</p>
</div>
<!-- Notifikasi Error -->
@if($errors->any())
<div class="mb-5 flex items-start space-x-3 p-4 bg-rose-50 border border-rose-100 rounded-2xl text-xs">
<i class="fa-solid fa-circle-xmark text-rose-500 mt-0.5 flex-shrink-0"></i>
<div class="text-rose-700">
<p class="font-semibold mb-0.5">Autentikasi gagal</p>
@foreach($errors->all() as $error)
<p>{{ $error }}</p>
@endforeach
</div>
</div>
@endif
@if(session('success'))
<div class="mb-5 flex items-center space-x-2.5 p-4 bg-emerald-50 border border-emerald-100 rounded-2xl text-xs text-emerald-700">
<i class="fa-solid fa-circle-check flex-shrink-0"></i>
<p class="font-medium">{{ session('success') }}</p>
</div>
@endif
@if(session('error'))
<div class="mb-5 flex items-center space-x-2.5 p-4 bg-amber-50 border border-amber-100 rounded-2xl text-xs text-amber-700">
<i class="fa-solid fa-triangle-exclamation flex-shrink-0"></i>
<p class="font-medium">{{ session('error') }}</p>
</div>
@endif
<!-- Form -->
<form action="{{ route('login.post') }}" method="POST" class="space-y-4">
@csrf
<!-- Username -->
<div class="space-y-1.5">
<label for="username" class="block text-xs font-semibold text-slate-500 tracking-wider uppercase">
Username atau Email
</label>
<div class="relative">
<span class="absolute inset-y-0 left-4 flex items-center pointer-events-none text-slate-400">
<i class="fa-regular fa-user text-sm"></i>
</span>
<input type="text"
name="username"
id="username"
value="{{ old('username') }}"
required autofocus
placeholder="Masukkan username atau email"
class="form-input w-full text-sm pl-11 pr-4 py-3.5 rounded-xl text-slate-800 placeholder-slate-400">
</div>
</div>
<!-- Password -->
<div class="space-y-1.5">
<label for="password" class="block text-xs font-semibold text-slate-500 tracking-wider uppercase">
Password
</label>
<div class="relative">
<span class="absolute inset-y-0 left-4 flex items-center pointer-events-none text-slate-400">
<i class="fa-solid fa-lock text-sm"></i>
</span>
<input type="password"
name="password"
id="password"
required
placeholder="Masukkan password"
class="form-input w-full text-sm pl-11 pr-4 py-3.5 rounded-xl text-slate-800 placeholder-slate-400">
</div>
</div>
<!-- Tombol Masuk -->
<div class="pt-2">
<button type="submit"
class="btn-login w-full text-white font-semibold text-sm py-4 rounded-xl flex items-center justify-center gap-2">
Masuk ke Sistem
<i class="fa-solid fa-arrow-right text-xs arrow-icon"></i>
</button>
</div>
</form>
<!-- Footer -->
<div class="mt-7 pt-5 border-t border-slate-100 flex items-center justify-between">
<details class="text-[11px] text-slate-400 cursor-pointer group">
<summary class="list-none flex items-center gap-1.5 font-medium hover:text-slate-600 transition-colors">
<i class="fa-solid fa-circle-info text-[#1b5e20]/60"></i>
Akun Pengujian
</summary>
<div class="absolute mt-2 bg-white rounded-xl p-3 border border-slate-200 shadow-lg text-left space-y-2 w-60 z-50">
<div class="text-[10px] font-semibold text-slate-400 uppercase tracking-wider mb-2">Akun Tersedia</div>
@php
$accounts = [
['role' => 'Admin HSE', 'username' => '1185'],
['role' => 'Admin QMA', 'username' => '1171'],
['role' => 'Admin PG', 'username' => 'AdminPG'],
];
@endphp
@foreach($accounts as $acc)
<div class="flex items-center justify-between py-1.5 border-b border-slate-100 last:border-0">
<div>
<span class="text-[11px] font-semibold text-slate-700">{{ $acc['role'] }}</span>
<code class="ml-1.5 text-[10px] bg-slate-100 text-slate-600 px-1.5 py-0.5 rounded-md">{{ $acc['username'] }}</code>
</div>
<span class="text-[10px] text-slate-400 italic">password</span>
</div>
@endforeach
</div>
</details>
<p class="text-[11px] text-slate-400">&copy; 2026 PT KMH</p>
</div>
</div>
</div>
</body>
</html>
+217
View File
@@ -0,0 +1,217 @@
@extends('layouts.app')
@section('title', 'Dashboard - Admin HSE | PT Kerinci Merangin Hidro')
@section('content')
<div class="space-y-6">
<!-- Header Admin HSE (Persis Gaya Referensi IT KMH) -->
<div>
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20] block mb-1">
SISTEM ADMINISTRATOR
</span>
<div class="flex items-center space-x-2.5">
<h2 class="text-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Selamat datang, {{ auth()->user()->name }}
</h2>
<span class="w-5 h-5 rounded-full bg-slate-200/90 text-slate-500 text-xs inline-flex items-center justify-center font-bold shadow-sm" title="Dashboard Operasional Admin HSE">
<i class="fa-solid fa-info text-[10px]"></i>
</span>
</div>
<p class="text-xs sm:text-sm text-slate-500 mt-1">
Berikut ringkasan operasional keselamatan dan tata kelola izin mengemudi SIMPER PT Kerinci Merangin Hidro secara keseluruhan.
</p>
</div>
<!-- 5 Kartu Metrik Ringkasan (Persis Gaya Kotak Warna Pastel Referensi) -->
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-4">
<!-- 1. Total Karyawan (Pastel Hijau) -->
<div>
<div class="bg-[#eef7ee] border border-[#d6ebd7] rounded-3xl h-28 flex items-center justify-center shadow-xs">
<span class="text-4xl sm:text-5xl font-black text-[#2e7d32]">{{ $totalEmployees }}</span>
</div>
<p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">TOTAL KARYAWAN</p>
</div>
<!-- 2. Driver Aktif (Pastel Biru Muda) -->
<div>
<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]">{{ $totalDrivers }}</span>
</div>
<p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">DRIVER AKTIF</p>
</div>
<!-- 3. SIMPER Tersedia (Pastel Mint / Emerald) -->
<div>
<div class="bg-[#edfbf4] border border-[#d1f5e2] rounded-3xl h-28 flex items-center justify-center shadow-xs">
<span class="text-4xl sm:text-5xl font-black text-[#10b981]">{{ $validSimperCount }}</span>
</div>
<p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">SIMPER TERSEDIA</p>
</div>
<!-- 4. SIMPER Kedaluwarsa (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]">{{ $expiredSimperCount }}</span>
</div>
<p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">SIMPER KEDALUWARSA</p>
</div>
<!-- 5. Bukan Driver (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]">{{ $nonDriversCount }}</span>
</div>
<p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">BUKAN DRIVER</p>
</div>
</div>
<!-- Layout 2 Kolom Bawah: Log Driver & Mutasi SIMPER (Persis Gambar Referensi) -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 items-start">
<!-- Kolom Kiri: Log Driver & SIMPER Terkini (Format Log Serah Terima) -->
<div class="bg-white rounded-2xl border border-slate-200 p-6 shadow-sm">
<div class="flex items-center justify-between mb-5">
<h3 class="text-sm font-bold text-slate-900">Log Driver & SIMPER Terkini</h3>
<a href="{{ route('hse.employees.index') }}" class="text-xs font-bold text-[#1b5e20] hover:underline">
Lihat Semua
</a>
</div>
<div class="space-y-4">
@forelse($recentDrivers as $driver)
<div class="flex items-start space-x-3.5 py-2 border-b border-slate-50 last:border-b-0">
<!-- Avatar Inisial Bulat Hijau Pastel -->
<div class="w-9 h-9 rounded-full bg-[#eef7ee] text-[#1b5e20] font-bold text-xs flex items-center justify-center flex-shrink-0 mt-0.5">
{{ strtoupper(substr($driver->name, 0, 1)) }}
</div>
<div class="min-w-0 flex-1">
<p class="text-xs font-bold text-slate-900 leading-tight">
{{ $driver->nik }} <span class="text-slate-400 font-normal">driver</span> {{ $driver->name }}
</p>
<p class="text-[11px] text-slate-500 mt-0.5">
{{ $driver->position }} &bull; {{ $driver->division }}
</p>
<p class="text-[10px] text-slate-400 mt-0.5">
SIMPER: {{ $driver->simper_expired_at ? $driver->simper_expired_at->format('d M Y') : 'Tidak Ada Tanggal' }}
</p>
</div>
<div class="flex-shrink-0">
@if($driver->hasValidSimper())
<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">
Aktif
</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">
Kedaluwarsa
</span>
@endif
</div>
</div>
@empty
<p class="text-xs text-slate-400 text-center py-6">Belum ada data driver.</p>
@endforelse
</div>
</div>
<!-- Kolom Kanan: 2 Kartu Stacked (Format Log Mutasi & Log Pengembalian) -->
<div class="space-y-6">
<!-- Kartu Atas: Log Status SIMPER (Format Log Mutasi) -->
<div class="bg-white rounded-2xl border border-slate-200 p-6 shadow-sm">
<div class="flex items-center justify-between mb-5">
<h3 class="text-sm font-bold text-slate-900">Log Status SIMPER</h3>
<a href="{{ route('hse.employees.index') }}" class="text-xs font-bold text-[#1b5e20] hover:underline">
Lihat Semua
</a>
</div>
<div class="space-y-4">
@forelse($simperLogs as $log)
<div class="flex items-start space-x-3.5 py-2 border-b border-slate-50 last:border-b-0">
<!-- Icon Bulat Biru Pastel (Swap / Arrow Icon) -->
<div class="w-9 h-9 rounded-full bg-[#edf5fd] text-[#1976d2] flex items-center justify-center flex-shrink-0 mt-0.5">
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" d="M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"></path>
</svg>
</div>
<div class="min-w-0 flex-1">
<p class="text-xs font-bold text-slate-900 leading-tight">
{{ $log->nik }} &rarr; {{ $log->name }}
</p>
<p class="text-[11px] text-slate-500 mt-0.5">
Divisi {{ $log->division }}
</p>
<p class="text-[10px] text-slate-400 mt-0.5">
SIMPER: {{ $log->simper_expired_at ? $log->simper_expired_at->format('d M Y') : 'Belum Diatur' }}
</p>
</div>
<div class="flex-shrink-0">
@if($log->hasValidSimper())
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-emerald-50 text-emerald-700">
Valid
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-rose-50 text-rose-700">
Kedaluwarsa
</span>
@endif
</div>
</div>
@empty
<p class="text-xs text-slate-400 text-center py-4">Belum ada riwayat SIMPER.</p>
@endforelse
</div>
</div>
<!-- Kartu Bawah: Log Karyawan Non-Driver (Format Log Pengembalian) -->
<div class="bg-white rounded-2xl border border-slate-200 p-6 shadow-sm">
<div class="flex items-center justify-between mb-5">
<h3 class="text-sm font-bold text-slate-900">Log Karyawan Non-Driver</h3>
<a href="{{ route('hse.employees.index') }}" class="text-xs font-bold text-[#1b5e20] hover:underline">
Lihat Semua
</a>
</div>
<div class="space-y-4">
@forelse($nonDrivers as $staff)
<div class="flex items-start space-x-3.5 py-2 border-b border-slate-50 last:border-b-0">
<!-- Icon Bulat Netral -->
<div class="w-9 h-9 rounded-full bg-slate-100 text-slate-500 font-bold text-xs flex items-center justify-center flex-shrink-0 mt-0.5">
{{ strtoupper(substr($staff->name, 0, 1)) }}
</div>
<div class="min-w-0 flex-1">
<p class="text-xs font-bold text-slate-900 leading-tight">
{{ $staff->nik }} &bull; {{ $staff->name }}
</p>
<p class="text-[11px] text-slate-500 mt-0.5">
{{ $staff->position }} &bull; {{ $staff->division }}
</p>
<p class="text-[10px] text-slate-400 mt-0.5">
Unit Kerja: {{ $staff->unit_kerja }}
</p>
</div>
<div class="flex-shrink-0">
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-semibold bg-slate-100 text-slate-600">
Non-Driver
</span>
</div>
</div>
@empty
<p class="text-xs text-slate-400 text-center py-4">Belum ada karyawan non-driver.</p>
@endforelse
</div>
</div>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,466 @@
@extends('layouts.app')
@section('title', 'Data Simper - Admin HSE | PT Kerinci Merangin Hidro')
@section('content')
<div class="space-y-6">
<!-- Header Judul & Tombol Aksi (Persis Format Gambar Data Karyawan IT All Role) -->
<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-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Data Simper
</h2>
<!-- Info Icon Badge bulat abu-abu sesuai gambar -->
<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="Kelola data driver dan masa berlaku SIMPER">
<i class="fa-solid fa-info"></i>
</span>
</div>
</div>
<!-- Tombol Aksi Kanan (Ekspor Simper & Tambah Karyawan) -->
<div class="flex items-center space-x-3 w-full sm:w-auto">
<!-- Tombol Ekspor Dropdown -->
<button type="button"
onclick="alert('Fitur ekspor spreadsheet SIMPER sedang disiapkan')"
class="border border-emerald-600/30 text-emerald-900 bg-white hover:bg-emerald-50/50 px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
<i class="fa-regular fa-file-excel text-emerald-700 text-sm"></i>
<span>Ekspor Simper</span>
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
</button>
<!-- Tombol Tambah Karyawan (+ Tambah Karyawan Hijau Tua) -->
<button onclick="document.getElementById('addKaryawanModal').classList.remove('hidden')"
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 Karyawan</span>
</button>
</div>
</div>
<!-- Kotak Pencarian (Search Bar Persis Format Gambar Data Karyawan) -->
<div class="relative w-full max-w-sm sm:max-w-md">
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400">
<i class="fa-solid fa-magnifying-glass text-xs"></i>
</span>
<input type="text"
id="simperSearchInput"
placeholder="Cari NIK atau nama karyawan..."
class="w-full text-xs pl-10 pr-4 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-emerald-600 focus:ring-2 focus:ring-emerald-600/10 shadow-sm transition">
</div>
<!-- Tabel Data Simper dengan Header Biru Tua Navy (Persis Format Gambar) -->
<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 Tabel Navy Gelap 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">NIK</th>
<th class="py-3.5 px-4">NAMA LENGKAP</th>
<th class="py-3.5 px-4">JABATAN</th>
<th class="py-3.5 px-4">UNIT / DIVISI</th>
<th class="py-3.5 px-4 text-center">STATUS DRIVER</th>
<th class="py-3.5 px-4 text-center">MASA BERLAKU SIMPER</th>
<th class="py-3.5 px-4 text-center">AKSI</th>
</tr>
</thead>
<tbody id="simperTableBody" class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($employees as $index => $emp)
@php
$isValid = $emp->hasValidSimper();
@endphp
<tr class="simper-row hover:bg-slate-50/70 transition">
<!-- Nomor -->
<td class="py-3.5 px-4 text-center font-medium text-slate-400">{{ $index + 1 }}</td>
<!-- NIK (Font Bold Hitam Tegas) -->
<td class="py-3.5 px-4 font-bold text-slate-900 font-mono text-xs">{{ $emp->nik }}</td>
<!-- Nama Lengkap (Font Bold Hitam) -->
<td class="py-3.5 px-4 font-bold text-slate-900">{{ $emp->name }}</td>
<!-- Jabatan -->
<td class="py-3.5 px-4 text-slate-600">{{ $emp->position ?? '-' }}</td>
<!-- Unit / Divisi -->
<td class="py-3.5 px-4 text-slate-500">
<span class="font-medium text-slate-700">{{ $emp->unit_kerja ?? '-' }}</span>
@if($emp->division)
<span class="text-slate-400 block text-[10px]">{{ $emp->division }}</span>
@endif
</td>
<!-- Status Driver -->
<td class="py-3.5 px-4 text-center">
@if($emp->is_operator)
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-blue-50 text-blue-700 border border-blue-200">
Driver
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium bg-slate-100 text-slate-500">
Bukan Driver
</span>
@endif
</td>
<!-- Masa Berlaku SIMPER -->
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if(!$emp->is_operator)
<span class="text-slate-400 italic text-[11px]">-</span>
@elseif($isValid)
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[11px] font-semibold bg-emerald-50 text-emerald-700 border border-emerald-200 font-mono">
<i class="fa-solid fa-circle-check mr-1.5 text-emerald-600 text-[10px]"></i>
{{ $emp->simper_expired_at->format('d/m/Y') }}
</span>
@else
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[11px] font-semibold bg-rose-50 text-rose-700 border border-rose-200 font-mono">
<i class="fa-solid fa-circle-xmark mr-1.5 text-rose-600 text-[10px]"></i>
{{ $emp->simper_expired_at ? $emp->simper_expired_at->format('d/m/Y') : 'Belum Ada' }}
</span>
@endif
</td>
<!-- Aksi (Edit Data Simper & Perpanjang SIMPER) -->
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<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"
title="Edit Data Simper Karyawan">
<i class="fa-regular fa-pen-to-square text-sm"></i>
<span class="text-xs font-semibold">Edit</span>
</button>
<span class="text-slate-200">|</span>
<button onclick="openRenewModal({{ $emp->id }}, '{{ $emp->name }}', '{{ $emp->simper_expired_at ? $emp->simper_expired_at->format('Y-m-d') : '' }}', {{ $emp->is_operator ? '1' : '0' }})"
class="text-emerald-700 hover:text-emerald-900 font-bold underline text-[11px]"
title="Perpanjang Masa Berlaku SIMPER">
Perpanjang
</button>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="8" class="py-12 text-center text-slate-400">
<i class="fa-regular fa-folder-open text-3xl mb-2 block text-slate-300"></i>
Belum ada data pengemudi atau SIMPER yang terdaftar.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
<!-- Modal Dialog Add Karyawan (Persis Format Gambar IT All Role) -->
<div id="addKaryawanModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-7 sm:p-8 border border-slate-100 overflow-hidden">
<!-- Header Modal Bersih Tanpa Banner Gelap Sesuai Gambar -->
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Tambah Data Simper
</h3>
<button type="button" onclick="document.getElementById('addKaryawanModal').classList.add('hidden')" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form action="{{ route('hse.employees.store') }}" method="POST" class="mt-5 space-y-4">
@csrf
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Nomor Induk Karyawan (NIK) <span class="text-rose-500">*</span></label>
<input type="text" name="nik" required placeholder="Contoh: 0001"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Nama Lengkap <span class="text-rose-500">*</span></label>
<input type="text" name="name" required placeholder="Contoh: Ahmad Budi"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Unit Kerja <span class="text-rose-500">*</span></label>
<select name="unit_kerja" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="" disabled selected>Pilih Unit Kerja</option>
<option value="Pembangkit">Pembangkit</option>
<option value="Bendungan">Bendungan</option>
<option value="Teknik">Teknik</option>
<option value="Umum">Umum</option>
</select>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Divisi <span class="text-rose-500">*</span></label>
<select name="division" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="" disabled selected>Pilih Divisi</option>
<option value="INFORMATION & TECHNOLOGY">INFORMATION & TECHNOLOGY</option>
<option value="K3">K3 / HSE</option>
<option value="Quality Management Asset (QMA)">Quality Management Asset (QMA)</option>
<option value="GA">General Affairs (GA)</option>
<option value="HR">Human Resources (HR)</option>
<option value="Keuangan">Keuangan</option>
<option value="Logistik">Logistik / Warehouse</option>
<option value="Mechanical">Mechanical</option>
<option value="Civil & Inviro">Civil & Inviro</option>
<option value="PG">Private Guard (PG)</option>
</select>
</div>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Jabatan <span class="text-rose-500">*</span></label>
<input type="text" name="position" required placeholder="Contoh: Staff IT"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Operator / Driver <span class="text-rose-500">*</span></label>
<select name="is_operator" id="addOperator" onchange="toggleSimperInput('add')" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="1">YA (Aktif Mengemudi)</option>
<option value="0">TIDAK (Bukan Driver)</option>
</select>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Masa Berlaku SIMPER</label>
<input type="date" name="simper_expired_at" id="addSimperDate"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<!-- Footer Tombol: Batal & Simpan Data Sesuai Gambar -->
<div class="pt-6 border-t border-slate-100 flex items-center justify-end space-x-3 mt-6">
<button type="button" onclick="document.getElementById('addKaryawanModal').classList.add('hidden')"
class="px-6 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-sm transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-sm transition shadow-sm">
Simpan Data
</button>
</div>
</form>
</div>
</div>
<!-- Modal Dialog Perpanjang SIMPER (Clean White Card) -->
<div id="renewModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-3xl shadow-2xl max-w-md w-full p-7 border border-slate-100 overflow-hidden">
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">Perpanjang SIMPER</h3>
<button type="button" onclick="document.getElementById('renewModal').classList.add('hidden')" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form id="renewForm" method="POST" action="" class="mt-5 space-y-4">
@csrf
<div class="bg-slate-50 p-3.5 rounded-2xl border border-slate-200/80">
<span class="text-xs text-slate-400 block font-medium">Pengemudi:</span>
<strong id="renewName" class="block text-base text-slate-900 font-bold mt-0.5"></strong>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Status Driver</label>
<select name="is_operator" id="renewOperator" onchange="toggleSimperInput('renew')"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="1">YA (Aktif Mengemudi)</option>
<option value="0">TIDAK (Bukan Driver)</option>
</select>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Masa Berlaku Baru <span class="text-rose-500">*</span></label>
<input type="date" name="simper_expired_at" id="renewDate" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="pt-6 border-t border-slate-100 flex items-center justify-end space-x-3 mt-6">
<button type="button" onclick="document.getElementById('renewModal').classList.add('hidden')"
class="px-6 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-sm transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-sm transition shadow-sm">
Simpan Data
</button>
</div>
</form>
</div>
</div>
<!-- Modal Dialog Edit Data Simper Karyawan -->
<div id="editModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-7 sm:p-8 border border-slate-100 overflow-hidden">
<!-- Header Modal -->
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Edit Data Simper
</h3>
<button type="button" onclick="document.getElementById('editModal').classList.add('hidden')" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form id="editForm" method="POST" action="" class="mt-5 space-y-4">
@csrf
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Nomor Induk Karyawan (NIK) <span class="text-rose-500">*</span></label>
<input type="text" name="nik" id="editNik" required placeholder="Contoh: 0001"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Nama Lengkap <span class="text-rose-500">*</span></label>
<input type="text" name="name" id="editName" required placeholder="Contoh: Ahmad Budi"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Unit Kerja <span class="text-rose-500">*</span></label>
<select name="unit_kerja" id="editUnitKerja" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="Pembangkit">Pembangkit</option>
<option value="Bendungan">Bendungan</option>
<option value="Teknik">Teknik</option>
<option value="Umum">Umum</option>
</select>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Divisi <span class="text-rose-500">*</span></label>
<select name="division" id="editDivision" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="INFORMATION & TECHNOLOGY">INFORMATION & TECHNOLOGY</option>
<option value="K3">K3 / HSE</option>
<option value="Quality Management Asset (QMA)">Quality Management Asset (QMA)</option>
<option value="GA">General Affairs (GA)</option>
<option value="HR">Human Resources (HR)</option>
<option value="Keuangan">Keuangan</option>
<option value="Logistik">Logistik / Warehouse</option>
<option value="Mechanical">Mechanical</option>
<option value="Civil & Inviro">Civil & Inviro</option>
<option value="PG">Private Guard (PG)</option>
</select>
</div>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Jabatan <span class="text-rose-500">*</span></label>
<input type="text" name="position" id="editPosition" required placeholder="Contoh: Staff IT"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Operator / Driver <span class="text-rose-500">*</span></label>
<select name="is_operator" id="editOperator" onchange="toggleSimperInput('edit')" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="1">YA (Aktif Mengemudi)</option>
<option value="0">TIDAK (Bukan Driver)</option>
</select>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Masa Berlaku SIMPER</label>
<input type="date" name="simper_expired_at" id="editSimperDate"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<!-- Footer Tombol -->
<div class="pt-6 border-t border-slate-100 flex items-center justify-end space-x-3 mt-6">
<button type="button" onclick="document.getElementById('editModal').classList.add('hidden')"
class="px-6 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-sm transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-sm transition shadow-sm">
Simpan Perubahan
</button>
</div>
</form>
</div>
</div>
@endsection
@section('scripts')
<script>
// Logika Penguncian Input SIMPER jika Bukan Driver
function toggleSimperInput(type) {
let opSelect, dateInput;
if (type === 'add') {
opSelect = document.getElementById('addOperator');
dateInput = document.getElementById('addSimperDate');
} else if (type === 'edit') {
opSelect = document.getElementById('editOperator');
dateInput = document.getElementById('editSimperDate');
} else if (type === 'renew') {
opSelect = document.getElementById('renewOperator');
dateInput = document.getElementById('renewDate');
}
if (!opSelect || !dateInput) return;
if (opSelect.value === '0') {
// Bukan Driver: Kosongkan dan kunci input tanggal SIMPER
dateInput.value = '';
dateInput.disabled = true;
dateInput.required = false;
dateInput.classList.add('bg-slate-100', 'text-slate-400', 'cursor-not-allowed');
dateInput.classList.remove('bg-white', 'text-slate-800');
} else {
// Driver: Aktifkan input tanggal SIMPER
dateInput.disabled = false;
dateInput.classList.remove('bg-slate-100', 'text-slate-400', 'cursor-not-allowed');
dateInput.classList.add('bg-white', 'text-slate-800');
}
}
function openEditModal(emp) {
document.getElementById('editNik').value = emp.nik || '';
document.getElementById('editName').value = emp.name || '';
document.getElementById('editUnitKerja').value = emp.unit_kerja || '';
document.getElementById('editDivision').value = emp.division || '';
document.getElementById('editPosition').value = emp.position || '';
document.getElementById('editOperator').value = emp.is_operator ? '1' : '0';
let expDate = '';
if (emp.simper_expired_at) {
expDate = emp.simper_expired_at.substring(0, 10);
}
document.getElementById('editSimperDate').value = expDate;
// Cek status driver untuk mengunci/membuka input SIMPER
toggleSimperInput('edit');
document.getElementById('editForm').action = `/hse/employees/${emp.id}`;
document.getElementById('editModal').classList.remove('hidden');
}
function openRenewModal(id, name, expiredDate, isOperator) {
document.getElementById('renewName').textContent = name;
document.getElementById('renewOperator').value = isOperator ? '1' : '0';
document.getElementById('renewDate').value = expiredDate;
// Cek status driver untuk mengunci/membuka input SIMPER
toggleSimperInput('renew');
document.getElementById('renewForm').action = `/hse/employees/${id}`;
document.getElementById('renewModal').classList.remove('hidden');
}
// Inisialisasi awal untuk modal tambah
document.addEventListener('DOMContentLoaded', function() {
toggleSimperInput('add');
});
// Filter Pencarian Instan Real-time
document.getElementById('simperSearchInput')?.addEventListener('input', function(e) {
const query = e.target.value.toLowerCase();
const rows = document.querySelectorAll('#simperTableBody tr.simper-row');
rows.forEach(row => {
const text = row.textContent.toLowerCase();
row.style.display = text.includes(query) ? '' : 'none';
});
});
</script>
@endsection
+579
View File
@@ -0,0 +1,579 @@
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@yield('title', 'Sistem RKM - PT Kerinci Merangin Hidro')</title>
<!-- Tailwind CSS CDN -->
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
<style>
* {
font-family: 'Plus Jakarta Sans', sans-serif;
}
/* Active Sidebar Item Style (Seperti Sistem IT All Role) */
.sidebar-item-active {
background-color: #1b5e20;
color: #ffffff;
font-weight: 600;
border-radius: 0.75rem;
box-shadow: 0 4px 12px rgba(27, 94, 32, 0.25);
}
.sidebar-item-active i,
.sidebar-item-active svg {
color: #ffffff;
}
.sidebar-item-inactive {
color: #475569;
font-weight: 500;
border-radius: 0.75rem;
transition: all 0.2s ease;
}
.sidebar-item-inactive:hover {
background-color: #f1f5f9;
color: #0f172a;
}
.sidebar-item-inactive i,
.sidebar-item-inactive svg {
color: #64748b;
}
.sidebar-item-inactive:hover i,
.sidebar-item-inactive:hover svg {
color: #1b5e20;
}
</style>
</head>
<body class="bg-slate-50 text-slate-800 antialiased font-sans min-h-screen">
@auth
<!-- ========================================================================= -->
<!-- LAYOUT AUTHENTICATED: SIDEBAR + TOPBAR (PERSIS SISTEM IT ALL ROLE) -->
<!-- ========================================================================= -->
<!-- 1. SIDEBAR DESKTOP (Fixed di Sebelah Kiri) -->
<aside class="hidden md:flex flex-col justify-between w-64 bg-white border-r border-slate-200 h-screen fixed left-0 top-0 z-30 shadow-sm">
<div class="flex flex-col h-full overflow-hidden">
<!-- Header Sidebar: Logo Kerinci Hydropower (Tengah Sidebar) -->
<div class="h-16 px-6 flex items-center justify-center border-b border-slate-100 flex-shrink-0">
<a href="{{ url('/') }}" class="flex items-center justify-center">
<img src="{{ asset('images/logo-kerinci.png') }}"
alt="Kerinci Hydropower"
class="h-8 w-auto object-contain">
</a>
</div>
<!-- Menu Navigasi Sidebar -->
<div class="flex-1 overflow-y-auto px-4 py-5 space-y-6">
<!-- Grup: Navigasi Utama -->
<div>
<nav class="space-y-1">
@if(auth()->user()->isHseAdmin())
<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">
<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>
@elseif(auth()->user()->isQmaAdmin())
<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">
<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>
@elseif(auth()->user()->isPgAdmin() || auth()->user()->isGateOfficer())
<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' }}">
<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>Pos Gerbang</span>
</a>
@else
<a href="{{ route('qma.activity.log') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm sidebar-item-active">
<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>
@endif
</nav>
</div>
<!-- Grup: Modul Operasional RKM -->
<div>
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
MANAJEMEN SISTEM
</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
@if(auth()->user()->isQmaAdmin() || auth()->user()->isAdmin())
@php
$isVehicleRoute = request()->routeIs('qma.vehicles.*');
@endphp
<!-- Dropdown Menu: Data Kendaraan -->
<div>
<button type="button"
onclick="toggleVehicleMenu('desktop')"
class="w-full flex items-center justify-between px-3.5 py-2.5 text-sm rounded-xl transition group {{ $isVehicleRoute ? '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 text-base w-5 text-center {{ $isVehicleRoute ? 'text-[#1b5e20]' : '' }}"></i>
<span>Data Kendaraan</span>
</div>
<i id="vehicleChevronDesktop" class="fa-solid fa-chevron-down text-[11px] transition-transform duration-200 {{ $isVehicleRoute ? 'rotate-180 text-[#1b5e20]' : 'text-slate-400 group-hover:text-slate-600' }}"></i>
</button>
<!-- Submenu Dropdown: Light Vehicle & Unit Support (Tanpa Icon) -->
<div id="vehicleSubmenuDesktop" class="{{ $isVehicleRoute ? '' : '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.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>
@endif
@if(auth()->user()->isPgAdmin() || auth()->user()->isAdmin())
<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>Master Satpam (PG)</span>
</a>
@endif
@if(auth()->user()->isGateOfficer() || auth()->user()->isPgAdmin() || auth()->user()->isAdmin())
<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 Gerbang</span>
</a>
@endif
</nav>
</div>
<!-- Grup: Pengaturan Akun -->
<div class="mt-6">
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
PENGATURAN
</p>
<nav class="space-y-1">
<a href="{{ route('profile.index') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('profile.*') ? '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" stroke-linecap="round" stroke-linejoin="round">
<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"></path>
<circle cx="12" cy="7" r="4"></circle>
</svg>
<span>Profil Saya</span>
</a>
</nav>
</div>
</div>
<!-- Footer Bawah Sidebar: Profil Pengguna & Tombol Logout (Persis Gambar IT All Role) -->
<div class="p-4 border-t border-slate-100 flex items-center justify-between bg-slate-50/50">
<a href="{{ route('profile.index') }}" class="flex items-center space-x-2.5 min-w-0 hover:opacity-80 transition group" title="Buka Profil Saya">
<div class="w-8 h-8 rounded-full bg-[#1b5e20] text-white font-black text-xs flex items-center justify-center flex-shrink-0 shadow-sm group-hover:ring-2 ring-emerald-500/30">
{{ strtoupper(substr(auth()->user()->name, 0, 1)) }}
</div>
<div class="truncate">
<p class="text-xs font-bold text-slate-800 truncate leading-tight group-hover:text-[#1b5e20]">{{ auth()->user()->name }}</p>
<p class="text-[10px] text-slate-400 capitalize truncate">{{ str_replace('_', ' ', auth()->user()->role) }}</p>
</div>
</a>
<form action="{{ route('logout') }}" method="POST" class="inline">
@csrf
<button type="submit" title="Logout" class="w-8 h-8 rounded-lg flex items-center justify-center text-slate-400 hover:text-rose-600 hover:bg-rose-50 transition">
<i class="fa-solid fa-arrow-right-from-bracket text-sm"></i>
</button>
</form>
</div>
</div>
</aside>
<!-- 2. SIDEBAR MOBILE (Drawer Modal untuk Layar Kecil) -->
<div id="mobileDrawer" class="fixed inset-0 z-50 hidden md:hidden">
<!-- Backdrop gelap -->
<div id="mobileBackdrop" class="fixed inset-0 bg-slate-900/50 backdrop-blur-sm transition-opacity duration-300 ease-in-out opacity-0"></div>
<!-- Drawer Content -->
<div id="mobileDrawerPanel" class="fixed inset-y-0 left-0 w-72 bg-white shadow-2xl flex flex-col justify-between z-10 transform -translate-x-full transition-transform duration-300 ease-in-out">
<div class="p-5 border-b border-slate-100 flex items-center justify-between">
<img src="{{ asset('images/logo-kerinci.png') }}" alt="Kerinci Hydropower" class="h-7 w-auto object-contain">
<button id="closeDrawerBtn" class="text-slate-400 hover:text-slate-600 p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</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>
</a>
<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>
@endif
@if(auth()->user()->isPgAdmin() || auth()->user()->isAdmin())
<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>Master Satpam (PG)</span>
</a>
@endif
@if(auth()->user()->isGateOfficer() || auth()->user()->isPgAdmin() || auth()->user()->isAdmin())
<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>Pos Gerbang</span>
</a>
@endif
</div>
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider px-2 mt-4">PENGATURAN</p>
<div class="space-y-1">
<a href="{{ route('profile.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('profile.*') ? '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" stroke-linecap="round" stroke-linejoin="round">
<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"></path>
<circle cx="12" cy="7" r="4"></circle>
</svg>
<span>Profil Saya</span>
</a>
</div>
</div>
<div class="p-4 border-t border-slate-100 flex items-center justify-between bg-slate-50">
<a href="{{ route('profile.index') }}" class="flex items-center space-x-2 hover:opacity-80 transition">
<div class="w-8 h-8 rounded-full bg-[#1b5e20] text-white font-bold text-xs flex items-center justify-center">
{{ strtoupper(substr(auth()->user()->name, 0, 1)) }}
</div>
<span class="text-xs font-bold text-slate-800">{{ auth()->user()->name }}</span>
</a>
<form action="{{ route('logout') }}" method="POST">
@csrf
<button type="submit" class="text-rose-600 text-xs font-bold px-2.5 py-1 rounded bg-rose-50">Logout</button>
</form>
</div>
</div>
</div>
<!-- 3. TOPBAR HEADER (Di Bagian Atas Samping Sidebar) -->
<header class="md:ml-64 bg-white border-b border-slate-200 h-16 sticky top-0 z-20 flex items-center justify-between px-6 sm:px-8 shadow-sm">
<!-- Sisi Kiri: Judul Halaman / Hamburger Button -->
<div class="flex items-center space-x-3">
<button id="openDrawerBtn" class="md:hidden text-slate-600 hover:text-slate-900 p-1.5 rounded-lg border border-slate-200">
<i class="fa-solid fa-bars text-base"></i>
</button>
<h1 class="text-lg sm:text-xl font-bold text-slate-900 tracking-tight">
@if(request()->routeIs('hse.dashboard') || request()->routeIs('qma.dashboard'))
Dashboard
@elseif(request()->routeIs('hse.employees.*'))
Data Simper
@elseif(request()->routeIs('qma.vehicles.lv'))
Light Vehicle
@elseif(request()->routeIs('qma.vehicles.support'))
Unit Support
@elseif(request()->routeIs('qma.vehicles.*'))
Data Kendaraan
@elseif(request()->routeIs('qma.activity.log'))
Log Aktivitas Kendaraan
@elseif(request()->routeIs('profile.*'))
Profil Saya
@elseif(request()->routeIs('pg.gate.*'))
Verifikasi Pos Gerbang
@elseif(request()->routeIs('pg.guards.*'))
Master Data Satpam (PG)
@else
Dashboard
@endif
</h1>
</div>
<!-- Sisi Kanan: Profil Pengguna (Avatar Bulat + Nama + Role Huruf Kapital) Sesuai Gambar IT All Role -->
<div class="flex items-center space-x-3">
<a href="{{ route('profile.index') }}" class="flex items-center space-x-3 pl-3 hover:opacity-80 transition group" title="Buka Profil Saya">
<div class="w-9 h-9 rounded-full bg-[#1b5e20] text-white font-bold text-sm flex items-center justify-center shadow-sm group-hover:ring-2 ring-emerald-500/30">
{{ strtoupper(substr(auth()->user()->name, 0, 1)) }}
</div>
<div class="text-left hidden sm:block">
<p class="text-xs font-bold text-slate-800 leading-tight group-hover:text-[#1b5e20]">{{ auth()->user()->name }}</p>
<p class="text-[10px] font-semibold text-slate-400 uppercase tracking-wider mt-0.5">
{{ str_replace('_', ' ', auth()->user()->role) }}
</p>
</div>
</a>
</div>
</header>
<!-- 4. KONTEN UTAMA DASHBOARD -->
<main class="md:ml-64 p-6 sm:p-8 min-h-[calc(100vh-4rem)]">
@yield('content')
</main>
@else
<!-- ========================================================================= -->
<!-- LAYOUT PUBLIC (KHUSUS FORM SCAN QR LAPANGAN TANPA LOGIN) -->
<!-- ========================================================================= -->
<header class="bg-white border-b border-slate-200 sticky top-0 z-30 shadow-sm">
<div class="max-w-4xl mx-auto px-4 py-3 flex items-center justify-between">
<img src="{{ asset('images/logo-kerinci.png') }}" alt="Kerinci Hydropower" class="h-8 w-auto object-contain">
<a href="{{ route('login') }}" class="text-xs font-semibold text-[#1b5e20] hover:underline flex items-center space-x-1">
<span>Login Petugas</span>
<i class="fa-solid fa-arrow-right text-[10px]"></i>
</a>
</div>
</header>
<main class="max-w-4xl mx-auto p-4 sm:p-6 min-h-[calc(100vh-5rem)]">
@yield('content')
</main>
<footer class="py-4 text-center text-xs text-slate-400 border-t border-slate-200 bg-white">
&copy; 2026 PT Kerinci Merangin Hidro &bull; PLTA Merangin 350 MW
</footer>
@endauth
<!-- Toast Notification Container (Pojok Kanan Bawah) -->
<div id="toastContainer" class="fixed bottom-6 right-6 z-50 flex flex-col space-y-3 pointer-events-none">
@if(session('success'))
<div id="toast-success" class="pointer-events-auto bg-white rounded-2xl shadow-2xl border border-slate-100 overflow-hidden min-w-[320px] max-w-sm sm:max-w-md transform transition-all duration-300 ease-out translate-y-0 opacity-100">
<div class="px-5 py-4 flex items-center justify-between gap-4">
<div class="flex items-center space-x-3.5">
<div class="flex-shrink-0 text-[#10b981]">
<svg class="w-6 h-6" fill="none" stroke="currentColor" stroke-width="2.3" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="9" stroke="currentColor"></circle>
<path stroke-linecap="round" stroke-linejoin="round" d="M8.5 12.5l2.5 2.5 4.5-5"></path>
</svg>
</div>
<div class="text-sm font-bold text-slate-800 leading-snug">
{{ session('success') }}
</div>
</div>
<button type="button" onclick="dismissToast('toast-success')" class="text-slate-400 hover:text-slate-600 transition-colors p-1 flex-shrink-0 focus:outline-none" title="Tutup">
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2.2" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<!-- Progress Countdown Bar -->
<div class="w-full bg-slate-100 h-1 overflow-hidden">
<div id="toast-progress-success" class="h-full bg-[#10b981] transition-all ease-linear" style="transition-duration: 4000ms; width: 100%;"></div>
</div>
</div>
@endif
@if(session('error'))
<div id="toast-error" class="pointer-events-auto bg-white rounded-2xl shadow-2xl border border-slate-100 overflow-hidden min-w-[320px] max-w-sm sm:max-w-md transform transition-all duration-300 ease-out translate-y-0 opacity-100">
<div class="px-5 py-4 flex items-center justify-between gap-4">
<div class="flex items-center space-x-3.5">
<div class="flex-shrink-0 text-rose-500">
<svg class="w-6 h-6" fill="none" stroke="currentColor" stroke-width="2.3" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="9" stroke="currentColor"></circle>
<path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4m0 4h.01"></path>
</svg>
</div>
<div class="text-sm font-bold text-slate-800 leading-snug">
{{ session('error') }}
</div>
</div>
<button type="button" onclick="dismissToast('toast-error')" class="text-slate-400 hover:text-slate-600 transition-colors p-1 flex-shrink-0 focus:outline-none" title="Tutup">
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2.2" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<!-- Progress Countdown Bar -->
<div class="w-full bg-slate-100 h-1 overflow-hidden">
<div id="toast-progress-error" class="h-full bg-rose-500 transition-all ease-linear" style="transition-duration: 4000ms; width: 100%;"></div>
</div>
</div>
@endif
</div>
<!-- Script Javascript untuk Drawer Mobile & Toast Notification -->
<script>
const openBtn = document.getElementById('openDrawerBtn');
const closeBtn = document.getElementById('closeDrawerBtn');
const drawer = document.getElementById('mobileDrawer');
const backdrop = document.getElementById('mobileBackdrop');
const drawerPanel = document.getElementById('mobileDrawerPanel');
let drawerTimer = null;
if (openBtn && drawer && closeBtn && backdrop && drawerPanel) {
const openDrawer = () => {
if (drawerTimer) clearTimeout(drawerTimer);
drawer.classList.remove('hidden');
document.body.classList.add('overflow-hidden');
// Beri waktu 2 frame agar browser menyelesaikan repaint sebelum memulai transisi CSS
requestAnimationFrame(() => {
requestAnimationFrame(() => {
backdrop.classList.remove('opacity-0');
backdrop.classList.add('opacity-100');
drawerPanel.classList.remove('-translate-x-full');
drawerPanel.classList.add('translate-x-0');
});
});
};
const closeDrawer = () => {
backdrop.classList.remove('opacity-100');
backdrop.classList.add('opacity-0');
drawerPanel.classList.remove('translate-x-0');
drawerPanel.classList.add('-translate-x-full');
document.body.classList.remove('overflow-hidden');
if (drawerTimer) clearTimeout(drawerTimer);
drawerTimer = setTimeout(() => {
drawer.classList.add('hidden');
}, 300);
};
openBtn.addEventListener('click', openDrawer);
closeBtn.addEventListener('click', closeDrawer);
backdrop.addEventListener('click', closeDrawer);
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && !drawer.classList.contains('hidden')) {
closeDrawer();
}
});
}
// Fungsi Menutup Toast
function dismissToast(id) {
const toast = document.getElementById(id);
if (!toast) return;
toast.classList.add('opacity-0', 'translate-y-3');
setTimeout(() => {
toast.remove();
}, 300);
}
// Auto dismiss Toast dengan countdown progress bar
document.addEventListener('DOMContentLoaded', () => {
const successToast = document.getElementById('toast-success');
if (successToast) {
const bar = document.getElementById('toast-progress-success');
setTimeout(() => {
if (bar) bar.style.width = '0%';
}, 50);
setTimeout(() => {
dismissToast('toast-success');
}, 4100);
}
const errorToast = document.getElementById('toast-error');
if (errorToast) {
const bar = document.getElementById('toast-progress-error');
setTimeout(() => {
if (bar) bar.style.width = '0%';
}, 50);
setTimeout(() => {
dismissToast('toast-error');
}, 4100);
}
});
// Toggle Dropdown Menu Data Kendaraan (Desktop & Mobile)
function toggleVehicleMenu(target) {
const submenu = document.getElementById(target === 'desktop' ? 'vehicleSubmenuDesktop' : 'vehicleSubmenuMobile');
const chevron = document.getElementById(target === 'desktop' ? 'vehicleChevronDesktop' : 'vehicleChevronMobile');
if (submenu) {
submenu.classList.toggle('hidden');
}
if (chevron) {
chevron.classList.toggle('rotate-180');
}
}
</script>
@yield('scripts')
</body>
</html>
@@ -0,0 +1,188 @@
@extends('layouts.app')
@section('title', 'Verifikasi Pos Gerbang - Private Guard (PG)')
@section('content')
<div class="space-y-6">
<!-- Header Pos Gerbang -->
<div class="bg-gradient-to-r from-slate-900 to-slate-800 text-white p-5 rounded-xl shadow-md border border-slate-700 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<div class="flex items-center space-x-2">
<span class="inline-flex items-center px-2.5 py-0.5 rounded text-xs font-semibold bg-blue-500/20 text-blue-300 border border-blue-500/30">
<i class="fa-solid fa-shield-halved mr-1"></i> Pos Gerbang Aktif
</span>
<span class="text-xs text-slate-400">Akun Bersama Pos Jaga</span>
</div>
<h2 class="text-2xl font-black text-white tracking-tight mt-1">
{{ $gate ? $gate->name : 'Pos Gerbang Belum Dipilih' }}
</h2>
<p class="text-xs text-slate-300 mt-1">
Petugas Satpam yang sedang piket wajib memverifikasi kondisi fisik kendaraan dan angka odometer riil sebelum membuka portal.
</p>
</div>
<div>
<span class="bg-amber-500/20 text-amber-300 border border-amber-500/30 font-bold px-3 py-1.5 rounded-lg text-sm flex items-center">
<i class="fa-solid fa-clock-rotate-left mr-2 animate-spin"></i>
Antrean: {{ $pendingActivities->count() }} Kendaraan
</span>
</div>
</div>
<!-- Antrean Validasi Kendaraan -->
<div class="bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden">
<div class="p-4 bg-slate-50 border-b border-slate-200 flex justify-between items-center">
<h3 class="text-sm font-bold text-slate-800 uppercase tracking-wider flex items-center">
<i class="fa-solid fa-car-side text-emerald-600 mr-2"></i> Kendaraan Menunggu Verifikasi Fisik
</h3>
<span class="text-xs text-slate-500">Auto-refresh saat halaman dimuat ulang</span>
</div>
<div class="divide-y divide-slate-200">
@forelse($pendingActivities as $act)
<div class="p-5 hover:bg-slate-50 transition flex flex-col lg:flex-row justify-between items-start lg:items-center gap-4">
<div class="space-y-2 flex-1">
<div class="flex flex-wrap items-center gap-2">
<span class="text-sm font-black font-mono bg-slate-900 text-white px-2.5 py-1 rounded">
{{ $act->vehicle->code }}
</span>
<span class="text-xs font-bold text-amber-600 bg-amber-50 border border-amber-200 px-2 py-0.5 rounded">
{{ $act->vehicle->license_plate ?? 'Tanpa Plat' }}
</span>
@if($act->direction === 'in')
<span class="text-xs font-bold bg-emerald-100 text-emerald-800 px-2.5 py-0.5 rounded-full border border-emerald-300">
<i class="fa-solid fa-arrow-right-to-bracket mr-1"></i> MASUK (In)
</span>
@else
<span class="text-xs font-bold bg-blue-100 text-blue-800 px-2.5 py-0.5 rounded-full border border-blue-300">
<i class="fa-solid fa-arrow-right-from-bracket mr-1"></i> KELUAR (Out)
</span>
@endif
<span class="text-xs text-slate-500 font-mono">
Diinput: {{ $act->recorded_at->format('H:i:s d/m/Y') }}
</span>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-3 text-xs text-slate-600 pt-1">
<div><span class="text-slate-400 block">Unit:</span> <strong class="text-slate-800">{{ $act->vehicle->brand_type }}</strong></div>
<div><span class="text-slate-400 block">Pengemudi:</span> <strong class="text-slate-800">{{ $act->driver->name }}</strong> ({{ $act->driver->division ?? '-' }})</div>
<div><span class="text-slate-400 block">KM Input (Odometer):</span> <strong class="text-emerald-700 text-sm font-mono">{{ number_format($act->current_km, 0, ',', '.') }} KM</strong></div>
<div><span class="text-slate-400 block">Jarak Sesi Ini:</span> <strong class="text-slate-800 font-mono">+{{ number_format($act->distance, 0, ',', '.') }} KM</strong></div>
</div>
<div class="text-xs bg-slate-100 p-2.5 rounded-lg border border-slate-200 text-slate-700">
<span class="font-bold text-slate-800">Rencana Kerja:</span> {{ $act->purpose }}
</div>
</div>
<!-- Tombol Aksi Verifikasi Satpam -->
<div class="flex items-center space-x-2 self-end lg:self-center">
<button onclick="openVerificationModal({{ $act->id }}, '{{ $act->vehicle->code }}', '{{ $act->current_km }}', '{{ $act->driver->name }}')"
class="bg-emerald-600 hover:bg-emerald-700 text-white font-bold text-xs py-2.5 px-4 rounded-lg shadow-sm transition flex items-center space-x-1.5">
<i class="fa-solid fa-clipboard-check"></i>
<span>Verifikasi Satpam</span>
</button>
</div>
</div>
@empty
<div class="p-12 text-center text-slate-400">
<i class="fa-solid fa-circle-check text-4xl text-emerald-400 mb-2 block"></i>
<p class="text-sm font-medium text-slate-600">Tidak ada kendaraan yang menunggu verifikasi di gerbang ini saat ini.</p>
<span class="text-xs text-slate-400">Semua aktivitas kendaraan telah diperiksa atau belum ada pemindaian baru.</span>
</div>
@endforelse
</div>
</div>
</div>
<!-- Modal Dialog Verifikasi Satpam -->
<div id="verificationModal" class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-xl shadow-2xl max-w-md w-full overflow-hidden border border-slate-200 animate-in fade-in zoom-in duration-150">
<div class="bg-slate-900 text-white p-4 flex justify-between items-center">
<h3 class="text-sm font-bold flex items-center">
<i class="fa-solid fa-user-shield text-emerald-400 mr-2"></i> Pemeriksaan Fisik Satpam
</h3>
<button onclick="closeVerificationModal()" class="text-slate-400 hover:text-white"><i class="fa-solid fa-xmark"></i></button>
</div>
<div class="p-5 space-y-4">
<div class="bg-slate-50 p-3 rounded-lg border border-slate-200 text-xs space-y-1">
<div><span class="text-slate-500">Unit:</span> <strong id="modalUnitCode" class="text-slate-800 font-mono"></strong></div>
<div><span class="text-slate-500">Driver:</span> <strong id="modalDriverName" class="text-slate-800"></strong></div>
<div><span class="text-slate-500">KM Odometer Input:</span> <strong id="modalKmInput" class="text-emerald-700 font-mono text-sm"></strong> KM</div>
</div>
<!-- Form Approve -->
<form id="approveForm" method="POST" action="">
@csrf
<div class="mb-4">
<label for="security_guard_id" class="block text-xs font-semibold text-slate-700 mb-1">
Pilih Nama Satpam yang Bertugas <span class="text-rose-500">*</span>
</label>
<select name="security_guard_id" id="security_guard_id" required class="w-full text-xs rounded-lg border-slate-300 border p-2.5 focus:border-emerald-500 focus:ring-1 focus:ring-emerald-500">
<option value="" disabled selected>-- Pilih Nama Anda (Satpam) --</option>
@foreach($guards as $guard)
<option value="{{ $guard->id }}">{{ $guard->name }}</option>
@endforeach
</select>
</div>
<div class="flex items-center space-x-2 pt-2 border-t border-slate-200">
<button type="submit" class="flex-1 bg-emerald-600 hover:bg-emerald-700 text-white font-bold text-xs py-2.5 px-4 rounded-lg transition flex items-center justify-center space-x-1">
<i class="fa-solid fa-check"></i>
<span>Setujui (Buka Portal)</span>
</button>
<button type="button" onclick="showRejectSection()" class="bg-rose-50 hover:bg-rose-100 text-rose-700 border border-rose-300 font-bold text-xs py-2.5 px-3 rounded-lg transition">
Tolak
</button>
</div>
</form>
<!-- Section Form Reject (Hidden by default) -->
<form id="rejectForm" method="POST" action="" class="hidden border-t border-rose-200 pt-3">
@csrf
<div class="space-y-3">
<div>
<label class="block text-xs font-semibold text-rose-800 mb-1">Alasan Penolakan <span class="text-rose-500">*</span></label>
<textarea name="rejection_note" required rows="2" placeholder="Contoh: Angka KM di dashboard tidak cocok, driver tidak memiliki izin membawa penumpang..." class="w-full text-xs rounded-lg border-rose-300 border p-2 focus:ring-rose-500 focus:border-rose-500"></textarea>
</div>
<input type="hidden" name="security_guard_id" id="rejectGuardId">
<button type="submit" class="w-full bg-rose-600 hover:bg-rose-700 text-white font-bold text-xs py-2 px-3 rounded-lg transition">
Konfirmasi Tolak Kendaraan
</button>
</div>
</form>
</div>
</div>
</div>
@endsection
@section('scripts')
<script>
function openVerificationModal(activityId, unitCode, kmInput, driverName) {
document.getElementById('modalUnitCode').textContent = unitCode;
document.getElementById('modalDriverName').textContent = driverName;
document.getElementById('modalKmInput').textContent = parseFloat(kmInput).toLocaleString('id-ID');
document.getElementById('approveForm').action = `/pg/gate-inspection/${activityId}/approve`;
document.getElementById('rejectForm').action = `/pg/gate-inspection/${activityId}/reject`;
document.getElementById('rejectForm').classList.add('hidden');
document.getElementById('verificationModal').classList.remove('hidden');
}
function closeVerificationModal() {
document.getElementById('verificationModal').classList.add('hidden');
}
function showRejectSection() {
const guardSelect = document.getElementById('security_guard_id');
if (!guardSelect.value) {
alert('Silakan pilih nama Satpam terlebih dahulu sebelum menolak.');
guardSelect.focus();
return;
}
document.getElementById('rejectGuardId').value = guardSelect.value;
document.getElementById('rejectForm').classList.toggle('hidden');
}
</script>
@endsection
+91
View File
@@ -0,0 +1,91 @@
@extends('layouts.app')
@section('title', 'Master Data Satpam - Admin Private Guard')
@section('content')
<div class="space-y-6">
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 bg-white p-5 rounded-xl border border-slate-200 shadow-sm">
<div>
<h2 class="text-xl font-bold text-slate-900 tracking-tight flex items-center">
<i class="fa-solid fa-user-shield text-emerald-600 mr-2.5"></i> Master Data Satpam (Private Guard)
</h2>
<p class="text-xs text-slate-500 mt-1">
Kelola data petugas keamanan yang bertugas melakukan verifikasi kendaraan di pos gerbang proyek.
</p>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<!-- Form Tambah Satpam Baru -->
<div class="bg-white p-5 rounded-xl border border-slate-200 shadow-sm h-fit">
<h3 class="text-sm font-bold text-slate-800 uppercase tracking-wider mb-4 flex items-center">
<i class="fa-solid fa-user-plus text-emerald-600 mr-2"></i> Tambah Petugas Satpam
</h3>
<form action="{{ route('pg.guards.store') }}" method="POST" class="space-y-4">
@csrf
<div>
<label for="name" class="block text-xs font-semibold text-slate-700 mb-1">
Nama Lengkap Satpam <span class="text-rose-500">*</span>
</label>
<input type="text" name="name" id="name" required placeholder="Contoh: Budi Santoso" class="w-full text-xs rounded-lg border-slate-300 border p-2.5 focus:border-emerald-500 focus:ring-1 focus:ring-emerald-500">
</div>
<button type="submit" class="w-full bg-slate-900 hover:bg-slate-800 text-white font-bold text-xs py-2.5 px-4 rounded-lg shadow-sm transition">
<i class="fa-solid fa-floppy-disk mr-1"></i> Simpan Data Satpam
</button>
</form>
</div>
<!-- Tabel Daftar Satpam -->
<div class="md:col-span-2 bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden">
<div class="p-4 bg-slate-50 border-b border-slate-200">
<h3 class="text-xs font-bold text-slate-700 uppercase tracking-wider">
Daftar Petugas Satpam Aktif & Nonaktif
</h3>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-slate-200 text-xs text-left">
<thead class="bg-slate-100 font-semibold text-slate-600 uppercase tracking-wider">
<tr>
<th class="py-3 px-4 text-center">No</th>
<th class="py-3 px-4">Nama Lengkap</th>
<th class="py-3 px-4 text-center">Status Piket</th>
<th class="py-3 px-4 text-center">Aksi</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-200 text-slate-700">
@forelse($guards as $index => $g)
<tr class="hover:bg-slate-50 transition">
<td class="py-3 px-4 text-center text-slate-400">{{ $index + 1 }}</td>
<td class="py-3 px-4 font-bold text-slate-800">{{ $g->name }}</td>
<td class="py-3 px-4 text-center">
@if($g->is_active)
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold bg-emerald-100 text-emerald-800">
Aktif
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold bg-slate-100 text-slate-500">
Nonaktif
</span>
@endif
</td>
<td class="py-3 px-4 text-center">
<form action="{{ route('pg.guards.toggle', $g->id) }}" method="POST" class="inline">
@csrf
<button type="submit" class="text-[11px] font-medium text-slate-600 hover:text-slate-900 underline">
{{ $g->is_active ? 'Nonaktifkan' : 'Aktifkan' }}
</button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="4" class="py-6 text-center text-slate-400">Belum ada data petugas Satpam.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
+163
View File
@@ -0,0 +1,163 @@
@extends('layouts.app')
@section('title', 'Profil Saya - PT Kerinci Merangin Hidro')
@section('content')
<div class="space-y-6 max-w-5xl">
<!-- Header Judul -->
<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">
PENGATURAN AKUN
</span>
<div class="flex items-center space-x-3">
<h2 class="text-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Profil Saya
</h2>
<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="Informasi akun pengguna Anda">
<i class="fa-solid fa-info"></i>
</span>
</div>
<p class="text-xs text-slate-500 mt-1">
Kelola informasi identitas, kredensial login, dan pengaturan keamanan akun Anda.
</p>
</div>
</div>
<!-- Layout 2 Kolom Profil -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 items-start">
<!-- Kolom Kiri: Kartu Ringkasan Pengguna -->
<div class="bg-white rounded-2xl border border-slate-200 p-6 shadow-sm flex flex-col items-center text-center">
<!-- Avatar Besar -->
<div class="w-24 h-24 rounded-full bg-[#1b5e20] text-white text-3xl font-black flex items-center justify-center shadow-lg mb-4 ring-4 ring-emerald-50">
{{ strtoupper(substr($user->name, 0, 1)) }}
</div>
<h3 class="text-lg font-bold text-slate-900">{{ $user->name }}</h3>
<p class="text-xs font-mono text-slate-500 mt-0.5">NIK / Username: {{ $user->username ?? '-' }}</p>
<!-- Role Badge -->
<div class="mt-3">
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-emerald-100 text-emerald-800 uppercase tracking-wide">
<i class="fa-solid fa-user-shield mr-1.5 text-[11px]"></i>
{{ str_replace('_', ' ', $user->role) }}
</span>
</div>
<div class="w-full border-t border-slate-100 mt-6 pt-5 space-y-3 text-left text-xs">
<div class="flex justify-between items-center py-1">
<span class="text-slate-500">Status Akun</span>
<span class="inline-flex items-center font-bold text-emerald-700">
<span class="w-2 h-2 rounded-full bg-emerald-500 mr-1.5 animate-pulse"></span>
Aktif
</span>
</div>
<div class="flex justify-between items-center py-1">
<span class="text-slate-500">Unit Operasional</span>
<span class="font-semibold text-slate-800">PLTA Merangin 350 MW</span>
</div>
<div class="flex justify-between items-center py-1">
<span class="text-slate-500">Terdaftar Sejak</span>
<span class="font-semibold text-slate-800">{{ $user->created_at ? $user->created_at->format('d M Y') : '12 Okt 2026' }}</span>
</div>
</div>
</div>
<!-- Kolom Kanan: Form Edit Profil & Kata Sandi -->
<div class="lg:col-span-2 bg-white rounded-2xl border border-slate-200 p-6 sm:p-8 shadow-sm">
<h3 class="text-base font-bold text-slate-900 mb-1">Perbarui Data Akun</h3>
<p class="text-xs text-slate-400 mb-6">Ubah data nama lengkap, email, atau perbarui kata sandi akun Anda.</p>
@if($errors->any())
<div class="mb-6 p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-800 text-xs space-y-1">
<div class="font-bold flex items-center">
<i class="fa-solid fa-triangle-exclamation mr-2"></i> Mohon periksa kesalahan berikut:
</div>
<ul class="list-disc list-inside ml-2">
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form action="{{ route('profile.update') }}" method="POST" class="space-y-5">
@csrf
@method('PUT')
<!-- Nama Lengkap -->
<div>
<label class="block text-xs font-bold text-slate-800 mb-2">Nama Lengkap <span class="text-rose-500">*</span></label>
<input type="text" name="name" value="{{ old('name', $user->name) }}" required
class="w-full text-xs px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<!-- Username / NIK (Read-Only) -->
<div>
<label class="block text-xs font-bold text-slate-800 mb-2">Username / NIK</label>
<div class="relative">
<input type="text" value="{{ $user->username ?? '-' }}" readonly
class="w-full text-xs px-4 py-3 rounded-xl border border-slate-200 bg-slate-100 text-slate-500 font-mono cursor-not-allowed">
<span class="absolute inset-y-0 right-0 pr-3.5 flex items-center text-slate-400 text-xs" title="Username dikelola oleh Administrator">
<i class="fa-solid fa-lock"></i>
</span>
</div>
</div>
<!-- Role Sistem (Read-Only) -->
<div>
<label class="block text-xs font-bold text-slate-800 mb-2">Hak Akses Sistem</label>
<div class="relative">
<input type="text" value="{{ strtoupper(str_replace('_', ' ', $user->role)) }}" readonly
class="w-full text-xs px-4 py-3 rounded-xl border border-slate-200 bg-slate-100 text-slate-500 cursor-not-allowed">
<span class="absolute inset-y-0 right-0 pr-3.5 flex items-center text-slate-400 text-xs" title="Hak akses ditentukan administrator">
<i class="fa-solid fa-shield"></i>
</span>
</div>
</div>
</div>
<!-- Email Pengguna -->
<div>
<label class="block text-xs font-bold text-slate-800 mb-2">Alamat Email</label>
<input type="email" name="email" value="{{ old('email', $user->email) }}" placeholder="[email protected]"
class="w-full text-xs px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<!-- Pemisah Bagian Ganti Password -->
<div class="pt-4 border-t border-slate-100">
<h4 class="text-xs font-bold uppercase tracking-wider text-slate-700 mb-1">Keamanan & Kata Sandi</h4>
<p class="text-[11px] text-slate-400 mb-4">Kosongkan kolom kata sandi di bawah jika Anda tidak berniat mengubah kata sandi saat ini.</p>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-2">Kata Sandi Baru</label>
<input type="password" name="password" placeholder="Minimal 6 karakter"
class="w-full text-xs px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-2">Konfirmasi Kata Sandi Baru</label>
<input type="password" name="password_confirmation" placeholder="Ulangi kata sandi baru"
class="w-full text-xs px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
</div>
<!-- Tombol Aksi Simpan -->
<div class="pt-4 flex justify-end">
<button type="submit"
class="bg-[#1b5e20] hover:bg-[#144919] text-white px-6 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-md">
<i class="fa-solid fa-floppy-disk text-xs"></i>
<span>Simpan Perubahan</span>
</button>
</div>
</form>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,204 @@
@extends('layouts.app')
@section('title', 'Input Timesheet Unit - ' . $vehicle->code)
@section('content')
<div class="max-w-2xl mx-auto">
<!-- Card Utama Form Input Timesheet -->
<div class="bg-white rounded-xl shadow-md border border-slate-200 overflow-hidden">
<!-- Header Info Kendaraan (Readonly Card) -->
<div class="bg-gradient-to-r from-slate-800 to-slate-900 text-white p-5 border-b border-slate-700">
<div class="flex items-center justify-between mb-3">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-emerald-500/20 text-emerald-300 border border-emerald-500/30">
<i class="fa-solid fa-car mr-1"></i> Kendaraan Ringan (LV)
</span>
<span class="text-xs text-slate-400">Scan QR Code Aktif</span>
</div>
<h2 class="text-xl font-bold tracking-tight text-white mb-3">Input Timesheet Unit</h2>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2 text-xs text-slate-300 bg-slate-800/80 p-3 rounded-lg border border-slate-700">
<div><span class="text-slate-400 font-medium">Kode Unit:</span> <span class="font-bold text-white text-sm">{{ $vehicle->code }}</span></div>
<div><span class="text-slate-400 font-medium">Nopol:</span> <span class="font-bold text-amber-300 text-sm">{{ $vehicle->license_plate ?? '-' }}</span></div>
<div class="col-span-1 sm:col-span-2"><span class="text-slate-400 font-medium">Merk / Tipe:</span> <span class="text-white">{{ $vehicle->brand_type }}</span></div>
<div><span class="text-slate-400 font-medium">Penanggung Jawab:</span> <span class="text-slate-200">{{ $vehicle->ownership ?? '-' }}</span></div>
<div><span class="text-slate-400 font-medium">KM Sebelumnya:</span> <span class="font-bold text-emerald-400 text-sm">{{ number_format($vehicle->current_km, 0, ',', '.') }} KM</span></div>
</div>
</div>
<!-- Form Body -->
<form action="{{ route('vehicle.activity.store', ['code' => $vehicle->code]) }}" method="POST" id="timesheetForm" class="p-6 space-y-5">
@csrf
<!-- 1. Pilihan Pengemudi (Driver) dengan Validasi SIMPER Real-time -->
<div>
<label for="driver_id" class="block text-xs font-semibold uppercase tracking-wider text-slate-700 mb-1.5">
Nama Pemakai Unit (Driver) <span class="text-rose-500">*</span>
</label>
<select name="driver_id" id="driver_id" required class="w-full rounded-lg border border-slate-300 bg-white px-3.5 py-2.5 text-sm text-slate-800 focus:border-emerald-500 focus:ring-2 focus:ring-emerald-200 transition">
<option value="" disabled selected>-- Pilih Driver / Pemakai Unit --</option>
@foreach($drivers as $d)
@php
$isValid = $d->hasValidSimper();
$expiredDate = $d->simper_expired_at ? $d->simper_expired_at->format('d/m/Y') : 'Tidak Ada Data';
@endphp
<option value="{{ $d->id }}"
data-is-valid="{{ $isValid ? '1' : '0' }}"
data-expired="{{ $expiredDate }}"
{{ old('driver_id') == $d->id ? 'selected' : '' }}>
{{ $d->name }} ({{ $d->division ?? 'Umum' }}) — SIMPER: {{ $expiredDate }} {{ !$isValid ? '🔴 [KEDALUWARSA]' : '🟢' }}
</option>
@endforeach
</select>
<!-- Warning Banner SIMPER Kedaluwarsa (BR-01 & BR-02) -->
<div id="simperWarningBanner" class="hidden mt-3 p-3.5 bg-rose-50 border border-rose-200 rounded-lg text-rose-800 text-xs flex items-start space-x-2.5 animate-pulse">
<i class="fa-solid fa-triangle-exclamation text-rose-600 text-base mt-0.5"></i>
<div>
<span class="font-bold block text-sm">Peringatan: Masa Berlaku SIMPER Telah Kedaluwarsa!</span>
<p class="mt-0.5" id="simperWarningText">Karyawan ini tidak dapat mengoperasikan unit. Silakan lakukan perpanjangan SIMPER melalui Divisi HSE.</p>
</div>
</div>
</div>
<!-- 2. Pilihan Gate / Gerbang -->
<div>
<label for="gate_id" class="block text-xs font-semibold uppercase tracking-wider text-slate-700 mb-1.5">
Lokasi Gate / Gerbang <span class="text-rose-500">*</span>
</label>
<select name="gate_id" id="gate_id" required class="w-full rounded-lg border border-slate-300 bg-white px-3.5 py-2.5 text-sm text-slate-800 focus:border-emerald-500 focus:ring-2 focus:ring-emerald-200 transition">
<option value="" disabled selected>-- Pilih Pos Gerbang --</option>
@foreach($gates as $g)
<option value="{{ $g->id }}" {{ old('gate_id') == $g->id ? 'selected' : '' }}>
{{ $g->name }} ({{ $g->code }})
</option>
@endforeach
</select>
</div>
<!-- 3. Arah Gerbang (In/Out) dengan Logika Berpasangan -->
<div>
<div class="flex items-center justify-between mb-1.5">
<label for="direction" class="block text-xs font-semibold uppercase tracking-wider text-slate-700">
Arah Akses Gerbang (In / Out) <span class="text-rose-500">*</span>
</label>
@if($allowedDirection === 'ANY')
<span class="text-xs text-emerald-600 font-medium"><i class="fa-solid fa-sparkles"></i> Transaksi Perdana (Bebas Pilih)</span>
@else
<span class="text-xs text-amber-600 font-medium"><i class="fa-solid fa-lock"></i> Terkunci Berpasangan ({{ strtoupper($allowedDirection) }})</span>
@endif
</div>
@if($allowedDirection === 'ANY')
<select name="direction" id="direction" required class="w-full rounded-lg border border-slate-300 bg-white px-3.5 py-2.5 text-sm text-slate-800 focus:border-emerald-500 focus:ring-2 focus:ring-emerald-200 transition">
<option value="" disabled selected>-- Pilih Arah Akses --</option>
<option value="in" {{ old('direction') === 'in' ? 'selected' : '' }}>MASUK (In)</option>
<option value="out" {{ old('direction') === 'out' ? 'selected' : '' }}>KELUAR (Out)</option>
</select>
@else
<input type="hidden" name="direction" value="{{ $allowedDirection }}">
<div class="p-3 bg-slate-100 border border-slate-300 rounded-lg text-sm font-semibold flex items-center justify-between {{ $allowedDirection === 'in' ? 'text-emerald-700 bg-emerald-50 border-emerald-300' : 'text-blue-700 bg-blue-50 border-blue-300' }}">
<span>
<i class="fa-solid {{ $allowedDirection === 'in' ? 'fa-arrow-right-to-bracket' : 'fa-arrow-right-from-bracket' }} mr-2"></i>
Arah Otomatis: {{ $allowedDirection === 'in' ? 'MASUK (In)' : 'KELUAR (Out)' }}
</span>
<span class="text-xs font-normal text-slate-500">(Berdasarkan status terakhir)</span>
</div>
@endif
</div>
<!-- 4. Input Odometer KM -->
<div>
<label for="current_km" class="block text-xs font-semibold uppercase tracking-wider text-slate-700 mb-1.5">
Odometer Saat Ini (KM) <span class="text-rose-500">*</span>
</label>
<div class="relative">
<input type="number" step="0.1" name="current_km" id="current_km"
value="{{ old('current_km', $vehicle->current_km) }}"
min="{{ $vehicle->current_km }}"
required
placeholder="Masukkan angka odometer di speedometer"
class="w-full rounded-lg border border-slate-300 bg-white px-3.5 py-2.5 text-sm text-slate-800 font-semibold focus:border-emerald-500 focus:ring-2 focus:ring-emerald-200 transition">
<div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none text-xs font-bold text-slate-400">
KM
</div>
</div>
<div class="flex items-center justify-between mt-1 text-xs text-slate-500">
<span>Minimal: {{ number_format($vehicle->current_km, 0, ',', '.') }} KM</span>
<span id="distancePreview" class="font-medium text-emerald-600">Estimasi Jarak: 0 KM</span>
</div>
</div>
<!-- 5. Rencana Pekerjaan / Aktivitas -->
<div>
<label for="purpose" class="block text-xs font-semibold uppercase tracking-wider text-slate-700 mb-1.5">
Rencana Pekerjaan / Aktivitas <span class="text-rose-500">*</span>
</label>
<textarea name="purpose" id="purpose" rows="3" required placeholder="Jelaskan keperluan operasional penggunaan unit..." class="w-full rounded-lg border border-slate-300 bg-white px-3.5 py-2.5 text-sm text-slate-800 focus:border-emerald-500 focus:ring-2 focus:ring-emerald-200 transition">{{ old('purpose') }}</textarea>
</div>
<!-- Tombol Aksi -->
<div class="pt-3 border-t border-slate-200 flex items-center space-x-3">
<button type="submit" id="btnSubmit" class="flex-1 bg-emerald-600 hover:bg-emerald-700 text-white font-semibold py-2.5 px-4 rounded-lg shadow-sm transition flex items-center justify-center space-x-2 disabled:bg-slate-300 disabled:text-slate-500 disabled:cursor-not-allowed">
<i class="fa-solid fa-check"></i>
<span>Simpan Timesheet</span>
</button>
<button type="reset" class="bg-slate-100 hover:bg-slate-200 text-slate-700 font-semibold py-2.5 px-4 rounded-lg transition border border-slate-300">
<i class="fa-solid fa-rotate-left mr-1"></i> Reset
</button>
</div>
</form>
</div>
</div>
@endsection
@section('scripts')
<script>
document.addEventListener('DOMContentLoaded', function () {
const driverSelect = document.getElementById('driver_id');
const submitBtn = document.getElementById('btnSubmit');
const warningBanner = document.getElementById('simperWarningBanner');
const warningText = document.getElementById('simperWarningText');
const currentKmInput = document.getElementById('current_km');
const distancePreview = document.getElementById('distancePreview');
const previousKm = parseFloat("{{ $vehicle->current_km }}") || 0;
// Validasi SIMPER saat driver dipilih
function checkSimper() {
const selectedOption = driverSelect.options[driverSelect.selectedIndex];
if (!selectedOption || !selectedOption.value) {
warningBanner.classList.add('hidden');
submitBtn.disabled = false;
return;
}
const isValid = selectedOption.getAttribute('data-is-valid') === '1';
const expiredDate = selectedOption.getAttribute('data-expired');
if (!isValid) {
// SIMPER Kedaluwarsa -> Blokir Tombol Submit (BR-01 & BR-02)
warningText.textContent = `SIMPER pengemudi telah kedaluwarsa pada ${expiredDate}. Tombol simpan dinonaktifkan. Pengemudi wajib melakukan perpanjangan SIMPER melalui Divisi HSE.`;
warningBanner.classList.remove('hidden');
submitBtn.disabled = true;
} else {
warningBanner.classList.add('hidden');
submitBtn.disabled = false;
}
}
// Kalkulasi jarak real-time
function calculateDistance() {
const inputKm = parseFloat(currentKmInput.value) || 0;
const diff = Math.max(0, inputKm - previousKm);
distancePreview.textContent = `Estimasi Jarak: ${diff.toLocaleString('id-ID')} KM`;
}
driverSelect.addEventListener('change', checkSimper);
currentKmInput.addEventListener('input', calculateDistance);
// Run check on load
checkSimper();
calculateDistance();
});
</script>
@endsection
+170
View File
@@ -0,0 +1,170 @@
@extends('layouts.app')
@section('title', 'Log Aktivitas Kendaraan QMA - 10 Kolom')
@section('content')
<div class="space-y-6">
<!-- Header Judul & Total Catatan (Persis Format Standar Manajemen Sistem) -->
<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-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Log Aktivitas Kendaraan
</h2>
<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="Catatan komprehensif 10 kolom pergerakan armada kendaraan dengan validasi pos gerbang">
<i class="fa-solid fa-info"></i>
</span>
</div>
</div>
<div class="flex items-center space-x-3 w-full sm:w-auto">
<span class="inline-flex items-center px-4 py-2 rounded-xl text-xs font-bold bg-emerald-50 text-emerald-800 border border-emerald-200 shadow-sm">
<i class="fa-solid fa-clipboard-check mr-2 text-emerald-600"></i> Total: {{ $activities->total() }} Catatan
</span>
</div>
</div>
<!-- Filter Bar -->
<div class="bg-white p-4 rounded-xl border border-slate-200 shadow-sm">
<form method="GET" action="{{ route('qma.activity.log') }}" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-3">
<div>
<label class="block text-xs font-semibold text-slate-600 mb-1">Mulai Tanggal</label>
<input type="date" name="start_date" value="{{ request('start_date') }}" class="w-full text-xs rounded-lg border-slate-300 border px-3 py-2">
</div>
<div>
<label class="block text-xs font-semibold text-slate-600 mb-1">Sampai Tanggal</label>
<input type="date" name="end_date" value="{{ request('end_date') }}" class="w-full text-xs rounded-lg border-slate-300 border px-3 py-2">
</div>
<div>
<label class="block text-xs font-semibold text-slate-600 mb-1">Pos Gerbang</label>
<select name="gate_id" class="w-full text-xs rounded-lg border-slate-300 border px-3 py-2">
<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>
<div>
<label class="block text-xs font-semibold text-slate-600 mb-1">Arah Akses</label>
<select name="direction" class="w-full text-xs rounded-lg border-slate-300 border px-3 py-2">
<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>
<div class="flex items-end space-x-2">
<button type="submit" class="flex-1 bg-slate-800 hover:bg-slate-900 text-white text-xs font-bold py-2 px-3 rounded-lg transition">
<i class="fa-solid fa-filter mr-1"></i> Filter
</button>
<a href="{{ route('qma.activity.log') }}" class="bg-slate-100 hover:bg-slate-200 text-slate-600 text-xs font-semibold py-2 px-3 rounded-lg border border-slate-300 transition">
Reset
</a>
</div>
</form>
</div>
<!-- Tabel 10 Kolom Log Aktivitas QMA -->
<div class="bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-slate-200 text-xs text-left">
<thead class="bg-slate-800 text-white font-semibold uppercase tracking-wider">
<tr>
<th class="py-3 px-3 text-center">1. Tanggal</th>
<th class="py-3 px-3 text-center">2. Kode LV</th>
<th class="py-3 px-3">3. Unit</th>
<th class="py-3 px-3">4. Penanggung Jawab</th>
<th class="py-3 px-3">5. Driver</th>
<th class="py-3 px-3 text-center">6. Gate</th>
<th class="py-3 px-3 text-center">7. Akses</th>
<th class="py-3 px-3 text-right">8. KM Sebelumnya</th>
<th class="py-3 px-3 text-right">9. KM Berjalan</th>
<th class="py-3 px-3">10. Aktifitas</th>
<th class="py-3 px-3 text-center">Status PG</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-200 text-slate-700 bg-white">
@forelse($activities as $act)
<tr class="hover:bg-slate-50 transition">
<td class="py-3 px-3 text-center font-medium text-slate-600 whitespace-nowrap">
{{ $act->recorded_at->format('d/m/Y H:i') }}
</td>
<td class="py-3 px-3 text-center font-bold text-slate-900 whitespace-nowrap">
<span class="bg-slate-100 px-2 py-0.5 rounded border border-slate-300 font-mono">
{{ $act->vehicle->code }}
</span>
</td>
<td class="py-3 px-3 font-medium text-slate-800">
<div>{{ $act->vehicle->brand_type }}</div>
<span class="text-[10px] text-amber-700 font-mono">{{ $act->vehicle->license_plate ?? '-' }}</span>
</td>
<td class="py-3 px-3 text-slate-600">
{{ $act->vehicle->ownership ?? '-' }}
</td>
<td class="py-3 px-3 font-semibold text-slate-900">
{{ $act->driver->name }}
<div class="text-[10px] text-slate-400 font-normal">{{ $act->driver->division ?? '-' }}</div>
</td>
<td class="py-3 px-3 text-center whitespace-nowrap">
<span class="inline-flex items-center px-2 py-0.5 rounded text-[11px] font-medium bg-slate-100 text-slate-700 border border-slate-200">
{{ $act->gate->name }}
</span>
</td>
<td class="py-3 px-3 text-center whitespace-nowrap">
@if($act->direction === 'in')
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-100 text-emerald-800 border border-emerald-200">
<i class="fa-solid fa-arrow-right-to-bracket mr-1"></i> MASUK
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold bg-blue-100 text-blue-800 border border-blue-200">
<i class="fa-solid fa-arrow-right-from-bracket mr-1"></i> KELUAR
</span>
@endif
</td>
<td class="py-3 px-3 text-right font-mono font-medium text-slate-600 whitespace-nowrap">
{{ number_format($act->previous_km, 0, ',', '.') }} KM
</td>
<td class="py-3 px-3 text-right font-mono font-bold text-emerald-600 whitespace-nowrap">
+{{ number_format($act->distance, 0, ',', '.') }} KM
<div class="text-[10px] text-slate-400 font-normal">Akhir: {{ number_format($act->current_km, 0, ',', '.') }}</div>
</td>
<td class="py-3 px-3 text-slate-600 max-w-xs truncate" title="{{ $act->purpose }}">
{{ $act->purpose }}
</td>
<td class="py-3 px-3 text-center whitespace-nowrap">
@if($act->validation_status === 'approved')
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-semibold bg-emerald-50 text-emerald-700 border border-emerald-300" title="Divalidasi oleh: {{ $act->securityGuard->name ?? 'Satpam' }}">
<i class="fa-solid fa-circle-check mr-1"></i> Disetujui
</span>
@elseif($act->validation_status === 'rejected')
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-semibold bg-rose-50 text-rose-700 border border-rose-300" title="Alasan: {{ $act->rejection_note }}">
<i class="fa-solid fa-circle-xmark mr-1"></i> Ditolak
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-semibold bg-amber-50 text-amber-700 border border-amber-300 animate-pulse">
<i class="fa-solid fa-clock mr-1"></i> Menunggu PG
</span>
@endif
</td>
</tr>
@empty
<tr>
<td colspan="11" class="py-8 text-center text-slate-400">
<i class="fa-solid fa-inbox text-3xl mb-2 block"></i>
Belum ada catatan aktivitas kendaraan yang sesuai dengan kriteria filter.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<!-- Pagination -->
<div class="p-4 bg-slate-50 border-t border-slate-200">
{{ $activities->links() }}
</div>
</div>
</div>
@endsection
+58
View File
@@ -0,0 +1,58 @@
@extends('layouts.app')
@section('title', 'Dashboard - Admin QMA | PT Kerinci Merangin Hidro')
@section('content')
<div class="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">
<div>
<div class="flex items-center space-x-2">
<span class="inline-flex items-center px-2.5 py-0.5 rounded text-xs font-semibold bg-emerald-100 text-emerald-800">
<i class="fa-solid fa-car mr-1.5"></i> Divisi QMA (Quality Management Asset)
</span>
<span class="text-xs text-slate-400">Sistem Administrator</span>
</div>
<h2 class="text-2xl font-black text-slate-900 tracking-tight mt-1.5">
Selamat datang, {{ auth()->user()->name }}
</h2>
<p class="text-xs text-slate-500 mt-0.5">
Berikut ringkasan operasional aset kendaraan dan pencatatan log aktivitas armada PT Kerinci Merangin Hidro.
</p>
</div>
</div>
<!-- Area Konten Dashboard Sementara Dikosongkan (Placeholder Bersih - Sama seperti Admin HSE) -->
<div class="bg-white rounded-2xl border border-dashed border-slate-300 p-12 text-center shadow-sm">
<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>
</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') }}"
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">
<i class="fa-solid fa-tractor"></i>
<span>Buka Unit Support</span>
<i class="fa-solid fa-arrow-right text-[10px] ml-1"></i>
</a>
<a href="{{ route('qma.activity.log') }}"
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">
<i class="fa-solid fa-clipboard-list"></i>
<span>Buka Log Aktivitas Kendaraan</span>
<i class="fa-solid fa-arrow-right text-[10px] ml-1"></i>
</a>
</div>
</div>
</div>
@endsection
+727
View File
@@ -0,0 +1,727 @@
@extends('layouts.app')
@section('title', 'Light Vehicle - Admin QMA | PT Kerinci Merangin Hidro')
@section('content')
<div class="space-y-6">
<!-- Header Judul & Tombol Aksi -->
<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-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Light Vehicle
</h2>
<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="Kelola data master armada kendaraan ringan operasional">
<i class="fa-solid fa-info"></i>
</span>
</div>
</div>
<!-- Tombol Aksi Kanan -->
<div class="flex items-center space-x-3 w-full sm:w-auto">
<button type="button"
onclick="alert('Fitur ekspor spreadsheet Light Vehicle sedang disiapkan')"
class="border border-emerald-600/30 text-emerald-900 bg-white hover:bg-emerald-50/50 px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
<i class="fa-regular fa-file-excel text-emerald-700 text-sm"></i>
<span>Ekspor Light Vehicle</span>
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
</button>
<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>
</div>
</div>
<!-- Kotak Pencarian & Filter Status -->
<div class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3">
<form method="GET" action="{{ route('qma.vehicles.lv') }}" class="relative w-full max-w-sm sm:max-w-md">
@if(request('status'))
<input type="hidden" name="status" value="{{ request('status') }}">
@endif
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400">
<i class="fa-solid fa-magnifying-glass text-xs"></i>
</span>
<input type="text"
name="search"
value="{{ request('search') }}"
placeholder="Cari kode LV, nopol, merek, tipe, atau pemilik..."
class="w-full text-xs pl-10 pr-4 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-emerald-600 focus:ring-2 focus:ring-emerald-600/10 shadow-sm transition">
</form>
<div class="flex items-center space-x-2">
<form method="GET" action="{{ route('qma.vehicles.lv') }}">
@if(request('search'))
<input type="hidden" name="search" value="{{ request('search') }}">
@endif
<select name="status" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
<option value="">Semua Status Operasi</option>
<option value="Operation" {{ request('status') === 'Operation' ? 'selected' : '' }}>Operation (Siap Jalan)</option>
<option value="Standby" {{ request('status') === 'Standby' ? 'selected' : '' }}>Standby</option>
<option value="Breakdown" {{ request('status') === 'Breakdown' ? 'selected' : '' }}>Breakdown</option>
<option value="Maintenance" {{ request('status') === 'Maintenance' ? 'selected' : '' }}>Maintenance</option>
</select>
</form>
@if(request('search') || request('status'))
<a href="{{ route('qma.vehicles.lv') }}" class="text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-2">
<i class="fa-solid fa-rotate-left"></i>
<span>Reset Filter</span>
</a>
@endif
</div>
</div>
<!-- Tabel Data Light Vehicle (Header Navy Solid #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">
<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">KODE LV</th>
<th class="py-3.5 px-4">MEREK & TIPE</th>
<th class="py-3.5 px-4 text-center">NO. POLISI</th>
<th class="py-3.5 px-4">DIVISI</th>
<th class="py-3.5 px-4">KEPEMILIKAN</th>
<th class="py-3.5 px-4 text-right">ODOMETER</th>
<th class="py-3.5 px-4 text-center">STATUS</th>
<th class="py-3.5 px-4 text-center">AKSI</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($vehicles as $index => $v)
<tr class="hover:bg-slate-50/70 transition">
<td class="py-3.5 px-4 text-center font-medium text-slate-400">
{{ $vehicles->firstItem() + $index }}
</td>
<td class="py-3.5 px-4 font-bold text-slate-900 font-mono text-xs whitespace-nowrap">
<span class="bg-emerald-50 text-emerald-800 px-2 py-0.5 rounded border border-emerald-200">
{{ $v->code }}
</span>
</td>
<td class="py-3.5 px-4 font-bold text-slate-900">
{{ $v->brand_type }}
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($v->license_plate)
<span class="text-[11px] font-mono font-bold text-amber-800 bg-amber-50 px-2 py-0.5 rounded border border-amber-200">
{{ $v->license_plate }}
</span>
@else
<span class="text-slate-400 italic">-</span>
@endif
</td>
<td class="py-3.5 px-4 text-slate-600 font-medium">
{{ $v->division ?? '-' }}
</td>
<td class="py-3.5 px-4 text-slate-600">
{{ $v->ownership ?? '-' }}
</td>
<td class="py-3.5 px-4 text-right font-mono font-bold text-slate-800 whitespace-nowrap">
{{ number_format($v->current_km, 0, ',', '.') }}
<span class="text-[10px] text-slate-400 font-sans font-normal">KM</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($v->status === 'Operation')
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
<i class="fa-solid fa-circle-check mr-1 text-[9px]"></i> Operation
</span>
@elseif($v->status === 'Standby')
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-amber-50 text-amber-700 border border-amber-200">
<i class="fa-solid fa-pause mr-1 text-[9px]"></i> Standby
</span>
@elseif($v->status === 'Breakdown')
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-rose-50 text-rose-700 border border-rose-200">
<i class="fa-solid fa-triangle-exclamation mr-1 text-[9px]"></i> Breakdown
</span>
@else
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-medium bg-slate-100 text-slate-600">
{{ $v->status }}
</span>
@endif
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<div class="flex items-center justify-center space-x-1.5">
<button onclick='openDetailModal(@json($v))'
class="inline-flex items-center space-x-1 text-slate-600 hover:text-slate-900 hover:bg-slate-100 px-2 py-1 rounded-lg transition"
title="Lihat Detail Kendaraan">
<i class="fa-regular fa-eye text-sm"></i>
</button>
<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>
<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>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="9" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-car text-3xl mb-2 block text-slate-300"></i>
Belum ada armada Light Vehicle yang sesuai dengan kriteria pencarian.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="p-4 bg-slate-50 border-t border-slate-200">
{{ $vehicles->links() }}
</div>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: TAMBAH LIGHT VEHICLE -->
<!-- ========================================================================= -->
<div id="addVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
<div class="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-8 border border-slate-100">
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Tambah Aset -->
<div class="flex items-center justify-between mb-5">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Tambah Light Vehicle
</h3>
<button type="button" onclick="closeAddModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form id="addVehicleForm" action="{{ route('qma.vehicles.store') }}" method="POST" class="space-y-4">
@csrf
<input type="hidden" name="category" value="light_vehicle">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode LV <span class="text-rose-500">*</span></label>
<input type="text"
name="code"
id="addCodeInput"
required
value="{{ old('code') }}"
placeholder="MISAL: LV01, LV62"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border {{ $errors->has('code') ? 'border-rose-500 ring-2 ring-rose-500/10' : 'border-slate-200' }} bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono uppercase">
<p id="codeHint" class="text-[11px] text-slate-400 mt-1 {{ $errors->has('code') ? 'hidden' : '' }}">* Kode LV tidak boleh sama dengan kode aset yang lain.</p>
<p id="codeError" class="text-xs text-rose-600 font-semibold mt-1.5 {{ $errors->has('code') ? '' : 'hidden' }} flex items-center">
<i class="fa-solid fa-circle-exclamation mr-1.5 flex-shrink-0"></i>
<span id="codeErrorText">{{ $errors->first('code') ?? 'Kode LV sudah ada, silakan gunakan kode lain.' }}</span>
</p>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor Polisi (Nopol)</label>
<input type="text" name="license_plate" value="{{ old('license_plate') }}" placeholder="Misal: BH 1024 AB"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition uppercase font-mono">
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Merek & Tipe Kendaraan <span class="text-rose-500">*</span></label>
<input type="text" name="brand_type" required placeholder="Misal: Toyota Hilux 4x4 Double Cabin"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi Operasional</label>
<input type="text" name="division" placeholder="Misal: HSE, Civil, Bendungan, GA"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kepemilikan Aset</label>
<input type="text" name="ownership" placeholder="Misal: PT Kerinci Merangin Hidro"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Status Operasi <span class="text-rose-500">*</span></label>
<select name="status" required class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="Operation">Operation (Siap Jalan)</option>
<option value="Standby">Standby</option>
<option value="Breakdown">Breakdown</option>
<option value="Maintenance">Maintenance</option>
</select>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Odometer Awal (KM) <span class="text-rose-500">*</span></label>
<input type="number" step="0.01" name="current_km" required value="0"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono">
</div>
</div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset -->
<div class="pt-4 flex items-center justify-end space-x-3">
<button type="button" onclick="closeAddModal()"
class="px-5 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-xs transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-xs transition shadow-sm">
Simpan Light Vehicle
</button>
</div>
</form>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: EDIT LIGHT VEHICLE -->
<!-- ========================================================================= -->
<div id="editVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
<div class="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-8 border border-slate-100">
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Tambah Aset -->
<div class="flex items-center justify-between mb-5">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Edit Light Vehicle
</h3>
<button type="button" onclick="closeEditModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form id="editVehicleForm" action="" method="POST" class="space-y-4">
@csrf
<input type="hidden" name="category" value="light_vehicle">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode LV <span class="text-rose-500">*</span></label>
<input type="text" name="code" id="editCode" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono uppercase">
<p id="editCodeError" class="text-xs text-rose-600 font-semibold mt-1.5 hidden flex items-center">
<i class="fa-solid fa-circle-exclamation mr-1.5 flex-shrink-0"></i>
<span id="editCodeErrorText">Kode LV sudah ada, silakan gunakan kode lain.</span>
</p>
<p id="editCodeHint" class="text-[11px] text-slate-400 mt-1">* Kode LV tidak boleh sama dengan kendaraan lain.</p>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor Polisi (Nopol)</label>
<input type="text" name="license_plate" id="editLicensePlate"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition uppercase font-mono">
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Merek & Tipe Kendaraan <span class="text-rose-500">*</span></label>
<input type="text" name="brand_type" id="editBrandType" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi Operasional</label>
<input type="text" name="division" id="editDivision"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kepemilikan Aset</label>
<input type="text" name="ownership" id="editOwnership"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Status Operasi <span class="text-rose-500">*</span></label>
<select name="status" id="editStatus" required class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="Operation">Operation (Siap Jalan)</option>
<option value="Standby">Standby</option>
<option value="Breakdown">Breakdown</option>
<option value="Maintenance">Maintenance</option>
</select>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Odometer Saat Ini (KM) <span class="text-rose-500">*</span></label>
<input type="number" step="0.01" name="current_km" id="editCurrentKm" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono">
</div>
</div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset -->
<div class="pt-4 flex items-center justify-end space-x-3">
<button type="button" onclick="closeEditModal()"
class="px-5 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-xs transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-xs transition shadow-sm">
Perbarui Data
</button>
</div>
</form>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: DETAIL LIGHT VEHICLE -->
<!-- ========================================================================= -->
<div id="detailVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
<div class="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-8 border border-slate-100">
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Card Tambah Data -->
<div class="flex items-center justify-between mb-5">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Detail Light Vehicle
</h3>
<button type="button" onclick="closeDetailModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<div class="space-y-4">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode LV</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono font-bold flex items-center">
<span id="detailCode" class="bg-blue-50 text-blue-800 px-2 py-0.5 rounded border border-blue-200">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor Polisi (Nopol)</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono font-bold flex items-center uppercase">
<span id="detailNopol">-</span>
</div>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Merek & Tipe Kendaraan</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-bold flex items-center">
<span id="detailBrand">-</span>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi Operasional</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium flex items-center">
<span id="detailDivision">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kepemilikan Aset</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium flex items-center">
<span id="detailOwnership">-</span>
</div>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Status Operasi</label>
<div class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white flex items-center">
<span id="detailStatusBadge" class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
<span id="detailStatus">Operation</span>
</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Odometer Saat Ini</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-emerald-700 font-mono font-bold flex items-center">
<span id="detailKm">0 KM</span>
</div>
</div>
</div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset -->
<div class="pt-4 flex items-center justify-end">
<button type="button" onclick="closeDetailModal()"
class="px-6 py-2.5 rounded-xl bg-slate-800 hover:bg-slate-900 text-white font-bold text-xs transition shadow-sm">
Tutup
</button>
</div>
</div>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: KONFIRMASI HAPUS KENDARAAN (LIGHT VEHICLE) -->
<!-- ========================================================================= -->
<div id="deleteVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
<div class="bg-white rounded-3xl shadow-2xl max-w-sm sm:max-w-md w-full p-6 sm:p-7 border border-slate-100 transform transition-all text-center">
<!-- Icon Peringatan Elegan -->
<div class="w-14 h-14 rounded-2xl bg-rose-50 border border-rose-100 text-rose-600 flex items-center justify-center mx-auto mb-4 text-2xl shadow-sm">
<i class="fa-solid fa-triangle-exclamation"></i>
</div>
<h3 class="text-lg font-bold text-slate-900 tracking-tight">
Konfirmasi Hapus Kendaraan
</h3>
<p class="text-xs text-slate-600 mt-2 leading-relaxed">
Apakah Anda yakin ingin menghapus data kendaraan <span id="deleteVehicleCode" class="font-bold font-mono text-slate-900 bg-slate-100 px-2 py-0.5 rounded border border-slate-200"></span>?
</p>
<p class="text-[11px] text-rose-600 mt-3 bg-rose-50/70 border border-rose-100 py-1.5 px-3 rounded-xl inline-flex items-center">
<i class="fa-solid fa-circle-info mr-1.5 flex-shrink-0 text-xs"></i>
<span>Data yang dihapus tidak dapat dipulihkan kembali.</span>
</p>
<!-- Tombol Aksi -->
<div class="flex items-center space-x-3 mt-6">
<button type="button" onclick="closeDeleteModal()"
class="flex-1 py-2.5 px-4 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-xs transition">
Batal
</button>
<form id="deleteVehicleForm" action="" method="POST" class="flex-1">
@csrf
@method('DELETE')
<button type="submit"
class="w-full py-2.5 px-4 rounded-xl bg-rose-600 hover:bg-rose-700 text-white font-bold text-xs transition shadow-sm flex items-center justify-center space-x-1.5">
<i class="fa-regular fa-trash-can text-xs"></i>
<span>Ya, Hapus Data</span>
</button>
</form>
</div>
</div>
</div>
<script>
// Daftar semua kode kendaraan LV yang sudah terdaftar di sistem
const existingVehicleCodes = @json($existingCodes ?? \App\Models\Vehicle::lightVehicles()->pluck('code')->map(fn($c) => strtoupper(trim($c))));
const addCodeInput = document.getElementById('addCodeInput');
const codeError = document.getElementById('codeError');
const codeErrorText = document.getElementById('codeErrorText');
const codeHint = document.getElementById('codeHint');
const addVehicleForm = document.getElementById('addVehicleForm');
function checkDuplicateCode() {
if (!addCodeInput) return false;
const val = addCodeInput.value.trim().toUpperCase();
if (!val) {
hideCodeError();
return false;
}
if (existingVehicleCodes.includes(val)) {
showCodeError('Kode LV sudah ada, silakan gunakan kode lain.');
return true;
} else {
hideCodeError();
return false;
}
}
function showCodeError(message) {
if (codeErrorText) codeErrorText.innerText = message;
if (codeError) codeError.classList.remove('hidden');
if (codeHint) codeHint.classList.add('hidden');
if (addCodeInput) {
addCodeInput.classList.add('border-rose-500', 'ring-2', 'ring-rose-500/10');
addCodeInput.classList.remove('border-slate-200');
}
}
function hideCodeError() {
if (codeError) codeError.classList.add('hidden');
if (codeHint) codeHint.classList.remove('hidden');
if (addCodeInput) {
addCodeInput.classList.remove('border-rose-500', 'ring-2', 'ring-rose-500/10');
addCodeInput.classList.add('border-slate-200');
}
}
if (addCodeInput) {
addCodeInput.addEventListener('input', function() {
if (codeError && !codeError.classList.contains('hidden')) {
checkDuplicateCode();
}
});
addCodeInput.addEventListener('blur', function() {
checkDuplicateCode();
});
}
if (addVehicleForm) {
addVehicleForm.addEventListener('submit', function(e) {
if (checkDuplicateCode()) {
e.preventDefault();
addCodeInput.focus();
return false;
}
});
}
// Elemen modal Edit
const editCodeInput = document.getElementById('editCode');
const editCodeError = document.getElementById('editCodeError');
const editCodeErrorText = document.getElementById('editCodeErrorText');
const editCodeHint = document.getElementById('editCodeHint');
const editVehicleForm = document.getElementById('editVehicleForm');
let currentEditVehicleCode = '';
function checkEditDuplicateCode() {
if (!editCodeInput) return false;
const val = editCodeInput.value.trim().toUpperCase();
if (!val) {
hideEditCodeError();
return false;
}
// Jika kode sama dengan kode kendaraan ini saat ini, maka bukan duplikat
if (val === currentEditVehicleCode) {
hideEditCodeError();
return false;
}
if (existingVehicleCodes.includes(val)) {
showEditCodeError('Kode LV sudah ada, silakan gunakan kode lain.');
return true;
} else {
hideEditCodeError();
return false;
}
}
function showEditCodeError(message) {
if (editCodeErrorText) editCodeErrorText.innerText = message;
if (editCodeError) editCodeError.classList.remove('hidden');
if (editCodeHint) editCodeHint.classList.add('hidden');
if (editCodeInput) {
editCodeInput.classList.add('border-rose-500', 'ring-2', 'ring-rose-500/10');
editCodeInput.classList.remove('border-slate-200');
}
}
function hideEditCodeError() {
if (editCodeError) editCodeError.classList.add('hidden');
if (editCodeHint) editCodeHint.classList.remove('hidden');
if (editCodeInput) {
editCodeInput.classList.remove('border-rose-500', 'ring-2', 'ring-rose-500/10');
editCodeInput.classList.add('border-slate-200');
}
}
if (editCodeInput) {
editCodeInput.addEventListener('input', function() {
if (editCodeError && !editCodeError.classList.contains('hidden')) {
checkEditDuplicateCode();
}
});
editCodeInput.addEventListener('blur', function() {
checkEditDuplicateCode();
});
}
if (editVehicleForm) {
editVehicleForm.addEventListener('submit', function(e) {
if (checkEditDuplicateCode()) {
e.preventDefault();
editCodeInput.focus();
return false;
}
});
}
function openAddModal() {
document.getElementById('addVehicleModal').classList.remove('hidden');
if (addCodeInput) addCodeInput.focus();
}
function closeAddModal() {
document.getElementById('addVehicleModal').classList.add('hidden');
hideCodeError();
}
function openEditModal(v) {
document.getElementById('editVehicleModal').classList.remove('hidden');
document.getElementById('editVehicleForm').action = `/qma/vehicles/${v.id}`;
document.getElementById('editCode').value = v.code || '';
currentEditVehicleCode = (v.code || '').trim().toUpperCase();
hideEditCodeError();
document.getElementById('editBrandType').value = v.brand_type || '';
document.getElementById('editLicensePlate').value = v.license_plate || '';
document.getElementById('editDivision').value = v.division || '';
document.getElementById('editOwnership').value = v.ownership || '';
document.getElementById('editStatus').value = v.status || 'Operation';
document.getElementById('editCurrentKm').value = v.current_km || 0;
}
function closeEditModal() {
document.getElementById('editVehicleModal').classList.add('hidden');
hideEditCodeError();
}
function openDetailModal(v) {
document.getElementById('detailVehicleModal').classList.remove('hidden');
document.getElementById('detailCode').innerText = v.code || '-';
document.getElementById('detailBrand').innerText = v.brand_type || '-';
document.getElementById('detailNopol').innerText = v.license_plate || '-';
document.getElementById('detailStatus').innerText = v.status || '-';
document.getElementById('detailKm').innerText = Number(v.current_km || 0).toLocaleString('id-ID') + ' KM';
document.getElementById('detailDivision').innerText = v.division || '-';
document.getElementById('detailOwnership').innerText = v.ownership || '-';
const badge = document.getElementById('detailStatusBadge');
if (badge) {
badge.className = 'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold border ';
if (v.status === 'Operation') {
badge.className += 'bg-emerald-50 text-emerald-700 border-emerald-200';
} else if (v.status === 'Standby') {
badge.className += 'bg-amber-50 text-amber-700 border-amber-200';
} else if (v.status === 'Breakdown') {
badge.className += 'bg-rose-50 text-rose-700 border-rose-200';
} else {
badge.className += 'bg-slate-100 text-slate-700 border-slate-200';
}
}
}
function closeDetailModal() {
document.getElementById('detailVehicleModal').classList.add('hidden');
}
function openDeleteModal(id, code, brand) {
document.getElementById('deleteVehicleForm').action = `/qma/vehicles/${id}`;
document.getElementById('deleteVehicleCode').innerText = code + (brand ? ` (${brand})` : '');
document.getElementById('deleteVehicleModal').classList.remove('hidden');
}
function closeDeleteModal() {
document.getElementById('deleteVehicleModal').classList.add('hidden');
}
@if($errors->any())
document.addEventListener('DOMContentLoaded', function() {
openAddModal();
});
@endif
</script>
<style>
/* Hilangkan scrollbar default pada modal */
.no-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
.no-scrollbar::-webkit-scrollbar {
display: none; /* Chrome, Safari, Opera */
width: 0px;
height: 0px;
}
</style>
@endsection
@@ -0,0 +1,953 @@
@extends('layouts.app')
@section('title', 'Unit Support - Admin QMA | PT Kerinci Merangin Hidro')
@section('content')
<div class="space-y-6">
<!-- Header Judul & Tombol Aksi -->
<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-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Unit Support
</h2>
<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="Kelola data armada alat berat, spesifikasi teknis, dan perizinan SILO/KIR">
<i class="fa-solid fa-info"></i>
</span>
</div>
</div>
<!-- Tombol Aksi Kanan -->
<div class="flex items-center space-x-3 w-full sm:w-auto">
<button type="button"
onclick="alert('Fitur ekspor spreadsheet Unit Support sedang disiapkan')"
class="border border-emerald-600/30 text-emerald-900 bg-white hover:bg-emerald-50/50 px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
<i class="fa-regular fa-file-excel text-emerald-700 text-sm"></i>
<span>Ekspor Unit Support</span>
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
</button>
<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>
</div>
</div>
<!-- Kotak Pencarian & Filter Kategori Alat Berat -->
<div class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3">
<form method="GET" action="{{ route('qma.vehicles.support') }}" class="relative w-full max-w-sm sm:max-w-md">
@if(request('status'))
<input type="hidden" name="status" value="{{ request('status') }}">
@endif
@if(request('unit_category'))
<input type="hidden" name="unit_category" value="{{ request('unit_category') }}">
@endif
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400">
<i class="fa-solid fa-magnifying-glass text-xs"></i>
</span>
<input type="text"
name="search"
value="{{ request('search') }}"
placeholder="Cari kode unit, model, tipe, lokasi, dokumen..."
class="w-full text-xs pl-10 pr-4 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-emerald-600 focus:ring-2 focus:ring-emerald-600/10 shadow-sm transition">
</form>
<div class="flex flex-wrap items-center gap-2">
<!-- Filter Kategori Alat Berat -->
<form method="GET" action="{{ route('qma.vehicles.support') }}" class="flex items-center space-x-2">
@if(request('search'))
<input type="hidden" name="search" value="{{ request('search') }}">
@endif
@if(request('status'))
<input type="hidden" name="status" value="{{ request('status') }}">
@endif
<select name="unit_category" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
<option value="">Semua Kategori Alat</option>
@foreach($availableCategories as $cat)
<option value="{{ $cat }}" {{ request('unit_category') === $cat ? 'selected' : '' }}>{{ $cat }}</option>
@endforeach
</select>
</form>
<!-- Filter Status Operasional -->
<form method="GET" action="{{ route('qma.vehicles.support') }}" class="flex items-center space-x-2">
@if(request('search'))
<input type="hidden" name="search" value="{{ request('search') }}">
@endif
@if(request('unit_category'))
<input type="hidden" name="unit_category" value="{{ request('unit_category') }}">
@endif
<select name="status" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
<option value="">Semua Status Operasi</option>
<option value="Operation" {{ request('status') === 'Operation' ? 'selected' : '' }}>Operation (Siap Kerja)</option>
<option value="Standby" {{ request('status') === 'Standby' ? 'selected' : '' }}>Standby</option>
<option value="Breakdown" {{ request('status') === 'Breakdown' ? 'selected' : '' }}>Breakdown</option>
<option value="Maintenance" {{ request('status') === 'Maintenance' ? 'selected' : '' }}>Maintenance</option>
</select>
</form>
@if(request('search') || request('status') || request('unit_category'))
<a href="{{ route('qma.vehicles.support') }}" class="text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-1">
<i class="fa-solid fa-rotate-left"></i>
<span>Reset</span>
</a>
@endif
</div>
</div>
<!-- Tabel Data Unit Support (Header Navy Solid #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">
<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">KODE UNIT</th>
<th class="py-3.5 px-4">KATEGORI & MODEL</th>
<th class="py-3.5 px-4">MEREK & SPESIFIKASI</th>
<th class="py-3.5 px-4">LOKASI KERJA</th>
<th class="py-3.5 px-4 text-right">ODOMETER (HM/KM)</th>
<th class="py-3.5 px-4 text-center">DOKUMEN IZIN</th>
<th class="py-3.5 px-4 text-center">STATUS</th>
<th class="py-3.5 px-4 text-center">AKSI</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($vehicles as $index => $v)
<tr class="hover:bg-slate-50/70 transition">
<td class="py-3.5 px-4 text-center font-medium text-slate-400">
{{ $vehicles->firstItem() + $index }}
</td>
<td class="py-3.5 px-4 font-bold text-slate-900 font-mono text-xs whitespace-nowrap">
<span class="bg-blue-50 text-blue-800 px-2 py-0.5 rounded border border-blue-200">
{{ $v->code }}
</span>
</td>
<td class="py-3.5 px-4 whitespace-nowrap">
<span class="font-bold text-slate-900 block">{{ $v->unit_category ?? 'Alat Berat' }}</span>
<span class="text-[10px] text-slate-500 font-mono">{{ $v->model_number ? "Model: {$v->model_number}" : '-' }}</span>
</td>
<td class="py-3.5 px-4">
<div class="font-bold text-slate-900">{{ $v->brand_type }}</div>
<div class="flex items-center space-x-2 mt-0.5 text-[10px] text-slate-500">
@if($v->unit_type)
<span>{{ $v->unit_type }}</span>
@endif
@if($v->production_year)
<span>&bull; Thn {{ $v->production_year }}</span>
@endif
</div>
</td>
<td class="py-3.5 px-4 text-slate-600">
<div class="font-medium text-slate-800">
@if($v->location)
<i class="fa-solid fa-location-dot text-[9px] mr-1 text-rose-500"></i>{{ $v->location }}
@else
-
@endif
</div>
<span class="text-[10px] text-slate-400 block">{{ $v->division ?? '-' }}</span>
</td>
<td class="py-3.5 px-4 text-right font-mono font-bold text-slate-800 whitespace-nowrap">
{{ number_format($v->current_km, 0, ',', '.') }}
<span class="text-[10px] text-slate-400 font-sans font-normal">HM/KM</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<div class="flex flex-col items-center space-y-1">
@if($v->silo_document)
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-semibold bg-emerald-50 text-emerald-800 border border-emerald-200" title="SILO: {{ $v->silo_document }}">
<i class="fa-solid fa-certificate mr-1 text-[9px] text-emerald-600"></i> SILO Ada
</span>
@else
<span class="text-[10px] text-slate-400 italic">Tanpa SILO</span>
@endif
@if($v->kir_document)
<span class="inline-flex items-center px-1.5 py-0.2 rounded text-[9px] font-mono bg-slate-100 text-slate-600 border border-slate-200">
KIR: {{ $v->kir_document }}
</span>
@endif
</div>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($v->status === 'Operation')
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
<i class="fa-solid fa-circle-check mr-1 text-[9px]"></i> Operation
</span>
@elseif($v->status === 'Standby')
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-amber-50 text-amber-700 border border-amber-200">
<i class="fa-solid fa-pause mr-1 text-[9px]"></i> Standby
</span>
@elseif($v->status === 'Breakdown')
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-rose-50 text-rose-700 border border-rose-200">
<i class="fa-solid fa-screwdriver-wrench mr-1 text-[9px]"></i> Breakdown
</span>
@else
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-medium bg-slate-100 text-slate-600">
{{ $v->status }}
</span>
@endif
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<div class="flex items-center justify-center space-x-1.5">
<button onclick='openDetailModal(@json($v))'
class="inline-flex items-center space-x-1 text-slate-600 hover:text-slate-900 hover:bg-slate-100 px-2 py-1 rounded-lg transition"
title="Lihat Detail & Perizinan">
<i class="fa-regular fa-eye text-sm"></i>
</button>
<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>
<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>
</button>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="9" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-tractor text-3xl mb-2 block text-slate-300"></i>
Belum ada unit alat berat yang sesuai dengan filter.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="p-4 bg-slate-50 border-t border-slate-200">
{{ $vehicles->links() }}
</div>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: TAMBAH UNIT SUPPORT (KENDARAAN BERAT) -->
<!-- ========================================================================= -->
<div id="addVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
<div class="bg-white rounded-3xl shadow-2xl max-w-2xl w-full p-6 sm:p-7 border border-slate-100 max-h-[92vh] overflow-y-auto no-scrollbar">
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Tambah Aset -->
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Tambah Unit Support
</h3>
<button type="button" onclick="closeAddModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form id="addVehicleForm" action="{{ route('qma.vehicles.store') }}" method="POST" class="space-y-3">
@csrf
<input type="hidden" name="category" value="unit_support">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Kode Unit <span class="text-rose-500">*</span></label>
<input type="text" name="code" id="addCodeInput" required placeholder="MISAL: EX01, CR01, DT05" value="{{ old('code') }}"
class="w-full text-xs px-3.5 py-2 rounded-xl border @error('code') border-rose-500 @else border-slate-200 @enderror bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono uppercase">
<p id="codeError" class="text-xs text-rose-600 font-semibold mt-1 flex items-center space-x-1.5 @if(!$errors->has('code')) hidden @endif">
<i class="fa-solid fa-circle-exclamation text-rose-500 text-xs"></i>
<span id="codeErrorText">{{ $errors->first('code') ?? 'Kode unit sudah ada, silakan gunakan kode lain.' }}</span>
</p>
<p id="codeHint" class="text-[11px] text-slate-400 mt-0.5 @if($errors->has('code')) hidden @endif">
* Kode unit unik dan tidak boleh sama dengan kode aset yang lain.
</p>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Kategori Alat Berat <span class="text-rose-500">*</span></label>
<input type="text" name="unit_category" required placeholder="Contoh: Excavator / Mobile Crane / Dump Truck"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Merek & Tipe Lengkap <span class="text-rose-500">*</span></label>
<input type="text" name="brand_type" required placeholder="Contoh: KOMATSU PC200-8 / KATO SR-250R"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Tipe / Model Khusus</label>
<input type="text" name="unit_type" placeholder="Contoh: Hydraulic Excavator / Rough Terrain"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Nomor Model</label>
<input type="text" name="model_number" placeholder="Contoh: PC200-8M0"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Tahun Produksi</label>
<input type="number" name="production_year" placeholder="Contoh: 2021"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Nopol (Jika ada)</label>
<input type="text" name="license_plate" placeholder="Contoh: BH 8412 AA"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition uppercase font-mono">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Lokasi Kerja Lapangan</label>
<input type="text" name="location" placeholder="Contoh: Beringin Tunggal / CCR DAM / Tunnel"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Divisi Penanggung Jawab</label>
<input type="text" name="division" placeholder="Contoh: Civil & Inviro / Mechanical"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Kepemilikan Aset</label>
<input type="text" name="ownership" placeholder="Contoh: PT Kerinci Merangin Hidro"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Status Operasi <span class="text-rose-500">*</span></label>
<select name="status" required class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="Operation">Operation (Siap Kerja)</option>
<option value="Standby">Standby</option>
<option value="Breakdown">Breakdown</option>
<option value="Maintenance">Maintenance</option>
</select>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Odometer Awal (HM/KM) <span class="text-rose-500">*</span></label>
<input type="number" step="0.01" name="current_km" required value="0"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono">
</div>
</div>
<!-- Bagian Perizinan & Dokumen -->
<div class="p-3.5 rounded-2xl bg-slate-50 border border-slate-200 space-y-2.5">
<div class="flex items-center space-x-2 text-slate-800 font-bold text-xs">
<i class="fa-solid fa-file-contract text-emerald-600"></i>
<span>Dokumen Legalitas & Perizinan Kelayakan</span>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2.5">
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Nomor SILO (Surat Izin Layak Operasi)</label>
<input type="text" name="silo_document" placeholder="Contoh: SILO-KMH-2024/091"
class="w-full text-xs px-3 py-1.5 rounded-xl border border-slate-200 bg-white">
</div>
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Nomor Dokumen KIR</label>
<input type="text" name="kir_document" placeholder="Contoh: KIR-2026/08"
class="w-full text-xs px-3 py-1.5 rounded-xl border border-slate-200 bg-white">
</div>
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Nomor STNK</label>
<input type="text" name="stnk_document" placeholder="Contoh: STNK-BH-EX01"
class="w-full text-xs px-3 py-1.5 rounded-xl border border-slate-200 bg-white">
</div>
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Konsumsi BBM (Liter/Jam)</label>
<input type="number" step="0.01" name="fuel_consumption" placeholder="Contoh: 18.5"
class="w-full text-xs px-3 py-1.5 rounded-xl border border-slate-200 bg-white">
</div>
</div>
</div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset -->
<div class="pt-3 flex items-center justify-end space-x-3">
<button type="button" onclick="closeAddModal()"
class="px-5 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-xs transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-xs transition shadow-sm">
Simpan Unit Support
</button>
</div>
</form>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: EDIT UNIT SUPPORT -->
<!-- ========================================================================= -->
<div id="editVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
<div class="bg-white rounded-3xl shadow-2xl max-w-2xl w-full p-6 sm:p-7 border border-slate-100 max-h-[92vh] overflow-y-auto no-scrollbar">
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Tambah Aset -->
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Edit Unit Support
</h3>
<button type="button" onclick="closeEditModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form id="editVehicleForm" action="" method="POST" class="space-y-4">
@csrf
<input type="hidden" name="category" value="unit_support">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode Unit <span class="text-rose-500">*</span></label>
<input type="text" name="code" id="editCode" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono uppercase">
<p id="editCodeError" class="text-xs text-rose-600 font-semibold mt-1.5 hidden flex items-center">
<i class="fa-solid fa-circle-exclamation mr-1.5 flex-shrink-0"></i>
<span id="editCodeErrorText">Kode unit sudah ada, silakan gunakan kode lain.</span>
</p>
<p id="editCodeHint" class="text-[11px] text-slate-400 mt-1">* Kode unit unik dan tidak boleh sama dengan kode aset yang lain.</p>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kategori Alat Berat <span class="text-rose-500">*</span></label>
<input type="text" name="unit_category" id="editUnitCategory" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Merek & Tipe Lengkap <span class="text-rose-500">*</span></label>
<input type="text" name="brand_type" id="editBrandType" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Tipe / Model Khusus</label>
<input type="text" name="unit_type" id="editUnitType"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor Model</label>
<input type="text" name="model_number" id="editModelNumber"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Tahun Produksi</label>
<input type="number" name="production_year" id="editProductionYear"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nopol (Jika ada)</label>
<input type="text" name="license_plate" id="editLicensePlate"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition uppercase font-mono">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Lokasi Kerja</label>
<input type="text" name="location" id="editLocation"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi</label>
<input type="text" name="division" id="editDivision"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kepemilikan</label>
<input type="text" name="ownership" id="editOwnership"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Status Operasi <span class="text-rose-500">*</span></label>
<select name="status" id="editStatus" required class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="Operation">Operation (Siap Kerja)</option>
<option value="Standby">Standby</option>
<option value="Breakdown">Breakdown</option>
<option value="Maintenance">Maintenance</option>
</select>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Odometer HM/KM <span class="text-rose-500">*</span></label>
<input type="number" step="0.01" name="current_km" id="editCurrentKm" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono">
</div>
</div>
<!-- Bagian Perizinan di Edit -->
<div class="p-4 rounded-2xl bg-slate-50 border border-slate-200 space-y-3">
<div class="flex items-center space-x-2 text-slate-800 font-bold text-xs">
<i class="fa-solid fa-file-contract text-emerald-600"></i>
<span>Dokumen Legalitas & Perizinan</span>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Nomor Dokumen SILO</label>
<input type="text" name="silo_document" id="editSiloDocument"
class="w-full text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white">
</div>
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Nomor Dokumen KIR</label>
<input type="text" name="kir_document" id="editKirDocument"
class="w-full text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white">
</div>
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Nomor STNK</label>
<input type="text" name="stnk_document" id="editStnkDocument"
class="w-full text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white">
</div>
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Konsumsi BBM (L/Jam)</label>
<input type="number" step="0.01" name="fuel_consumption" id="editFuelConsumption"
class="w-full text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white">
</div>
</div>
</div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset -->
<div class="pt-4 flex items-center justify-end space-x-3">
<button type="button" onclick="closeEditModal()"
class="px-5 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-xs transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-xs transition shadow-sm">
Perbarui Data
</button>
</div>
</form>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: DETAIL UNIT SUPPORT -->
<!-- ========================================================================= -->
<div id="detailVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
<div class="bg-white rounded-3xl shadow-2xl max-w-2xl w-full p-6 sm:p-7 border border-slate-100 max-h-[92vh] overflow-y-auto no-scrollbar">
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Card Tambah Data -->
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Detail Unit Support
</h3>
<button type="button" onclick="closeDetailModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<div class="space-y-4">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode Unit</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono font-bold flex items-center">
<span id="detailCode" class="bg-blue-50 text-blue-800 px-2 py-0.5 rounded border border-blue-200">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kategori & Model</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-bold flex items-center">
<span id="detailCategoryModel">-</span>
</div>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Merek & Tipe Lengkap</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-bold flex items-center">
<span id="detailBrand">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor Polisi (Nopol)</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono font-bold flex items-center uppercase">
<span id="detailNopol">-</span>
</div>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Tahun Produksi</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium flex items-center">
<span id="detailYear">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Lokasi Kerja</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium flex items-center">
<span id="detailLocation">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Konsumsi BBM</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium flex items-center">
<span id="detailFuel">-</span>
</div>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi & Kepemilikan</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium flex items-center">
<span id="detailOwnerDiv">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Status Operasi</label>
<div class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white flex items-center">
<span id="detailStatusBadge" class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
<span id="detailStatus">Operation</span>
</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Odometer Saat Ini</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-blue-700 font-mono font-bold flex items-center">
<span id="detailKm">0 HM/KM</span>
</div>
</div>
</div>
<!-- Bagian Legalitas & Perizinan -->
<div class="p-4 rounded-2xl bg-slate-50 border border-slate-200 space-y-3">
<div class="flex items-center space-x-2 text-slate-800 font-bold text-xs">
<i class="fa-solid fa-file-contract text-emerald-600"></i>
<span>Dokumen Legalitas & Perizinan Kelayakan</span>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
<div>
<span class="text-[11px] font-bold text-slate-700 block mb-1">Nomor Dokumen SILO</span>
<div class="text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white font-mono font-semibold text-slate-800">
<span id="detailSilo">-</span>
</div>
</div>
<div>
<span class="text-[11px] font-bold text-slate-700 block mb-1">Nomor Dokumen KIR</span>
<div class="text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white font-mono font-semibold text-slate-800">
<span id="detailKir">-</span>
</div>
</div>
<div>
<span class="text-[11px] font-bold text-slate-700 block mb-1">Nomor STNK</span>
<div class="text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white font-mono font-semibold text-slate-800">
<span id="detailStnk">-</span>
</div>
</div>
</div>
</div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset -->
<div class="pt-4 flex items-center justify-end">
<button type="button" onclick="closeDetailModal()"
class="px-6 py-2.5 rounded-xl bg-slate-800 hover:bg-slate-900 text-white font-bold text-xs transition shadow-sm">
Tutup
</button>
</div>
</div>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: KONFIRMASI HAPUS UNIT SUPPORT (KENDARAAN BERAT) -->
<!-- ========================================================================= -->
<div id="deleteVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
<div class="bg-white rounded-3xl shadow-2xl max-w-sm sm:max-w-md w-full p-6 sm:p-7 border border-slate-100 transform transition-all text-center">
<!-- Icon Peringatan Elegan -->
<div class="w-14 h-14 rounded-2xl bg-rose-50 border border-rose-100 text-rose-600 flex items-center justify-center mx-auto mb-4 text-2xl shadow-sm">
<i class="fa-solid fa-triangle-exclamation"></i>
</div>
<h3 class="text-lg font-bold text-slate-900 tracking-tight">
Konfirmasi Hapus Unit Support
</h3>
<p class="text-xs text-slate-600 mt-2 leading-relaxed">
Apakah Anda yakin ingin menghapus data unit support <span id="deleteVehicleCode" class="font-bold font-mono text-slate-900 bg-slate-100 px-2 py-0.5 rounded border border-slate-200"></span>?
</p>
<p class="text-[11px] text-rose-600 mt-3 bg-rose-50/70 border border-rose-100 py-1.5 px-3 rounded-xl inline-flex items-center">
<i class="fa-solid fa-circle-info mr-1.5 flex-shrink-0 text-xs"></i>
<span>Data yang dihapus tidak dapat dipulihkan kembali.</span>
</p>
<!-- Tombol Aksi -->
<div class="flex items-center space-x-3 mt-6">
<button type="button" onclick="closeDeleteModal()"
class="flex-1 py-2.5 px-4 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-xs transition">
Batal
</button>
<form id="deleteVehicleForm" action="" method="POST" class="flex-1">
@csrf
@method('DELETE')
<button type="submit"
class="w-full py-2.5 px-4 rounded-xl bg-rose-600 hover:bg-rose-700 text-white font-bold text-xs transition shadow-sm flex items-center justify-center space-x-1.5">
<i class="fa-regular fa-trash-can text-xs"></i>
<span>Ya, Hapus Data</span>
</button>
</form>
</div>
</div>
</div>
<script>
// Daftar semua kode kendaraan unit support yang sudah terdaftar di sistem
const existingVehicleCodes = @json($existingCodes ?? \App\Models\Vehicle::unitSupports()->pluck('code')->map(fn($c) => strtoupper(trim($c))));
const addCodeInput = document.getElementById('addCodeInput');
const codeError = document.getElementById('codeError');
const codeErrorText = document.getElementById('codeErrorText');
const codeHint = document.getElementById('codeHint');
const addVehicleForm = document.getElementById('addVehicleForm');
function checkDuplicateCode() {
if (!addCodeInput) return false;
const val = addCodeInput.value.trim().toUpperCase();
if (!val) {
hideCodeError();
return false;
}
if (existingVehicleCodes.includes(val)) {
showCodeError('Kode unit sudah ada, silakan gunakan kode lain.');
return true;
} else {
hideCodeError();
return false;
}
}
function showCodeError(message) {
if (codeErrorText) codeErrorText.innerText = message;
if (codeError) codeError.classList.remove('hidden');
if (codeHint) codeHint.classList.add('hidden');
if (addCodeInput) {
addCodeInput.classList.add('border-rose-500', 'ring-2', 'ring-rose-500/10');
addCodeInput.classList.remove('border-slate-200');
}
}
function hideCodeError() {
if (codeError) codeError.classList.add('hidden');
if (codeHint) codeHint.classList.remove('hidden');
if (addCodeInput) {
addCodeInput.classList.remove('border-rose-500', 'ring-2', 'ring-rose-500/10');
addCodeInput.classList.add('border-slate-200');
}
}
if (addCodeInput) {
addCodeInput.addEventListener('input', function() {
if (codeError && !codeError.classList.contains('hidden')) {
checkDuplicateCode();
}
});
addCodeInput.addEventListener('blur', function() {
checkDuplicateCode();
});
}
if (addVehicleForm) {
addVehicleForm.addEventListener('submit', function(e) {
if (checkDuplicateCode()) {
e.preventDefault();
addCodeInput.focus();
return false;
}
});
}
// Elemen modal Edit Unit Support
const editCodeInput = document.getElementById('editCode');
const editCodeError = document.getElementById('editCodeError');
const editCodeErrorText = document.getElementById('editCodeErrorText');
const editCodeHint = document.getElementById('editCodeHint');
const editVehicleForm = document.getElementById('editVehicleForm');
let currentEditVehicleCode = '';
function checkEditDuplicateCode() {
if (!editCodeInput) return false;
const val = editCodeInput.value.trim().toUpperCase();
if (!val) {
hideEditCodeError();
return false;
}
// Jika kode sama dengan kode kendaraan yang sedang diedit, bukan duplikat
if (val === currentEditVehicleCode) {
hideEditCodeError();
return false;
}
if (existingVehicleCodes.includes(val)) {
showEditCodeError('Kode unit sudah ada, silakan gunakan kode lain.');
return true;
} else {
hideEditCodeError();
return false;
}
}
function showEditCodeError(message) {
if (editCodeErrorText) editCodeErrorText.innerText = message;
if (editCodeError) editCodeError.classList.remove('hidden');
if (editCodeHint) editCodeHint.classList.add('hidden');
if (editCodeInput) {
editCodeInput.classList.add('border-rose-500', 'ring-2', 'ring-rose-500/10');
editCodeInput.classList.remove('border-slate-200');
}
}
function hideEditCodeError() {
if (editCodeError) editCodeError.classList.add('hidden');
if (editCodeHint) editCodeHint.classList.remove('hidden');
if (editCodeInput) {
editCodeInput.classList.remove('border-rose-500', 'ring-2', 'ring-rose-500/10');
editCodeInput.classList.add('border-slate-200');
}
}
if (editCodeInput) {
editCodeInput.addEventListener('input', function() {
if (editCodeError && !editCodeError.classList.contains('hidden')) {
checkEditDuplicateCode();
}
});
editCodeInput.addEventListener('blur', function() {
checkEditDuplicateCode();
});
}
if (editVehicleForm) {
editVehicleForm.addEventListener('submit', function(e) {
if (checkEditDuplicateCode()) {
e.preventDefault();
editCodeInput.focus();
return false;
}
});
}
function openAddModal() {
document.getElementById('addVehicleModal').classList.remove('hidden');
if (addCodeInput) addCodeInput.focus();
}
function closeAddModal() {
document.getElementById('addVehicleModal').classList.add('hidden');
hideCodeError();
}
function openEditModal(v) {
document.getElementById('editVehicleModal').classList.remove('hidden');
document.getElementById('editVehicleForm').action = `/qma/vehicles/${v.id}`;
document.getElementById('editCode').value = v.code || '';
currentEditVehicleCode = (v.code || '').trim().toUpperCase();
hideEditCodeError();
document.getElementById('editUnitCategory').value = v.unit_category || '';
document.getElementById('editBrandType').value = v.brand_type || '';
document.getElementById('editUnitType').value = v.unit_type || '';
document.getElementById('editModelNumber').value = v.model_number || '';
document.getElementById('editProductionYear').value = v.production_year || '';
document.getElementById('editLicensePlate').value = v.license_plate || '';
document.getElementById('editLocation').value = v.location || '';
document.getElementById('editDivision').value = v.division || '';
document.getElementById('editOwnership').value = v.ownership || '';
document.getElementById('editStatus').value = v.status || 'Operation';
document.getElementById('editCurrentKm').value = v.current_km || 0;
document.getElementById('editSiloDocument').value = v.silo_document || '';
document.getElementById('editKirDocument').value = v.kir_document || '';
document.getElementById('editStnkDocument').value = v.stnk_document || '';
document.getElementById('editFuelConsumption').value = v.fuel_consumption || '';
}
function closeEditModal() {
document.getElementById('editVehicleModal').classList.add('hidden');
hideEditCodeError();
}
function openDetailModal(v) {
document.getElementById('detailVehicleModal').classList.remove('hidden');
document.getElementById('detailCode').innerText = v.code || '-';
document.getElementById('detailBrand').innerText = v.brand_type || '-';
document.getElementById('detailCategoryModel').innerText = (v.unit_category || '-') + (v.model_number ? ` (${v.model_number})` : '');
document.getElementById('detailStatus').innerText = v.status || '-';
document.getElementById('detailLocation').innerText = v.location || '-';
document.getElementById('detailKm').innerText = Number(v.current_km || 0).toLocaleString('id-ID') + ' HM/KM';
document.getElementById('detailYear').innerText = v.production_year || '-';
document.getElementById('detailFuel').innerText = v.fuel_consumption ? `${v.fuel_consumption} L/Jam` : '-';
document.getElementById('detailOwnerDiv').innerText = (v.division || '-') + ' / ' + (v.ownership || '-');
document.getElementById('detailSilo').innerText = v.silo_document || '-';
document.getElementById('detailKir').innerText = v.kir_document || '-';
document.getElementById('detailStnk').innerText = v.stnk_document || '-';
document.getElementById('detailNopol').innerText = v.license_plate || '-';
const badge = document.getElementById('detailStatusBadge');
if (badge) {
badge.className = 'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold border ';
if (v.status === 'Operation') {
badge.className += 'bg-emerald-50 text-emerald-700 border-emerald-200';
} else if (v.status === 'Standby') {
badge.className += 'bg-amber-50 text-amber-700 border-amber-200';
} else if (v.status === 'Breakdown') {
badge.className += 'bg-rose-50 text-rose-700 border-rose-200';
} else {
badge.className += 'bg-slate-100 text-slate-700 border-slate-200';
}
}
}
function closeDetailModal() {
document.getElementById('detailVehicleModal').classList.add('hidden');
}
function openDeleteModal(id, code, brand) {
document.getElementById('deleteVehicleForm').action = `/qma/vehicles/${id}`;
document.getElementById('deleteVehicleCode').innerText = code + (brand ? ` (${brand})` : '');
document.getElementById('deleteVehicleModal').classList.remove('hidden');
}
function closeDeleteModal() {
document.getElementById('deleteVehicleModal').classList.add('hidden');
}
@if($errors->any())
document.addEventListener('DOMContentLoaded', function() {
openAddModal();
});
@endif
</script>
<style>
/* Hilangkan scrollbar default pada modal tapi tetap bisa di-scroll secara halus */
.no-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
.no-scrollbar::-webkit-scrollbar {
display: none; /* Chrome, Safari, Opera */
width: 0px;
height: 0px;
}
</style>
@endsection
File diff suppressed because one or more lines are too long