feat(pg): add flexible gate selection pop-up and remove rigid guard gate assignment
This commit is contained in:
@@ -36,6 +36,14 @@
|
||||
<span class="px-2.5 py-1 rounded-lg text-xs font-black bg-blue-50 text-blue-700 border border-blue-200">
|
||||
Regu {{ $currentGuard->team ?? '1' }}
|
||||
</span>
|
||||
<!-- Tombol Fleksibel Ganti Pos Jaga -->
|
||||
<button type="button"
|
||||
onclick="openGateSelectionModal()"
|
||||
class="inline-flex items-center gap-1.5 px-3 py-1 rounded-xl text-xs font-bold bg-amber-500 hover:bg-amber-600 text-white transition shadow-2xs cursor-pointer"
|
||||
title="Ganti pos gerbang yang sedang dijaga">
|
||||
<i class="fa-solid fa-arrows-rotate text-[11px]"></i>
|
||||
<span>Ganti Pos</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="text-sm sm:text-base text-slate-600 font-medium truncate mt-1 flex items-center flex-wrap gap-1.5">
|
||||
<span>Petugas: <strong class="text-slate-900 font-bold">{{ $currentGuard ? $currentGuard->name : auth()->user()->name }}</strong></span>
|
||||
@@ -336,7 +344,7 @@
|
||||
isSyncing = true;
|
||||
|
||||
try {
|
||||
const response = await fetch("{{ route('pg.gate.live_queue') }}", {
|
||||
const response = await fetch("{{ route('pg.gate.live_queue') }}?gate_id={{ $gate ? $gate->id : '' }}", {
|
||||
headers: {
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept': 'application/json'
|
||||
@@ -427,6 +435,41 @@
|
||||
const modal = document.getElementById('imageLightboxModal');
|
||||
if (modal) modal.classList.add('hidden');
|
||||
}
|
||||
|
||||
// Modal Pemilihan Pos Gerbang Bertugas
|
||||
let isGateModalForced = {{ $needsGateSelection ? 'true' : 'false' }};
|
||||
|
||||
function openGateSelectionModal(isForced = false) {
|
||||
isGateModalForced = isForced;
|
||||
const modal = document.getElementById('gateSelectionModal');
|
||||
if (modal) {
|
||||
modal.classList.remove('hidden');
|
||||
modal.style.display = 'block';
|
||||
}
|
||||
}
|
||||
|
||||
function closeGateSelectionModal() {
|
||||
if (isGateModalForced) {
|
||||
return;
|
||||
}
|
||||
const modal = document.getElementById('gateSelectionModal');
|
||||
if (modal) {
|
||||
modal.classList.add('hidden');
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function onGateModalBackdropClick() {
|
||||
if (!isGateModalForced) {
|
||||
closeGateSelectionModal();
|
||||
}
|
||||
}
|
||||
|
||||
@if($needsGateSelection)
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
openGateSelectionModal(true);
|
||||
});
|
||||
@endif
|
||||
</script>
|
||||
|
||||
<!-- MODAL LIGHTBOX PRATINJAU FOTO DRIVER & MOBIL LV -->
|
||||
@@ -443,4 +486,98 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL POPUP: PILIH POS GERBANG BERTUGAS -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="gateSelectionModal"
|
||||
class="{{ $needsGateSelection ? '' : 'hidden' }} fixed inset-0 z-50 overflow-y-auto"
|
||||
style="{{ $needsGateSelection ? 'display: block;' : 'display: none;' }}">
|
||||
<!-- Backdrop Gelap -->
|
||||
<div class="fixed inset-0 bg-slate-900/60 backdrop-blur-xs transition-opacity"
|
||||
onclick="onGateModalBackdropClick()"></div>
|
||||
|
||||
<div class="flex min-h-full items-center justify-center p-4">
|
||||
<div class="relative w-full max-w-xl bg-white rounded-3xl shadow-2xl border border-slate-100 overflow-hidden transform transition-all p-6 sm:p-7 space-y-5">
|
||||
<!-- Header Modal -->
|
||||
<div class="flex items-start justify-between gap-3 pb-3 border-b border-slate-100">
|
||||
<div class="flex items-center space-x-3">
|
||||
<div class="w-12 h-12 rounded-2xl bg-amber-100 text-amber-700 flex items-center justify-center text-xl flex-shrink-0 shadow-2xs">
|
||||
<i class="fa-solid fa-door-open"></i>
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="text-base sm:text-lg font-black text-slate-900 tracking-tight">
|
||||
Pilih Pos Gerbang Bertugas
|
||||
</h3>
|
||||
<p class="text-xs text-slate-500 mt-0.5">
|
||||
Tentukan gerbang tempat Anda berjaga saat ini untuk verifikasi perlintasan.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@if(!$needsGateSelection)
|
||||
<button type="button" onclick="closeGateSelectionModal()" class="text-slate-400 hover:text-slate-600 p-1.5 rounded-lg hover:bg-slate-100 transition cursor-pointer">
|
||||
<i class="fa-solid fa-xmark text-sm"></i>
|
||||
</button>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<!-- Form Pemilihan Pos Gerbang -->
|
||||
<form action="{{ route('pg.gate.select_gate') }}" method="POST" id="gateSelectionForm">
|
||||
@csrf
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5 max-h-[60vh] overflow-y-auto p-1">
|
||||
@foreach($allGates as $g)
|
||||
@php
|
||||
$isCurrent = $gate && $gate->id === $g->id;
|
||||
$queueCount = $gateQueueCounts[$g->id] ?? 0;
|
||||
@endphp
|
||||
<label class="relative flex flex-col justify-between p-4 rounded-2xl border-2 cursor-pointer transition-all hover:shadow-md {{ $isCurrent ? 'border-amber-500 bg-amber-50/50' : 'border-slate-200 bg-white hover:border-slate-300' }}">
|
||||
<input type="radio"
|
||||
name="gate_id"
|
||||
value="{{ $g->id }}"
|
||||
{{ $isCurrent ? 'checked' : '' }}
|
||||
class="sr-only"
|
||||
onchange="document.getElementById('gateSelectionForm').submit()">
|
||||
<div>
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<span class="w-8 h-8 rounded-xl flex items-center justify-center text-xs font-bold {{ $isCurrent ? 'bg-amber-500 text-white' : 'bg-slate-100 text-slate-700' }}">
|
||||
<i class="fa-solid fa-shield-halved"></i>
|
||||
</span>
|
||||
@if($isCurrent)
|
||||
<span class="text-[10px] font-black uppercase px-2 py-0.5 rounded-full bg-emerald-100 text-emerald-800 border border-emerald-300">
|
||||
Pos Aktif
|
||||
</span>
|
||||
@elseif($queueCount > 0)
|
||||
<span class="text-[10px] font-black px-2 py-0.5 rounded-full bg-amber-100 text-amber-900 border border-amber-300">
|
||||
{{ $queueCount }} Antrean
|
||||
</span>
|
||||
@else
|
||||
<span class="text-[10px] font-semibold px-2 py-0.5 rounded-full bg-slate-100 text-slate-500">
|
||||
Bebas
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
<h4 class="text-sm font-black text-slate-900">{{ $g->name }}</h4>
|
||||
<p class="text-xs text-slate-500 mt-1 line-clamp-2">
|
||||
{{ $g->location ?: 'Pos pemeriksaan keluar/masuk kendaraan' }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="mt-4 pt-3 border-t border-slate-100 flex items-center justify-between text-xs font-bold {{ $isCurrent ? 'text-amber-700' : 'text-slate-600' }}">
|
||||
<span>{{ $isCurrent ? 'Sedang Dipilih' : 'Klik untuk Memilih' }}</span>
|
||||
<i class="fa-solid fa-arrow-right text-[11px]"></i>
|
||||
</div>
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
@if(!$needsGateSelection)
|
||||
<div class="flex items-center justify-end pt-3 border-t border-slate-100 mt-4">
|
||||
<button type="button" onclick="closeGateSelectionModal()" class="px-4 py-2 text-xs font-bold text-slate-600 hover:bg-slate-100 rounded-xl transition cursor-pointer">
|
||||
Batal
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@@ -78,30 +78,17 @@
|
||||
|
||||
<!-- Filter di Kanan (Pada Mobile: Sejajar 2 Kolom 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">
|
||||
<div class="flex items-center gap-2 sm:gap-2.5 w-full sm:w-auto">
|
||||
<!-- Filter Regu Satpam -->
|
||||
<select name="team"
|
||||
id="guardTeamSelect"
|
||||
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">
|
||||
class="w-full sm:w-auto 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] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition truncate">
|
||||
<option value="">Semua Regu</option>
|
||||
<option value="1" {{ request('team') == '1' ? 'selected' : '' }}>Regu 1</option>
|
||||
<option value="2" {{ request('team') == '2' ? 'selected' : '' }}>Regu 2</option>
|
||||
<option value="3" {{ request('team') == '3' ? 'selected' : '' }}>Regu 3</option>
|
||||
</select>
|
||||
|
||||
<!-- Filter Penempatan Pos Gerbang -->
|
||||
<select name="gate_id"
|
||||
id="guardGateSelect"
|
||||
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="">Semua Penempatan</option>
|
||||
@foreach($gates as $gate)
|
||||
<option value="{{ $gate->id }}" {{ request('gate_id') == $gate->id ? 'selected' : '' }}>
|
||||
{{ $gate->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Tombol Reset Filter (Sesuai Referensi Merah / Rose Clean Text) -->
|
||||
@@ -129,7 +116,6 @@
|
||||
<th class="py-3.5 px-4">ID SATPAM</th>
|
||||
<th class="py-3.5 px-4">NAMA LENGKAP</th>
|
||||
<th class="py-3.5 px-4 text-center">REGU</th>
|
||||
<th class="py-3.5 px-4 text-center">PENEMPATAN</th>
|
||||
<th class="py-3.5 px-4 text-center">STATUS</th>
|
||||
<th class="py-3.5 px-4 text-center w-36">AKSI</th>
|
||||
</tr>
|
||||
@@ -171,13 +157,6 @@
|
||||
@endif
|
||||
</td>
|
||||
|
||||
<!-- Penempatan Pos Gerbang -->
|
||||
<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-semibold bg-slate-100 text-slate-700 border border-slate-200">
|
||||
{{ $g->gate->name ?? 'Belum Ditentukan' }}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<!-- Status Aktif / Nonaktif -->
|
||||
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||
@if($g->is_active)
|
||||
@@ -232,7 +211,7 @@
|
||||
</tr>
|
||||
@empty
|
||||
<tr id="serverGuardEmptyRow">
|
||||
<td colspan="7" class="py-12 text-center text-slate-400">
|
||||
<td colspan="6" 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">
|
||||
@@ -241,7 +220,7 @@
|
||||
<p class="text-xs text-slate-400 mt-1">Pastikan ejaan ID Satpam atau nama petugas yang dicari sudah benar.</p>
|
||||
@elseif(request()->anyFilled(['team', 'gate_id']))
|
||||
<p class="text-sm font-semibold text-slate-700">Belum ada data petugas Satpam yang sesuai kriteria filter.</p>
|
||||
<p class="text-xs text-slate-400 mt-1">Silakan pilih regu atau penempatan pos gerbang lain.</p>
|
||||
<p class="text-xs text-slate-400 mt-1">Silakan pilih regu atau ubah kata kunci pencarian.</p>
|
||||
@else
|
||||
<i class="fa-solid fa-user-slash text-3xl mb-2 block text-slate-300"></i>
|
||||
<p class="text-sm font-semibold text-slate-700">Belum ada data petugas Satpam terdaftar.</p>
|
||||
@@ -317,39 +296,21 @@
|
||||
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
|
||||
</div>
|
||||
|
||||
<!-- Grid: Regu & Penempatan -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
|
||||
<div>
|
||||
<label for="team" class="block text-sm font-bold text-slate-800 mb-2">
|
||||
Regu Tugas <span class="text-rose-500">*</span>
|
||||
</label>
|
||||
<select name="team"
|
||||
id="team"
|
||||
required
|
||||
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
|
||||
<option value="" disabled selected>Pilih Regu</option>
|
||||
<option value="1" {{ old('team') == 1 ? 'selected' : '' }}>Regu 1</option>
|
||||
<option value="2" {{ old('team') == 2 ? 'selected' : '' }}>Regu 2</option>
|
||||
<option value="3" {{ old('team') == 3 ? 'selected' : '' }}>Regu 3</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="gate_id" class="block text-sm font-bold text-slate-800 mb-2">
|
||||
Penempatan Pos <span class="text-rose-500">*</span>
|
||||
</label>
|
||||
<select name="gate_id"
|
||||
id="gate_id"
|
||||
required
|
||||
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
|
||||
<option value="" disabled selected>Pilih Pos Gerbang</option>
|
||||
@foreach($gates as $gate)
|
||||
<option value="{{ $gate->id }}" {{ old('gate_id') == $gate->id ? 'selected' : '' }}>
|
||||
{{ $gate->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<!-- Regu Tugas Satpam (Fleksibel Lintas Seluruh Pos Gerbang) -->
|
||||
<div>
|
||||
<label for="team" class="block text-sm font-bold text-slate-800 mb-2">
|
||||
Regu Tugas <span class="text-rose-500">*</span>
|
||||
</label>
|
||||
<select name="team"
|
||||
id="team"
|
||||
required
|
||||
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
|
||||
<option value="" disabled selected>Pilih Regu</option>
|
||||
<option value="1" {{ old('team') == 1 ? 'selected' : '' }}>Regu 1</option>
|
||||
<option value="2" {{ old('team') == 2 ? 'selected' : '' }}>Regu 2</option>
|
||||
<option value="3" {{ old('team') == 3 ? 'selected' : '' }}>Regu 3</option>
|
||||
</select>
|
||||
<span class="text-[11px] text-slate-400 block mt-1">Petugas dapat memilih pos gerbang jaga saat login/bertugas secara fleksibel.</span>
|
||||
</div>
|
||||
|
||||
<!-- Password Akun Login -->
|
||||
@@ -414,31 +375,18 @@
|
||||
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
|
||||
</div>
|
||||
|
||||
<!-- Grid: Regu & Penempatan -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
|
||||
<div>
|
||||
<label for="editTeam" class="block text-sm font-bold text-slate-800 mb-2">
|
||||
Regu Tugas <span class="text-rose-500">*</span>
|
||||
</label>
|
||||
<select name="team" id="editTeam" required
|
||||
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
|
||||
<option value="1">Regu 1</option>
|
||||
<option value="2">Regu 2</option>
|
||||
<option value="3">Regu 3</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="editGateId" class="block text-sm font-bold text-slate-800 mb-2">
|
||||
Penempatan Pos <span class="text-rose-500">*</span>
|
||||
</label>
|
||||
<select name="gate_id" id="editGateId" required
|
||||
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
|
||||
@foreach($gates as $gate)
|
||||
<option value="{{ $gate->id }}">{{ $gate->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<!-- Regu Tugas -->
|
||||
<div>
|
||||
<label for="editTeam" class="block text-sm font-bold text-slate-800 mb-2">
|
||||
Regu Tugas <span class="text-rose-500">*</span>
|
||||
</label>
|
||||
<select name="team" id="editTeam" required
|
||||
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
|
||||
<option value="1">Regu 1</option>
|
||||
<option value="2">Regu 2</option>
|
||||
<option value="3">Regu 3</option>
|
||||
</select>
|
||||
<span class="text-[11px] text-slate-400 block mt-1">Petugas dapat memilih pos gerbang jaga saat login/bertugas secara fleksibel.</span>
|
||||
</div>
|
||||
|
||||
<!-- Ganti Password Baru (Opsional) -->
|
||||
@@ -659,7 +607,8 @@
|
||||
document.getElementById('editBadgeId').value = guard.badge_id || ('SEC-' + String(guard.id).padStart(3, '0'));
|
||||
document.getElementById('editName').value = guard.name || '';
|
||||
document.getElementById('editTeam').value = guard.team || 1;
|
||||
document.getElementById('editGateId').value = guard.gate_id || '';
|
||||
const editGateInput = document.getElementById('editGateId');
|
||||
if (editGateInput) editGateInput.value = guard.gate_id || '';
|
||||
document.getElementById('editPassword').value = '';
|
||||
|
||||
modal.classList.remove('hidden');
|
||||
@@ -710,7 +659,7 @@
|
||||
const emptyTr = document.createElement('tr');
|
||||
emptyTr.id = 'guardEmptySearchRow';
|
||||
emptyTr.innerHTML = `
|
||||
<td colspan="7" class="py-12 text-center text-slate-400">
|
||||
<td colspan="6" 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
|
||||
|
||||
Reference in New Issue
Block a user