feat: setup Docker production stack, Vite asset compilation, and resolve audit findings (P1/P2)

This commit is contained in:
Wahyudin
2026-10-15 13:53:52 +07:00
parent 9c00515a73
commit 38c70f9413
65 changed files with 13315 additions and 933 deletions
+76 -43
View File
@@ -1,6 +1,6 @@
@extends('layouts.app')
@section('title', 'Log Aktivitas Kendaraan QMA')
@section('title', 'Timesheet LV QMA')
@section('content')
<div class="w-full space-y-6">
@@ -15,12 +15,12 @@
<button type="button"
onclick="openGuideModal()"
class="w-3.5 h-3.5 rounded-full bg-slate-200/90 hover:bg-slate-300 text-slate-500 hover:text-slate-800 text-[8px] inline-flex items-center justify-center font-bold transition shadow-2xs cursor-pointer focus:outline-none"
title="Panduan Halaman Log Aktivitas Kendaraan">
title="Panduan Halaman Timesheet LV">
<i class="fa-solid fa-info"></i>
</button>
</div>
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight">
Log Aktivitas Kendaraan
Timesheet LV
</h2>
</div>
@@ -286,46 +286,48 @@
</td>
</tr>
@empty
<tr>
<tr id="serverActivityEmptyRow">
<td colspan="11" class="py-12 px-4 text-center">
<div class="flex flex-col items-center justify-center space-y-3">
<div class="w-14 h-14 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 text-2xl">
<i class="fa-solid fa-route"></i>
<i class="fa-solid fa-magnifying-glass"></i>
</div>
<div class="text-sm font-bold text-slate-700">Belum Ada Data Log Aktivitas</div>
<p class="text-xs text-slate-400 max-w-sm">
Tidak ditemukan catatan aktivitas kendaraan yang sesuai dengan kriteria filter saat ini.
</p>
@if(request()->anyFilled(['search', 'start_date', 'end_date', 'gate_id', 'direction', 'status']))
<a href="{{ route('qma.activity.log') }}" class="mt-2 inline-flex items-center space-x-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold text-[#1b5e20] bg-emerald-50 border border-emerald-200 hover:bg-emerald-100 transition">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Reset Filter</span>
</a>
@if(request('search'))
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<a href="{{ route('qma.activity.log') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<div class="text-sm font-bold text-slate-700">Belum Ada Data Log Aktivitas</div>
<p class="text-xs text-slate-400 max-w-sm">
Tidak ditemukan catatan aktivitas kendaraan yang sesuai dengan kriteria filter saat ini.
</p>
@if(request()->anyFilled(['start_date', 'end_date', 'gate_id', 'direction', 'status']))
<a href="{{ route('qma.activity.log') }}" class="mt-2 inline-flex items-center space-x-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold text-[#1b5e20] bg-emerald-50 border border-emerald-200 hover:bg-emerald-100 transition">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Reset Filter</span>
</a>
@endif
@endif
</div>
</td>
</tr>
@endforelse
<!-- Baris Hasil Pencarian Real-Time Kosong -->
<tr id="clientSearchEmptyRow" class="hidden">
<td colspan="11" class="py-12 px-4 text-center">
<div class="flex flex-col items-center justify-center space-y-2">
<div class="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 text-xl">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
<div class="text-sm font-bold text-slate-700">Tidak Ada Hasil Pencarian</div>
<p class="text-xs text-slate-400">Tidak ditemukan log aktivitas yang sesuai dengan kata kunci pencarian Anda.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Pagination -->
@if($activities->hasPages())
<div class="p-4 bg-slate-50 border-t border-slate-100">
<div id="activityPaginationContainer" class="p-4 bg-slate-50 border-t border-slate-100">
{{ $activities->links() }}
</div>
@endif
@@ -333,16 +335,24 @@
</div>
<script>
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('activityLogSearchInput');
const tableBody = document.getElementById('activityLogTableBody');
const resetContainer = document.getElementById('headerResetFilterContainer');
const emptyRow = document.getElementById('clientSearchEmptyRow');
const paginationContainer = document.getElementById('activityPaginationContainer');
const serverEmptyRow = document.getElementById('serverActivityEmptyRow');
const hasServerFilters = {{ request()->anyFilled(['start_date', 'end_date', 'gate_id', 'direction', 'status']) ? 'true' : 'false' }};
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const query = e.target.value.toLowerCase().trim();
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.activity-row');
let visibleCount = 0;
@@ -356,16 +366,42 @@ document.addEventListener('DOMContentLoaded', function () {
}
});
// Tampilkan pesan kosong jika tidak ada baris yang cocok secara instan
if (emptyRow) {
if (rows.length > 0 && visibleCount === 0) {
emptyRow.classList.remove('hidden');
} else {
emptyRow.classList.add('hidden');
}
if (paginationContainer) {
paginationContainer.style.display = query.length > 0 ? 'none' : '';
}
const existingEmptyRow = document.getElementById('clientSearchEmptyRow');
if (existingEmptyRow) existingEmptyRow.remove();
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'clientSearchEmptyRow';
emptyTr.innerHTML = `
<td colspan="11" class="py-12 px-4 text-center">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('activityLogSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
// Tampilkan atau sembunyikan tombol Reset Filter secara real-time
if (resetContainer) {
let resetBtn = document.getElementById('headerResetFilterBtn');
if (query.length > 0 || hasServerFilters) {
@@ -374,7 +410,6 @@ document.addEventListener('DOMContentLoaded', function () {
resetBtn.href = "{{ route('qma.activity.log') }}";
resetBtn.id = 'headerResetFilterBtn';
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center space-x-1 transition';
const resetIcon = document.createElement('i');
resetIcon.className = 'fa-solid fa-rotate-left text-[11px]';
const resetText = document.createElement('span');
@@ -384,10 +419,8 @@ document.addEventListener('DOMContentLoaded', function () {
resetBtn.appendChild(resetText);
resetContainer.appendChild(resetBtn);
}
} else {
if (resetBtn && !hasServerFilters) {
resetBtn.remove();
}
} else if (!hasServerFilters && resetBtn) {
resetBtn.remove();
}
}
});
+75 -32
View File
@@ -307,26 +307,33 @@
</td>
</tr>
@empty
<tr>
<td colspan="9" class="py-10 text-center text-slate-400">
<i class="fa-solid fa-chart-simple text-3xl mb-2 block"></i>
Belum ada data aktivitas kendaraan untuk periode yang dipilih.
<tr id="serverSummaryEmptyRow">
<td colspan="9" class="py-12 px-4 text-center">
<div class="flex flex-col items-center justify-center space-y-3">
<div class="w-12 h-12 rounded-2xl bg-rose-50 text-rose-500 flex items-center justify-center text-xl shadow-xs">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
@if(request('search'))
<h4 class="text-sm font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</h4>
<p class="text-xs text-slate-400 max-w-sm">
Pastikan kata kunci yang dicari sudah benar atau gunakan filter lainnya.
</p>
<div class="mt-4">
<a href="{{ route('qma.activity.summary') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<div class="text-sm font-bold text-slate-700">Belum Ada Data Rekapitulasi</div>
<p class="text-xs text-slate-400">Belum ada data aktivitas kendaraan untuk periode yang dipilih.</p>
@endif
</div>
</td>
</tr>
@endforelse
<!-- Baris Hasil Pencarian Real-Time Kosong -->
<tr id="clientSearchEmptyRow" class="hidden">
<td colspan="9" class="py-12 px-4 text-center">
<div class="flex flex-col items-center justify-center space-y-2">
<div class="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 text-xl">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
<div class="text-sm font-bold text-slate-700">Tidak Ada Hasil Pencarian</div>
<p class="text-xs text-slate-400">Tidak ditemukan armada yang sesuai dengan kata kunci pencarian Anda.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
@@ -517,32 +524,68 @@ document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('summarySearchInput');
const tableBody = document.getElementById('summaryTableBody');
const resetContainer = document.getElementById('headerResetFilterContainer');
const emptyRow = document.getElementById('clientSearchEmptyRow');
const serverEmptyRow = document.getElementById('serverSummaryEmptyRow');
const hasServerFilters = {{ request()->anyFilled(['start_date', 'end_date', 'type', 'gate_id']) ? 'true' : 'false' }};
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const query = e.target.value.toLowerCase().trim();
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.summary-vehicle-row');
let visibleCount = 0;
rows.forEach(row => {
const text = row.textContent.toLowerCase();
if (text.includes(query)) {
row.style.display = '';
visibleCount++;
} else {
row.style.display = 'none';
}
const match = text.includes(query);
row.style.display = match ? '' : 'none';
if (match) visibleCount++;
});
// Tampilkan pesan kosong jika tidak ada baris yang cocok secara instan
if (emptyRow) {
if (rows.length > 0 && visibleCount === 0) {
emptyRow.classList.remove('hidden');
} else {
emptyRow.classList.add('hidden');
}
// Sembunyikan pesan SSR kosong saat user mengetik
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
// Hapus baris pesan kosong pencarian client jika ada sebelumnya
const existingEmptyRow = document.getElementById('summaryClientEmptyRow');
if (existingEmptyRow) {
existingEmptyRow.remove();
}
// Tampilkan pesan jika tidak ada data yang cocok di tabel
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'summaryClientEmptyRow';
emptyTr.innerHTML = `
<td colspan="9" class="py-12 px-4 text-center">
<div class="flex flex-col items-center justify-center space-y-3">
<div class="w-12 h-12 rounded-2xl bg-rose-50 text-rose-500 flex items-center justify-center text-xl shadow-xs">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
<h4 class="text-sm font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</h4>
<p class="text-xs text-slate-400 max-w-sm">
Pastikan kata kunci yang dicari sudah benar atau gunakan filter lainnya.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('summarySearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
// Tampilkan atau sembunyikan tombol Reset Filter secara real-time
+8 -1
View File
@@ -55,7 +55,14 @@
<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>
<span>Log Timesheet LV</span>
<i class="fa-solid fa-arrow-right text-[10px] ml-1"></i>
</a>
<a href="{{ route('qma.p2h.index') }}"
class="inline-flex items-center space-x-2 bg-amber-600 hover:bg-amber-700 text-white font-bold text-xs py-3 px-5 rounded-xl shadow-md hover:shadow-lg transition">
<i class="fa-solid fa-clipboard-check"></i>
<span>Log P2H Unit Support</span>
<i class="fa-solid fa-arrow-right text-[10px] ml-1"></i>
</a>
</div>
+415
View File
@@ -0,0 +1,415 @@
@extends('layouts.app')
@section('title', 'P2H Unit Support - Admin QMA')
@section('content')
<div class="w-full space-y-6">
<!-- Header Judul & Tombol Aksi (Tanpa Card Pembungkus Sesuai Panduan Desain QMA) -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<div class="flex items-center space-x-1.5 mb-1">
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20]">
MANAJEMEN SISTEM
</span>
<!-- Tombol Info Panduan Halaman Sejajar Kicker -->
<button type="button"
onclick="openGuideModal()"
class="w-3.5 h-3.5 rounded-full bg-slate-200/90 hover:bg-slate-300 text-slate-500 hover:text-slate-800 text-[8px] inline-flex items-center justify-center font-bold transition shadow-2xs cursor-pointer focus:outline-none"
title="Panduan Halaman P2H Unit Support">
<i class="fa-solid fa-info"></i>
</button>
</div>
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight">
P2H Unit Support
</h2>
</div>
<div class="flex items-center space-x-2.5 w-full sm:w-auto">
<a href="{{ route('qma.p2h.summary') }}" class="w-full sm:w-auto inline-flex items-center justify-center space-x-2 px-4 py-2.5 rounded-xl border border-slate-200 text-xs font-bold text-slate-700 bg-white hover:bg-slate-50 shadow-sm transition group">
<i class="fa-solid fa-chart-pie text-slate-400 group-hover:text-slate-700"></i>
<span>Summary Aktivitas</span>
</a>
</div>
</div>
<!-- Kotak Pencarian & Filter Status P2H (Tanpa Card Pembungkus Sesuai Gambar Referensi) -->
<form method="GET" action="{{ route('qma.p2h.index') }}" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3">
@if(request('date'))
<input type="hidden" name="date" value="{{ request('date') }}">
@endif
<!-- Sisi Kiri: Kotak Pencarian -->
<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="p2hSearchInput"
name="search"
value="{{ request('search') }}"
placeholder="Cari No. TRX, kode unit (EX01), nama/NIK operator..."
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>
<!-- Sisi Kanan: Filter Dropdown & Reset -->
<div class="flex flex-wrap items-center gap-2">
<!-- Filter Status Approval -->
<select name="validation_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] shadow-sm">
<option value="">Semua Status Approval</option>
<option value="pending" {{ request('validation_status') === 'pending' ? 'selected' : '' }}>Menunggu Approval</option>
<option value="approved" {{ request('validation_status') === 'approved' ? 'selected' : '' }}>Disetujui (Approved)</option>
<option value="rejected" {{ request('validation_status') === 'rejected' ? 'selected' : '' }}>Ditolak (Rejected)</option>
</select>
<!-- Filter Kondisi Fisik -->
<select name="summary_condition" 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] shadow-sm">
<option value="">Semua Kondisi Fisik</option>
<option value="good" {{ request('summary_condition') === 'good' ? 'selected' : '' }}>Semua Baik (Normal)</option>
<option value="has_defect" {{ request('summary_condition') === 'has_defect' ? 'selected' : '' }}>Ada Temuan Rusak</option>
</select>
<div id="p2hResetWrapper">
@if(request('search') || request('validation_status') || request('summary_condition') || request('date'))
<a id="p2hResetBtn" href="{{ route('qma.p2h.index') }}" class="text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-1" title="Reset Semua Filter">
<i class="fa-solid fa-rotate-left"></i>
<span>Reset</span>
</a>
@endif
</div>
</div>
</form>
<!-- Tabel Data Riwayat P2H -->
<div class="bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
<div class="overflow-x-auto">
<table class="w-full text-left text-xs text-slate-600">
<thead class="bg-[#06213f] text-white font-bold text-[11px] uppercase tracking-wider">
<tr>
<th class="py-3.5 px-4 text-center w-12">No</th>
<th class="py-3.5 px-4">Waktu Inspeksi</th>
<th class="py-3.5 px-4">No. Transaksi</th>
<th class="py-3.5 px-4">Unit Support</th>
<th class="py-3.5 px-4">Operator (SIMPER)</th>
<th class="py-3.5 px-4 text-center">Shift</th>
<th class="py-3.5 px-4 text-right">HM Operasi</th>
<th class="py-3.5 px-4 text-center">Kondisi Fisik</th>
<th class="py-3.5 px-4 text-center">Status QMA</th>
<th class="py-3.5 px-4 text-center w-24">Aksi</th>
</tr>
</thead>
<tbody id="p2hTableBody" class="divide-y divide-slate-100">
@forelse($records as $rec)
<tr class="p2h-row hover:bg-slate-50/80 transition">
<td class="py-3.5 px-4 text-center text-slate-400 font-medium">
{{ ($records->currentPage() - 1) * $records->perPage() + $loop->iteration }}
</td>
<td class="py-3.5 px-4 whitespace-nowrap">
<span class="font-bold text-slate-800">{{ $rec->inspected_at->format('d/m/Y') }}</span>
<span class="text-slate-400 block text-[10px]">{{ $rec->inspected_at->format('H:i') }} WIB</span>
</td>
<td class="py-3.5 px-4 whitespace-nowrap">
<span class="font-mono font-bold text-slate-700 bg-slate-100 px-2 py-0.5 rounded text-[11px]">{{ $rec->transaction_no }}</span>
</td>
<td class="py-3.5 px-4">
<div class="font-extrabold text-slate-900 text-sm leading-tight">{{ $rec->vehicle->code }}</div>
<div class="text-[11px] text-slate-500 truncate max-w-[160px]">{{ $rec->vehicle->brand_type }}</div>
</td>
<td class="py-3.5 px-4">
<div class="font-bold text-slate-800">{{ $rec->employee->name ?? '-' }}</div>
<div class="text-[10px] text-slate-400">NIK: {{ $rec->employee->nik ?? '-' }}</div>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<span class="px-2 py-0.5 rounded-md text-[10px] font-semibold bg-slate-100 text-slate-700">
{{ Str::contains($rec->shift, '1') ? 'Shift 1' : 'Shift 2' }}
</span>
</td>
<td class="py-3.5 px-4 text-right whitespace-nowrap">
<span class="font-black text-slate-900">{{ number_format($rec->start_hm, 1, ',', '.') }}</span>
<span class="text-[10px] text-slate-400 font-bold ml-0.5">HM</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($rec->hasDefects())
<span class="inline-flex items-center px-2 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-rose-600"></i> {{ $rec->defect_count }} Item Rusak
</span>
@else
<span class="inline-flex items-center px-2 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-emerald-600"></i> Normal (Baik)
</span>
@endif
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($rec->isPending())
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-[10px] font-bold bg-amber-50 text-amber-800 border border-amber-200">
<span class="w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse mr-1.5"></span>
Menunggu Review
</span>
@elseif($rec->isApproved())
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-[10px] font-bold bg-emerald-50 text-emerald-800 border border-emerald-200">
<i class="fa-solid fa-check mr-1"></i> Disetujui QMA
</span>
@else
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-[10px] font-bold bg-rose-50 text-rose-800 border border-rose-200">
<i class="fa-solid fa-xmark mr-1"></i> Ditolak
</span>
@endif
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<a href="{{ route('qma.p2h.show', $rec->id) }}" class="inline-flex items-center space-x-1 px-3 py-1.5 rounded-xl text-xs font-bold text-white bg-[#1b5e20] hover:bg-[#144918] shadow-sm transition">
<i class="fa-solid fa-magnifying-glass text-[10px]"></i>
<span>Review</span>
</a>
</td>
</tr>
@empty
<tr id="serverEmptyRow">
<td colspan="10" class="py-12 text-center text-slate-400">
@if(request('search'))
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<a href="{{ route('qma.p2h.index') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<i class="fa-solid fa-clipboard-question text-3xl mb-2 text-slate-300 block"></i>
<span class="font-bold text-slate-600">Belum ada catatan riwayat P2H Unit Support</span>
<p class="text-[11px] text-slate-400 mt-0.5">Form P2H yang dikirim oleh operator alat berat akan muncul pada daftar ini.</p>
@endif
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@if($records->hasPages())
<div id="p2hPaginationContainer" class="p-4 border-t border-slate-100">
{{ $records->links() }}
</div>
@endif
</div>
</div>
<!-- ========================================================================= -->
<!-- ========================================================================= -->
<!-- JAVASCRIPT: REAL-TIME CLIENT SEARCH & MODAL -->
<!-- ========================================================================= -->
<script>
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('p2hSearchInput');
const tableBody = document.getElementById('p2hTableBody');
const resetWrapper = document.getElementById('p2hResetWrapper');
const serverEmptyRow = document.getElementById('serverEmptyRow');
const paginationContainer = document.getElementById('p2hPaginationContainer');
const hasServerFilters = {{ request()->anyFilled(['validation_status', 'summary_condition', 'date']) ? 'true' : 'false' }};
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.p2h-row');
let visibleCount = 0;
rows.forEach(row => {
const text = row.textContent.toLowerCase();
if (text.includes(query)) {
row.style.display = '';
visibleCount++;
} else {
row.style.display = 'none';
}
});
// Sembunyikan pagination saat client-side search aktif
if (paginationContainer) {
paginationContainer.style.display = query.length > 0 ? 'none' : '';
}
const existingEmptyRow = document.getElementById('clientSearchEmptyRow');
if (existingEmptyRow) existingEmptyRow.remove();
// Sembunyikan server empty row saat mengetik jika ada
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
// Tampilkan pesan kosong jika tidak ada baris yang cocok
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'clientSearchEmptyRow';
emptyTr.innerHTML = `
<td colspan="10" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('p2hSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
// Tampilkan atau sembunyikan tombol Reset Filter secara real-time
if (resetWrapper) {
let resetBtn = document.getElementById('p2hResetBtn');
if (query.length > 0 || hasServerFilters) {
if (!resetBtn) {
resetBtn = document.createElement('a');
resetBtn.id = 'p2hResetBtn';
resetBtn.href = "{{ route('qma.p2h.index') }}";
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-1';
resetBtn.title = 'Reset Semua Filter';
const resetIcon = document.createElement('i');
resetIcon.className = 'fa-solid fa-rotate-left';
const resetText = document.createElement('span');
resetText.textContent = 'Reset';
resetBtn.appendChild(resetIcon);
resetBtn.appendChild(resetText);
resetWrapper.appendChild(resetBtn);
}
} else {
if (resetBtn && !hasServerFilters) {
resetBtn.remove();
}
}
}
});
}
});
function openGuideModal() {
const modal = document.getElementById('guideModal');
if (modal) {
modal.classList.remove('hidden');
document.documentElement.classList.add('modal-open');
document.body.classList.add('modal-open');
}
}
function closeGuideModal() {
const modal = document.getElementById('guideModal');
if (modal) {
modal.classList.add('hidden');
document.documentElement.classList.remove('modal-open');
document.body.classList.remove('modal-open');
}
}
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeGuideModal();
}
});
</script>
<!-- ========================================================================= -->
<!-- MODAL POPUP: PANDUAN HALAMAN (LOG P2H UNIT SUPPORT) -->
<!-- ========================================================================= -->
<div id="guideModal"
onclick="if(event.target === this) closeGuideModal()"
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
<!-- Header Modal -->
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
<div class="flex items-center space-x-3">
<div class="w-9 h-9 rounded-full bg-slate-100 text-slate-700 flex items-center justify-center font-bold text-sm border border-slate-200">
<i class="fa-solid fa-info"></i>
</div>
<div>
<h3 class="text-base font-bold text-slate-900 tracking-tight leading-tight">Panduan Halaman</h3>
<p class="text-xs text-slate-500">P2H Unit Support</p>
</div>
</div>
<button type="button"
onclick="closeGuideModal()"
class="text-slate-400 hover:text-slate-600 transition p-1.5 rounded-lg hover:bg-slate-100 cursor-pointer">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<div class="mt-4 space-y-4">
<p class="text-xs text-slate-600 leading-relaxed">
Halaman <strong>P2H Unit Support</strong> digunakan untuk memantau, memeriksa, dan memvalidasi riwayat pemeriksaan kelayakan operasi harian alat berat proyek yang diajukan oleh operator.
</p>
<div class="space-y-3">
<!-- Fitur 1 (Hijau) -->
<div class="bg-slate-50/70 border border-slate-100 rounded-2xl p-3.5 flex items-start space-x-3.5">
<div class="w-9 h-9 rounded-xl bg-emerald-100/70 text-emerald-700 flex items-center justify-center flex-shrink-0 mt-0.5 text-sm border border-emerald-200/50">
<i class="fa-solid fa-clipboard-check"></i>
</div>
<div class="min-w-0 flex-1">
<h4 class="text-xs font-bold text-slate-900">Review & Validasi Kelayakan</h4>
<p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed">
Buka detail setiap pengajuan P2H untuk meninjau status checklist kelayakan alat dan beri persetujuan (Approve) atau penolakan (Reject).
</p>
</div>
</div>
<!-- Fitur 2 (Amber) -->
<div class="bg-slate-50/70 border border-slate-100 rounded-2xl p-3.5 flex items-start space-x-3.5">
<div class="w-9 h-9 rounded-xl bg-amber-100/70 text-amber-700 flex items-center justify-center flex-shrink-0 mt-0.5 text-sm border border-amber-200/50">
<i class="fa-solid fa-triangle-exclamation"></i>
</div>
<div class="min-w-0 flex-1">
<h4 class="text-xs font-bold text-slate-900">Deteksi Temuan Kerusakan</h4>
<p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed">
Pantau kartu statistik 'Temuan Rusak' dan 'Menunggu QMA' untuk memprioritaskan unit yang membutuhkan perbaikan atau tindakan cepat.
</p>
</div>
</div>
<!-- Fitur 3 (Biru) -->
<div class="bg-slate-50/70 border border-slate-100 rounded-2xl p-3.5 flex items-start space-x-3.5">
<div class="w-9 h-9 rounded-xl bg-blue-100/70 text-blue-700 flex items-center justify-center flex-shrink-0 mt-0.5 text-sm border border-blue-200/50">
<i class="fa-solid fa-layer-group"></i>
</div>
<div class="min-w-0 flex-1">
<h4 class="text-xs font-bold text-slate-900">Master Checksheet P2H</h4>
<p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed">
Akses daftar 28 standarisasi template checksheet pertanyaan P2H melalui tombol 'Master 28 Template' di bagian kanan atas.
</p>
</div>
</div>
</div>
</div>
<!-- Footer Tombol -->
<div class="pt-4 mt-5 border-t border-slate-100 flex items-center justify-end">
<button type="button"
onclick="closeGuideModal()"
class="px-6 py-2.5 rounded-xl bg-slate-100 hover:bg-slate-200 text-slate-700 font-bold text-xs transition cursor-pointer shadow-2xs">
Saya Mengerti
</button>
</div>
</div>
</div>
@endsection
+217
View File
@@ -0,0 +1,217 @@
@extends('layouts.app')
@section('title', 'Review P2H Unit ' . $record->vehicle->code . ' - ' . $record->transaction_no)
@section('content')
<div class="w-full space-y-6">
<!-- Top Action Bar -->
<div class="flex items-center justify-between pb-1">
<a href="{{ route('qma.p2h.index') }}" class="inline-flex items-center space-x-1.5 text-xs font-bold text-slate-600 hover:text-[#1b5e20] transition bg-white px-3 py-1.5 rounded-xl border border-slate-200 shadow-sm">
<i class="fa-solid fa-arrow-left text-[11px]"></i>
<span>Kembali ke P2H Unit Support</span>
</a>
<!-- Badge Status Validasi -->
<div>
@if($record->isPending())
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-amber-50 text-amber-800 border border-amber-300">
<span class="w-2 h-2 rounded-full bg-amber-500 animate-pulse mr-2"></span>
Menunggu Approval QMA
</span>
@elseif($record->isApproved())
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-emerald-50 text-emerald-800 border border-emerald-300">
<i class="fa-solid fa-check mr-1.5 text-emerald-600"></i> Disetujui (Approved)
</span>
@else
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-rose-50 text-rose-800 border border-rose-300">
<i class="fa-solid fa-xmark mr-1.5 text-rose-600"></i> Ditolak (Rejected)
</span>
@endif
</div>
</div>
<!-- Header Transaksi & Metadata -->
<div class="bg-gradient-to-r from-slate-800 to-slate-900 text-white p-6 rounded-2xl shadow-sm border border-slate-700">
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 border-b border-slate-700 pb-4 mb-4">
<div>
<span class="text-xs font-semibold text-slate-400 uppercase tracking-wider block">LEMBAR PEMERIKSAAN PRA-HARIAN (P2H)</span>
<h1 class="text-2xl font-black text-white mt-0.5">{{ $record->transaction_no }}</h1>
</div>
<div class="text-left sm:text-right text-xs text-slate-300">
<span class="text-slate-400">Waktu Pemeriksaan:</span>
<span class="font-bold text-white block text-sm">{{ $record->inspected_at->format('d F Y, H:i') }} WIB</span>
</div>
</div>
<!-- 3 Kolom Info: Unit, Operator, Ringkasan HM -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 text-xs">
<!-- Kolom 1: Unit Support -->
<div class="bg-slate-800/80 p-3.5 rounded-xl border border-slate-700/80 space-y-1.5">
<span class="text-[10px] font-bold text-amber-400 uppercase tracking-wider block">UNIT SUPPORT</span>
<p class="text-base font-black text-white leading-tight">{{ $record->vehicle->code }}</p>
<p class="text-slate-300 font-medium">{{ $record->vehicle->brand_type }}</p>
<div class="pt-1 text-[11px] text-slate-400 border-t border-slate-700/60 flex items-center justify-between">
<span>Kategori:</span>
<span class="text-slate-200 font-semibold">{{ $record->vehicle->unit_category ?? ($record->template->name ?? '-') }}</span>
</div>
<div class="text-[11px] text-slate-400 flex items-center justify-between">
<span>Lokasi:</span>
<span class="text-slate-200 font-semibold">{{ $record->vehicle->location ?? '-' }}</span>
</div>
</div>
<!-- Kolom 2: Operator -->
<div class="bg-slate-800/80 p-3.5 rounded-xl border border-slate-700/80 space-y-1.5">
<span class="text-[10px] font-bold text-emerald-400 uppercase tracking-wider block">OPERATOR (HSE)</span>
<p class="text-base font-black text-white leading-tight">{{ $record->employee->name ?? '-' }}</p>
<p class="text-slate-300 font-medium">NIK: {{ $record->employee->nik ?? '-' }}</p>
<div class="pt-1 text-[11px] text-slate-400 border-t border-slate-700/60 flex items-center justify-between">
<span>Divisi:</span>
<span class="text-slate-200 font-semibold">{{ $record->employee->division ?? '-' }}</span>
</div>
<div class="text-[11px] text-slate-400 flex items-center justify-between">
<span>SIMPER:</span>
<span class="text-emerald-400 font-semibold">Aktif (s.d {{ $record->employee->simper_expired_at ? $record->employee->simper_expired_at->format('d/m/Y') : '-' }})</span>
</div>
</div>
<!-- Kolom 3: Operasional Shift & HM -->
<div class="bg-slate-800/80 p-3.5 rounded-xl border border-slate-700/80 space-y-1.5">
<span class="text-[10px] font-bold text-blue-400 uppercase tracking-wider block">OPERASIONAL SHIFT</span>
<p class="text-base font-black text-white leading-tight">{{ $record->shift }}</p>
<div class="pt-1 text-[11px] text-slate-400 border-t border-slate-700/60 flex items-center justify-between">
<span>Hour Meter (HM):</span>
<span class="text-emerald-300 font-extrabold text-sm">{{ number_format($record->start_hm, 1, ',', '.') }} HM</span>
</div>
<div class="text-[11px] text-slate-400 flex items-center justify-between">
<span>Kondisi Fisik:</span>
@if($record->hasDefects())
<span class="text-rose-400 font-bold">{{ $record->defect_count }} Item Rusak</span>
@else
<span class="text-emerald-400 font-bold">Semua Normal</span>
@endif
</div>
</div>
</div>
</div>
<!-- Catatan Umum Operator (Jika ada) -->
@if($record->general_notes)
<div class="bg-amber-50/60 border border-amber-200 rounded-2xl p-4 text-xs space-y-1 shadow-sm">
<span class="font-bold text-amber-900 block flex items-center space-x-1.5">
<i class="fa-solid fa-comment-dots text-amber-600"></i>
<span>Catatan Umum dari Operator:</span>
</span>
<p class="text-slate-700 leading-relaxed italic">"{{ $record->general_notes }}"</p>
</div>
@endif
<!-- Panel Keputusan Approval Admin QMA -->
<div class="bg-white rounded-2xl p-6 border border-slate-200 shadow-sm space-y-4">
<h3 class="font-bold text-slate-900 text-sm flex items-center space-x-2 border-b border-slate-100 pb-3">
<i class="fa-solid fa-stamp text-[#1b5e20]"></i>
<span>Verifikasi & Keputusan Approval Admin QMA</span>
</h3>
@if($record->isPending())
<!-- Form Aksi Approval / Reject -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<!-- Form Approve -->
<form action="{{ route('qma.p2h.approve', $record->id) }}" method="POST" class="bg-emerald-50/50 border border-emerald-200 p-4 rounded-xl space-y-3">
@csrf
<div>
<span class="font-bold text-emerald-900 text-xs block mb-1">Setujui Hasil Pemeriksaan</span>
<input type="text" name="validation_notes" placeholder="Catatan persetujuan (opsional)..." class="w-full text-xs px-3 py-2 rounded-xl border border-emerald-300 focus:border-emerald-600 bg-white">
</div>
<button type="submit" onclick="return confirm('Apakah Anda yakin ingin MENYETUJUI hasil P2H untuk unit ini?')" class="w-full bg-[#1b5e20] hover:bg-[#144918] text-white font-bold py-2 px-4 rounded-xl text-xs shadow-sm transition flex items-center justify-center space-x-2">
<i class="fa-solid fa-circle-check"></i>
<span>Setujui P2H (Approve)</span>
</button>
</form>
<!-- Form Reject -->
<form action="{{ route('qma.p2h.reject', $record->id) }}" method="POST" class="bg-rose-50/50 border border-rose-200 p-4 rounded-xl space-y-3">
@csrf
<div>
<span class="font-bold text-rose-900 text-xs block mb-1">Tolak Hasil Pemeriksaan <span class="text-rose-600">*</span></span>
<input type="text" name="validation_notes" required placeholder="Tuliskan alasan penolakan / instruksi perbaikan..." class="w-full text-xs px-3 py-2 rounded-xl border border-rose-300 focus:border-rose-600 bg-white">
</div>
<button type="submit" onclick="return confirm('Apakah Anda yakin ingin MENOLAK hasil P2H untuk unit ini?')" class="w-full bg-rose-600 hover:bg-rose-700 text-white font-bold py-2 px-4 rounded-xl text-xs shadow-sm transition flex items-center justify-center space-x-2">
<i class="fa-solid fa-circle-xmark"></i>
<span>Tolak P2H (Reject)</span>
</button>
</form>
</div>
@else
<!-- Info Hasil Validasi Sebelumnya -->
<div class="bg-slate-50 p-4 rounded-xl border border-slate-200 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 text-xs">
<div>
<span class="text-slate-400 block">Diverifikasi Oleh:</span>
<span class="font-bold text-slate-800 text-sm">{{ $record->validator->name ?? 'Admin QMA' }}</span>
<span class="text-slate-500 block text-[11px]">Pada {{ $record->validated_at ? $record->validated_at->format('d/m/Y H:i') . ' WIB' : '-' }}</span>
</div>
<div class="sm:text-right">
<span class="text-slate-400 block">Catatan Verifikator:</span>
<span class="font-medium text-slate-700">{{ $record->validation_notes ?? '-' }}</span>
</div>
</div>
@endif
</div>
<!-- Detail Hasil Cek Per Section (Checklist Butir Soal) -->
<div class="space-y-4">
<h3 class="font-extrabold text-slate-900 text-base px-1">Rincian Butir Pemeriksaan Pra-Harian</h3>
@foreach($groupedItems as $sectionName => $itemsInSection)
<div class="bg-white rounded-none sm:rounded-2xl shadow-sm border border-slate-200 overflow-hidden">
<div class="p-3.5 bg-slate-50 border-b border-slate-200 flex items-center justify-between">
<div class="flex items-center space-x-2">
<span class="w-2 h-2 rounded-full bg-[#1b5e20]"></span>
<h4 class="font-bold text-slate-800 text-xs uppercase tracking-wide">{{ $sectionName }}</h4>
</div>
<span class="text-[10px] font-semibold text-slate-500 bg-white border border-slate-200 px-2 py-0.5 rounded-full">
{{ count($itemsInSection) }} butir
</span>
</div>
<div class="divide-y divide-slate-100 p-2 sm:p-4 text-xs">
@foreach($itemsInSection as $item)
<div class="p-2.5 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 hover:bg-slate-50/60 rounded-xl transition">
<div class="flex items-start space-x-2 flex-1 pr-2">
<span class="font-bold text-slate-400">{{ $loop->iteration }}.</span>
<div>
<span class="font-semibold text-slate-800 leading-snug">{{ $item->title }}</span>
@if($item->notes)
<p class="text-[11px] text-rose-600 font-medium mt-0.5 flex items-center space-x-1">
<i class="fa-solid fa-circle-exclamation text-[10px]"></i>
<span>Catatan: {{ $item->notes }}</span>
</p>
@endif
</div>
</div>
<div class="flex-shrink-0">
@if(in_array($item->question_type, ['choice', 'condition', 'Multiple choice: only one answer', 'Matrix']) || !empty($item->condition_status))
@if($item->condition_status === 'rusak')
<span class="inline-flex items-center px-2.5 py-1 rounded-xl text-xs font-bold bg-rose-50 text-rose-700 border border-rose-200">
<i class="fa-solid fa-triangle-exclamation mr-1 text-rose-600"></i> Rusak
</span>
@else
<span class="inline-flex items-center px-2.5 py-1 rounded-xl text-xs font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
<i class="fa-solid fa-check mr-1 text-emerald-600"></i> Baik
</span>
@endif
@else
<span class="font-semibold text-slate-700 bg-slate-100 px-2.5 py-1 rounded-lg text-xs">
{{ $item->answer_value ?? '-' }}
</span>
@endif
</div>
</div>
@endforeach
</div>
</div>
@endforeach
</div>
</div>
@endsection
+527
View File
@@ -0,0 +1,527 @@
@extends('layouts.app')
@section('title', 'Summary P2H Unit Support - Admin QMA')
@section('content')
<div class="w-full space-y-6">
<!-- Header Halaman Summary P2H -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<div class="flex items-center space-x-1.5 mb-1">
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20]">
MANAJEMEN SISTEM
</span>
<!-- Tombol Info Panduan Halaman Sejajar Kicker -->
<button type="button"
onclick="openGuideModal()"
class="w-3.5 h-3.5 rounded-full bg-slate-200/90 hover:bg-slate-300 text-slate-500 hover:text-slate-800 text-[8px] inline-flex items-center justify-center font-bold transition shadow-2xs cursor-pointer focus:outline-none"
title="Panduan Halaman Summary P2H">
<i class="fa-solid fa-info"></i>
</button>
</div>
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight">
Summary P2H Unit Support
</h2>
</div>
<div class="grid grid-cols-2 gap-2.5 w-full sm:flex sm:items-center sm:gap-3 sm:w-auto">
<a href="{{ route('qma.p2h.index') }}" class="w-full sm:w-auto flex items-center justify-center space-x-2 px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold text-slate-700 bg-white border border-slate-200 hover:bg-slate-50 shadow-sm transition group">
<i class="fa-solid fa-clipboard-check text-slate-400 group-hover:text-slate-700"></i>
<span class="truncate">Detail P2H</span>
</a>
<a href="{{ route('qma.p2h.templates') }}" class="w-full sm:w-auto flex items-center justify-center space-x-2 px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold text-slate-700 bg-white border border-slate-200 hover:bg-slate-50 shadow-sm transition group">
<i class="fa-solid fa-layer-group text-slate-400 group-hover:text-slate-700"></i>
<span class="truncate">Master Template</span>
</a>
</div>
</div>
@php
$activeFilterCount = count(array_filter(request()->only(['search', 'start_date', 'end_date', 'vehicle_id', 'validation_status', 'shift'])));
$isFilterOpen = request()->anyFilled(['start_date', 'end_date', 'vehicle_id', 'validation_status', 'shift']);
@endphp
<!-- Form Filter & Pencarian Cepat -->
<form method="GET" action="{{ route('qma.p2h.summary') }}" class="space-y-3">
<!-- Baris Atas: Search Bar Mandiri di Luar Card Filter & Tombol Toggle -->
<div class="flex flex-col sm:flex-row items-stretch sm:items-center gap-3">
<!-- Search Bar Utama (Real-Time) -->
<div class="relative flex-1">
<div 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>
</div>
<input type="text"
name="search"
id="p2hSummarySearchInput"
value="{{ request('search') }}"
placeholder="Cari No. TRX, kode unit (EX01), model, nama operator..."
class="w-full text-xs rounded-xl border border-slate-200 bg-white hover:border-slate-300 focus:bg-white pl-9 pr-3.5 py-2.5 text-slate-800 placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition shadow-2xs">
</div>
<!-- Tombol Buka/Tutup Filter Card & Reset Filter -->
<div class="flex items-center gap-2.5 self-end sm:self-auto w-full sm:w-auto justify-between sm:justify-start">
<button type="button"
id="filterToggleBtn"
onclick="toggleFilterCard()"
class="inline-flex items-center justify-center px-4 py-2.5 rounded-xl text-xs font-bold text-slate-700 bg-white hover:bg-slate-50 border border-slate-200 shadow-2xs transition group cursor-pointer">
<i class="fa-solid fa-sliders text-slate-500 mr-2 group-hover:text-[#1b5e20] transition-colors"></i>
<span>Filter</span>
@if($activeFilterCount > 0)
<span class="ml-1.5 px-1.5 py-0.5 rounded-full text-[10px] font-extrabold bg-[#1b5e20] text-white">
{{ $activeFilterCount }}
</span>
@endif
<i id="filterChevron" class="fa-solid fa-chevron-down ml-2 text-[10px] text-slate-400 transition-transform duration-200 {{ $isFilterOpen ? 'rotate-180' : '' }}"></i>
</button>
<div id="p2hSummaryResetContainer">
@if(request()->anyFilled(['search', 'start_date', 'end_date', 'vehicle_id', 'validation_status', 'shift']))
<a href="{{ route('qma.p2h.summary') }}"
id="p2hSummaryResetBtn"
class="text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center space-x-1 transition px-3 py-2 rounded-xl hover:bg-rose-50 border border-transparent hover:border-rose-100">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Reset Filter</span>
</a>
@endif
</div>
</div>
</div>
<!-- Card Filter Lanjutan (Bisa Di Buka-Tutup / Collapsible) -->
<div id="collapsibleFilterCard" class="{{ $isFilterOpen ? '' : 'hidden ' }}bg-white rounded-2xl border border-slate-200 shadow-sm p-4 sm:p-5 transition-all">
<div class="flex items-center justify-between pb-3 border-b border-slate-100 mb-3.5">
<div class="flex items-center space-x-2">
<span class="text-slate-800 font-bold text-xs uppercase tracking-wider">
Opsi Filter Lanjutan
</span>
@if($activeFilterCount > 0)
<span class="text-[11px] text-slate-400 font-medium">({{ $activeFilterCount }} filter aktif)</span>
@endif
</div>
<button type="button"
onclick="toggleFilterCard()"
class="text-xs text-slate-400 hover:text-slate-600 transition flex items-center space-x-1 cursor-pointer">
<span>Tutup</span>
<i class="fa-solid fa-xmark text-[11px]"></i>
</button>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-3.5">
<!-- Mulai Tanggal -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Mulai Tanggal</label>
<input type="date"
name="start_date"
value="{{ request('start_date', $startDate ?? now()->startOfMonth()->format('Y-m-d')) }}"
onchange="this.form.submit()"
class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
</div>
<!-- Sampai Tanggal -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Sampai Tanggal</label>
<input type="date"
name="end_date"
value="{{ request('end_date', $endDate ?? now()->format('Y-m-d')) }}"
onchange="this.form.submit()"
class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
</div>
<!-- Unit Support -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Unit Support</label>
<select name="vehicle_id" onchange="this.form.submit()" class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
<option value="">Semua Unit Support</option>
@foreach($supportVehicles as $sv)
<option value="{{ $sv->id }}" {{ request('vehicle_id') == $sv->id ? 'selected' : '' }}>
{{ $sv->code }} - {{ $sv->brand_type }}
</option>
@endforeach
</select>
</div>
<!-- Status Validasi -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Status Validasi</label>
<select name="validation_status" onchange="this.form.submit()" class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
<option value="">Semua Status</option>
<option value="pending" {{ request('validation_status') === 'pending' ? 'selected' : '' }}>Menunggu Approval</option>
<option value="approved" {{ request('validation_status') === 'approved' ? 'selected' : '' }}>Disetujui (Approved)</option>
<option value="rejected" {{ request('validation_status') === 'rejected' ? 'selected' : '' }}>Ditolak (Rejected)</option>
</select>
</div>
<!-- Shift Kerja -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Shift Kerja</label>
<select name="shift" onchange="this.form.submit()" class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
<option value="">Semua Shift</option>
<option value="1" {{ request('shift') === '1' ? 'selected' : '' }}>Shift 1 (Pagi)</option>
<option value="2" {{ request('shift') === '2' ? 'selected' : '' }}>Shift 2 (Malam)</option>
</select>
</div>
</div>
</div>
</form>
<!-- 4 Kartu KPI Metrik Ringkasan P2H -->
<div class="grid grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-4">
<!-- 1. Total Inspeksi P2H -->
<div class="bg-white rounded-2xl p-4 sm:p-5 border border-slate-200 shadow-sm flex flex-col justify-between">
<div>
<p class="text-[11px] sm:text-xs font-bold text-slate-400 uppercase tracking-wider">Total Inspeksi P2H</p>
<h3 class="text-xl sm:text-2xl font-black text-slate-900 mt-1">{{ number_format($totalInspections, 0, ',', '.') }}</h3>
</div>
<div class="flex flex-wrap items-center gap-1 sm:space-x-2 mt-2 text-[10px] sm:text-[11px]">
<span class="text-emerald-700 font-semibold"><i class="fa-solid fa-check mr-0.5"></i> {{ $totalApproved }} Disetujui</span>
<span class="text-slate-300 hidden sm:inline">•</span>
<span class="text-amber-600 font-semibold"><i class="fa-solid fa-hourglass-half mr-0.5"></i> {{ $totalPending }} Menunggu</span>
</div>
</div>
<!-- 2. Kondisi Fisik Alat Berat -->
<div class="bg-white rounded-2xl p-4 sm:p-5 border border-slate-200 shadow-sm flex flex-col justify-between">
<div>
<p class="text-[11px] sm:text-xs font-bold text-slate-400 uppercase tracking-wider">Kondisi Alat Berat</p>
<h3 class="text-xl sm:text-2xl font-black text-emerald-700 mt-1">
{{ $totalInspections > 0 ? round(($totalNormal / $totalInspections) * 100) : 0 }}% <span class="text-xs font-sans font-bold text-slate-500">Normal</span>
</h3>
</div>
<div class="flex flex-wrap items-center gap-1 sm:space-x-2 mt-2 text-[10px] sm:text-[11px]">
<span class="text-emerald-700 font-semibold">{{ $totalNormal }} Unit Baik</span>
<span class="text-slate-300 hidden sm:inline">•</span>
<span class="text-rose-600 font-semibold">{{ $totalDefects }} Ada Temuan Rusak</span>
</div>
</div>
<!-- 3. Status Penolakan / Tindak Lanjut -->
<div class="bg-white rounded-2xl p-4 sm:p-5 border border-slate-200 shadow-sm flex flex-col justify-between">
<div>
<p class="text-[11px] sm:text-xs font-bold text-slate-400 uppercase tracking-wider">Unit Ditolak / Reject</p>
<h3 class="text-xl sm:text-2xl font-black text-rose-600 mt-1">{{ number_format($totalRejected, 0, ',', '.') }}</h3>
</div>
<div class="flex flex-wrap items-center gap-1 sm:space-x-2 mt-2 text-[10px] sm:text-[11px]">
<span class="text-rose-600 font-semibold"><i class="fa-solid fa-triangle-exclamation mr-0.5"></i> {{ $totalRejected }} Perlu Perbaikan</span>
</div>
</div>
<!-- 4. Total Akumulasi Hour Meter (HM) -->
<div class="bg-white rounded-2xl p-4 sm:p-5 border border-slate-200 shadow-sm flex flex-col justify-between">
<div>
<p class="text-[11px] sm:text-xs font-bold text-slate-400 uppercase tracking-wider">Total HM Tercatat</p>
<h3 class="text-xl sm:text-2xl font-black text-slate-900 font-mono mt-1">
{{ number_format($totalHm, 1, ',', '.') }} <span class="text-xs font-sans font-bold text-slate-500">Jam</span>
</h3>
</div>
<div class="flex flex-wrap items-center gap-1 sm:space-x-2 mt-2 text-[10px] sm:text-[11px]">
<span class="text-slate-500 font-semibold"><i class="fa-solid fa-clock mr-0.5"></i> Hour Meter Operasi</span>
</div>
</div>
</div>
<!-- Tabel Rekapitulasi per Unit Support -->
<div class="bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
<div class="px-5 py-4 border-b border-slate-100 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3">
<div>
<h3 class="text-sm font-bold text-slate-900">Rekapitulasi Pemeriksaan per Unit Support</h3>
<p class="text-xs text-slate-400 mt-0.5">Ringkasan kepatuhan dan status kelayakan inspeksi masing-masing unit alat berat.</p>
</div>
<span class="text-xs font-semibold px-2.5 py-1 rounded-full bg-slate-100 text-slate-600">
{{ $unitSummary->count() }} Unit Aktif
</span>
</div>
<div class="overflow-x-auto">
<table class="w-full text-left text-xs text-slate-600">
<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">Model & Kategori</th>
<th class="py-3.5 px-4 text-center">Total P2H</th>
<th class="py-3.5 px-4 text-center">Disetujui</th>
<th class="py-3.5 px-4 text-center">Menunggu</th>
<th class="py-3.5 px-4 text-center">Ditolak</th>
<th class="py-3.5 px-4 text-center">Temuan Rusak</th>
<th class="py-3.5 px-4 text-right">HM Terakhir</th>
<th class="py-3.5 px-4 text-center">Terakhir Diperiksa</th>
</tr>
</thead>
<tbody id="p2hSummaryTableBody" class="divide-y divide-slate-100">
@forelse($unitSummary as $idx => $us)
<tr class="p2h-summary-row hover:bg-slate-50/80 transition">
<td class="py-3.5 px-4 text-center text-slate-400 font-medium">{{ $loop->iteration }}</td>
<td class="py-3.5 px-4 whitespace-nowrap">
<span class="font-bold text-slate-900">{{ $us['vehicle']->code ?? '-' }}</span>
</td>
<td class="py-3.5 px-4">
<span class="text-slate-800 font-semibold block">{{ $us['vehicle']->brand_type ?? '-' }}</span>
<span class="text-slate-400 text-[10px]">{{ $us['vehicle']->unit_category ?? 'Alat Berat' }}</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap font-bold text-slate-900">
{{ number_format($us['total']) }}
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap font-semibold text-emerald-700">
{{ number_format($us['approved']) }}
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap font-semibold text-amber-600">
{{ number_format($us['pending']) }}
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap font-semibold {{ $us['rejected'] > 0 ? 'text-rose-600' : 'text-slate-400' }}">
{{ number_format($us['rejected']) }}
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($us['has_defect'] > 0)
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold bg-rose-50 text-rose-700 border border-rose-200">
{{ $us['has_defect'] }} Temuan
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
Normal
</span>
@endif
</td>
<td class="py-3.5 px-4 text-right font-mono font-bold text-slate-800 whitespace-nowrap">
{{ $us['latest_hm'] ? number_format($us['latest_hm'], 1, ',', '.') : '-' }}
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap text-slate-500">
{{ $us['latest_inspection'] ? \Carbon\Carbon::parse($us['latest_inspection'])->format('d/m/Y H:i') : '-' }}
</td>
</tr>
@empty
<tr id="serverP2hSummaryEmptyRow">
<td colspan="10" class="py-12 px-4 text-center">
<div class="flex flex-col items-center justify-center space-y-3">
<div class="w-12 h-12 rounded-2xl bg-rose-50 text-rose-500 flex items-center justify-center text-xl shadow-xs">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
@if(request('search'))
<h4 class="text-sm font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</h4>
<p class="text-xs text-slate-400 max-w-sm">
Pastikan kata kunci yang dicari sudah benar atau gunakan filter lainnya.
</p>
<div class="mt-4">
<a href="{{ route('qma.p2h.summary') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<div class="text-sm font-bold text-slate-700">Belum Ada Data Rekapitulasi</div>
<p class="text-xs text-slate-400">Tidak ada data rekapitulasi P2H untuk rentang tanggal yang dipilih.</p>
@endif
</div>
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
<!-- ========================================================================= -->
<!-- JAVASCRIPT MODAL PANDUAN HALAMAN -->
<!-- ========================================================================= -->
<script>
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('p2hSummarySearchInput');
const tableBody = document.getElementById('p2hSummaryTableBody');
const resetContainer = document.getElementById('p2hSummaryResetContainer');
const serverEmptyRow = document.getElementById('serverP2hSummaryEmptyRow');
const hasServerFilters = {{ request()->anyFilled(['start_date', 'end_date', 'vehicle_id', 'validation_status', 'shift']) ? 'true' : 'false' }};
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.p2h-summary-row');
let visibleCount = 0;
rows.forEach(row => {
const text = row.textContent.toLowerCase();
const match = text.includes(query);
row.style.display = match ? '' : 'none';
if (match) visibleCount++;
});
// Sembunyikan baris SSR jika user sedang mengetik
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
// Hapus baris pesan kosong pencarian client jika ada sebelumnya
const existingEmptyRow = document.getElementById('p2hSummaryClientEmptyRow');
if (existingEmptyRow) {
existingEmptyRow.remove();
}
// Tampilkan pesan jika tidak ada data yang cocok di tabel
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'p2hSummaryClientEmptyRow';
emptyTr.innerHTML = `
<td colspan="10" class="py-12 px-4 text-center">
<div class="flex flex-col items-center justify-center space-y-3">
<div class="w-12 h-12 rounded-2xl bg-rose-50 text-rose-500 flex items-center justify-center text-xl shadow-xs">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
<h4 class="text-sm font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</h4>
<p class="text-xs text-slate-400 max-w-sm">
Pastikan kata kunci yang dicari sudah benar atau gunakan filter lainnya.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('p2hSummarySearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
// Tampilkan atau sembunyikan tombol Reset Filter secara real-time
if (resetContainer) {
let resetBtn = document.getElementById('p2hSummaryResetBtn');
if (query.length > 0 || hasServerFilters) {
if (!resetBtn) {
resetBtn = document.createElement('a');
resetBtn.href = "{{ route('qma.p2h.summary') }}";
resetBtn.id = 'p2hSummaryResetBtn';
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center space-x-1 transition px-3 py-2 rounded-xl hover:bg-rose-50 border border-transparent hover:border-rose-100';
const resetIcon = document.createElement('i');
resetIcon.className = 'fa-solid fa-rotate-left text-[11px]';
const resetText = document.createElement('span');
resetText.textContent = 'Reset Filter';
resetBtn.appendChild(resetIcon);
resetBtn.appendChild(resetText);
resetContainer.appendChild(resetBtn);
}
} else {
if (resetBtn && !hasServerFilters) {
resetBtn.remove();
}
}
}
});
}
});
function toggleFilterCard() {
const card = document.getElementById('collapsibleFilterCard');
const chevron = document.getElementById('filterChevron');
if (card) {
card.classList.toggle('hidden');
}
if (chevron) {
chevron.classList.toggle('rotate-180');
}
}
function openGuideModal() {
const modal = document.getElementById('guideModal');
if (modal) {
modal.classList.remove('hidden');
document.documentElement.classList.add('modal-open');
document.body.classList.add('modal-open');
}
}
function closeGuideModal() {
const modal = document.getElementById('guideModal');
if (modal) {
modal.classList.add('hidden');
document.documentElement.classList.remove('modal-open');
document.body.classList.remove('modal-open');
}
}
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeGuideModal();
}
});
</script>
<!-- ========================================================================= -->
<!-- MODAL POPUP: PANDUAN HALAMAN (SUMMARY P2H) -->
<!-- ========================================================================= -->
<div id="guideModal"
onclick="if(event.target === this) closeGuideModal()"
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
<div class="flex items-center space-x-3">
<div class="w-9 h-9 rounded-full bg-slate-100 text-slate-700 flex items-center justify-center font-bold text-sm border border-slate-200">
<i class="fa-solid fa-info"></i>
</div>
<div>
<h3 class="text-base font-bold text-slate-900 tracking-tight leading-tight">Panduan Halaman</h3>
<p class="text-xs text-slate-500">Summary P2H Unit Support</p>
</div>
</div>
<button type="button"
onclick="closeGuideModal()"
class="text-slate-400 hover:text-slate-600 transition p-1.5 rounded-lg hover:bg-slate-100 cursor-pointer">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<div class="mt-4 space-y-4">
<p class="text-xs text-slate-600 leading-relaxed">
Halaman <strong>Summary P2H Unit Support</strong> menampilkan rekapitulasi performa dan tingkat kelaikan operasi harian alat berat.
</p>
<div class="space-y-3">
<div class="bg-slate-50/70 border border-slate-100 rounded-2xl p-3.5 flex items-start space-x-3.5">
<div class="w-9 h-9 rounded-xl bg-emerald-100/70 text-emerald-700 flex items-center justify-center flex-shrink-0 mt-0.5 text-sm border border-emerald-200/50">
<i class="fa-solid fa-chart-pie"></i>
</div>
<div class="min-w-0 flex-1">
<h4 class="text-xs font-bold text-slate-900">Rekapitulasi per Unit Support</h4>
<p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed">
Melihat total inspeksi, jumlah lolos persetujuan, unit dengan temuan kerusakan, serta catatan jam kerja (HM) setiap alat.
</p>
</div>
</div>
<div class="bg-slate-50/70 border border-slate-100 rounded-2xl p-3.5 flex items-start space-x-3.5">
<div class="w-9 h-9 rounded-xl bg-amber-100/70 text-amber-700 flex items-center justify-center flex-shrink-0 mt-0.5 text-sm border border-amber-200/50">
<i class="fa-solid fa-filter"></i>
</div>
<div class="min-w-0 flex-1">
<h4 class="text-xs font-bold text-slate-900">Filter Fleksibel</h4>
<p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed">
Pilih rentang tanggal, filter berdasarkan unit spesifik, status approval, atau shift kerja.
</p>
</div>
</div>
</div>
</div>
<div class="pt-4 mt-5 border-t border-slate-100 flex items-center justify-end">
<button type="button"
onclick="closeGuideModal()"
class="px-6 py-2.5 rounded-xl bg-slate-100 hover:bg-slate-200 text-slate-700 font-bold text-xs transition cursor-pointer shadow-2xs">
Saya Mengerti
</button>
</div>
</div>
</div>
@endsection
File diff suppressed because it is too large Load Diff
+246
View File
@@ -0,0 +1,246 @@
@extends('layouts.app')
@section('title', 'Master Template P2H - Admin QMA')
@section('content')
<div class="w-full space-y-6">
<!-- Header Judul (Tanpa Card Pembungkus Sesuai Referensi) -->
<div>
<div class="flex items-center space-x-1.5 mb-1">
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20]">
MANAJEMEN SISTEM
</span>
</div>
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight">
Master Template P2H Unit Support
</h2>
<p class="text-xs sm:text-sm text-slate-500 mt-1">
Daftar checksheet resmi pemeriksaan pra-harian untuk setiap kategori unit alat berat di proyek PLTA Merangin.
</p>
</div>
<!-- Kotak Pencarian & Reset Filter -->
<form method="GET" action="{{ route('qma.p2h.templates') }}" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3">
<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="templateSearchInput"
name="search"
value="{{ request('search') }}"
placeholder="Cari nama template alat (Excavator, Crane, Vibro) atau kode..."
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>
<div id="templateResetContainer">
@if(request('search'))
<a href="{{ route('qma.p2h.templates') }}"
id="templateResetBtn"
class="text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center space-x-1 transition px-3 py-2 rounded-xl hover:bg-rose-50 border border-transparent hover:border-rose-100">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Reset Filter</span>
</a>
@endif
</div>
</form>
<!-- Tabel Master Template P2H Unit Support (Tampilan Tabel Bukan Card) -->
<div class="bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden" id="templatesTableContainer">
<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 text-center w-32">KODE TEMPLATE</th>
<th class="py-3.5 px-4">NAMA TEMPLATE ALAT</th>
<th class="py-3.5 px-4 text-center">STATUS</th>
<th class="py-3.5 px-4 text-center">BUTIR CEK</th>
<th class="py-3.5 px-4 text-center">UNIT TERKAIT</th>
<th class="py-3.5 px-4 text-center">RIWAYAT P2H</th>
<th class="py-3.5 px-4 text-center w-52">AKSI</th>
</tr>
</thead>
<tbody id="templatesTableBody" class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($templates as $index => $tmpl)
<tr class="template-row hover:bg-slate-50/70 transition">
<td class="py-3.5 px-4 text-center font-medium text-slate-400">
{{ $index + 1 }}
</td>
<td class="py-3.5 px-4 text-center font-bold text-slate-900 font-mono text-xs whitespace-nowrap">
<span class="bg-blue-50 text-blue-800 px-2.5 py-1 rounded-lg border border-blue-200">
{{ $tmpl->code }}
</span>
</td>
<td class="py-3.5 px-4">
<div class="font-bold text-slate-900 text-sm leading-snug">{{ $tmpl->name }}</div>
<div class="text-[11px] text-slate-400 mt-0.5 line-clamp-1 max-w-lg">{{ $tmpl->description }}</div>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($tmpl->items_count > 0)
<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> Aktif
</span>
@else
<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-triangle-exclamation mr-1 text-[9px]"></i> Template Baru (Kosong)
</span>
@endif
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<span class="inline-flex items-center px-2.5 py-1 rounded-lg text-xs font-bold {{ $tmpl->items_count > 0 ? 'bg-slate-100 text-slate-800 border border-slate-200' : 'bg-slate-50 text-slate-400' }}">
{{ $tmpl->items_count }} Butir
</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<span class="font-bold text-slate-800">{{ $tmpl->vehicles_count }}</span>
<span class="text-[10px] text-slate-400">Unit</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<span class="font-bold text-slate-800">{{ $tmpl->records_count }}</span>
<span class="text-[10px] text-slate-400">Laporan</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<a href="{{ route('qma.p2h.templates.show', $tmpl->id) }}"
class="inline-flex items-center space-x-1.5 px-3 py-1.5 rounded-xl text-xs font-bold transition shadow-2xs {{ $tmpl->items_count > 0 ? 'bg-[#1b5e20] hover:bg-[#144919] text-white' : 'bg-emerald-50 hover:bg-emerald-100 text-[#1b5e20] border border-emerald-200' }}"
title="Buka & Kelola Pertanyaan Template {{ $tmpl->name }}">
<i class="fa-solid fa-list-check text-[11px]"></i>
<span>{{ $tmpl->items_count > 0 ? 'Lihat & Kelola Pertanyaan' : 'Kelola & Isi Pertanyaan' }}</span>
</a>
</td>
</tr>
@empty
<tr id="serverTemplateEmptyRow">
<td colspan="8" class="py-12 px-4 text-center text-slate-400">
<div class="w-12 h-12 rounded-2xl bg-rose-50 text-rose-500 flex items-center justify-center text-xl shadow-xs mx-auto mb-3">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
@if(request('search'))
<h4 class="text-sm font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</h4>
<p class="text-xs text-slate-400 max-w-sm mx-auto mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<a href="{{ route('qma.p2h.templates') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<div class="text-sm font-bold text-slate-700">Belum Ada Template</div>
<p class="text-xs text-slate-400 mt-1">Belum ada template checksheet P2H yang terdaftar.</p>
@endif
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('templateSearchInput');
const tableBody = document.getElementById('templatesTableBody');
const resetContainer = document.getElementById('templateResetContainer');
const serverEmptyRow = document.getElementById('serverTemplateEmptyRow');
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.template-row');
let visibleCount = 0;
rows.forEach(row => {
const text = row.textContent.toLowerCase();
const match = text.includes(query);
row.style.display = match ? '' : 'none';
if (match) visibleCount++;
});
// Sembunyikan baris SSR empty jika sedang mengetik
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
// Hapus baris empty client jika ada sebelumnya
const existingClientEmpty = document.getElementById('clientTemplateEmptyRow');
if (existingClientEmpty) {
existingClientEmpty.remove();
}
// Tampilkan pesan jika tidak ada data yang cocok
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'clientTemplateEmptyRow';
emptyTr.innerHTML = `
<td colspan="8" class="py-12 px-4 text-center text-slate-400">
<div class="w-12 h-12 rounded-2xl bg-rose-50 text-rose-500 flex items-center justify-center text-xl shadow-xs mx-auto mb-3">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
<h4 class="text-sm font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</h4>
<p class="text-xs text-slate-400 max-w-sm mx-auto mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('templateSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
// Tampilkan atau sembunyikan tombol Reset Filter secara real-time
if (resetContainer) {
let resetBtn = document.getElementById('templateResetBtn');
if (query.length > 0) {
if (!resetBtn) {
resetBtn = document.createElement('a');
resetBtn.href = "{{ route('qma.p2h.templates') }}";
resetBtn.id = 'templateResetBtn';
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center space-x-1 transition px-3 py-2 rounded-xl hover:bg-rose-50 border border-transparent hover:border-rose-100';
const resetIcon = document.createElement('i');
resetIcon.className = 'fa-solid fa-rotate-left text-[11px]';
const resetText = document.createElement('span');
resetText.textContent = 'Reset Filter';
resetBtn.appendChild(resetIcon);
resetBtn.appendChild(resetText);
resetContainer.appendChild(resetBtn);
}
} else {
if (resetBtn && !{{ request()->filled('search') ? 'true' : 'false' }}) {
resetBtn.remove();
}
}
}
});
}
});
</script>
@endsection
+129 -25
View File
@@ -26,19 +26,19 @@
</div>
<!-- Tombol Aksi Kanan -->
<div class="flex items-center space-x-3 w-full sm:w-auto">
<div class="grid grid-cols-2 gap-2.5 w-full sm:flex sm:items-center sm:gap-3 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">
class="w-full sm:w-auto flex items-center justify-center space-x-2 border border-emerald-600/30 text-emerald-900 bg-white hover:bg-emerald-50/50 px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold transition shadow-sm">
<i class="fa-regular fa-file-excel text-emerald-700 text-sm"></i>
<span>Ekspor Light Vehicle</span>
<span class="truncate">Ekspor LV</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">
class="w-full sm:w-auto flex items-center justify-center space-x-2 bg-[#1b5e20] hover:bg-[#144919] text-white px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold transition shadow-sm cursor-pointer">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Light Vehicle</span>
<span class="truncate">Tambah LV</span>
</button>
</div>
</div>
@@ -46,19 +46,17 @@
<!-- 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
<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="lvSearchInput"
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>
<div class="flex items-center space-x-2">
<form method="GET" action="{{ route('qma.vehicles.lv') }}">
@@ -74,17 +72,19 @@
</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 id="lvResetWrapper" class="flex items-center">
@if(request('search') || request('status'))
<a id="lvResetBtn" 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>
</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="bg-white rounded-none sm: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">
@@ -101,9 +101,9 @@
<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">
<tbody id="lvTableBody" class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($vehicles as $index => $v)
<tr class="hover:bg-slate-50/70 transition">
<tr class="lv-row hover:bg-slate-50/70 transition">
<td class="py-3.5 px-4 text-center font-medium text-slate-400">
{{ $vehicles->firstItem() + $index }}
</td>
@@ -119,12 +119,11 @@
<button type="button"
onclick="openQrModal('{{ $v->code }}', '{{ addslashes($v->brand_type ?? '') }}', '{{ addslashes($v->license_plate ?? '-') }}', '{{ addslashes($v->division ?? '-') }}', '{{ url('/gate-activity/' . $v->code) }}', this)"
data-qr-base64="{{ base64_encode(\SimpleSoftwareIO\QrCode\Facades\QrCode::size(240)->margin(1)->generate(url('/gate-activity/' . $v->code))) }}"
class="group inline-flex items-center space-x-1.5 px-2 py-1 rounded-xl bg-slate-50 hover:bg-emerald-50 border border-slate-200 hover:border-emerald-300 transition shadow-2xs cursor-pointer"
class="group inline-flex items-center justify-center p-1 rounded-xl bg-slate-50 hover:bg-emerald-50 border border-slate-200 hover:border-emerald-300 transition shadow-2xs cursor-pointer"
title="Klik untuk Lihat, Unduh & Cetak Stiker QR {{ $v->code }}">
<div class="w-7 h-7 bg-white rounded-lg border border-slate-200 group-hover:border-emerald-300 flex items-center justify-center p-0.5 overflow-hidden [&>svg]:w-full [&>svg]:h-full shadow-2xs">
{!! \SimpleSoftwareIO\QrCode\Facades\QrCode::size(24)->margin(0)->generate(url('/gate-activity/' . $v->code)) !!}
</div>
<i class="fa-solid fa-expand text-[10px] text-slate-400 group-hover:text-emerald-600"></i>
</button>
</td>
@@ -197,10 +196,26 @@
</td>
</tr>
@empty
<tr>
<tr id="serverLvEmptyRow">
<td colspan="10" 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.
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
@if(request('search'))
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<a href="{{ route('qma.vehicles.lv') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<p class="text-sm font-semibold text-slate-700">Belum ada armada Light Vehicle</p>
<p class="text-xs text-slate-400 mt-0.5">Belum ada data armada Light Vehicle yang sesuai dengan kriteria filter.</p>
@endif
</td>
</tr>
@endforelse
@@ -208,7 +223,7 @@
</table>
</div>
<div class="p-4 bg-slate-50 border-t border-slate-200">
<div id="lvPaginationContainer" class="p-4 bg-slate-50 border-t border-slate-200">
{{ $vehicles->links() }}
</div>
</div>
@@ -857,6 +872,95 @@
document.getElementById('deleteVehicleModal').classList.add('hidden');
}
// =========================================================================
// REAL-TIME CLIENT-SIDE SEARCH
// =========================================================================
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('lvSearchInput');
const tableBody = document.getElementById('lvTableBody');
const resetWrapper = document.getElementById('lvResetWrapper');
const paginationContainer = document.getElementById('lvPaginationContainer');
const serverEmptyRow = document.getElementById('serverLvEmptyRow');
const hasServerFilters = {{ request()->filled('status') ? 'true' : 'false' }};
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.lv-row');
let visibleCount = 0;
rows.forEach(row => {
const text = row.textContent.toLowerCase();
if (text.includes(query)) {
row.style.display = '';
visibleCount++;
} else {
row.style.display = 'none';
}
});
if (paginationContainer) {
paginationContainer.style.display = query.length > 0 ? 'none' : '';
}
const existingEmptyRow = document.getElementById('clientLvEmptyRow');
if (existingEmptyRow) existingEmptyRow.remove();
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'clientLvEmptyRow';
emptyTr.innerHTML = `
<td colspan="10" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('lvSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
if (resetWrapper) {
let resetBtn = document.getElementById('lvResetBtn');
if (query.length > 0 || hasServerFilters) {
if (!resetBtn) {
resetBtn = document.createElement('a');
resetBtn.id = 'lvResetBtn';
resetBtn.href = "{{ route('qma.vehicles.lv') }}";
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-2';
resetBtn.innerHTML = '<i class="fa-solid fa-rotate-left"></i><span>Reset Filter</span>';
resetWrapper.appendChild(resetBtn);
}
} else if (!hasServerFilters && resetBtn) {
resetBtn.remove();
}
}
});
}
});
@if($errors->any())
document.addEventListener('DOMContentLoaded', function() {
openAddModal();
+293 -379
View File
@@ -26,19 +26,19 @@
</div>
<!-- Tombol Aksi Kanan -->
<div class="flex items-center space-x-3 w-full sm:w-auto">
<div class="grid grid-cols-2 gap-2.5 w-full sm:flex sm:items-center sm:gap-3 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">
class="w-full sm:w-auto flex items-center justify-center space-x-2 border border-emerald-600/30 text-emerald-900 bg-white hover:bg-emerald-50/50 px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold transition shadow-sm">
<i class="fa-regular fa-file-excel text-emerald-700 text-sm"></i>
<span>Ekspor Unit Support</span>
<span class="truncate">Ekspor Data</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">
class="w-full sm:w-auto flex items-center justify-center space-x-2 bg-[#1b5e20] hover:bg-[#144919] text-white px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold transition shadow-sm cursor-pointer">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Unit Support</span>
<span class="truncate">Tambah Kategori</span>
</button>
</div>
</div>
@@ -46,22 +46,17 @@
<!-- 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
<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="supportSearchInput"
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>
<div class="flex flex-wrap items-center gap-2">
<!-- Filter Kategori Alat Berat -->
@@ -69,9 +64,6 @@
@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)
@@ -80,159 +72,121 @@
</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') }}">
<div id="supportResetWrapper" class="flex items-center">
@if(request('search') || request('unit_category'))
<a id="supportResetBtn" 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
@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>
</div>
<!-- Tabel Data Unit Support (Header Navy Solid #06213f) -->
<div class="bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
<!-- Tabel Data Kategori Unit Support (Header Navy Solid #06213f) -->
<div class="bg-white rounded-none sm: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">KODE KATEGORI</th>
<th class="py-3.5 px-4">KATEGORI ALAT</th>
<th class="py-3.5 px-4 text-center">JUMLAH (QTY)</th>
<th class="py-3.5 px-4">MEREK & MODEL</th>
<th class="py-3.5 px-4">SPESIFIKASI</th>
<th class="py-3.5 px-4">DIVISI & KEPEMILIKAN</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">
<tbody id="supportTableBody" class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($vehicles as $index => $v)
<tr class="hover:bg-slate-50/70 transition">
<tr class="support-row 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">
<span class="bg-blue-50 text-blue-800 px-2.5 py-1 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>
<span class="font-bold text-slate-900 block text-xs">{{ $v->unit_category ?? 'Alat Berat' }}</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<a href="{{ route('qma.vehicles.support.units', $v->id) }}"
class="inline-flex items-center space-x-1.5 px-3.5 py-1.5 rounded-full text-xs font-bold bg-[#e8f8f0] text-[#00897b] border border-[#a7f3d0] hover:bg-[#d1fae5] transition shadow-2xs group cursor-pointer"
title="Buka daftar {{ $v->units_count ?? 0 }} unit fisik">
<span>{{ $v->units_count ?? 0 }} Unit</span>
<i class="fa-solid fa-chevron-right text-[10px] ml-1 transition group-hover:translate-x-0.5"></i>
</a>
</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>
@if($v->model_number)
<div class="text-[10px] text-slate-500 font-mono mt-0.5">Model: {{ $v->model_number }}</div>
@endif
</td>
<td class="py-3.5 px-4 text-slate-700">
@if($v->unit_type)
<span class="font-medium text-xs">{{ $v->unit_type }}</span>
@else
<span class="text-slate-300">-</span>
@endif
</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
<div class="font-medium text-slate-800">{{ $v->division ?? '-' }}</div>
<span class="text-[10px] text-slate-400 block">{{ $v->ownership ?? 'PT Kerinci Merangin Hidro' }}</span>
</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">
title="Lihat Spesifikasi Kategori">
<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">
title="Edit Data Kategori">
<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">
title="Hapus Kategori">
<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.
<tr id="serverSupportEmptyRow">
<td colspan="8" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
@if(request('search'))
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<a href="{{ route('qma.vehicles.support') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<p class="text-sm font-semibold text-slate-700">Belum ada unit alat berat</p>
<p class="text-xs text-slate-400 mt-0.5">Belum ada unit alat berat yang sesuai dengan filter.</p>
@endif
</td>
</tr>
@endforelse
@@ -240,7 +194,7 @@
</table>
</div>
<div class="p-4 bg-slate-50 border-t border-slate-200">
<div id="supportPaginationContainer" class="p-4 bg-slate-50 border-t border-slate-200">
{{ $vehicles->links() }}
</div>
</div>
@@ -252,39 +206,41 @@
<div id="addVehicleModal"
onclick="if(event.target === this) closeAddModal()"
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="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-7 border border-slate-100 max-h-[92vh] overflow-y-auto no-scrollbar">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Tambah Unit Support
</h3>
<div>
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Tambah Kategori Unit Support
</h3>
<p class="text-xs text-slate-500 mt-0.5">Mendaftarkan kategori/tipe master aset baru ke sistem.</p>
</div>
<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">
<form id="addVehicleForm" action="{{ route('qma.vehicles.store') }}" method="POST" class="space-y-3.5">
@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">
<label class="block text-xs font-bold text-slate-800 mb-1">Kode Kategori <span class="text-rose-500">*</span></label>
<input type="text" name="code" id="addCodeInput" required placeholder="MISAL: EX01, CR01, BL01" value="{{ old('code') }}"
class="w-full text-xs px-3.5 py-2.5 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 font-bold">
<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.
* Digunakan sebagai dasar kode unit fisik (contoh: BL01-001).
</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">
<input type="text" name="unit_category" required placeholder="Contoh: Excavator / Mobile Crane / Boomlift"
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 font-medium">
</div>
</div>
@@ -292,99 +248,47 @@
<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">
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">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">
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-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">
<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.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 font-mono">
</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">
<label class="block text-xs font-bold text-slate-800 mb-1">Estimasi 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.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 font-mono">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
<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">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>
<label class="block text-xs font-bold text-slate-800 mb-1">Divisi Penanggung Jawab</label>
<select name="division"
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-medium">
<option value="">-- Pilih Divisi Penanggung Jawab --</option>
@foreach($availableDivisions as $div)
<option value="{{ $div }}" {{ old('division') === $div ? 'selected' : '' }}>{{ $div }}</option>
@endforeach
</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">
<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.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>
<!-- 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 -->
<!-- Footer Tombol -->
<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">
@@ -392,7 +296,7 @@
</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
Simpan Kategori
</button>
</div>
</form>
@@ -400,42 +304,44 @@
</div>
<!-- ========================================================================= -->
<!-- MODAL: EDIT UNIT SUPPORT -->
<!-- MODAL: EDIT KATEGORI UNIT SUPPORT -->
<!-- ========================================================================= -->
<div id="editVehicleModal"
onclick="if(event.target === this) closeEditModal()"
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="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-7 border border-slate-100 max-h-[92vh] overflow-y-auto no-scrollbar">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Edit Unit Support
</h3>
<div>
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Edit Kategori Unit Support
</h3>
<p class="text-xs text-slate-500 mt-0.5">Memperbarui informasi master kategori aset.</p>
</div>
<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">
<form id="editVehicleForm" action="" method="POST" class="space-y-3.5">
@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>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode Kategori <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">
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 font-bold">
<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>
<p id="editCodeHint" class="text-[11px] text-slate-400 mt-1">* Jika diubah, kode seluruh unit fisik di bawahnya akan otomatis menyesuaikan.</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">
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-medium">
</div>
</div>
@@ -452,90 +358,38 @@
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5">
<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">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">
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>
<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">
<label class="block text-xs font-bold text-slate-800 mb-1.5">Konsumsi BBM Standar (L/Jam)</label>
<input type="number" step="0.01" name="fuel_consumption" id="editFuelConsumption"
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>
<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">
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi Penanggung Jawab</label>
<select 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 font-medium">
<option value="">-- Pilih Divisi Penanggung Jawab --</option>
@foreach($availableDivisions as $div)
<option value="{{ $div }}">{{ $div }}</option>
@endforeach
</select>
</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 -->
<!-- Footer Tombol -->
<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">
@@ -543,7 +397,7 @@
</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
Perbarui Kategori
</button>
</div>
</form>
@@ -551,15 +405,17 @@
</div>
<!-- ========================================================================= -->
<!-- MODAL: DETAIL UNIT SUPPORT -->
<!-- MODAL: DETAIL SPESIFIKASI KATEGORI UNIT SUPPORT -->
<!-- ========================================================================= -->
<div id="detailVehicleModal" onclick="if(event.target === this) closeDetailModal()" 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="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-7 border border-slate-100 max-h-[92vh] overflow-y-auto no-scrollbar">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Detail Unit Support
</h3>
<div>
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Detail Spesifikasi Kategori
</h3>
<p class="text-xs text-slate-500 mt-0.5">Informasi master kategori aset Unit Support.</p>
</div>
<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>
@@ -568,15 +424,15 @@
<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>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode Kategori</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>
<span id="detailCode" class="bg-blue-50 text-blue-800 px-2.5 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>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kategori Alat</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>
<span id="detailCategory">-</span>
</div>
</div>
</div>
@@ -589,89 +445,58 @@
</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>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Tipe / Model Khusus</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="detailUnitType">-</span>
</div>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5">
<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">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>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor 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-mono flex items-center">
<span id="detailModelNumber">-</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>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Konsumsi BBM Standar</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 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 & Kepemilikan</label>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi Penanggung Jawab</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>
<span id="detailDivision">-</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>
<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>
<!-- 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>
<!-- Card Unit Fisik Terdaftar -->
<div class="p-4 rounded-2xl bg-emerald-50/70 border border-emerald-200/80 flex items-center justify-between">
<div>
<span class="text-xs font-bold text-emerald-950 block">Unit Fisik Terdaftar</span>
<span id="detailUnitCountText" class="text-xs text-emerald-800 font-medium">0 Unit Fisik</span>
</div>
<a id="detailManageUnitsBtn" href="#" class="px-4 py-2 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white text-xs font-bold transition shadow-sm inline-flex items-center justify-center">
<span>Kelola Unit Fisik</span>
</a>
</div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset -->
<div class="pt-4 flex items-center justify-end">
<!-- Footer Tombol Tutup -->
<div class="pt-2 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">
class="px-6 py-2.5 rounded-xl bg-slate-800 hover:bg-slate-900 text-white font-bold text-xs transition shadow-sm cursor-pointer">
Tutup
</button>
</div>
@@ -722,6 +547,95 @@
</div>
<script>
// =========================================================================
// REAL-TIME CLIENT-SIDE SEARCH
// =========================================================================
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('supportSearchInput');
const tableBody = document.getElementById('supportTableBody');
const resetWrapper = document.getElementById('supportResetWrapper');
const paginationContainer = document.getElementById('supportPaginationContainer');
const serverEmptyRow = document.getElementById('serverSupportEmptyRow');
const hasServerFilters = {{ request()->anyFilled(['status', 'unit_category']) ? 'true' : 'false' }};
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.support-row');
let visibleCount = 0;
rows.forEach(row => {
const text = row.textContent.toLowerCase();
if (text.includes(query)) {
row.style.display = '';
visibleCount++;
} else {
row.style.display = 'none';
}
});
if (paginationContainer) {
paginationContainer.style.display = query.length > 0 ? 'none' : '';
}
const existingEmptyRow = document.getElementById('clientSupportEmptyRow');
if (existingEmptyRow) existingEmptyRow.remove();
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'clientSupportEmptyRow';
emptyTr.innerHTML = `
<td colspan="8" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('supportSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
if (resetWrapper) {
let resetBtn = document.getElementById('supportResetBtn');
if (query.length > 0 || hasServerFilters) {
if (!resetBtn) {
resetBtn = document.createElement('a');
resetBtn.id = 'supportResetBtn';
resetBtn.href = "{{ route('qma.vehicles.support') }}";
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-1';
resetBtn.innerHTML = '<i class="fa-solid fa-rotate-left"></i><span>Reset</span>';
resetWrapper.appendChild(resetBtn);
}
} else if (!hasServerFilters && resetBtn) {
resetBtn.remove();
}
}
});
}
});
// 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))));
@@ -878,16 +792,28 @@
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 || '';
const divSelect = document.getElementById('editDivision');
if (divSelect) {
if (v.division) {
let found = false;
for (let i = 0; i < divSelect.options.length; i++) {
if (divSelect.options[i].value === v.division) {
found = true;
break;
}
}
if (!found) {
const newOpt = document.createElement('option');
newOpt.value = v.division;
newOpt.textContent = v.division;
divSelect.appendChild(newOpt);
}
divSelect.value = v.division;
} else {
divSelect.value = '';
}
}
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() {
@@ -898,31 +824,19 @@
function openDetailModal(v) {
document.getElementById('detailVehicleModal').classList.remove('hidden');
document.getElementById('detailCode').innerText = v.code || '-';
document.getElementById('detailCategory').innerText = v.unit_category || '-';
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('detailUnitType').innerText = v.unit_type || '-';
document.getElementById('detailModelNumber').innerText = v.model_number || '-';
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 || '-';
document.getElementById('detailDivision').innerText = v.division || '-';
document.getElementById('detailOwnership').innerText = v.ownership || 'PT Kerinci Merangin Hidro';
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';
}
const count = v.units_count !== undefined ? v.units_count : 0;
document.getElementById('detailUnitCountText').innerText = count + ' Unit Fisik';
const manageBtn = document.getElementById('detailManageUnitsBtn');
if (manageBtn) {
manageBtn.href = `/qma/vehicles/unit-support/${v.id}/units`;
}
}
function closeDetailModal() {
@@ -0,0 +1,829 @@
@extends('layouts.app')
@section('title', 'Unit Fisik ' . $category->code . ' - Admin QMA | PT Kerinci Merangin Hidro')
@section('content')
<div class="w-full space-y-6">
<!-- Header Judul & Tombol Aksi (Pola justify-between antara judul kiri & grup tombol kanan) -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<div class="flex items-center space-x-2 mb-1">
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20]">
MANAJEMEN UNIT FISIK
</span>
</div>
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight">
{{ $category->unit_category ?? 'Alat Berat' }}
</h2>
<p class="text-xs text-slate-500 mt-1">
{{ $category->brand_type }}{{ $category->model_number ? ' • Model: ' . $category->model_number : '' }}
</p>
</div>
<!-- Tombol Aksi Kanan -->
<div class="grid grid-cols-2 gap-2.5 w-full sm:flex sm:items-center sm:gap-3 sm:w-auto">
<a href="{{ route('qma.vehicles.support') }}"
class="w-full sm:w-auto flex items-center justify-center space-x-2 text-xs font-bold text-slate-700 hover:text-slate-900 bg-white border border-gray-200 rounded-xl px-4 py-2.5 shadow-sm transition hover:bg-gray-50 cursor-pointer">
<i class="fa-solid fa-arrow-left text-xs text-slate-500"></i>
<span>Kembali</span>
</a>
<button onclick="openAddUnitModal()"
class="w-full sm:w-auto flex items-center justify-center space-x-2 bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2.5 rounded-xl text-xs font-bold transition shadow-sm cursor-pointer">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Unit Baru</span>
</button>
</div>
</div>
{{-- Alert Error / Validasi Form (Pesan sukses telah ditangani oleh Toast Notification global di layout) --}}
@if(session('error'))
<div class="p-3.5 bg-rose-50 border border-rose-200 text-rose-800 rounded-xl text-xs flex items-center space-x-2">
<i class="fa-solid fa-circle-exclamation text-rose-600"></i>
<span class="font-semibold">{{ session('error') }}</span>
</div>
@endif
@if($errors->any())
<div class="p-3.5 bg-rose-50 border border-rose-200 text-rose-800 rounded-xl text-xs">
<div class="font-bold mb-1 flex items-center space-x-1">
<i class="fa-solid fa-triangle-exclamation"></i>
<span>Gagal memproses data:</span>
</div>
<ul class="list-disc pl-5 space-y-0.5">
@foreach($errors->all() as $err)
<li>{{ $err }}</li>
@endforeach
</ul>
</div>
@endif
<!-- Kotak Pencarian & Filter Status Unit Fisik -->
<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.units', $category->id) }}" 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"
id="unitSearchInput"
name="search"
value="{{ request('search') }}"
placeholder="Cari kode unit fisik, lokasi, SILO..."
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 Status Dropdown -->
<form method="GET" action="{{ route('qma.vehicles.support.units', $category->id) }}" class="flex items-center space-x-2">
@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] shadow-sm cursor-pointer">
<option value="">Semua Status</option>
<option value="Operation" {{ request('status') === 'Operation' ? 'selected' : '' }}>Operation</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>
<div id="unitResetWrapper" class="flex items-center">
@if(request('search') || request('status'))
<a id="unitResetBtn" href="{{ route('qma.vehicles.support.units', $category->id) }}" 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 text-[11px]"></i>
<span>Reset Filter</span>
</a>
@endif
</div>
</div>
</div>
<!-- Tabel Data Unit Fisik (Header Navy Solid #06213f) -->
<div class="bg-white rounded-none sm: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">NO. SERI / RANGKA</th>
<th class="py-3.5 px-4 text-center">TAHUN</th>
<th class="py-3.5 px-4 text-center">NO. POLISI</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 id="unitsTableBody" class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($units as $index => $u)
<tr class="unit-row hover:bg-slate-50/70 transition">
<td class="py-3.5 px-4 text-center font-medium text-slate-400">
{{ $units->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.5 py-1 rounded-lg border border-blue-200 font-bold">
{{ $u->code }}
</span>
</td>
<td class="py-3.5 px-4 font-mono text-xs text-slate-700 whitespace-nowrap">
@if($u->serial_number)
<span class="font-semibold">{{ $u->serial_number }}</span>
@else
<span class="text-slate-300">-</span>
@endif
</td>
<td class="py-3.5 px-4 text-center text-xs text-slate-700 font-medium whitespace-nowrap">
@if($u->production_year)
<span>{{ $u->production_year }}</span>
@else
<span class="text-slate-300">-</span>
@endif
</td>
<td class="py-3.5 px-4 text-center font-mono text-xs whitespace-nowrap">
@if($u->license_plate)
<span class="bg-slate-100 text-slate-800 px-2 py-0.5 rounded border border-slate-200 font-semibold">{{ $u->license_plate }}</span>
@else
<span class="text-slate-300 font-sans font-normal">-</span>
@endif
</td>
<td class="py-3.5 px-4 text-slate-600">
<div class="font-medium text-slate-800">
@if($u->location)
<i class="fa-solid fa-location-dot text-[9px] mr-1 text-rose-500"></i>{{ $u->location }}
@else
<span class="text-slate-400 italic">Belum ditentukan</span>
@endif
</div>
</td>
<td class="py-3.5 px-4 text-right font-mono font-bold text-slate-800 whitespace-nowrap">
{{ number_format($u->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($u->silo_document)
<span class="inline-flex items-center px-2.5 py-0.5 rounded text-[10px] font-semibold bg-emerald-50 text-emerald-800 border border-emerald-200" title="SILO: {{ $u->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($u->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: {{ $u->kir_document }}
</span>
@endif
</div>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($u->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">
Operation
</span>
@elseif($u->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">
Standby
</span>
@elseif($u->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">
Breakdown
</span>
@elseif($u->status === 'Maintenance')
<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">
Maintenance
</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">
{{ $u->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">
<a href="{{ route('p2h.form', ['code' => $u->code]) }}"
target="_blank"
class="inline-flex items-center space-x-1 text-[#1b5e20] hover:text-[#144918] hover:bg-emerald-50 px-2 py-1 rounded-lg transition"
title="Buka Form P2H Unit Ini">
<i class="fa-solid fa-file-pen text-sm"></i>
</a>
<button onclick='openDetailModal(@json($u))'
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 Unit">
<i class="fa-regular fa-eye text-sm"></i>
</button>
<button onclick='openEditModal(@json($u))'
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">
<i class="fa-regular fa-pen-to-square text-sm"></i>
</button>
<button type="button"
onclick="openDeleteModal('{{ $u->id }}', '{{ $u->code }}')"
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 Fisik">
<i class="fa-regular fa-trash-can text-sm"></i>
</button>
</div>
</td>
</tr>
@empty
<tr id="serverUnitEmptyRow">
<td colspan="10" class="py-12 px-4 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
@if(request('search'))
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<a href="{{ route('qma.vehicles.support.units', array_merge(['id' => $category->id], request()->except('search', 'page'))) }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<div class="flex flex-col items-center justify-center">
<div class="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 mb-3">
<i class="fa-solid fa-cubes text-xl"></i>
</div>
<p class="font-semibold text-slate-700 text-sm">Belum ada unit fisik untuk kategori ini</p>
<p class="text-xs text-slate-400 mt-1 max-w-sm">
Kategori ini belum memiliki armada fisik terdaftar. Silakan klik tombol di bawah untuk menambahkan unit fisik pertama.
</p>
<button onclick="openAddUnitModal()" class="mt-4 bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2 rounded-xl text-xs font-bold transition inline-flex items-center space-x-2">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Unit Baru</span>
</button>
</div>
@endif
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div id="unitsPaginationContainer">
@if($units->hasPages())
<div class="px-6 py-4 border-t border-slate-200">
{{ $units->links() }}
</div>
@endif
</div>
</div>
</div>
<!-- Modal Tambah Unit Baru (Sesuai Referensi Gambar media_1792028135493_30b2da2e.png) -->
<div id="addUnitModal" class="fixed inset-0 z-50 hidden overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true">
<div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity bg-slate-900/60 backdrop-blur-xs" aria-hidden="true" onclick="closeAddUnitModal()"></div>
<span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span>
<div class="inline-block align-bottom bg-white rounded-2xl text-left overflow-hidden shadow-2xl transform transition-all sm:my-8 sm:align-middle sm:max-w-md sm:w-full border border-slate-200">
<div class="p-6">
<!-- Judul Modal -->
<h3 class="text-xl font-extrabold text-slate-900 tracking-tight mb-5" id="modal-title">
Tambah Unit Baru
</h3>
<form method="POST" action="{{ route('qma.vehicles.support.units.store', $category->id) }}" id="addUnitForm" class="space-y-4">
@csrf
<!-- Aset Induk (Readonly) Sesuai Mockup -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Aset Induk
</label>
<input type="text"
readonly
value="{{ $category->code }} - {{ $category->brand_type ?? $category->unit_category }}"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-slate-50 text-slate-600 font-medium focus:outline-none cursor-not-allowed">
</div>
<!-- Kode Unit * (Prefix Box + Input Urut Hijau Border Sesuai Mockup) -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Kode Unit <span class="text-rose-500">*</span>
</label>
<div class="flex rounded-xl overflow-hidden border-2 border-emerald-700 focus-within:ring-2 focus-within:ring-emerald-600/20 transition shadow-2xs">
<span class="inline-flex items-center px-3.5 py-2 bg-slate-100 text-slate-700 text-xs font-bold font-mono border-r border-slate-200 select-none">
{{ $category->code }}-
</span>
<input type="text"
name="unit_number"
id="unitNumberInput"
required
value="{{ $nextUnitNumber }}"
placeholder="Contoh: 001"
class="w-full text-xs px-3.5 py-2.5 bg-white text-slate-900 font-mono font-bold placeholder-slate-400 focus:outline-none">
</div>
<p class="text-[10px] text-slate-400 mt-1">
Kode lengkap: <span id="fullCodePreview" class="font-mono font-bold text-slate-700">{{ $nextUnitCode }}</span>
</p>
</div>
<!-- Nomor Seri / Rangka & Nomor Polisi / Plat -->
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
No. Seri / Rangka
</label>
<input type="text"
name="serial_number"
placeholder="Contoh: VIN/SN12345"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono focus:outline-none focus:border-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Nomor Polisi / Plat
</label>
<input type="text"
name="license_plate"
placeholder="Contoh: BH 1234 XX"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono uppercase focus:outline-none focus:border-emerald-600">
</div>
</div>
<!-- Tahun Produksi & Status Operasi Awal -->
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Tahun Produksi
</label>
<input type="number"
name="production_year"
min="1980"
max="{{ date('Y') + 1 }}"
placeholder="Contoh: 2021"
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-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Status Operasional <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 font-semibold focus:outline-none focus:border-emerald-600">
<option value="Operation" selected>Operation (Siap Operasi)</option>
<option value="Standby">Standby (Tersedia)</option>
<option value="Breakdown">Breakdown (Rusak)</option>
<option value="Maintenance">Maintenance (Perawatan)</option>
</select>
</div>
</div>
<!-- Odometer Awal (HM/KM) -->
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Odometer Awal (HM/KM)
</label>
<input type="number"
name="current_km"
step="0.01"
min="0"
value="0"
placeholder="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-emerald-600 font-mono">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Lokasi Penempatan
</label>
<select name="location"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium focus:outline-none focus:border-emerald-600">
<option value="" disabled {{ empty($category->location) ? 'selected' : '' }}>-- Pilih Lokasi Penempatan --</option>
@foreach($masterLocations as $loc)
<option value="{{ $loc }}" {{ (old('location') ?? $category->location) === $loc ? 'selected' : '' }}>
{{ $loc }}
</option>
@endforeach
</select>
</div>
</div>
<!-- Dokumen SILO & KIR -->
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
No Dokumen SILO
</label>
<input type="text"
name="silo_document"
placeholder="Nomor SILO (opsional)"
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-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
No Dokumen KIR
</label>
<input type="text"
name="kir_document"
placeholder="Nomor KIR (opsional)"
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-emerald-600">
</div>
</div>
<!-- Tombol Aksi Batal & Simpan Unit (Sesuai Desain Mockup) -->
<div class="pt-4 flex items-center justify-end space-x-3">
<button type="button"
onclick="closeAddUnitModal()"
class="px-5 py-2.5 text-xs font-bold text-slate-700 bg-white border border-slate-300 rounded-xl hover:bg-slate-50 transition cursor-pointer">
Batal
</button>
<button type="submit"
class="px-5 py-2.5 text-xs font-bold text-white bg-[#1b5e20] hover:bg-[#144919] rounded-xl transition shadow-sm cursor-pointer">
Simpan Unit
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Modal Edit Data Unit Fisik -->
<div id="editModal" class="fixed inset-0 z-50 hidden overflow-y-auto" role="dialog" aria-modal="true">
<div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity bg-slate-900/60 backdrop-blur-xs" onclick="closeEditModal()"></div>
<span class="hidden sm:inline-block sm:align-middle sm:h-screen">&#8203;</span>
<div class="inline-block align-bottom bg-white rounded-2xl text-left overflow-hidden shadow-2xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full border border-slate-200">
<div class="p-6">
<h3 class="text-xl font-extrabold text-slate-900 tracking-tight mb-5">
Edit Data Unit Fisik
</h3>
<form id="editUnitForm" method="POST" action="" class="space-y-4">
@csrf
<input type="hidden" name="category" value="unit_support">
<input type="hidden" name="brand_type" id="edit_brand_type">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Kode Unit <span class="text-rose-500">*</span></label>
<input type="text" name="code" id="edit_code" required class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-slate-100 text-slate-700 font-mono font-bold focus:outline-none" readonly>
</div>
<!-- Nomor Seri / Rangka & Nomor Polisi / Plat -->
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">No. Seri / Rangka</label>
<input type="text" name="serial_number" id="edit_serial_number" placeholder="Contoh: VIN/SN12345" class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono focus:outline-none focus:border-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Nomor Polisi / Plat</label>
<input type="text" name="license_plate" id="edit_license_plate" placeholder="Contoh: BH 1234 XX" class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono uppercase focus:outline-none focus:border-emerald-600">
</div>
</div>
<!-- Tahun Produksi & Status Operasi -->
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Tahun Produksi</label>
<input type="number" name="production_year" id="edit_production_year" min="1980" max="{{ date('Y') + 1 }}" placeholder="Contoh: 2021" 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-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Status Operasi <span class="text-rose-500">*</span></label>
<select name="status" id="edit_status" required class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white font-semibold text-slate-800 focus:outline-none focus:border-emerald-600">
<option value="Operation">Operation</option>
<option value="Standby">Standby</option>
<option value="Breakdown">Breakdown</option>
<option value="Maintenance">Maintenance</option>
</select>
</div>
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Odometer (HM/KM) <span class="text-rose-500">*</span></label>
<input type="number" step="0.01" name="current_km" id="edit_current_km" required class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono focus:outline-none focus:border-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Lokasi Penempatan</label>
<select name="location" id="edit_location" class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium focus:outline-none focus:border-emerald-600">
<option value="">-- Pilih Lokasi Penempatan --</option>
@foreach($masterLocations as $loc)
<option value="{{ $loc }}">{{ $loc }}</option>
@endforeach
</select>
</div>
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Dokumen SILO</label>
<input type="text" name="silo_document" id="edit_silo" 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-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Dokumen KIR</label>
<input type="text" name="kir_document" id="edit_kir" 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-emerald-600">
</div>
</div>
<div class="pt-4 flex items-center justify-end space-x-3">
<button type="button" onclick="closeEditModal()" class="px-5 py-2.5 text-xs font-bold text-slate-700 bg-white border border-slate-300 rounded-xl hover:bg-slate-50 transition cursor-pointer">Batal</button>
<button type="submit" class="px-5 py-2.5 text-xs font-bold text-white bg-[#1b5e20] hover:bg-[#144919] rounded-xl transition shadow-sm cursor-pointer">Simpan Perubahan</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Modal Detail Unit Fisik -->
<div id="detailModal" class="fixed inset-0 z-50 hidden overflow-y-auto" role="dialog" aria-modal="true">
<div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity bg-slate-900/60 backdrop-blur-xs" onclick="closeDetailModal()"></div>
<span class="hidden sm:inline-block sm:align-middle sm:h-screen">&#8203;</span>
<div class="inline-block align-bottom bg-white rounded-2xl text-left overflow-hidden shadow-2xl transform transition-all sm:my-8 sm:align-middle sm:max-w-md sm:w-full border border-slate-200">
<div class="p-6">
<div class="flex items-center justify-between pb-3 border-b border-slate-100">
<div>
<span class="text-[10px] font-bold uppercase tracking-wider text-slate-400">DETAIL UNIT FISIK</span>
<h3 class="text-xl font-extrabold text-slate-900" id="detail_code">-</h3>
</div>
<button onclick="closeDetailModal()" class="text-slate-400 hover:text-slate-600">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<div class="py-4 space-y-3 text-xs">
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Kategori Induk:</span>
<span class="font-bold text-slate-800">{{ $category->code }} - {{ $category->unit_category }}</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Merek & Tipe:</span>
<span class="font-semibold text-slate-800">{{ $category->brand_type }}</span>
</div>
@if($category->model_number)
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Nomor Model:</span>
<span class="font-mono font-medium text-slate-800">{{ $category->model_number }}</span>
</div>
@endif
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">No. Seri / Rangka:</span>
<span id="detail_serial_number" class="font-mono font-medium text-slate-800">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Nomor Polisi / Plat:</span>
<span id="detail_plate" class="font-mono font-medium text-slate-800">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Tahun Produksi:</span>
<span id="detail_year" class="font-medium text-slate-800">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Status Operasi:</span>
<span id="detail_status" class="font-bold">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Odometer:</span>
<span id="detail_km" class="font-mono font-bold text-slate-800">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Lokasi Kerja:</span>
<span id="detail_location" class="font-medium text-slate-800">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Dokumen SILO:</span>
<span id="detail_silo" class="font-medium text-slate-800">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Dokumen KIR:</span>
<span id="detail_kir" class="font-medium text-slate-800">-</span>
</div>
</div>
<div class="pt-3 border-t border-slate-100 flex justify-end">
<button onclick="closeDetailModal()" class="px-5 py-2 text-xs font-bold text-slate-700 bg-slate-100 hover:bg-slate-200 rounded-xl transition">Tutup</button>
</div>
</div>
</div>
</div>
</div>
<!-- Modal Hapus Unit Fisik -->
<div id="deleteModal" class="fixed inset-0 z-50 hidden overflow-y-auto" role="dialog" aria-modal="true">
<div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity bg-slate-900/60 backdrop-blur-xs" onclick="closeDeleteModal()"></div>
<span class="hidden sm:inline-block sm:align-middle sm:h-screen">&#8203;</span>
<div class="inline-block align-bottom bg-white rounded-2xl text-left overflow-hidden shadow-2xl transform transition-all sm:my-8 sm:align-middle sm:max-w-sm sm:w-full border border-slate-200">
<div class="p-6 text-center">
<div class="w-12 h-12 rounded-full bg-rose-100 text-rose-600 flex items-center justify-center mx-auto mb-4">
<i class="fa-solid fa-triangle-exclamation text-xl"></i>
</div>
<h3 class="text-lg font-bold text-slate-900 mb-2">Hapus Unit Fisik?</h3>
<p class="text-xs text-slate-500 mb-6">
Apakah Anda yakin ingin menghapus unit <span id="deleteUnitCode" class="font-mono font-bold text-slate-800"></span>? Data yang sudah dihapus tidak dapat dipulihkan.
</p>
<form id="deleteForm" method="POST" action="">
@csrf
@method('DELETE')
<div class="flex items-center justify-center space-x-3">
<button type="button" onclick="closeDeleteModal()" class="px-5 py-2 text-xs font-bold text-slate-700 bg-white border border-slate-300 rounded-xl hover:bg-slate-50 transition cursor-pointer">Batal</button>
<button type="submit" class="px-5 py-2 text-xs font-bold text-white bg-rose-600 hover:bg-rose-700 rounded-xl transition shadow-sm cursor-pointer">Ya, Hapus Unit</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
const categoryCode = "{{ $category->code }}";
function openAddUnitModal() {
document.getElementById('addUnitModal').classList.remove('hidden');
document.getElementById('unitNumberInput').focus();
}
function closeAddUnitModal() {
document.getElementById('addUnitModal').classList.add('hidden');
}
// Live preview kode lengkap
document.getElementById('unitNumberInput')?.addEventListener('input', function(e) {
let val = e.target.value.trim();
if (val) {
document.getElementById('fullCodePreview').textContent = categoryCode + '-' + val;
} else {
document.getElementById('fullCodePreview').textContent = '-';
}
});
function openEditModal(unit) {
const form = document.getElementById('editUnitForm');
form.action = "{{ url('qma/vehicles') }}/" + unit.id;
document.getElementById('edit_code').value = unit.code;
document.getElementById('edit_brand_type').value = unit.brand_type || "{{ $category->brand_type }}";
document.getElementById('edit_serial_number').value = unit.serial_number || '';
document.getElementById('edit_license_plate').value = unit.license_plate || '';
document.getElementById('edit_production_year').value = unit.production_year || '';
document.getElementById('edit_status').value = unit.status || 'Operation';
document.getElementById('edit_current_km').value = unit.current_km || 0;
const locSelect = document.getElementById('edit_location');
if (locSelect) {
if (unit.location) {
let found = Array.from(locSelect.options).some(opt => opt.value === unit.location);
if (!found) {
const newOpt = document.createElement('option');
newOpt.value = unit.location;
newOpt.textContent = unit.location;
locSelect.appendChild(newOpt);
}
locSelect.value = unit.location;
} else {
locSelect.value = '';
}
}
document.getElementById('edit_silo').value = unit.silo_document || '';
document.getElementById('edit_kir').value = unit.kir_document || '';
document.getElementById('editModal').classList.remove('hidden');
}
function closeEditModal() {
document.getElementById('editModal').classList.add('hidden');
}
function openDetailModal(unit) {
document.getElementById('detail_code').textContent = unit.code;
document.getElementById('detail_serial_number').textContent = unit.serial_number || 'Tidak ada';
document.getElementById('detail_plate').textContent = unit.license_plate || 'Tidak ada';
document.getElementById('detail_year').textContent = unit.production_year || 'Tidak ada';
document.getElementById('detail_status').textContent = unit.status;
document.getElementById('detail_km').textContent = Number(unit.current_km).toLocaleString('id-ID') + ' HM/KM';
document.getElementById('detail_location').textContent = unit.location || '-';
document.getElementById('detail_silo').textContent = unit.silo_document || 'Tidak ada';
document.getElementById('detail_kir').textContent = unit.kir_document || 'Tidak ada';
document.getElementById('detailModal').classList.remove('hidden');
}
function closeDetailModal() {
document.getElementById('detailModal').classList.add('hidden');
}
function openDeleteModal(id, code) {
const form = document.getElementById('deleteForm');
form.action = "{{ url('qma/vehicles') }}/" + id;
document.getElementById('deleteUnitCode').textContent = code;
document.getElementById('deleteModal').classList.remove('hidden');
}
function closeDeleteModal() {
document.getElementById('deleteModal').classList.add('hidden');
}
// =========================================================================
// REAL-TIME CLIENT-SIDE SEARCH WITH MULTI-FIELD MATCHING & EMPTY STATE
// =========================================================================
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('unitSearchInput');
const tableBody = document.getElementById('unitsTableBody');
const resetWrapper = document.getElementById('unitResetWrapper');
const paginationContainer = document.getElementById('unitsPaginationContainer');
const serverEmptyRow = document.getElementById('serverUnitEmptyRow');
const hasServerFilters = {{ request()->anyFilled(['status']) ? 'true' : 'false' }};
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.unit-row');
let visibleCount = 0;
rows.forEach(row => {
const text = row.textContent.toLowerCase();
if (text.includes(query)) {
row.style.display = '';
visibleCount++;
} else {
row.style.display = 'none';
}
});
if (paginationContainer) {
paginationContainer.style.display = query.length > 0 ? 'none' : '';
}
const existingEmptyRow = document.getElementById('clientUnitEmptyRow');
if (existingEmptyRow) existingEmptyRow.remove();
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'clientUnitEmptyRow';
emptyTr.innerHTML = `
<td colspan="10" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('unitSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
if (resetWrapper) {
let resetBtn = document.getElementById('unitResetBtn');
if (query.length > 0 || hasServerFilters) {
if (!resetBtn) {
resetBtn = document.createElement('a');
resetBtn.id = 'unitResetBtn';
resetBtn.href = "{{ route('qma.vehicles.support.units', $category->id) }}";
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-1';
resetBtn.innerHTML = '<i class="fa-solid fa-rotate-left text-[11px]"></i><span>Reset Filter</span>';
resetWrapper.appendChild(resetBtn);
}
} else if (!hasServerFilters && resetBtn) {
resetBtn.remove();
}
}
});
// Trigger saat awal memuat halaman jika ada nilai pencarian dari SSR
if (searchInput.value.trim() !== '') {
searchInput.dispatchEvent(new Event('input'));
}
}
});
</script>
@endsection