fix: resolve client-side table search limitation across all 7 paginated views with global server search and per-page selector

This commit is contained in:
Ray1111-aa
2026-10-27 13:42:40 +07:00
parent 500547116f
commit 8c41f33c19
14 changed files with 292 additions and 691 deletions
+29 -80
View File
@@ -71,7 +71,7 @@
</div>
<!-- Kotak Pencarian & Filter Status Simper (Tanpa Card Wrapper, Format Referensi) -->
<form method="GET" action="{{ route('hse.employees.index') }}" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-2.5 sm:gap-3">
<form method="GET" action="{{ route('hse.employees.index') }}" id="employeeFilterForm" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-2.5 sm:gap-3">
<!-- Pencarian Cepat di Kiri -->
<div class="relative w-full sm:max-w-md">
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400">
@@ -85,7 +85,7 @@
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-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition">
</div>
<!-- Filter di Kanan (Pada Mobile: Sejajar 2 Kolom di Bawah Search Bar) -->
<!-- Filter di Kanan (Pada Mobile: Sejajar di Bawah Search Bar) -->
<div class="flex flex-col sm:flex-row items-stretch sm:items-center justify-end gap-2 sm:gap-2.5 w-full sm:w-auto">
<div class="grid grid-cols-2 gap-2 sm:flex sm:items-center sm:gap-2.5 w-full sm:w-auto">
<!-- Filter Jenis Personil / Karyawan -->
@@ -118,11 +118,25 @@
<option value="expiring_soon" {{ request('simper_status') === 'expiring_soon' ? 'selected' : '' }}>Segera Habis (≤ 30 Hari)</option>
<option value="expired" {{ request('simper_status') === 'expired' ? 'selected' : '' }}>Kedaluwarsa (Expired)</option>
</select>
<!-- Filter Tampilan Per Halaman -->
<select name="per_page"
onchange="this.form.submit()"
class="w-full sm:w-auto text-xs rounded-xl border border-slate-200 bg-white px-2.5 sm:px-3 py-2.5 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition truncate">
<option value="20" {{ request('per_page', '20') == '20' ? 'selected' : '' }}>20 / Hal</option>
<option value="50" {{ request('per_page') == '50' ? 'selected' : '' }}>50 / Hal</option>
<option value="100" {{ request('per_page') == '100' ? 'selected' : '' }}>Semua (100)</option>
</select>
<!-- Tombol Submit Pencarian -->
<button type="submit" class="px-4 py-2.5 bg-slate-900 hover:bg-slate-800 text-white text-xs font-bold rounded-xl transition shadow-sm cursor-pointer whitespace-nowrap col-span-2 sm:col-span-1">
Cari
</button>
</div>
<!-- Tombol Reset Filter (Sesuai Referensi Merah / Rose Clean Text) -->
<div id="simperResetContainer">
@if(request()->anyFilled(['search', 'employee_type', 'driver_status', 'simper_status']))
@if(request()->anyFilled(['search', 'employee_type', 'driver_status', 'simper_status', 'per_page']))
<a href="{{ route('hse.employees.index') }}"
id="simperResetBtn"
class="text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center justify-center sm:justify-start space-x-1.5 transition whitespace-nowrap py-1 sm:py-0 sm:ml-2">
@@ -1217,87 +1231,22 @@
document.getElementById('renewModal').classList.remove('hidden');
}
// Filter Pencarian Instan Real-time
// Pencarian Server-side Otomatis (Global ke seluruh database)
const employeeFilterForm = document.getElementById('employeeFilterForm');
const searchInput = document.getElementById('simperSearchInput');
const resetContainer = document.getElementById('simperResetContainer');
const tableBody = document.getElementById('simperTableBody');
const hasServerFilters = {{ request()->anyFilled(['search', 'driver_status', 'simper_status']) ? 'true' : 'false' }};
let searchDebounce = null;
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
if (searchInput && searchInput.value) {
searchInput.focus();
const len = searchInput.value.length;
searchInput.setSelectionRange(len, len);
}
searchInput?.addEventListener('input', function(e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = document.querySelectorAll('#simperTableBody tr.simper-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++;
});
const serverEmptyRow = document.getElementById('serverSimperEmptyRow');
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
// Hapus baris pesan kosong pencarian jika ada sebelumnya
const existingEmptyRow = document.getElementById('simperEmptySearchRow');
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 = 'simperEmptySearchRow';
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 ejaan NIK atau nama karyawan yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('simperSearchInput'); 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/sembunyikan tombol Reset Filter secara real-time saat mengetik
let resetBtn = document.getElementById('simperResetBtn');
if (query.length > 0) {
if (!resetBtn && resetContainer) {
resetBtn = document.createElement('a');
resetBtn.id = 'simperResetBtn';
resetBtn.href = "{{ route('hse.employees.index') }}";
resetBtn.className = "text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center justify-center sm:justify-start space-x-1.5 transition whitespace-nowrap py-1 sm:py-0 sm:ml-2";
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 (!hasServerFilters && resetBtn) {
resetBtn.remove();
}
searchInput?.addEventListener('input', function() {
clearTimeout(searchDebounce);
searchDebounce = setTimeout(function() {
employeeFilterForm?.submit();
}, 500);
});
// Toggle Menu Dropdown Ekspor Simper (Format it.allrole.web.id)
+31 -94
View File
@@ -64,10 +64,10 @@
@endphp
<!-- Form Filter & Pencarian Cepat (Aturan Standar: Separated Search Bar & Collapsible Filter Card) -->
<form method="GET" action="{{ route('pg.logs.index') }}" class="space-y-3">
<form method="GET" action="{{ route('pg.logs.index') }}" id="verificationLogFilterForm" class="space-y-3">
<!-- Level 1: Quick 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) -->
<!-- Search Bar Utama (Real-Time Server Search) -->
<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>
@@ -80,8 +80,22 @@
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 -->
<!-- Tombol Buka/Tutup Filter Card & Pilihan Per Halaman -->
<div class="flex items-center gap-2.5 self-end sm:self-auto w-full sm:w-auto justify-between sm:justify-start">
<!-- Filter Tampilan Per Halaman -->
<select name="per_page"
onchange="this.form.submit()"
class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2.5 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20] shadow-2xs transition truncate">
<option value="20" {{ request('per_page', '20') == '20' ? 'selected' : '' }}>20 / Hal</option>
<option value="50" {{ request('per_page', '50') == '50' ? 'selected' : '' }}>50 / Hal</option>
<option value="100" {{ request('per_page', '100') == '100' ? 'selected' : '' }}>Semua (100)</option>
</select>
<!-- Tombol Submit Pencarian -->
<button type="submit" class="px-4 py-2.5 bg-slate-900 hover:bg-slate-800 text-white text-xs font-bold rounded-xl transition shadow-2xs cursor-pointer whitespace-nowrap">
Cari
</button>
<button type="button"
id="filterToggleBtn"
onclick="toggleFilterCard()"
@@ -97,7 +111,7 @@
</button>
<div id="headerResetFilterContainer">
@if(request()->anyFilled(['search', 'team', 'security_guard_id', 'gate_id', 'direction', 'status', 'start_date', 'end_date']))
@if(request()->anyFilled(['search', 'team', 'security_guard_id', 'gate_id', 'direction', 'status', 'start_date', 'end_date', 'per_page']))
<a href="{{ route('pg.logs.index') }}"
id="headerResetFilterBtn"
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">
@@ -629,99 +643,22 @@
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('verificationLogSearchInput');
const tableBody = document.getElementById('verificationLogTableBody');
const resetContainer = document.getElementById('headerResetFilterContainer');
const hasServerFilters = {{ request()->anyFilled($filterKeys) ? 'true' : 'false' }};
const filterForm = document.getElementById('verificationLogFilterForm');
let searchDebounce = null;
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.verification-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++;
});
const serverEmptyRow = document.getElementById('serverVerificationEmptyRow');
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
// Hapus baris pesan kosong pencarian jika ada sebelumnya
const existingEmptyRow = document.getElementById('verificationEmptySearchRow');
if (existingEmptyRow) {
existingEmptyRow.remove();
}
// Tampilkan pesan instan jika tidak ada baris yang cocok di tabel
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'verificationEmptySearchRow';
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">
<span class="inline-block mr-1">🔍</span>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 ejaan nomor transaksi, nomor plat, nama driver, atau petugas satpam yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('verificationLogSearchInput'); 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
let resetBtn = document.getElementById('headerResetFilterBtn');
if (query.length > 0) {
if (!resetBtn && resetContainer) {
resetBtn = document.createElement('a');
resetBtn.href = "{{ route('pg.logs.index') }}";
resetBtn.id = 'headerResetFilterBtn';
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 (!hasServerFilters && resetBtn) {
resetBtn.remove();
}
});
if (searchInput && searchInput.value) {
searchInput.focus();
const len = searchInput.value.length;
searchInput.setSelectionRange(len, len);
}
// Reset filter click handler saat hanya input client-side tanpa server filter
if (resetContainer) {
resetContainer.addEventListener('click', function(e) {
const btn = e.target.closest('#headerResetFilterBtn');
if (btn && !hasServerFilters) {
e.preventDefault();
if (searchInput) {
searchInput.value = '';
searchInput.dispatchEvent(new Event('input'));
searchInput.focus();
}
}
});
}
searchInput?.addEventListener('input', function() {
clearTimeout(searchDebounce);
searchDebounce = setTimeout(function() {
filterForm?.submit();
}, 500);
});
});
});
// Panduan Halaman Modal
+31 -84
View File
@@ -63,10 +63,10 @@
@endphp
<!-- Form Filter & Pencarian Cepat -->
<form method="GET" action="{{ route('qma.activity.log') }}" class="space-y-3">
<form method="GET" action="{{ route('qma.activity.log') }}" id="activityLogFilterForm" 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) -->
<!-- Search Bar Utama (Real-Time Server Search) -->
<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>
@@ -79,8 +79,22 @@
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 -->
<!-- Tombol Buka/Tutup Filter Card & Pilihan Per Halaman -->
<div class="flex items-center gap-2.5 self-end sm:self-auto w-full sm:w-auto justify-between sm:justify-start">
<!-- Filter Tampilan Per Halaman -->
<select name="per_page"
onchange="this.form.submit()"
class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2.5 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20] shadow-2xs transition truncate">
<option value="20" {{ request('per_page', '20') == '20' ? 'selected' : '' }}>20 / Hal</option>
<option value="50" {{ request('per_page', '50') == '50' ? 'selected' : '' }}>50 / Hal</option>
<option value="100" {{ request('per_page', '100') == '100' ? 'selected' : '' }}>Semua (100)</option>
</select>
<!-- Tombol Submit Pencarian -->
<button type="submit" class="px-4 py-2.5 bg-slate-900 hover:bg-slate-800 text-white text-xs font-bold rounded-xl transition shadow-2xs cursor-pointer whitespace-nowrap">
Cari
</button>
<button type="button"
id="filterToggleBtn"
onclick="toggleFilterCard()"
@@ -96,7 +110,7 @@
</button>
<div id="headerResetFilterContainer">
@if(request()->anyFilled(['search', 'start_date', 'end_date', 'gate_id', 'direction', 'status']))
@if(request()->anyFilled(['search', 'start_date', 'end_date', 'gate_id', 'direction', 'status', 'per_page']))
<a href="{{ route('qma.activity.log') }}"
id="headerResetFilterBtn"
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">
@@ -449,88 +463,21 @@ function escapeHtml(str) {
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('activityLogSearchInput');
const tableBody = document.getElementById('activityLogTableBody');
const resetContainer = document.getElementById('headerResetFilterContainer');
const paginationContainer = document.getElementById('activityPaginationContainer');
const serverEmptyRow = document.getElementById('serverActivityEmptyRow');
const hasServerFilters = {{ request()->anyFilled(['start_date', 'end_date', 'gate_id', 'direction', 'status']) ? 'true' : 'false' }};
const filterForm = document.getElementById('activityLogFilterForm');
let searchDebounce = null;
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.activity-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('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);
}
if (resetContainer) {
let resetBtn = document.getElementById('headerResetFilterBtn');
if (query.length > 0 || hasServerFilters) {
if (!resetBtn) {
resetBtn = document.createElement('a');
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');
resetText.textContent = 'Reset Filter';
resetBtn.appendChild(resetIcon);
resetBtn.appendChild(resetText);
resetContainer.appendChild(resetBtn);
}
} else if (!hasServerFilters && resetBtn) {
resetBtn.remove();
}
}
});
if (searchInput && searchInput.value) {
searchInput.focus();
const len = searchInput.value.length;
searchInput.setSelectionRange(len, len);
}
searchInput?.addEventListener('input', function() {
clearTimeout(searchDebounce);
searchDebounce = setTimeout(function() {
filterForm?.submit();
}, 500);
});
});
// Toggle Card Filter Lanjutan
+27 -88
View File
@@ -60,7 +60,7 @@
<!-- 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">
<form method="GET" action="{{ route('qma.p2h.index') }}" id="p2hFilterForm" 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
@@ -95,8 +95,20 @@
<option value="has_defect" {{ request('summary_condition') === 'has_defect' ? 'selected' : '' }}>Ada Temuan Rusak</option>
</select>
<!-- Filter Jumlah Per Halaman -->
<select name="per_page" 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="15" {{ request('per_page', '15') == '15' ? 'selected' : '' }}>15 / Hal</option>
<option value="50" {{ request('per_page') == '50' ? 'selected' : '' }}>50 / Hal</option>
<option value="100" {{ request('per_page') == '100' ? 'selected' : '' }}>Semua (100)</option>
</select>
<!-- Tombol Submit Pencarian -->
<button type="submit" class="px-4 py-2 bg-slate-900 hover:bg-slate-800 text-white text-xs font-bold rounded-xl transition shadow-sm cursor-pointer whitespace-nowrap">
Cari
</button>
<div id="p2hResetWrapper">
@if(request('search') || request('validation_status') || request('summary_condition') || request('date'))
@if(request()->anyFilled(['search', 'validation_status', 'summary_condition', 'date', 'per_page']))
<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>
@@ -243,94 +255,21 @@ function escapeHtml(str) {
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' }};
const filterForm = document.getElementById('p2hFilterForm');
let searchDebounce = null;
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-16 text-center">
<p class="text-sm font-bold 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 px-4 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">
<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();
}
}
}
});
if (searchInput && searchInput.value) {
searchInput.focus();
const len = searchInput.value.length;
searchInput.setSelectionRange(len, len);
}
searchInput?.addEventListener('input', function() {
clearTimeout(searchDebounce);
searchDebounce = setTimeout(function() {
filterForm?.submit();
}, 500);
});
});
function openGuideModal() {
+24 -61
View File
@@ -101,7 +101,7 @@
</div>
<!-- Kotak Pencarian & Filter Status Timesheet (Tanpa Card Wrapper, Format Persis HSE Employees) -->
<form method="GET" action="{{ url()->current() }}" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-2.5 sm:gap-3">
<form method="GET" action="{{ url()->current() }}" id="timesheetFilterForm" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-2.5 sm:gap-3">
<!-- Pencarian Cepat di Kiri dengan Tombol Cari -->
<div class="relative w-full sm:max-w-md flex items-center">
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400 z-10">
@@ -172,11 +172,20 @@
<option value="Karyawan" {{ request('operator_type') === 'Karyawan' ? 'selected' : '' }}>Karyawan</option>
<option value="Sukon" {{ request('operator_type') === 'Sukon' ? 'selected' : '' }}>Sukon</option>
</select>
<!-- Filter Tampilan Per Halaman -->
<select name="per_page"
onchange="this.form.submit()"
class="w-full sm:w-auto text-xs rounded-xl border border-slate-200 bg-white px-2.5 sm:px-3 py-2.5 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition truncate">
<option value="15" {{ request('per_page', '15') == '15' ? 'selected' : '' }}>15 / Hal</option>
<option value="50" {{ request('per_page', '50') == '50' ? 'selected' : '' }}>50 / Hal</option>
<option value="100" {{ request('per_page', '100') == '100' ? 'selected' : '' }}>Semua (100)</option>
</select>
</div>
<!-- Tombol Reset Filter -->
<div id="timesheetResetContainer">
@if(request()->anyFilled(['search', 'vehicle_id', 'shift', 'operator_type']) || (request('start_date') && request('start_date') !== now()->toDateString()) || (request('end_date') && request('end_date') !== now()->toDateString()))
@if(request()->anyFilled(['search', 'vehicle_id', 'shift', 'operator_type', 'per_page']) || (request('start_date') && request('start_date') !== now()->toDateString()) || (request('end_date') && request('end_date') !== now()->toDateString()))
<a href="{{ url()->current() }}"
id="timesheetResetBtn"
class="text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center justify-center sm:justify-start space-x-1.5 transition whitespace-nowrap py-1 sm:py-0 sm:ml-2">
@@ -1626,68 +1635,22 @@
document.getElementById('addMeterType')?.addEventListener('change', () => updateMeterUnitLabels('add'));
document.getElementById('editMeterType')?.addEventListener('change', () => updateMeterUnitLabels('edit'));
// 8. Filter Pencarian Instan Real-Time (Persis Standar HSE Employees)
// 8. Pencarian Server-Side Otomatis (Global ke seluruh database)
const timesheetFilterForm = document.getElementById('timesheetFilterForm');
const timesheetSearchInput = document.getElementById('timesheetSearchInput');
const timesheetResetContainer = document.getElementById('timesheetResetContainer');
const timesheetTableBody = document.getElementById('timesheetTableBody');
let timesheetSearchDebounce = null;
timesheetSearchInput?.addEventListener('input', function(e) {
const query = e.target.value.toLowerCase().trim();
const cleanQuery = query.replace(/[\s\-_]/g, '');
const rows = document.querySelectorAll('#timesheetTableBody tr.timesheet-row');
let visibleCount = 0;
if (timesheetSearchInput && timesheetSearchInput.value) {
timesheetSearchInput.focus();
const len = timesheetSearchInput.value.length;
timesheetSearchInput.setSelectionRange(len, len);
}
rows.forEach(row => {
const text = row.innerText.toLowerCase();
const cleanText = text.replace(/[\s\-_]/g, '');
const match = query === '' || text.includes(query) || (cleanQuery.length > 0 && cleanText.includes(cleanQuery));
if (match) {
row.style.display = '';
visibleCount++;
} else {
row.style.display = 'none';
}
});
// Dynamic empty state
const existingEmptyTr = document.getElementById('timesheetClientEmptyRow');
if (existingEmptyTr) existingEmptyTr.remove();
if (visibleCount === 0 && rows.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'timesheetClientEmptyRow';
emptyTr.innerHTML = `
<td colspan="9" 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">Tidak ada timesheet yang cocok</p>
<p class="text-xs text-slate-400 mt-1">
Tidak ditemukan data dengan kata kunci "${escapeHtml(query)}" pada halaman ini.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('timesheetSearchInput'); 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>
`;
timesheetTableBody?.appendChild(emptyTr);
}
// Dynamic reset button
let resetBtn = document.getElementById('timesheetResetBtn');
if (query.length > 0) {
if (!resetBtn && timesheetResetContainer) {
resetBtn = document.createElement('a');
resetBtn.id = 'timesheetResetBtn';
resetBtn.href = window.location.pathname;
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center justify-center sm:justify-start space-x-1.5 transition whitespace-nowrap py-1 sm:py-0 sm:ml-2';
resetBtn.innerHTML = '<i class="fa-solid fa-rotate-left text-[11px]"></i><span>Reset Filter</span>';
timesheetResetContainer.appendChild(resetBtn);
}
}
timesheetSearchInput?.addEventListener('input', function() {
clearTimeout(timesheetSearchDebounce);
timesheetSearchDebounce = setTimeout(function() {
timesheetFilterForm?.submit();
}, 500);
});
function escapeHtml(str) {
+33 -89
View File
@@ -62,7 +62,7 @@
<!-- 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') }}" id="lvFilterForm" 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>
@@ -76,21 +76,26 @@
</div>
<div class="flex items-center space-x-2">
<form method="GET" action="{{ route('qma.vehicles.lv') }}">
@if(request('search'))
<input type="hidden" name="search" value="{{ request('search') }}">
@endif
<select name="status" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
<option value="">Semua Status Operasi</option>
<option value="Operation" {{ request('status') === 'Operation' ? 'selected' : '' }}>Operation (Siap Jalan)</option>
<option value="Standby" {{ request('status') === 'Standby' ? 'selected' : '' }}>Standby</option>
<option value="Breakdown" {{ request('status') === 'Breakdown' ? 'selected' : '' }}>Breakdown</option>
<option value="Maintenance" {{ request('status') === 'Maintenance' ? 'selected' : '' }}>Maintenance</option>
</select>
</form>
<select name="status" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
<option value="">Semua Status Operasi</option>
<option value="Operation" {{ request('status') === 'Operation' ? 'selected' : '' }}>Operation (Siap Jalan)</option>
<option value="Standby" {{ request('status') === 'Standby' ? 'selected' : '' }}>Standby</option>
<option value="Breakdown" {{ request('status') === 'Breakdown' ? 'selected' : '' }}>Breakdown</option>
<option value="Maintenance" {{ request('status') === 'Maintenance' ? 'selected' : '' }}>Maintenance</option>
</select>
<select name="per_page" 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="15" {{ request('per_page', '15') == '15' ? 'selected' : '' }}>15 / Hal</option>
<option value="50" {{ request('per_page', '50') == '50' ? 'selected' : '' }}>50 / Hal</option>
<option value="100" {{ request('per_page', '100') == '100' ? 'selected' : '' }}>Semua (100)</option>
</select>
<button type="submit" class="px-4 py-2 bg-slate-900 hover:bg-slate-800 text-white text-xs font-bold rounded-xl transition shadow-sm cursor-pointer whitespace-nowrap">
Cari
</button>
<div id="lvResetWrapper" class="flex items-center">
@if(request('search') || request('status'))
@if(request()->anyFilled(['search', 'status', 'per_page']))
<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>
@@ -98,7 +103,7 @@
@endif
</div>
</div>
</div>
</form>
<!-- Tabel Data Light Vehicle (Header Navy Solid #06213f) -->
<div class="bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
@@ -1018,82 +1023,21 @@
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' }};
const filterForm = document.getElementById('lvFilterForm');
let searchDebounce = null;
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 (searchInput && searchInput.value) {
searchInput.focus();
const len = searchInput.value.length;
searchInput.setSelectionRange(len, len);
}
searchInput?.addEventListener('input', function() {
clearTimeout(searchDebounce);
searchDebounce = setTimeout(function() {
filterForm?.submit();
}, 500);
});
});
@if($errors->any())
+33 -88
View File
@@ -62,7 +62,7 @@
<!-- 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') }}" id="supportFilterForm" 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>
@@ -77,20 +77,26 @@
<div class="flex flex-wrap items-center gap-2">
<!-- Filter Kategori Alat Berat -->
<form method="GET" action="{{ route('qma.vehicles.support') }}" class="flex items-center space-x-2">
@if(request('search'))
<input type="hidden" name="search" value="{{ request('search') }}">
@endif
<select name="unit_category" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
<option value="">Semua Kategori Alat</option>
@foreach($availableCategories as $cat)
<option value="{{ $cat }}" {{ request('unit_category') === $cat ? 'selected' : '' }}>{{ $cat }}</option>
@endforeach
</select>
</form>
<select name="unit_category" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
<option value="">Semua Kategori Alat</option>
@foreach($availableCategories as $cat)
<option value="{{ $cat }}" {{ request('unit_category') === $cat ? 'selected' : '' }}>{{ $cat }}</option>
@endforeach
</select>
<!-- Filter Jumlah Per Halaman -->
<select name="per_page" 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="15" {{ request('per_page', '15') == '15' ? 'selected' : '' }}>15 / Hal</option>
<option value="50" {{ request('per_page', '50') == '50' ? 'selected' : '' }}>50 / Hal</option>
<option value="100" {{ request('per_page', '100') == '100' ? 'selected' : '' }}>Semua (100)</option>
</select>
<button type="submit" class="px-4 py-2 bg-slate-900 hover:bg-slate-800 text-white text-xs font-bold rounded-xl transition shadow-sm cursor-pointer whitespace-nowrap">
Cari
</button>
<div id="supportResetWrapper" class="flex items-center">
@if(request('search') || request('unit_category'))
@if(request()->anyFilled(['search', 'unit_category', 'per_page']))
<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>
@@ -98,7 +104,7 @@
@endif
</div>
</div>
</div>
</form>
<!-- Tabel Data Kategori Heavy Equipment (Header Navy Solid #06213f) -->
<div class="bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
@@ -633,82 +639,21 @@
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' }};
const filterForm = document.getElementById('supportFilterForm');
let searchDebounce = null;
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();
}
}
});
if (searchInput && searchInput.value) {
searchInput.focus();
const len = searchInput.value.length;
searchInput.setSelectionRange(len, len);
}
searchInput?.addEventListener('input', function() {
clearTimeout(searchDebounce);
searchDebounce = setTimeout(function() {
filterForm?.submit();
}, 500);
});
});
// Daftar semua kode kendaraan heavy equipment yang sudah terdaftar di sistem
@@ -86,11 +86,8 @@
@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
<form method="GET" action="{{ route('qma.vehicles.support.units', $category->id) }}" id="unitFilterForm" 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>
@@ -100,25 +97,31 @@
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>
<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>
<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>
<!-- Filter Jumlah Per Halaman -->
<select name="per_page" 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="15" {{ request('per_page', '15') == '15' ? 'selected' : '' }}>15 / Hal</option>
<option value="50" {{ request('per_page', '50') == '50' ? 'selected' : '' }}>50 / Hal</option>
<option value="100" {{ request('per_page', '100') == '100' ? 'selected' : '' }}>Semua (100)</option>
</select>
<button type="submit" class="px-4 py-2 bg-slate-900 hover:bg-slate-800 text-white text-xs font-bold rounded-xl transition shadow-sm cursor-pointer whitespace-nowrap">
Cari
</button>
<div id="unitResetWrapper" class="flex items-center">
@if(request('search') || request('status'))
@if(request()->anyFilled(['search', 'status', 'per_page']))
<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>
@@ -126,7 +129,7 @@
@endif
</div>
</div>
</div>
</form>
<!-- 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">
@@ -958,87 +961,21 @@
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' }};
const filterForm = document.getElementById('unitFilterForm');
let searchDebounce = null;
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'));
}
if (searchInput && searchInput.value) {
searchInput.focus();
const len = searchInput.value.length;
searchInput.setSelectionRange(len, len);
}
searchInput?.addEventListener('input', function() {
clearTimeout(searchDebounce);
searchDebounce = setTimeout(function() {
filterForm?.submit();
}, 500);
});
});
// Dropdown Menu Ekspor Heavy Equipment Kategori Ini